📄 iai_ezmac_plus.h
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* *
* FILE NAME: IAI_EZMac_Plus.h *
* *
* DESIGNER: Kovacs, Krisztian; Lukacs, Miklos *
* PROGRAMMER: Kovacs, Krisztian; Lukacs, Miklos; Szell Andras *
* *
* DESCRIPTION: EZMac function definitions *
* *
* REVISION: 01_2 March 04, 2005 deviation 75kHz *
* 01_3 March 23, 2005 Transmit and receive packet lenght *
* can be different in fixed leght mode*
* 01_4 April 20, 2005 EZradio initialization fime tuning, *
* Wake-up timer is in on state *
* between Wake_Up() and Sleep() *
* (not correct POR fix) *
* 01_5 April 28, 2005 Clock Recovery lock checking after *
* DQD check, *
* Received PL=0 corrected *
* 01_6 Aug 11, 2005 *
* 02_0 March 21, 2006 Finalize the HiTech porting *
* 02_1 April 03, 2006 Universal baud rate and freq band *
* *
* EZMac Plus: *
* 01_0 Sept 28, 2006 Create EZMac Plus from EZMac *
* *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#pragma nolist
#ifndef EZmac
#define EZmac
/* ======================================= *
* I N T R O D U C T I O N *
* ======================================= */
/*
Using EZmac is only consist of calling the following functions:
char EZMacIdle (void);
char EZMac_Transmit (void);
char EZMac_Receive (void);
char EZMacReg_Write (MacRegs Name,char Value);
char EZMacReg_Read (MacRegs Name,char* Value);
char EZMacBuf_Write (char* buf);
char EZMacBuf_Read (char* buf);
Before any transmit or receive the RF parameters must be configured by EZMacReg_Write.
Before transmit, the data buffer must be filled with EZMacBuf_Write.
After receive, the received packet can be read by EZMacBuf_Read.
The MAC uses only two resources of the microcontroller, the Timer1 IT, and the external IT.
For the correct operation the following routines must be included into the global ISR:
(void) EZMac_TimerISR (void);
(void) EZMac_CommISR (void);
There is no any restriction about the structure of the application program, the only requirement is that:
this two routines must be included into the very first lines of main() function:
(void) EZMac_SysInit (void);
(void) EZMac_Config (void);
*/
/* ======================================= *
* P A R A M E T E R S *
* ======================================= */
/***************************************************************************\
* Set EZMacP lus parameters *
* These parameters highly depend on the parameters of the network *
\***************************************************************************/
#define FORWARD_RADIUS 3 // Forwarding radius: it specify how many time the packet can be forwarded
#define REPEATED_TABLE_SIZE 3 // It specify how many packet could be differentiate. This number has to be lower than 15, otherwise it can cause packet loss
#define MAX_CSMA_CYCLE 5 // Max CSMA retry
/***************************************************************************\
* Set EZMac main parameters *
* NOTE: only one parameter has to be selected from every group! *
\***************************************************************************/
//set relative LNA gain
#define RELATIVE_LNA_GAIN 0x0000 //0dB
//#define RELATIVE_LNA_GAIN 0x0008 //-6dB
//#define RELATIVE_LNA_GAIN 0x0010 //-14dB
//#define RELATIVE_LNA_GAIN 0x0018 //-20dB
#define XTAL_COMP 0x000A //0x0000 ... 0x000F - 8.5 ... 16pF, by 0.5pF step
/**************************************************************************\
* IMPORTANT: do not modify the code below *
\**************************************************************************/
#define ACK_WAIT_LIMIT ((FORWARD_RADIUS+1) << 8 ) // Ack Wait Limit highly depends on the used forwarding radius
#define CSMA_COUNTER_BASE 50+((EZ_reg.bytes.SFIDB & 0x0F)<<3) // The Base time between DQD checks, be carefull, that an ACK has absolut priority
#ifdef DATA_RATE_9600
//is any other data rate selected too -> error
#ifdef DATA_RATE_19200 | DATA_RATE_38400 | DATA_RATE_57600 | DATA_RATE_115200
#error EZMac error: only one baud rate can be selected!
#endif
#define DR_CMD 0xC623 //9600bps
#ifdef BAND_315
//is any other band selected?
#ifdef BAND_434 | BAND_868 | BAND_915
#error EZMac error: define only one frequency band!
#endif
//define radio parameters
#define FREQ_Band 0x0000 //315MHz
#define TX_CMD 0x9820 //deviation: 45kHz
#define RX_CMD (RELATIVE_LNA_GAIN | 0x97C0) //BW: 67kHz
#define FREQ_start 112
#define FREQ_step 132
#define FREQ_maxid 29
#define BAND_SELECTED
#endif
#ifdef BAND_434
#ifdef BAND_315 | BAND_868 | BAND_915
#error EZMac error: only one frequency band can be selected!
#endif
//define radio parameters
#define FREQ_Band 0x0010 //434MHz
#define TX_CMD 0x9820 //deviation: 45kHz
#define RX_CMD (RELATIVE_LNA_GAIN | 0x97C0) //BW: 67kHz
#define FREQ_start 1332
#define FREQ_step 132
#define FREQ_maxid 4
#define BAND_SELECTED
#endif
#ifdef BAND_868
#ifdef BAND_315 | BAND_434 | BAND_915
#error EZMac error: only one frequency band can be selected!
#endif
//define radio parameters
#define FREQ_Band 0x0020 //868MHz
#define TX_CMD 0x9840 //deviation: 75kHz
#define RX_CMD (RELATIVE_LNA_GAIN | 0x97A0) //BW: 134kHz
#define FREQ_start 710
#define FREQ_step 90
#define FREQ_maxid 14
#define BAND_SELECTED
#endif
#ifdef BAND_915
#ifdef BAND_315 | BAND_434 | BAND_868
#error EZMac error: only one frequency band can be selected!
#endif
//define radio parameters
#define FREQ_Band 0x0030 //915MHz
#define TX_CMD 0x9840 //deviation: 75kHz
#define RX_CMD (RELATIVE_LNA_GAIN | 0x97A0) //BW: 134kHz
#define FREQ_start 112
#define FREQ_step 64
#define FREQ_maxid 60
#define BAND_SELECTED
#endif
#define BAUD_RATE_SELECTED
#endif
#ifdef DATA_RATE_19200
//is any other data rate selected too -> error
#ifdef DATA_RATE_9600 | DATA_RATE_38400 | DATA_RATE_57600 | DATA_RATE_115200
#error EZMac error: only one baud rate can be selected!
#endif
#define DR_CMD 0xC611 //19200bps
#ifdef BAND_315
//is any other band selected?
#ifdef BAND_434 | BAND_868 | BAND_915
#error EZMac error: define only one frequency band!
#endif
//define radio parameters
#define FREQ_Band 0x0000 //315MHz
#define TX_CMD 0x9830 //deviation: 60kHz
#define RX_CMD (RELATIVE_LNA_GAIN | 0x97A0) //BW: 134kHz
#define FREQ_start 112
#define FREQ_step 154
#define FREQ_maxid 25
#define BAND_SELECTED
#endif
#ifdef BAND_434
#ifdef BAND_315 | BAND_868 | BAND_915
#error EZMac error: only one frequency band can be selected!
#endif
//define radio parameters
#define FREQ_Band 0x0010 //434MHz
#define TX_CMD 0x9830 //deviation: 60kHz
#define RX_CMD (RELATIVE_LNA_GAIN | 0x97A0) //BW: 134kHz
#define FREQ_start 1412
#define FREQ_step 154
#define FREQ_maxid 3
#define BAND_SELECTED
#endif
#ifdef BAND_868
#ifdef BAND_315 | BAND_434 | BAND_915
#error EZMac error: only one frequency band can be selected!
#endif
//define radio parameters
#define FREQ_Band 0x0020 //868MHz
#define TX_CMD 0x9850 //deviation: 90kHz
#define RX_CMD (RELATIVE_LNA_GAIN | 0x97A0) //BW: 134kHz
#define FREQ_start 740
#define FREQ_step 110
#define FREQ_maxid 11
#define BAND_SELECTED
#endif
#ifdef BAND_915
#ifdef BAND_315 | BAND_434 | BAND_868
#error EZMac error: only one frequency band can be selected!
#endif
//define radio parameters
#define FREQ_Band 0x0030 //915MHz
#define TX_CMD 0x9850 //deviation: 90kHz
#define RX_CMD (RELATIVE_LNA_GAIN | 0x97A0) //BW: 134kHz
#define FREQ_start 112
#define FREQ_step 74
#define FREQ_maxid 52
#define BAND_SELECTED
#endif
#define BAUD_RATE_SELECTED
#endif
#ifdef DATA_RATE_38400
//is any other data rate selected too -> error
#ifdef DATA_RATE_9600 | DATA_RATE_19200 | DATA_RATE_57600 | DATA_RATE_115200
#error EZMac error: only one baud rate can be selected!
#endif
#define DR_CMD 0xC608 //38400bps
#ifdef BAND_315
//is any other band selected?
#ifdef BAND_434 | BAND_868 | BAND_915
#error EZMac error: define only one frequency band!
#endif
//define radio parameters
#define FREQ_Band 0x0000 //315MHz
#define TX_CMD 0x9830 //deviation: 60kHz
#define RX_CMD (RELATIVE_LNA_GAIN | 0x97A0) //BW: 134kHz
#define FREQ_start 112
#define FREQ_step 154
#define FREQ_maxid 25
#define BAND_SELECTED
#endif
#ifdef BAND_434
#ifdef BAND_315 | BAND_868 | BAND_915
#error EZMac error: only one frequency band can be selected!
#endif
//define radio parameters
#define FREQ_Band 0x0010 //434MHz
#define TX_CMD 0x9840 //deviation: 75kHz
#define RX_CMD (RELATIVE_LNA_GAIN | 0x9780) //BW: 200kHz
#define FREQ_start 1388
#define FREQ_step 180
#define FREQ_maxid 3
#define BAND_SELECTED
#endif
#ifdef BAND_868
#ifdef BAND_315 | BAND_434 | BAND_915
#error EZMac error: only one frequency band can be selected!
#endif
//define radio parameters
#define FREQ_Band 0x0020 //868MHz
#define TX_CMD 0x9860 //deviation: 90kHz
#define RX_CMD (RELATIVE_LNA_GAIN | 0x9780) //BW: 200kHz
#define FREQ_start 724
#define FREQ_step 128
#define FREQ_maxid 10
#define BAND_SELECTED
#endif
#ifdef BAND_915
#ifdef BAND_315 | BAND_434 | BAND_868
#error EZMac error: only one frequency band can be selected!
#endif
//define radio parameters
#define FREQ_Band 0x0030 //915MHz
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -