⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcu_interface.h

📁 Atmega8L控制CC1020 TI的另外一款使用很多的RF IC。
💻 H
字号:

/*                                                                           *
 * Revision history:                                                         *

 ****************************************************************************/


/* Pin usage definitions */
#define PDO         PORTC.3    //26     input  
#define readPDO     PINC.3     //

#define PDI         PORTC.4    //27     output  

#define PCLK        PORTC.5    //28     output
#define PSEL        PORTD.4    //2      output
#define DIO         PORTC.2    //25
#define DCLK        PORTD.2    //32     input
#define ALARM       PORTB.4  // the JP2.D pin

#define bPDO         3
#define bPDI         4
#define bPCLK        5
#define bPSEL        4
#define bDIO         2
#define bDCLK        2  

#define SET_DIO_OUTPUT DDRC.2=1                //set DIO as ourput pin  

#define SET_DIO_INPUT  DDRC.2=0; \               //set DIO as input pin 
                       PORTC.2=1
//#define SET_DIO_OUTPUT (DDRC |= (1<<bDIO))   //set DIO as ourput pin
//#define SET_DIO_INPUT  (DDRC &= ~(1<<bDIO))  //set DIO as input pin  

//JP2 D is the alarm output pin 
#define SET_Pin_ALARM_OUTPUT DDRB.4=1
#define SET_ALARM     ALARM=1  // Notice: this is the opposite of the Document
#define Cancel_ALARM  ALARM=0  //

//#define PREAMBLE_LENGTH 4       // Number of bytes of preamble to send
#define PREAMBLE_bit_REQ    90       // Number of bits required in addition to
                                // the initial 8 bits for the preamble to be
                                // accepted  Iknow what this means now. the first 8bits of Preamble won't be 
                                //treated as preamble. ShiftReg != 0xAA or 0x55

#define PREAMBLE_BYTE           0xAA
#define VALID_PREAMBLE_BYTE_1   0x55
#define VALID_PREAMBLE_BYTE_2   0xAA

#define UI1 0xD3                // First byte of unique identifier
#define UI2 0x91                // Second byte of unique identifier


//#define RFPACKET_EXTENSION  3   // Number of bits to send on RF after end-of-packet:
                                // maintain output power until last bit of RF-packet
                                // has definitely been transmitted on the air.

// Time-out values
#define CAL_TIMEOUT   0x2ffe          //0x7FFE
#define LOCK_TIMEOUT  0x2ffe          //0x7FFE
#define RESET_TIMEOUT 0x2ffe          //0x7FFE
#define RSSI_TIMEOUT   0x3000
#define INIT_TIMEOUT   0x0010   // Corresponds to approx. 150 usec
//#define BUTTON_TIMEOUT 0x6000

// Maximum number of re-calibration attempts upon calibration failure
#define CAL_ATTEMPT_MAX   4

// LOCK status definitions
#define  LOCK_NOK         0x00
#define  LOCK_OK          0x01
#define  LOCK_RECAL_OK    0x02

// Define timer 2 macros:
#define TIMER2_INIT(config, time) \
        TMR2ON=0;                 \
        TMR2IF=0;                 \
        T2CON=config;             \
        PR2=time;                 \
        TMR2=0;                   \
        TMR2ON=1;

#define TIMER2_TIMEOUT TMR2IF

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -