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

📄 mac_tx_pool.c

📁 zigbee location examples
💻 C
字号:
/*******************************************************************************************************
 *                                                                                                     *
 *        **********                                                                                   *
 *       ************                                                                                  *
 *      ***        ***                                                                                 *
 *      ***   +++   ***                                                                                *
 *      ***   + +   ***                                                                                *
 *      ***   +                         CHIPCON CC2430 INTEGRATED 802.15.4 MAC AND PHY                 *
 *      ***   + +   ***                                TX Packet Pool                                  *
 *      ***   +++   ***                                                                                *
 *      ***        ***                                                                                 *
 *       ************                                                                                  *
 *        **********                                                                                   *
 *                                                                                                     *
 *******************************************************************************************************
 * CONFIDENTIAL                                                                                        *
 * The use of this file is restricted by the signed MAC software license agreement.                    *
 *                                                                                                     *
 * Copyright Chipcon AS, 2005                                                                          *
 *******************************************************************************************************
 * This module contains the TX packet pool, which manages a table of MAC_TX_PACKET structures to be    *
 * used with the TX engine.                                                                            *
 *******************************************************************************************************/
#include <mac_headers.h>


//-------------------------------------------------------------------------------------------------------
// The TX packet pool
__no_init MAC_TX_PACKET   pMtxPacketPool[MAC_OPT_TX_POOL_SIZE] @ "PM0_XDATA";

//-------------------------------------------------------------------------------------------------------




//-------------------------------------------------------------------------------------------------------
//  void mtxpInit(void)
//
//  DESCRIPTION:
//      Initializes the TX packet pool and the indirect packet queue
//-------------------------------------------------------------------------------------------------------
ROOT void mtxpInit(void) {
    UINT8 n;
    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
//-------------------------------------------------------------------------------------------------------
ROOT MAC_TX_PACKET  * mtxpReservePacket(void) {
    MAC_TX_PACKET   *pPacket;
    UINT8 n;
    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. This parameter can be NULL
//-------------------------------------------------------------------------------------------------------
ROOT void mtxpReleasePacket(MAC_TX_PACKET   *pPacket) {
    if (pPacket) {
        if (mtxInfo.pPacket == pPacket) mtxInfo.pPacket = NULL;
        pPacket->occupied = FALSE;
    }
} // mtxpReleasePacket

⌨️ 快捷键说明

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