📄 iai_ezmac_plus_internal.h
字号:
byte SIDB;
byte DIDB;
byte PLENB;
byte DBuff[PLEN_MAX];
} T_EZRegbytes;
union {
T_EZRegfield bits;
T_EZRegbytes bytes;
byte arr[REGBANK_SIZE + DATABANK_SIZE];
#ifdef HITECH_COMPILER
} bank1 EZ_reg;
#endif
#ifdef CCS_C_COMPILER
} EZ_reg;
#endif
#ifdef FIX_MEM_ADDRESS
#pragma locate EZ_reg = 0x2B
#endif
// shortcut for state register:
#define EZ_state EZ_reg.bytes.MSRB
#define EZ_dbuff EZ_reg.bytes.DBuff
typedef enum
{
Config_command,
Power_command,
Freq_command,
Data_Rate_command,
RX_Ctrl_command,
Data_Filter_command,
Fifo_command,
AFC_command,
TX_Ctrl_command,
Wake_command,
Low_Duty_command,
LBD_command
}Command_words;
typedef struct { // EZradio registers
int16 ConfigW;
int16 PowerW;
int16 FreqW;
int16 DataW;
int16 RX_CtrlW;
int16 Data_FltW;
int16 FifoW;
int16 AFCW;
int16 TX_CtrlW;
int16 WakeW;
int16 Low_DutyW;
int16 LBDW;
} stru_EZRadioregs;
#define NR_OF_CMDS 12
union {
stru_EZRadioregs words;
int16 arr[NR_OF_CMDS];
#ifdef HITECH_COMPILER
} bank1 EZ_commands;
#endif
#ifdef CCS_C_COMPILER
} EZ_commands;
#endif
////////////////////////////////
//// EZMac Plus Type define ////
////////////////////////////////
typedef struct { // Repeated Rx Table
byte SID;
byte DID;
byte CONTROL; // We use SEQ and ACK field of the Control byte other fields are indifferent
} REPEATED_T;
/* ======================================= *
* V A R I A B L E S *
* ======================================= */
#ifdef HITECH_COMPILER
volatile static int8 bank2 Frequency,EZ_crccnt; //the current frequency channel
volatile static reg16_union bank2 EZ_crc; //the current CRC value
volatile static state bank2 EZInternalState; //internal states
volatile static int8 bank2 DataByteCounter; //temp variable for the State_Machine
volatile static int8 bank2 Data, Data1; //temp registers for State_Machine
volatile static BOOL bank2 SetSpiEn; //In Rx states it shouldn't set the SPI select pin to 1 in the Interrupt routine, because the
//state machine will read the data byte from the FIFO after the status read command
//if SetSpiEn = 1 - the interrupt routine will set the SPI select pin
volatile static int8 bank2 ARSSI_value; //this variable contains the last ARSSI value
static int8 bank2 SequenceNumber = 0; // EzMacPlus
static int8 bank2 ControlField; // EzMacPlus
static BOOL bank2 AckNeeded; // EzMacPlus
static unsigned int bank2 AckWaitCounter; // EzMacPlus
static byte bank2 AckSender; // EzMacPlus
static bank2 REPEATED_T repeatedTable[REPEATED_TABLE_SIZE]; // EzMacPlus
static bank2 rtWritePointer; // EzMacPlus
static BOOL bank2 ForwardOnly; // EzMacPlus
static byte bank2 StateAfterForward; // EzMacPlus
static unsigned int bank2 csmaCycle = 0; // EzMacPlus
static unsigned int bank2 csmaCounter = 30; // EzMacPlus
#endif
#ifdef CCS_C_COMPILER
volatile static int8 Frequency,EZ_crccnt; //the current frequency channel
volatile static reg16_union EZ_crc; //the current CRC value
volatile static state EZInternalState; //internal states
volatile static int8 DataByteCounter; //temp variable for the State_Machine
volatile static int8 Data, Data1; //temp registers for State_Machine
volatile static BOOL SetSpiEn; //In Rx states it shouldn't set the SPI select pin to 1 in the Interrupt routine, because the
//state machine will read the data byte from the FIFO after the status read command
//if SetSpiEn = 1 - the interrupt routine will set the SPI select pin
volatile static int8 ARSSI_value; //this variable contains the last ARSSI value
static int8 SequenceNumber = 0; // EzMacPlus
static int8 ControlField; // EzMacPlus
static BOOL AckNeeded; // EzMacPlus
static unsigned int AckWaitCounter; // EzMacPlus
static int8 AckSender; // EzMacPlus
static REPEATED_T repeatedTable[REPEATED_TABLE_SIZE]; // EzMacPlus
static int8 rtWritePointer; // EzMacPlus
static BOOL ForwardOnly; // EzMacPlus
static byte StateAfterForward; // EzMacPlus
static unsigned int csmaCycle = 0; // EzMacPlus
static unsigned int csmaCounter = 30; // EzMacPlus
#endif
#ifdef FIX_MEM_ADDRESS
#pragma locate EZ_crc = 0x5D
#pragma byte Frequency = 0x5F
#pragma byte EZ_crccnt = 0x60
#pragma byte EZInternalState = 0x61
#pragma byte DataByteCounter = 0x66
#pragma byte Data = 0x6A
#pragma byte Data1 = 0x6B
#pragma bit SetSpiEn = 0x64.4
#endif
/* ======================================= *
* M I S C E L L A N E O U S *
* ======================================= */
/* void */
/* ======================================= *
* F U N C T I O N P R O T O T Y P E S *
* ======================================= */
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ FUNCTION NAME: Ch_Check_Start
+
+ DESCRIPTION: Set the frequency of the channel (input parameter), set the Timer
+ and start checking of the channel.
+
+ RETURN: none.
+
+ NOTES:
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma separate
void Ch_Check_Start (bool ChangeFreq);
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ FUNCTION NAME: DQD_Check
+
+ DESCRIPTION: Read the DQD and return the value.
+
+ RETURN: TRUE: DQD = 1 (the channel is occupied)
+ FALSE: DQD = 0 (the channel is free)
+
+ NOTES:
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma separate
bool DQD_Check (void);
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ FUNCTION NAME: State_Machine
+
+ DESCRIPTION: EZmac's state machine implementation.
+
+ RETURN: none.
+
+ NOTES: The function is called from the Timer or External ISR.
+ It_Source parameter shows from witch ISR was called the function.
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma separate
void State_Machine (char It_Source);
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ FUNCTION NAME: Crc_On_Fly
+
+ DESCRIPTION: Calculate the CRC value from byte to byte during the receiving.
+
+ RETURN: Crc: the current value of the CRC
+
+ NOTES: Data is the current input byte.
+ Crc is an input and output parameter too. The state machine should store
+ the previously Crc value and this is the input parameter for the next crc calculation.
+ If the state machine want to reset the crc calculations, then it should call the
+ function with Crc = 0 value.
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma separate
void Crc_On_Fly(int8 Data);
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ FUNCTION NAME: Crc_Init
+
+ DESCRIPTION: Initialise the CRC routine
+
+ RETURN: none.
+
+ NOTES: This function should call before the first calling of the Crc_On_Fly routine.
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
void Crc_Init(void);
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ FUNCTION NAME: void _Set_Timer1(char Limit)
+
+ DESCRIPTION: Set and start the Timer1. Input parameter is the TIMER_LIMIT defines
+
+ RETURN: none.
+
+ NOTES:
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma separate
void _Set_Timer1(int16 Limit);
#ifdef CCS_C_COMPILER
#pragma inline
void _Turn_Off_Timer1(void);
#endif
#ifdef HITECH_COMPILER
void _Turn_Off_Timer1(void);
#endif
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ FUNCTION NAME: void EZ_Reg_Default(void)
+
+ DESCRIPTION: Set the default values to the EZ_reg
+
+ RETURN: none.
+
+ NOTES:
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma separate
void EZ_Reg_Default(void);
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ FUNCTION NAME: void EZ_Radio_Config(void)
+
+ DESCRIPTION: Configures the EZradio with default values
+
+ RETURN: none.
+
+ NOTES:
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma separate
void EZ_Radio_Config(void);
//===============================================================================================
#pragma separate
void EZMac_AckTransmit(void);
//===============================================================================================
#pragma separate
void EZMac_AckReceive (void);
//===============================================================================================
#pragma separate
void EZMac_Ackwait (unsigned int cycle_plus);
//===============================================================================================
#pragma separate
void EZMac_ForwardPacket (void);
//===============================================================================================
#pragma separate
bool EZMac_IsRepeatedRx (void);
//===============================================================================================
#pragma separate
void EZMac_RepeatedRxTableInit (void);
#pragma separate
char EZRadio_CMD_Write (int8 CMD_index);
#endif
#pragma list
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -