📄 mac_rx_engine.h
字号:
/*******************************************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + CHIPCON CC2430 INTEGRATED 802.15.4 MAC AND PHY *
* *** + + *** RX Engine *
* *** +++ *** *
* *** *** *
* ************ *
* ********** *
* *
*******************************************************************************************************
* CONFIDENTIAL *
* The use of this file is restricted by the signed MAC software license agreement. *
* *
* Copyright Chipcon AS, 2005 *
*******************************************************************************************************/
#ifndef MAC_RX_ENGINE_H
#define MAC_RX_ENGINE_H
/*******************************************************************************************************
*******************************************************************************************************
************************** CONSTANTS AND MACROS **************************
*******************************************************************************************************
*******************************************************************************************************/
//-------------------------------------------------------------------------------------------------------
// The time constant used when delaying the re-activation of the FIFOP interrupt
#define MRX_FIFOP_INT_ON_DELAY 200 /* MCU cycles */
// Flags used as taskData in mrxForceRxOffTask(...)
#define MRX_PRESERVE_ON_COUNTER 0
#define MRX_RESET_ON_COUNTER 1
//-------------------------------------------------------------------------------------------------------
/*******************************************************************************************************
*******************************************************************************************************
************************** STATE MACHINES **************************
*******************************************************************************************************
*******************************************************************************************************/
//-------------------------------------------------------------------------------------------------------
typedef enum {
MRX_STATE_LEN_FCF_SEQ = 0,
MRX_STATE_ADDR,
MRX_STATE_FCS,
MRX_STATE_DISCARD
} MAC_RX_STATE;
// mrxProcessBeacon
#define MRX_STATE_BCN_ALIGN_OR_SPEC_MODES 0
#define MRX_STATE_BCN_TX_AFTER_BEACON 1
#define MRX_STATE_BCN_EXAMINE_PENDING_FIELDS 2
#define MRX_STATE_BCN_ALIGN 3
#define MRX_STATE_BCN_PENDING_DATA 4
// ReceiveEngine
#define RECEIVE_ENGINE_STATE_DECODE_MHR 0
#define RECEIVE_ENGINE_STATE_COPY_PAYLOAD_AND_FORWARD_PACKET 1
//-------------------------------------------------------------------------------------------------------
/*******************************************************************************************************
*******************************************************************************************************
************************** MODULE DATA **************************
*******************************************************************************************************
*******************************************************************************************************/
//-------------------------------------------------------------------------------------------------------
// Internal module data
typedef struct {
// The four initial bytes of the received packet
INT8 length;
WORD frameControlField;
UINT8 sequenceNumber;
UINT8 destAddrLength;
UINT8 srcAddrLength;
BYTE pFooter[2];
// A pointer to the structure that stores the received packet
MAC_RX_PACKET *pPacket;
// The task that will be responsible for processing the received packet
UINT8 taskNumber;
BOOL discardReceivedPacket;
// The current state of the MAC RX engine
volatile MAC_RX_STATE state;
// This counter decides whether or not the receiver is on (greater than 0) or off (0)
UINT8 onCounter;
// FIFO underflow prevention/detection
BOOL handleFifoUnderflow;
BOOL keepFifopIntOff;
// mlmeRxEnableRequest parameters
UINT32 rxEnableOnDuration;
#if (MAC_OPT_ACL_SIZE>0)
UINT8 aclEntrySearch; // Used for indexing during search for ACL
#endif
FRAME_TYPE frameType;
BYTE msduLength;
BYTE msduOffset;
} MAC_RX_INFO;
extern MAC_RX_INFO mrxInfo;
#if MAC_OPT_SECURITY
typedef struct {
DWORD frameCounter; // Incoming Frame Counter
BYTE keySequenceCounter; // Incoming Key Sequence Counter
BYTE securitySuite;
UINT8 authenticateLength;
MSEC_SETUP_INFO securitySetup;
SECURITY_MATERIAL *pMrxSecurityMaterial;
ADDRESS *pExtendedAddress;
} MAC_RX_SECURITY_INFO;
extern MAC_RX_SECURITY_INFO mrxSecurityInfo;
#endif // MAC_OPT_SECURITY
//-------------------------------------------------------------------------------------------------------
/*******************************************************************************************************
*******************************************************************************************************
************************** FUNCTION PROTOTYPES **************************
*******************************************************************************************************
*******************************************************************************************************/
//-------------------------------------------------------------------------------------------------------
// RX state control
// The counter which is used to control RX on/off. RX is off when the counter is 0, or on otherwise. The
// counter is incremented each time there is a reason for being in RX, or when the chip will turn on RX
// automatically (after TX)
void mrxIncrOnCounter(void);
void mrxAutoIncrOnCounter(void);
void mrxDecrOnCounter(void);
// Functions related to forcing RX off, and cleaning up (to avoid FIFO underflow)
void mrxForceRxOff(void);
void mrxForceRxOffTask(MAC_TASK_INFO *pTask);
ROOT void mrxResetRxEngine(void);
// The task created by mlmeRxEnableRequest()
void mrxRxEnableRequestTask(MAC_TASK_INFO *pTask);
void mrxRxEnableRequestOff(void);
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// Interrupt Service Routines
__near_func __interrupt void DmaIsr(void);
__near_func __interrupt void RfIsr (void);
__near_func __interrupt void RferrIsr(void);
#endif
void mrxProcessData(MAC_TASK_INFO *pTask);
void mrxProcessBeacon(MAC_TASK_INFO *pTask);
void mrxProcessAcknowledgment(MAC_TASK_INFO *pTask);
void mrxProcessMacCommand(MAC_TASK_INFO *pTask);
void mrxCommStatusIndication(MAC_TASK_INFO *pTask);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -