📄 mac_rx_engine.h
字号:
/*******************************************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + CHIPCON CC2420 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, 2004 *
*******************************************************************************************************
* This module contains the MAC RX engine (FIFOP interrupt), including packet processing functions, *
* and functions to control the RX state (on/off...) *
*******************************************************************************************************
* Compiler: NEC Electronics PM plus V5.20 *
* Target platform: CC2420DB, CC2420 + 78K0/KF2 *
*******************************************************************************************************
* The revision history is located at the bottom of this file *
*******************************************************************************************************/
#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_DEST_ADDR,
MRX_STATE_SRC_ADDR,
MRX_STATE_SECURITY_INIT,
MRX_STATE_SECURITY_ACL_SEARCH,
MRX_STATE_FIND_COUNTERS,
MRX_STATE_CMD_IDENTIFIER,
MRX_STATE_READ_FRAME_COUNTER,
MRX_STATE_READ_KEY_SEQUENCE_COUNTER,
MRX_STATE_KEY_SETUP_AND_DECRYPT,
MRX_STATE_PAYLOAD,
MRX_STATE_FCS,
MRX_STATE_DISCARD_ALL,
MRX_STATE_DISCARD_REMAINING,
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
//-------------------------------------------------------------------------------------------------------
/*******************************************************************************************************
*******************************************************************************************************
************************** MODULE DATA **************************
*******************************************************************************************************
*******************************************************************************************************/
//-------------------------------------------------------------------------------------------------------
// Internal module data
typedef struct {
UINT8 dstAddrLength;
UINT8 srcAddrLength;
BYTE *pDstAddrStoragePtr;
BYTE *pSrcAddrStoragePtr;
} ADDR;
typedef struct {
BYTE *pPayloadStoragePtr;
BYTE pFooter[2];
} FOOTER;
// Data used in the RX engine state machine
typedef union {
ADDR a;
FOOTER f;
} RX_INFO_DATA;
typedef struct {
// The four initial bytes of the received packet
INT8 length;
WORD frameControlField;
UINT8 sequenceNumber;
RX_INFO_DATA rd;
// A pointer to the structure that stores the received packet
MAC_RX_PACKET *pMrxPacket;
// The task that will be responsible for processing the received packet
UINT8 taskNumber;
// 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
} 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;
QWORD* 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);
void mrxResetRxEngine(void);
// The task created by mlmeRxEnableRequest()
void mrxRxEnableRequestTask(MAC_TASK_INFO *pTask);
void mrxRxEnableRequestOff(void);
//-------------------------------------------------------------------------------------------------------
#endif
/*******************************************************************************************************
* Revision history:
*
* $Log: mac_rx_engine.h,v $
* Revision 1.9 2004/08/13 13:04:43 jol
* CC2420 MAC Release v0.7
*
*
*******************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -