📄 basic_rf.h
字号:
// The acknowledgment is received through the FIFOP interrupt.
//
// ARGUMENTS:
// BASIC_RF_TX_INFO *pRTI
// The transmission structure, which contains all relevant info about the packet.
//
// RETURN VALUE:
// BOOL
// Successful transmission (acknowledgment received)
//-------------------------------------------------------------------------------------------------------
BOOL basicRfSendPacket(BASIC_RF_TX_INFO *pRTI);
/*******************************************************************************************************
*******************************************************************************************************
************************** Packet reception **************************
*******************************************************************************************************
*******************************************************************************************************/
//-------------------------------------------------------------------------------------------------------
// The receive struct:
typedef struct {
BYTE seqNumber;
WORD srcAddr;
WORD srcPanId;
INT8 length;
BYTE *pPayload;
BOOL ackRequest;
INT8 rssi;
} BASIC_RF_RX_INFO;
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// void halRfReceiveOn(void)
//
// DESCRIPTION:
// Enables the CC2420 receiver and the FIFOP interrupt. When a packet is received through this
// interrupt, it will call halRfReceivePacket(...), which must be defined by the application
//-------------------------------------------------------------------------------------------------------
void basicRfReceiveOn(void);
//-------------------------------------------------------------------------------------------------------
// void halRfReceiveOff(void)
//
// DESCRIPTION:
// Disables the CC2420 receiver and the FIFOP interrupt.
//-------------------------------------------------------------------------------------------------------
void basicRfReceiveOff(void);
//-------------------------------------------------------------------------------------------------------
// SIGNAL(SIG_INTERRUPT0) - CC2420 FIFOP interrupt service routine
//
// DESCRIPTION:
// When a packet has been completely received, this ISR will extract the data from the RX FIFO, put
// it into the active BASIC_RF_RX_INFO structure, and call basicRfReceivePacket() (defined by the
// application). FIFO overflow and illegally formatted packets is handled by this routine.
//
// Note: Packets are acknowledged automatically by CC2420 through the auto-acknowledgment feature.
//-------------------------------------------------------------------------------------------------------
// SIGNAL(SIG_INTERRUPT0)
//-------------------------------------------------------------------------------------------------------
// BASIC_RF_RX_INFO* basicRfReceivePacket(BASIC_RF_RX_INFO *pRRI)
//
// DESCRIPTION:
// This function is a part of the basic RF library, but must be declared by the application. Once
// the application has turned on the receiver, using basicRfReceiveOn(), all incoming packets will
// be received by the FIFOP interrupt service routine. When finished, the ISR will call the
// basicRfReceivePacket() function. Please note that this function must return quickly, since the
// next received packet will overwrite the active BASIC_RF_RX_INFO structure (pointed to by pRRI).
//
// ARGUMENTS:
// BASIC_RF_RX_INFO *pRRI
// The reception structure, which contains all relevant info about the received packet.
//
// RETURN VALUE:
// BASIC_RF_RX_INFO*
// The pointer to the next BASIC_RF_RX_INFO structure to be used by the FIFOP ISR. If there is
// only one buffer, then return pRRI.
//-------------------------------------------------------------------------------------------------------
BASIC_RF_RX_INFO* basicRfReceivePacket(BASIC_RF_RX_INFO *pRRI);
/*******************************************************************************************************
*******************************************************************************************************
************************** Initialization **************************
*******************************************************************************************************
*******************************************************************************************************/
//-------------------------------------------------------------------------------------------------------
// The RF settings structure:
typedef struct {
BASIC_RF_RX_INFO *pRxInfo;
UINT8 txSeqNumber;
volatile BOOL ackReceived;
WORD panId;
WORD myAddr;
BOOL receiveOn;
} BASIC_RF_SETTINGS;
extern volatile BASIC_RF_SETTINGS rfSettings;
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// void basicRfInit(BASIC_RF_RX_INFO *pRRI, UINT8 channel, WORD panId, WORD myAddr)
//
// DESCRIPTION:
// Initializes CC2420 for radio communication via the basic RF library functions. Turns on the
// voltage regulator, resets the CC2420, turns on the crystal oscillator, writes all necessary
// registers and protocol addresses (for automatic address recognition). Note that the crystal
// oscillator will remain on (forever).
//
// ARGUMENTS:
// BASIC_RF_RX_INFO *pRRI
// A pointer the BASIC_RF_RX_INFO data structure to be used during the first packet reception.
// The structure can be switched upon packet reception.
// UINT8 channel
// The RF channel to be used (11 = 2405 MHz to 26 = 2480 MHz)
// WORD panId
// The personal area network identification number
// WORD myAddr
// The 16-bit short address which is used by this node. Must together with the PAN ID form a
// unique 32-bit identifier to avoid addressing conflicts. Normally, in a 802.15.4 network, the
// short address will be given to associated nodes by the PAN coordinator.
//-------------------------------------------------------------------------------------------------------
void basicRfInit(BASIC_RF_RX_INFO *pRRI, UINT8 channel, WORD panId, WORD myAddr);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -