⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mac_rx_engine.h

📁 ucos在NEC平台下的移植
💻 H
字号:
#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 {
    // The four initial bytes of the received packet
    INT8 length;
    WORD frameControlField;
    UINT8 sequenceNumber;

    // Data used in the RX engine state machine
   // union {
   //     struct {
   //         UINT8 dstAddrLength;
   //         UINT8 srcAddrLength;
   //         BYTE *pDstAddrStoragePtr;
   //         BYTE *pSrcAddrStoragePtr;
   //     }ADDR;
   //      struct {
   //         BYTE *pPayloadStoragePtr;
   //         BYTE pFooter[2];
   //     }RX_INFO_DATA;
  //  };
   
 
            UINT8 dstAddrLength;
            UINT8 srcAddrLength;
            BYTE *pDstAddrStoragePtr;
            BYTE *pSrcAddrStoragePtr;
            BYTE *pPayloadStoragePtr;
            BYTE pFooter[2];
   
 
   
    // 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
    ZBOOL handleFifoUnderflow;
    ZBOOL 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 + -