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

📄 mac_tx_pool.c

📁 ucos在NEC平台下的移植
💻 C
字号:
/*******************************************************************************************************
 *                                                                                                     *
 *        **********                                                                                   *
 *       ************                                                                                  *
 *      ***        ***                                                                                 *
 *      ***   +++   ***                                                                                *
 *      ***   + +   ***                                                                                *
 *      ***   +                         CHIPCON CC2420 INTEGRATED 802.15.4 MAC AND PHY                 *
 *      ***   + +   ***                                RX Packet Pool                                  *
 *      ***   +++   ***                                                                                *
 *      ***        ***                                                                                 *
 *       ************                                                                                  *
 *        **********                                                                                   *
 *                                                                                                     *
 *******************************************************************************************************
 * CONFIDENTIAL                                                                                        *
 * The use of this file is restricted by the signed MAC software license agreement.                    *
 *                                                                                                     *
 * Copyright Chipcon AS, 2004                                                                          *
 *******************************************************************************************************
 * This module contains the TX packet pool, which manages a table of MAC_TX_PACKET structures to be    *
 * used with the TX engine.                                                                            *
 *******************************************************************************************************
 * Compiler: AVR-GCC                                                                                   *
 * Target platform: CC2420DB, CC2420 + any ATMEGA MCU                                                  *
 *******************************************************************************************************
 * The revision history is located at the bottom of this file                                          *
 *******************************************************************************************************/
#pragma SFR
#pragma NOP
#pragma STOP
#pragma HALT
#pragma DI
#pragma EI

#include "mac_headers.h"


//-------------------------------------------------------------------------------------------------------
// The TX packet pool
MAC_TX_PACKET pMtxPacketPool[MAC_OPT_TX_POOL_SIZE];
//-------------------------------------------------------------------------------------------------------




//-------------------------------------------------------------------------------------------------------
//  void mtxpInit(void)
//
//  DESCRIPTION:
//      Initializes the TX packet pool and the indirect packet queue
//-------------------------------------------------------------------------------------------------------
void mtxpInit(void) {
UINT8 n = 0; ///
    for (n = 0; n < MAC_OPT_TX_POOL_SIZE; n++) {///
        pMtxPacketPool[n].occupied = FALSE;
        pMtxPacketPool[n].poolIndex = n;
    }
} // mtxpInit




//-------------------------------------------------------------------------------------------------------
//  MAC_TX_PACKET* mtxpReservePacket(void)
//
//  DESCRIPTION:
//      Reserves a packet in the packet pool
//
//  RETURN VALUE:
//      MAC_TX_PACKET*
//          A pointer to the reserved packet, or NULL if the pool is empty
//-------------------------------------------------------------------------------------------------------
MAC_TX_PACKET* mtxpReservePacket(void) {
    MAC_TX_PACKET *pPacket;
	UINT8 n = 0; ///
    for (n = 0; n < MAC_OPT_TX_POOL_SIZE; n++) {///
        pPacket = &pMtxPacketPool[n];
        if (!pPacket->occupied) {
            DISABLE_GLOBAL_INT();
            if (!pPacket->occupied) {
                pPacket->occupied = TRUE;
                ENABLE_GLOBAL_INT();
                return pPacket;
            }
            ENABLE_GLOBAL_INT();
        }
    }
    return NULL;
} // mtxpReservePacket




//-------------------------------------------------------------------------------------------------------
//  void mtxpReleasePacket(MAC_TX_PACKET* pPacket)
//
//  DESCRIPTION:
//      Releases a packet back to the TX packet pool
//
//  ARGUMENTS:
//      MAC_TX_PACKET* pPacket
//          A pointer to the packet to be released
//-------------------------------------------------------------------------------------------------------
void mtxpReleasePacket(MAC_TX_PACKET* pPacket) {
    if (mtxInfo.pPacket == pPacket) mtxInfo.pPacket = NULL;
    pPacket->occupied = FALSE;
} // mtxpReleasePacket




/*******************************************************************************************************
 * Revision history:
 *
 * $Log: mac_tx_pool.c,v $
 * Revision 1.6  2004/11/10 09:33:16  thl
 * Fixed a number of bugs according to: MAC software check lists.xls
 *
 * Revision 1.5  2004/08/13 13:04:48  jol
 * CC2420 MAC Release v0.7
 *
 *
 *******************************************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -