Error[Pe167]: argument of type "uint8 *" is incompatible with parameter of type "unsigned char volatile __xdata *" 代码:/* low-level */#include "mac_api.h"#include "mac_radio_defs.h"/* osal */#include "OSAL.h"#include "saddr.h"#include "ZComDef.h"#include "mac_autopend.h"/* ------------------------------------------------------------------------------------------------ * Defines * ------------------------------------------------------------------------------------------------ */#define MAC_SRCMATCH_INVALID_INDEX 0xFF#define MAC_SRCMATCH_SHORT_ENTRY_SIZE 4#define MAC_SRCMATCH_EXT_ENTRY_SIZE Z_EXTADDR_LEN#define MAC_SRCMATCH_SHORT_MAX_NUM_ENTRIES 24#define MAC_SRCMATCH_EXT_MAX_NUM_ENTRIES 12#define MAC_SRCMATCH_ENABLE_BITMAP_LEN 3 /* ------------------------------------------------------------------------------------------------ * Global Variables * ------------------------------------------------------------------------------------------------ */bool macSrcMatchIsEnabled = FALSE; /* ------------------------------------------------------------------------------------------------ * Local Variables * ------------------------------------------------------------------------------------------------ *//* The following local Varables are only set in MAC_SrcMatchEnable() They are read only to the rest of the module. */uint8 macSrcMatchMaxNumEntries = 0; uint8 macSrcMatchAddrMode = SADDR_MODE_SHORT; bool macSrcMatchIsAckAllPending = FALSE;/* ------------------------------------------------------------------------------------------------ * Local Functions * ------------------------------------------------------------------------------------------------ */static uint8 macSrcMatchFindEmptyEntry( void );static uint8 macSrcMatchCheckSrcAddr ( sAddr_t *addr, uint16 panID );static void macSrcMatchSetPendEnBit( uint8 index );static void macSrcMatchSetEnableBit( uint8 index, bool option );static bool macSrcMatchCheckEnableBit( uint8 index );static uint24 macSrcMatchGetEnableBit( void );static uint24 macSrcMatchGetPendEnBit( void );/********************************************************************* * @fn MAC_SrcMatchEnable * * @brief Enabled AUTOPEND and source address matching. If number of source * address table entries asked for is more than the hardware * supports. It will allocate maximum number of entries and return * MAC_INVALID_PARAMETER. This function shall be not be called from * ISR. It is not thread safe. * * @param addressType - address type that the application uses * SADDR_MODE_SHORT or SADDR_MODE_EXT * @param num - number of source address table entries to be used * * @return MAC_SUCCESS or MAC_INVALID_PARAMETER */uint8 MAC_SrcMatchEnable ( uint8 addrType, uint8 num ){ uint8 rtn; uint8 maxNum; /* Verify the address type */ if( addrType != SADDR_MODE_SHORT && addrType != SADDR_MODE_EXT ) { return MAC_INVALID_PARAMETER; } maxNum = ( addrType == SADDR_MODE_SHORT ) ? MAC_SRCMATCH_SHORT_MAX_NUM_ENTRIES : MAC_SRCMATCH_EXT_MAX_NUM_ENTRIES; if( num > maxNum ) { rtn = MAC_INVALID_PARAMETER; num = maxNum; } else { rtn = MAC_SUCCESS; } /* Turn on Frame Filter (TIMAC enables frame filter by default), TBD */ MAC_RADIO_TURN_ON_RX_FRAME_FILTERING(); /* Turn on Auto ACK (TIMAC turn on Auto ACK by default), TBD */ MAC_RADIO_TURN_ON_AUTO_ACK(); /* Turn on Autopend: set SRCMATCH.AUTOPEND and SRCMATCH.SRC_MATCH_EN */ MAC_RADIO_TURN_ON_SRC_MATCH(); /* Set SRCMATCH.AUTOPEND */ MAC_RADIO_TURN_ON_AUTOPEND(); /* Configure all the globals */ macSrcMatchIsEnabled = TRUE; macSrcMatchMaxNumEntries = num; macSrcMatchAddrMode = addrType; return rtn;}/********************************************************************* * @fn MAC_SrcMatchAddEntry * * @brief Add a short or extended address to source address table. This * function shall be not be called from ISR. It is not thread safe. * * @param addr - a pointer to sAddr_t which contains addrMode * and a union of a short 16-bit MAC address or an extended * 64-bit MAC address to be added to the source address table. * @param panID - the device PAN ID. It is only used when the addr is * using short address * @return MAC_SUCCESS or MAC_NO_RESOURCES (source address table full) * or MAC_DUPLICATED_ENTRY (the entry added is duplicated), * or MAC_INVALID_PARAMETER if the input parameters are invalid. */uint8 MAC_SrcMatchAddEntry ( sAddr_t *addr, uint16 panID ){ uint8 index; uint8 entry[MAC_SRCMATCH_SHORT_ENTRY_SIZE]; /* Check if the input parameters are valid */ if ( addr == NULL || addr->addrMode != macSrcMatchAddrMode ) { return MAC_INVALID_PARAMETER; } /* Check if the entry already exists. Do not add duplicated entry */ if ( macSrcMatchCheckSrcAddr( addr, panID ) != MAC_SRCMATCH_INVALID_INDEX ) { return MAC_DUPLICATED_ENTRY; } /* If not duplicated, write to the radio RAM and enable the control bit */ /* Find the first empty entry */ index = macSrcMatchFindEmptyEntry(); if ( index == macSrcMatchMaxNumEntries ) { return MAC_NO_RESOURCES; /* Table is full */ } if ( macSrcMatchAddrMode == SADDR_MODE_SHORT ) { /* Write the PanID and short address */ entry[0] = LO_UINT16( panID ); /* Little Endian for the radio RAM */ entry[1] = HI_UINT16( panID ); entry[2] = LO_UINT16( addr->addr.shortAddr ); entry[3] = HI_UINT16( addr->addr.shortAddr ); MAC_RADIO_SRC_MATCH_TABLE_WRITE( ( index * MAC_SRCMATCH_SHORT_ENTRY_SIZE ), entry, MAC_SRCMATCH_SHORT_ENTRY_SIZE ); } else { /* Write the extended address */ MAC_RADIO_SRC_MATCH_TABLE_WRITE( ( index * MAC_SRCMATCH_EXT_ENTRY_SIZE ), addr->addr.extAddr, MAC_SRCMATCH_EXT_ENTRY_SIZE ); } /* Set the Autopend enable bits */ macSrcMatchSetPendEnBit( index ); /* Set the Src Match enable bits */ macSrcMatchSetEnableBit( index, TRUE ); return MAC_SUCCESS;}/********************************************************************* * @fn MAC_SrcMatchDeleteEntry * * @brief Delete a short or extended address from source address table. * This function shall be not be called from ISR. It is not thread safe. * * @param addr - a pointer to sAddr_t which contains addrMode * and a union of a short 16-bit MAC address or an extended * 64-bit MAC address to be deleted from the source address table. * @param panID - the device PAN ID. It is only used when the addr is * using short address * * @return MAC_SUCCESS or MAC_INVALID_PARAMETER (address to be deleted * cannot be found in the source address table). */uint8 MAC_SrcMatchDeleteEntry ( sAddr_t *addr, uint16 panID ){ uint8 index; if ( addr == NULL || addr->addrMode != macSrcMatchAddrMode ) { return MAC_INVALID_PARAMETER; } /* Look up the source address table and find the entry. */ index = macSrcMatchCheckSrcAddr( addr, panID ); if( index == MAC_SRCMATCH_INVALID_INDEX ) { return MAC_INVALID_PARAMETER; } /* Clear Src Match enable bits */ macSrcMatchSetEnableBit( index, FALSE ); return MAC_SUCCESS;} /********************************************************************* * @fn MAC_SrcMatchAckAllPending * * @brief Enabled/disable acknowledging all packets with pending bit set * The application normally enables it when adding new entries to * the source address table fails due to the table is full, or * disables it when more entries are deleted and the table has * empty slots. * * @param option - TRUE (acknowledging all packets with pending field set) * FALSE (acknowledging all packets with pending field cleared) * * @return none */void MAC_SrcMatchAckAllPending ( uint8 option ) { if( option == TRUE ) { macSrcMatchIsAckAllPending = TRUE; /* Set the PENDING_OR register */ MAC_RADIO_TURN_ON_PENDING_OR(); } else { macSrcMatchIsAckAllPending = FALSE; /* Clear the PENDING_OR register */ MAC_RADIO_TURN_OFF_PENDING_OR(); }}/********************************************************************* * @fn MAC_SrcMatchCheckAllPending * * @brief Check if acknowledging all packets with pending bit set * is enabled. * * @param none * * @return MAC_AUTOACK_PENDING_ALL_ON or MAC_AUTOACK_PENDING_ALL_OFF */uint8 MAC_SrcMatchCheckAllPending ( void ){ if( macSrcMatchIsAckAllPending == TRUE ) { return MAC_AUTOACK_PENDING_ALL_ON; } return MAC_AUTOACK_PENDING_ALL_OFF;}/********************************************************************* * @fn MAC_SrcMatchCheckResult * * @brief Check the result of source matching * * @param index - index of the entry in the source address table * * @return TRUE or FALSE */MAC_INTERNAL_API bool MAC_SrcMatchCheckResult( void ){ uint8 resIndex; if ( macSrcMatchIsAckAllPending ) { return (TRUE); } MAC_RADIO_SRC_MATCH_RESINDEX( resIndex ); return ( resIndex & AUTOPEND_RES );}/********************************************************************* * @fn macSrcMatchFindEmptyEntry * * @brief return index of the first empty entry found * * @param none * * @return uint8 - return index of the first empty entry found */static uint8 macSrcMatchFindEmptyEntry( void ){ uint8 index; uint24 enable; enable = MAC_RADIO_SRC_MATCH_GET_EN(); if( macSrcMatchAddrMode == SADDR_MODE_SHORT ) { for( index = 0; index < macSrcMatchMaxNumEntries; index++ ) { if( ( enable & ( (uint24)0x01 << index ) ) == 0 ) { return index; } } } else { for( index = 0; index < macSrcMatchMaxNumEntries; index++ ) { if( ( enable & ( (uint24)0x01 << ( index * 2 ) ) ) == 0 ) { return index; } } } /* The value of index shall be macSrcMatchMaxNumEntries when it executes here. The table is full. */ return index;}/********************************************************************* * @fn macSrcMatchCheckSrcAddr * * @brief Check if a short or extended address is in the source address table. * This function shall not be called from ISR. It is not thread safe. * * @param addr - a pointer to sAddr_t which contains addrMode * and a union of a short 16-bit MAC address or an extended * 64-bit MAC address to be checked in the source address table. * @param panID - the device PAN ID. It is only used when the addr is * using short address * @return uint8 - index of the entry in the table. Return * MAC_SRCMATCH_INVALID_INDEX (0xFF) if address not found. */static uint8 macSrcMatchCheckSrcAddr ( sAddr_t *addr, uint16 panID ){ uint8 index; uint8 *pAddr; uint8 entrySize; uint8 entry[MAC_SRCMATCH_SHORT_ENTRY_SIZE]; uint8 ramEntry[MAC_SRCMATCH_EXT_ENTRY_SIZE]; /* Currently, shadow memory is not supported to optimize SPI traffic. */ if( macSrcMatchAddrMode == SADDR_MODE_SHORT ) { entry[0] = LO_UINT16( panID ); /* Little Endian for the radio RAM */ entry[1] = HI_UINT16( panID ); entry[2] = LO_UINT16( addr->addr.shortAddr ); entry[3] = HI_UINT16( addr->addr.shortAddr ); pAddr = entry; entrySize = MAC_SRCMATCH_SHORT_ENTRY_SIZE; } else { pAddr = addr->addr.extAddr; entrySize = MAC_SRCMATCH_EXT_ENTRY_SIZE; } for( index = 0; index < macSrcMatchMaxNumEntries; index++ ) { /* Check if the entry is enabled */ if( macSrcMatchCheckEnableBit( index ) == FALSE ) { continue; } /* Compare the short address and pan ID */ MAC_RADIO_SRC_MATCH_TABLE_READ( ( index * entrySize ), ramEntry, entrySize ); if( osal_memcmp( pAddr, ramEntry, entrySize ) == TRUE ) { /* Match found */ return index; } } return MAC_SRCMATCH_INVALID_INDEX;}/********************************************************************* * @fn macSrcMatchSetPendEnBit * * @brief Set the enable bit in the source address table * * @param index - index of the entry in the source address table * * @return none */static void macSrcMatchSetPendEnBit( uint8 index ){ uint24 enable; uint8 buf[MAC_SRCMATCH_ENABLE_BITMAP_LEN]; enable = MAC_RADIO_SRC_MATCH_GET_PENDEN(); if( macSrcMatchAddrMode == SADDR_MODE_SHORT ) { enable |= ( (uint24)0x01 << index ); osal_buffer_uint24( buf, enable ); MAC_RADIO_SRC_MATCH_SET_SHORTPENDEN( (unsigned char *)buf ); } else { enable |= ( (uint24)0x01 << ( index * 2 ) ); osal_buffer_uint24( buf, enable ); MAC_RADIO_SRC_MATCH_SET_EXTPENDEN( (unsigned char *)buf ); }}/********************************************************************* * @fn macSrcMatchSetEnableBit * * @brief Set or clear the enable bit in the SRCMATCH EN register * * @param index - index of the entry in the source address table * @param option - true (set the enable bit), or false (clear the enable bit) * * @return none */static void macSrcMatchSetEnableBit( uint8 index, bool option ){ uint24 enable; enable = MAC_RADIO_SRC_MATCH_GET_EN(); if( option == TRUE ) { if( macSrcMatchAddrMode == SADDR_MODE_SHORT ) { enable |= ( (uint24)0x01 << index ); MAC_RADIO_SRC_MATCH_SET_SHORTEN( enable ); } else { enable |= ( (uint24)0x01 << ( index * 2 ) ); MAC_RADIO_SRC_MATCH_SET_EXTEN( enable ); } } else { if( macSrcMatchAddrMode == SADDR_MODE_SHORT ) { enable &= ~( (uint24)0x01 << index ); MAC_RADIO_SRC_MATCH_SET_SHORTEN( enable ); } else { enable &= ~( (uint24)0x01 << ( index * 2 ) ); MAC_RADIO_SRC_MATCH_SET_EXTEN( enable ); } }}/********************************************************************* * @fn macSrcMatchCheckEnableBit * * @brief Check the enable bit in the source address table * * @param index - index of the entry in the source address table * * @return TRUE or FALSE */static bool macSrcMatchCheckEnableBit( uint8 index ){ uint24 enable; if( macSrcMatchAddrMode == SADDR_MODE_EXT ) { index *= 2; } enable = MAC_RADIO_SRC_MATCH_GET_EN(); if( enable & ( (uint24)0x01 << index ) ) { return TRUE; } return FALSE; } /********************************************************************* * @fn macSrcMatchGetEnableBit * * @brief Return the SRCMATCH enable bitmap * * @param none * * @return uint24 - 24 bits bitmap */static uint24 macSrcMatchGetEnableBit( void ){ uint8 buf[MAC_SRCMATCH_ENABLE_BITMAP_LEN]; if( macSrcMatchAddrMode == SADDR_MODE_SHORT ) { MAC_RADIO_GET_SRC_SHORTEN( (unsigned char *)buf ); } else { MAC_RADIO_GET_SRC_EXTEN( (unsigned char *)buf ); } return osal_build_uint32( buf, MAC_SRCMATCH_ENABLE_BITMAP_LEN );}/********************************************************************* * @fn macSrcMatchGetPendEnBit * * @brief Return the SRCMATCH Pend enable bitmap * * @param none * * @return uint24 - 24 bits bitmap */static uint24 macSrcMatchGetPendEnBit( void ){ uint8 buf[MAC_SRCMATCH_ENABLE_BITMAP_LEN]; if( macSrcMatchAddrMode == SADDR_MODE_SHORT ) { MAC_RADIO_GET_SRC_SHORTPENDEN( (unsigned char *)buf ); } else { MAC_RADIO_GET_SRC_EXTENPEND( (unsigned char *)buf ); } return osal_build_uint32( buf, MAC_SRCMATCH_ENABLE_BITMAP_LEN );}
你这个看着头疼,格式化一下再贴出来看看。
/* low-level */
#include "mac_api.h"
#include "mac_radio_defs.h"
/* osal */
#include "OSAL.h"
#include "saddr.h"
#include "ZComDef.h"
#include "mac_autopend.h"
/* ------------------------------------------------------------------------------------------------
* Defines
* ------------------------------------------------------------------------------------------------
*/
#define MAC_SRCMATCH_INVALID_INDEX 0xFF
#define MAC_SRCMATCH_SHORT_ENTRY_SIZE 4
#define MAC_SRCMATCH_EXT_ENTRY_SIZE Z_EXTADDR_LEN
#define MAC_SRCMATCH_SHORT_MAX_NUM_ENTRIES 24
#define MAC_SRCMATCH_EXT_MAX_NUM_ENTRIES 12
#define MAC_SRCMATCH_ENABLE_BITMAP_LEN 3
/* ------------------------------------------------------------------------------------------------
* Global Variables
* ------------------------------------------------------------------------------------------------
*/
bool macSrcMatchIsEnabled = FALSE;
/* ------------------------------------------------------------------------------------------------
* Local Variables
* ------------------------------------------------------------------------------------------------
*/
/*
The following local Varables are only set in MAC_SrcMatchEnable()
They are read only to the rest of the module.
*/
uint8 macSrcMatchMaxNumEntries = 0;
uint8 macSrcMatchAddrMode = SADDR_MODE_SHORT;
bool macSrcMatchIsAckAllPending = FALSE;
/* ------------------------------------------------------------------------------------------------
* Local Functions
* ------------------------------------------------------------------------------------------------
*/
static uint8 macSrcMatchFindEmptyEntry( void );
static uint8 macSrcMatchCheckSrcAddr ( sAddr_t *addr, uint16 panID );
static void macSrcMatchSetPendEnBit( uint8 index );
static void macSrcMatchSetEnableBit( uint8 index, bool option );
static bool macSrcMatchCheckEnableBit( uint8 index );
static uint24 macSrcMatchGetEnableBit( void );
static uint24 macSrcMatchGetPendEnBit( void );
/*********************************************************************
* @fn MAC_SrcMatchEnable
*
* @brief Enabled AUTOPEND and source address matching. If number of source
* address table entries asked for is more than the hardware
* supports. It will allocate maximum number of entries and return
* MAC_INVALID_PARAMETER. This function shall be not be called from
* ISR. It is not thread safe.
*
* @param addressType - address type that the application uses
* SADDR_MODE_SHORT or SADDR_MODE_EXT
* @param num - number of source address table entries to be used
*
* @return MAC_SUCCESS or MAC_INVALID_PARAMETER
*/
uint8 MAC_SrcMatchEnable ( uint8 addrType, uint8 num )
{
uint8 rtn;
uint8 maxNum;
/* Verify the address type */
if( addrType != SADDR_MODE_SHORT && addrType != SADDR_MODE_EXT )
{
return MAC_INVALID_PARAMETER;
}
maxNum = ( addrType == SADDR_MODE_SHORT ) ?
MAC_SRCMATCH_SHORT_MAX_NUM_ENTRIES : MAC_SRCMATCH_EXT_MAX_NUM_ENTRIES;
if( num > maxNum )
{
rtn = MAC_INVALID_PARAMETER;
num = maxNum;
}
else
{
rtn = MAC_SUCCESS;
}
/* Turn on Frame Filter (TIMAC enables frame filter by default), TBD */
MAC_RADIO_TURN_ON_RX_FRAME_FILTERING();
/* Turn on Auto ACK (TIMAC turn on Auto ACK by default), TBD */
MAC_RADIO_TURN_ON_AUTO_ACK();
/* Turn on Autopend: set SRCMATCH.AUTOPEND and SRCMATCH.SRC_MATCH_EN */
MAC_RADIO_TURN_ON_SRC_MATCH();
/* Set SRCMATCH.AUTOPEND */
MAC_RADIO_TURN_ON_AUTOPEND();
/* Configure all the globals */
macSrcMatchIsEnabled = TRUE;
macSrcMatchMaxNumEntries = num;
macSrcMatchAddrMode = addrType;
return rtn;
}
/*********************************************************************
* @fn MAC_SrcMatchAddEntry
*
* @brief Add a short or extended address to source address table. This
* function shall be not be called from ISR. It is not thread safe.
*
* @param addr - a pointer to sAddr_t which contains addrMode
* and a union of a short 16-bit MAC address or an extended
* 64-bit MAC address to be added to the source address table.
* @param panID - the device PAN ID. It is only used when the addr is
* using short address
* @return MAC_SUCCESS or MAC_NO_RESOURCES (source address table full)
* or MAC_DUPLICATED_ENTRY (the entry added is duplicated),
* or MAC_INVALID_PARAMETER if the input parameters are invalid.
*/
uint8 MAC_SrcMatchAddEntry ( sAddr_t *addr, uint16 panID )
{
uint8 index;
uint8 entry[MAC_SRCMATCH_SHORT_ENTRY_SIZE];
/* Check if the input parameters are valid */
if ( addr == NULL || addr->addrMode != macSrcMatchAddrMode )
{
return MAC_INVALID_PARAMETER;
}
/* Check if the entry already exists. Do not add duplicated entry */
if ( macSrcMatchCheckSrcAddr( addr, panID ) != MAC_SRCMATCH_INVALID_INDEX )
{
return MAC_DUPLICATED_ENTRY;
}
/* If not duplicated, write to the radio RAM and enable the control bit */
/* Find the first empty entry */
index = macSrcMatchFindEmptyEntry();
if ( index == macSrcMatchMaxNumEntries )
{
return MAC_NO_RESOURCES; /* Table is full */
}
if ( macSrcMatchAddrMode == SADDR_MODE_SHORT )
{
/* Write the PanID and short address */
entry[0] = LO_UINT16( panID ); /* Little Endian for the radio RAM */
entry[1] = HI_UINT16( panID );
entry[2] = LO_UINT16( addr->addr.shortAddr );
entry[3] = HI_UINT16( addr->addr.shortAddr );
MAC_RADIO_SRC_MATCH_TABLE_WRITE( ( index * MAC_SRCMATCH_SHORT_ENTRY_SIZE ),
entry, MAC_SRCMATCH_SHORT_ENTRY_SIZE );
}
else
{
/* Write the extended address */
MAC_RADIO_SRC_MATCH_TABLE_WRITE( ( index * MAC_SRCMATCH_EXT_ENTRY_SIZE ),
addr->addr.extAddr, MAC_SRCMATCH_EXT_ENTRY_SIZE );
}
/* Set the Autopend enable bits */
macSrcMatchSetPendEnBit( index );
/* Set the Src Match enable bits */
macSrcMatchSetEnableBit( index, TRUE );
return MAC_SUCCESS;
}
/*********************************************************************
* @fn MAC_SrcMatchDeleteEntry
*
* @brief Delete a short or extended address from source address table.
* This function shall be not be called from ISR. It is not thread safe.
*
* @param addr - a pointer to sAddr_t which contains addrMode
* and a union of a short 16-bit MAC address or an extended
* 64-bit MAC address to be deleted from the source address table.
* @param panID - the device PAN ID. It is only used when the addr is
* using short address
*
* @return MAC_SUCCESS or MAC_INVALID_PARAMETER (address to be deleted
* cannot be found in the source address table).
*/
uint8 MAC_SrcMatchDeleteEntry ( sAddr_t *addr, uint16 panID )
{
uint8 index;
if ( addr == NULL || addr->addrMode != macSrcMatchAddrMode )
{
return MAC_INVALID_PARAMETER;
}
/* Look up the source address table and find the entry. */
index = macSrcMatchCheckSrcAddr( addr, panID );
if( index == MAC_SRCMATCH_INVALID_INDEX )
{
return MAC_INVALID_PARAMETER;
}
/* Clear Src Match enable bits */
macSrcMatchSetEnableBit( index, FALSE );
return MAC_SUCCESS;
}
/*********************************************************************
* @fn MAC_SrcMatchAckAllPending
*
* @brief Enabled/disable acknowledging all packets with pending bit set
* The application normally enables it when adding new entries to
* the source address table fails due to the table is full, or
* disables it when more entries are deleted and the table has
* empty slots.
*
* @param option - TRUE (acknowledging all packets with pending field set)
* FALSE (acknowledging all packets with pending field cleared)
*
* @return none
*/
void MAC_SrcMatchAckAllPending ( uint8 option )
{
if( option == TRUE )
{
macSrcMatchIsAckAllPending = TRUE;
/* Set the PENDING_OR register */
MAC_RADIO_TURN_ON_PENDING_OR();
}
else
{
macSrcMatchIsAckAllPending = FALSE;
/* Clear the PENDING_OR register */
MAC_RADIO_TURN_OFF_PENDING_OR();
}
}
/*********************************************************************
* @fn MAC_SrcMatchCheckAllPending
*
* @brief Check if acknowledging all packets with pending bit set
* is enabled.
*
* @param none
*
* @return MAC_AUTOACK_PENDING_ALL_ON or MAC_AUTOACK_PENDING_ALL_OFF
*/
uint8 MAC_SrcMatchCheckAllPending ( void )
{
if( macSrcMatchIsAckAllPending == TRUE )
{
return MAC_AUTOACK_PENDING_ALL_ON;
}
return MAC_AUTOACK_PENDING_ALL_OFF;
}
/*********************************************************************
* @fn MAC_SrcMatchCheckResult
*
* @brief Check the result of source matching
*
* @param index - index of the entry in the source address table
*
* @return TRUE or FALSE
*/
MAC_INTERNAL_API bool MAC_SrcMatchCheckResult( void )
{
uint8 resIndex;
if ( macSrcMatchIsAckAllPending )
{
return (TRUE);
}
MAC_RADIO_SRC_MATCH_RESINDEX( resIndex );
return ( resIndex & AUTOPEND_RES );
}
/*********************************************************************
* @fn macSrcMatchFindEmptyEntry
*
* @brief return index of the first empty entry found
*
* @param none
*
* @return uint8 - return index of the first empty entry found
*/
static uint8 macSrcMatchFindEmptyEntry( void )
{
uint8 index;
uint24 enable;
enable = MAC_RADIO_SRC_MATCH_GET_EN();
if( macSrcMatchAddrMode == SADDR_MODE_SHORT )
{
for( index = 0; index < macSrcMatchMaxNumEntries; index++ )
{
if( ( enable & ( (uint24)0x01 << index ) ) == 0 )
{
return index;
}
}
}
else
{
for( index = 0; index < macSrcMatchMaxNumEntries; index++ )
{
if( ( enable & ( (uint24)0x01 << ( index * 2 ) ) ) == 0 )
{
return index;
}
}
}
/*
The value of index shall be macSrcMatchMaxNumEntries when it executes
here. The table is full.
*/
return index;
}
/*********************************************************************
* @fn macSrcMatchCheckSrcAddr
*
* @brief Check if a short or extended address is in the source address table.
* This function shall not be called from ISR. It is not thread safe.
*
* @param addr - a pointer to sAddr_t which contains addrMode
* and a union of a short 16-bit MAC address or an extended
* 64-bit MAC address to be checked in the source address table.
* @param panID - the device PAN ID. It is only used when the addr is
* using short address
* @return uint8 - index of the entry in the table. Return
* MAC_SRCMATCH_INVALID_INDEX (0xFF) if address not found.
*/
static uint8 macSrcMatchCheckSrcAddr ( sAddr_t *addr, uint16 panID )
{
uint8 index;
uint8 *pAddr;
uint8 entrySize;
uint8 entry[MAC_SRCMATCH_SHORT_ENTRY_SIZE];
uint8 ramEntry[MAC_SRCMATCH_EXT_ENTRY_SIZE];
/*
Currently, shadow memory is not supported to optimize SPI traffic.
*/
if( macSrcMatchAddrMode == SADDR_MODE_SHORT )
{
entry[0] = LO_UINT16( panID ); /* Little Endian for the radio RAM */
entry[1] = HI_UINT16( panID );
entry[2] = LO_UINT16( addr->addr.shortAddr );
entry[3] = HI_UINT16( addr->addr.shortAddr );
pAddr = entry;
entrySize = MAC_SRCMATCH_SHORT_ENTRY_SIZE;
}
else
{
pAddr = addr->addr.extAddr;
entrySize = MAC_SRCMATCH_EXT_ENTRY_SIZE;
}
for( index = 0; index < macSrcMatchMaxNumEntries; index++ )
{
/* Check if the entry is enabled */
if( macSrcMatchCheckEnableBit( index ) == FALSE )
{
continue;
}
/* Compare the short address and pan ID */
MAC_RADIO_SRC_MATCH_TABLE_READ( ( index * entrySize ), ramEntry, entrySize );
if( osal_memcmp( pAddr, ramEntry, entrySize ) == TRUE )
{
/* Match found */
return index;
}
}
return MAC_SRCMATCH_INVALID_INDEX;
}
/*********************************************************************
* @fn macSrcMatchSetPendEnBit
*
* @brief Set the enable bit in the source address table
*
* @param index - index of the entry in the source address table
*
* @return none
*/
static void macSrcMatchSetPendEnBit( uint8 index )
{
uint24 enable;
uint8 buf[MAC_SRCMATCH_ENABLE_BITMAP_LEN];
enable = MAC_RADIO_SRC_MATCH_GET_PENDEN();
if( macSrcMatchAddrMode == SADDR_MODE_SHORT )
{
enable |= ( (uint24)0x01 << index );
osal_buffer_uint24( buf, enable );
MAC_RADIO_SRC_MATCH_SET_SHORTPENDEN( (unsigned char *)buf );
}
else
{
enable |= ( (uint24)0x01 << ( index * 2 ) );
osal_buffer_uint24( buf, enable );
MAC_RADIO_SRC_MATCH_SET_EXTPENDEN( (unsigned char *)buf );
}
}
/*********************************************************************
* @fn macSrcMatchSetEnableBit
*
* @brief Set or clear the enable bit in the SRCMATCH EN register
*
* @param index - index of the entry in the source address table
* @param option - true (set the enable bit), or false (clear the enable bit)
*
* @return none
*/
static void macSrcMatchSetEnableBit( uint8 index, bool option )
{
uint24 enable;
enable = MAC_RADIO_SRC_MATCH_GET_EN();
if( option == TRUE )
{
if( macSrcMatchAddrMode == SADDR_MODE_SHORT )
{
enable |= ( (uint24)0x01 << index );
MAC_RADIO_SRC_MATCH_SET_SHORTEN( enable );
}
else
{
enable |= ( (uint24)0x01 << ( index * 2 ) );
MAC_RADIO_SRC_MATCH_SET_EXTEN( enable );
}
}
else
{
if( macSrcMatchAddrMode == SADDR_MODE_SHORT )
{
enable &= ~( (uint24)0x01 << index );
MAC_RADIO_SRC_MATCH_SET_SHORTEN( enable );
}
else
{
enable &= ~( (uint24)0x01 << ( index * 2 ) );
MAC_RADIO_SRC_MATCH_SET_EXTEN( enable );
}
}
}
/*********************************************************************
* @fn macSrcMatchCheckEnableBit
*
* @brief Check the enable bit in the source address table
*
* @param index - index of the entry in the source address table
*
* @return TRUE or FALSE
*/
static bool macSrcMatchCheckEnableBit( uint8 index )
{
uint24 enable;
if( macSrcMatchAddrMode == SADDR_MODE_EXT )
{
index *= 2;
}
enable = MAC_RADIO_SRC_MATCH_GET_EN();
if( enable & ( (uint24)0x01 << index ) )
{
return TRUE;
}
return FALSE;
}
/*********************************************************************
* @fn macSrcMatchGetEnableBit
*
* @brief Return the SRCMATCH enable bitmap
*
* @param none
*
* @return uint24 - 24 bits bitmap
*/
static uint24 macSrcMatchGetEnableBit( void )
{
uint8 buf[MAC_SRCMATCH_ENABLE_BITMAP_LEN];
if( macSrcMatchAddrMode == SADDR_MODE_SHORT )
{
MAC_RADIO_GET_SRC_SHORTEN( buf );
}
else
{
MAC_RADIO_GET_SRC_EXTEN( buf );
}
return osal_build_uint32( buf, MAC_SRCMATCH_ENABLE_BITMAP_LEN );
}
/*********************************************************************
* @fn macSrcMatchGetPendEnBit
*
* @brief Return the SRCMATCH Pend enable bitmap
*
* @param none
*
* @return uint24 - 24 bits bitmap
*/
static uint24 macSrcMatchGetPendEnBit( void )
{
uint8 buf[MAC_SRCMATCH_ENABLE_BITMAP_LEN];
if( macSrcMatchAddrMode == SADDR_MODE_SHORT )
{
MAC_RADIO_GET_SRC_SHORTPENDEN( buf );
}
else
{
MAC_RADIO_GET_SRC_EXTENPEND( buf );
}
return osal_build_uint32( buf, MAC_SRCMATCH_ENABLE_BITMAP_LEN );
}
类型不匹配,强转一下类型就可以啦
您好,我是有问必答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632
非常感谢您使用有问必答服务,为了后续更快速的帮您解决问题,现诚邀您参与有问必答体验反馈。您的建议将会运用到我们的产品优化中,希望能得到您的支持与协助!
速戳参与调研>>>https://t.csdnimg.cn/Kf0y