本文整理汇总了C++中WF_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ WF_ASSERT函数的具体用法?C++ WF_ASSERT怎么用?C++ WF_ASSERT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WF_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WaitForMgmtResponseAndReadData
/*******************************************************************************
Function:
void WaitForMgmtResponseAndReadData(UINT8 expectedSubtype, UINT8 numDataBytes,
UINT8 startIndex, UINT8 *p_data)
Summary:
Waits for a management response and read data.
Description:
Waits for the mgmt response message and validates it by:
1) checking the result field
2) verifying that the received subtype matches the expected subtype
In addition, this function reads the desired number of data bytes from
the mgmt response, copies them to p_data, and then frees the mgmt buffer.
Precondition:
MACInit must be called.
Parameters:
expectedSubtype -- management message subtype that we are expecting
p_data -- pointer where any desired management data bytes will be written
numDataBytes -- Number of data bytes from mgmt response to write to
p_data. Data always starts at index 4 of mgmt response.
skipDataRead -- if TRUE, then no data will be read and the mgmt buffer will not
be freed. If FALSE, the data will be read and the mgmt buffer
will be freed.
Returns:
None
Remarks:
*****************************************************************************/
void WaitForMgmtResponseAndReadData(UINT8 expectedSubtype,
UINT8 numDataBytes,
UINT8 startIndex,
UINT8 *p_data)
{
tMgmtMsgRxHdr hdr; /* management msg header struct */
WaitForMgmtResponse(expectedSubtype, DO_NOT_FREE_MGMT_BUFFER);
/* if made it here then received a management message */
RawRead(RAW_MGMT_RX_ID, 0, (UINT16)(sizeof(tMgmtMsgRxHdr)), (UINT8 *)&hdr);
/* check header result and subtype fields */
WF_ASSERT(hdr.result == WF_SUCCESS || hdr.result == WF_ERROR_NO_STORED_BSS_DESCRIPTOR);
WF_ASSERT(hdr.subtype == expectedSubtype);
/* if caller wants to read data from this mgmt response */
if (numDataBytes > 0)
{
RawRead(RAW_MGMT_RX_ID, startIndex, numDataBytes, p_data);
}
/* free the mgmt buffer */
DeallocateMgmtRxBuffer();
}
示例2: AllocateDataTxBuffer
/*****************************************************************************
Function:
BOOL AllocateDataTxBuffer(UINT16 bytesNeeded)
Summary:
Allocates a Data Tx buffer for use by the TCP/IP stack.
Description:
Determines if WiFi chip has enough memory to allocate a tx data buffer, and,
if so, allocates it.
Precondition:
None
Parameters:
bytesNeeded -- number of bytes needed for the data tx message
Returns:
True if data tx buffer successfully allocated, else False
Remarks:
None
*****************************************************************************/
BOOL AllocateDataTxBuffer(UINT16 bytesNeeded)
{
UINT16 bufAvail;
UINT16 byteCount;
WF_ASSERT(GetRawWindowState(RAW_DATA_TX_ID) != WF_RAW_DATA_MOUNTED);
/* Ensure the MRF24W is awake (only applies if PS-Poll was enabled) */
EnsureWFisAwake();
/* get total bytes available for DATA tx memory pool */
bufAvail = Read16BitWFRegister(WF_HOST_WFIFO_BCNT0_REG) & 0x0fff; /* LS 12 bits contain length */
/* if enough bytes available to allocate */
if ( bufAvail >= bytesNeeded )
{
/* allocate and create the new Tx buffer (mgmt or data) */
byteCount = RawMove(RAW_DATA_TX_ID, RAW_DATA_POOL, TRUE, bytesNeeded);
WF_ASSERT(byteCount != 0);
/* flag this raw window as mounted (in use) */
SetRawWindowState(RAW_DATA_TX_ID, WF_RAW_DATA_MOUNTED);
return TRUE;
}
/* else not enough bytes available at this time to satisfy request */
else
{
return FALSE;
}
}
示例3: WaitForMgmtResponseAndReadData
/*****************************************************************************
* FUNCTION: WaitForMgmtRespAndReadData
*
* RETURNS: None
*
* PARAMS: expectedSubtype -- management message subtype that we are expecting
* p_data -- pointer where any desired management data bytes
* will be written
* numDataBytes -- Number of data bytes from mgmt response to write to
* p_data. Data always starts at index 4 of mgmt response.
* skipDataRead -- if TRUE, then no data will be read and the mgmt buffer will not
* be freed. If FALSE, the data will be read and the mgmt buffer
* will be freed.
*
* NOTES: Waits for the mgmt response message and validates it by:
* 1) checking the result field
* 2) verifying that the received subtype matches the execpted subtype
*
* In addition, this function reads the desired number of data bytes from
* the mgmt response, copies them to p_data, and then frees the mgmt buffer.
*****************************************************************************/
void WaitForMgmtResponseAndReadData(UINT8 expectedSubtype,
UINT8 numDataBytes,
UINT8 startIndex,
UINT8 *p_data)
{
tMgmtMsgRxHdr hdr; /* management msg header struct */
WaitForMgmtResponse(expectedSubtype, DO_NOT_FREE_MGMT_BUFFER);
/* if made it here then received a management message */
RawRead(RAW_RX_ID, 0, (UINT16)(sizeof(tMgmtMsgRxHdr)), (UINT8 *)&hdr);
/* check header result and subtype fields */
WF_ASSERT(hdr.result == WF_SUCCESS || hdr.result == WF_ERROR_NO_STORED_BSS_DESCRIPTOR);
WF_ASSERT(hdr.subtype == expectedSubtype);
/* if caller wants to read data from this mgmt response */
if (numDataBytes > 0)
{
RawRead(RAW_RX_ID, startIndex, numDataBytes, p_data);
}
/* free the mgmt buffer */
DeallocateMgmtRxBuffer();
/* if there was a mounted data packet prior to the mgmt tx/rx transaction, then restore it */
if (RestoreRxData == TRUE)
{
RestoreRxData = FALSE;
PopRawWindow(RAW_RX_ID);
SetRawWindowState(RAW_RX_ID, WF_RAW_DATA_MOUNTED);
}
}
示例4: WF_RxDataReadPacket
/*
*********************************************************************************************************
* WF_RxDataReadPacket()
*
* Description : Reads all or part of an Rx data packet from MRF24WB0M memory to Host CPU memory.
*
* Argument(s) : p_rxData - pointer to where Rx data packet will be written
* length - Number of bytes to read from MRF24WB0M memory
* startIndex - start index within MRF24WB0M memory to start read from
*
* Return(s) : None
*
* Caller(s) : Application
*
* Notes: : None
*
*********************************************************************************************************
*/
void WF_RxDataReadPacket(uint8_t *p_rxData,
uint16_t length,
uint16_t startIndex)
{
#if !defined(USE_WF_HOST_BUFFER)
uint16_t byteCount;
#endif
WF_ASSERT(startIndex == 0);
/* if application calls this function, and gHostRAWDataPacketReceived is not true, then error, because */
/* driver has not received a data packet. */
if (!g_HostRAWDataPacketReceived)
{
WF_ASSERT(false);
}
g_HostRAWDataPacketReceived = false; /* clear flag for next data packet */
/* Ensure the MRF24WB0M is awake (only applies if PS-Poll was enabled) */
EnsureWFisAwake();
#if !defined(USE_WF_HOST_BUFFER) /* when testing with MCHP stack the packet is already mounted */
/* Mount Read FIFO to RAW Rx window. Size of Rx data packet is returned */
byteCount = RawMountRxBuffer();
WF_ASSERT(byteCount > 0);
#endif
/* now that buffer mounted it is safe to reenable interrupts */
WF_EintEnable();
/* read the requested bytes into callers buffer */
RawRead(RAW_RX_ID, RAW_RX_DEST_ADD_INDEX + startIndex, length, p_rxData);
}
示例5: ChipReset
/*****************************************************************************
* FUNCTION: ChipReset
*
* RETURNS: N/A
*
* PARAMS:
* N/A
*
*
* NOTES: Performs the necessary SPI operations to cause the MRF24WB0M to reset.
* This function also implements a delay so that it will not return until
* the WiFi device is ready to receive messages again. The delay time will
* vary depending on the amount of code that must be loaded from serial
* flash.
*****************************************************************************/
static void ChipReset(void)
{
UINT16 value;
UINT32 timeoutPeriod;
UINT32 startTickCount;
timeoutPeriod = TICKS_PER_SECOND; /* 1000 ms */
/* needed for Microchip PICTail (chip enable active low) */
WF_SetCE_N(WF_LOW); /* set low to enable regulator */
/* Configure reset pin */
WF_SetRST_N(WF_HIGH);
/* Let SPI lines settle before first SPI transaction */
DelayMs(1);
/* clear the power bit to disable low power mode on the MRF24WB0M */
Write16BitWFRegister(WF_PSPOLL_H_REG, 0x0000);
/* Set HOST_RESET bit in register to put device in reset */
Write16BitWFRegister(WF_HOST_RESET_REG, Read16BitWFRegister(WF_HOST_RESET_REG) | WF_HOST_RESET_MASK);
/* Clear HOST_RESET bit in register to take device out of reset */
Write16BitWFRegister(WF_HOST_RESET_REG, Read16BitWFRegister(WF_HOST_RESET_REG) & ~WF_HOST_RESET_MASK);
/* after reset is started poll register to determine when HW reset has completed */
startTickCount = (UINT32)TickGet();
do
{
Write16BitWFRegister(WF_INDEX_ADDR_REG, WF_HW_STATUS_REG);
value = Read16BitWFRegister(WF_INDEX_DATA_REG);
if (TickGet() - startTickCount >= timeoutPeriod)
{
WF_ASSERT(FALSE);
}
} while ( (value & WF_HW_STATUS_NOT_IN_RESET_MASK) == 0);
/* if SPI not connected will read all 1's */
WF_ASSERT(value != 0xffff);
/* now that chip has come out of HW reset, poll the FIFO byte count register */
/* which will be set to a non-zero value when the MRF24WB0M initialization is */
/* complete. */
startTickCount = (UINT32)TickGet();
do
{
value = Read16BitWFRegister(WF_HOST_WFIFO_BCNT0_REG);
if (TickGet() - startTickCount >= timeoutPeriod)
{
WF_ASSERT(FALSE);
}
} while (value == 0);
}
示例6: WaitForMgmtResponse
/*****************************************************************************
* FUNCTION: WaitForMgmtResponse
*
* RETURNS: None
*
* PARAMS: expectedSubtype -- The expected subtype of the mgmt response
* freeAction -- FREE_MGMT_BUFFER or DO_NOT_FREE_MGMT_BUFFER
*
* NOTES: Called after sending a mgmt request. This function waits for a mgmt
* response. The caller can optionally request the the management
* response be freed immediately (by this function) or not freed. If not
* freed the caller is responsible to free the response buffer.
*****************************************************************************/
void WaitForMgmtResponse(UINT8 expectedSubtype, UINT8 freeAction)
{
tMgmtMsgRxHdr hdr;
/* Wait until mgmt response is received */
while (gMgmtConfirmMsgReceived == FALSE)
{
WFProcess();
/* if received a data packet while waiting for mgmt packet */
if (g_HostRAWDataPacketReceived)
{
/* loop until stack has processed the received data message */
while (g_HostRAWDataPacketReceived)
{
StackTask();
}
/* ensure interrupts enabled */
WF_EintEnable();
}
}
/* set this back to FALSE so the next mgmt send won't think he has a response before one is received */
gMgmtConfirmMsgReceived = FALSE;
/* if the caller wants to delete the response immediately (doesn't need any data from it */
if (freeAction == FREE_MGMT_BUFFER)
{
/* read and verify result before freeing up buffer to ensure our message send was successful */
RawRead(RAW_RX_ID, 0, (UINT16)(sizeof(tMgmtMsgRxHdr)), (UINT8 *)&hdr);
/* Mgmt response 'result' field should always indicate success. If this assert is hit the error codes are located */
/* WFApi.h. Search for WF_SUCCESS for the list of error codes. */
WF_ASSERT(hdr.result == WF_SUCCESS);
/* mgmt response subtype had better match subtype we were expecting */
WF_ASSERT(hdr.subtype == expectedSubtype);
/* free mgmt buffer */
DeallocateMgmtRxBuffer();
/* if there was a mounted data packet prior to the mgmt tx/rx transaction, then restore it */
if (RestoreRxData == TRUE)
{
RestoreRxData = FALSE;
PopRawWindow(RAW_RX_ID);
SetRawWindowState(RAW_RX_ID, WF_RAW_DATA_MOUNTED);
}
}
}
示例7: ChipReset
/*****************************************************************************
* FUNCTION: ChipReset
*
* RETURNS: N/A
*
* PARAMS:
* N/A
*
*
* NOTES: Performs the necessary SPI operations to cause the MRF24W to do a soft
* reset.
*
* This function waits for the MRF24WG to complete its initialization before
* returning to the caller. The largest part of the wait is for the MRF24WG
* to download any patch code in FLASH into its RAM.
*****************************************************************************/
static void ChipReset(void)
{
UINT16 value;
UINT32 timeoutPeriod;
UINT32 startTickCount;
/* clear the power bit to disable low power mode on the MRF24W */
Write16BitWFRegister(WF_PSPOLL_H_REG, 0x0000);
/* Set HOST_RESET bit in register to put device in reset */
Write16BitWFRegister(WF_HOST_RESET_REG, Read16BitWFRegister(WF_HOST_RESET_REG) | WF_HOST_RESET_MASK);
/* Clear HOST_RESET bit in register to take device out of reset */
Write16BitWFRegister(WF_HOST_RESET_REG, Read16BitWFRegister(WF_HOST_RESET_REG) & ~WF_HOST_RESET_MASK);
/* after reset is started poll register to determine when HW reset has completed */
timeoutPeriod = TICKS_PER_SECOND * 3; /* 3000 ms */
startTickCount = (UINT32)TickGet();
do
{
Write16BitWFRegister(WF_INDEX_ADDR_REG, WF_HW_STATUS_REG);
value = Read16BitWFRegister(WF_INDEX_DATA_REG);
if (TickGet() - startTickCount >= timeoutPeriod)
{
WF_ASSERT(FALSE);
}
} while ( (value & WF_HW_STATUS_NOT_IN_RESET_MASK) == 0);
/* if SPI not connected will read all 1's */
WF_ASSERT(value != 0xffff);
/* now that chip has come out of HW reset, poll the FIFO byte count register */
/* which will be set to a non-zero value when the MRF24W initialization is */
/* complete. */
startTickCount = (UINT32)TickGet();
do
{
value = Read16BitWFRegister(WF_HOST_WFIFO_BCNT0_REG);
if (TickGet() - startTickCount >= timeoutPeriod)
{
#if defined(__Digilent_Build__)
break;
#else
WF_ASSERT(FALSE);
#endif
}
} while (value == 0);
}
示例8: WF_MulticastGetConfig
/*******************************************************************************
Function:
void WF_MulticastGetConfig(uint8_t filterId, tWFMultiCastConfig *p_config);
Summary:
Gets a multicast address filter from one of the two multicast filters.
Description:
Gets the current state of the specified Multicast Filter.
Normally would call SendGetParamMsg, but this GetParam returns all 6 address
filters + 2 more bytes for a total of 48 bytes plus header. So, doing this
msg manually to not require a large stack allocation to hold all the data.
Exact format of management message stored on device is:
[0] -- always mgmt response (2)
[1] -- always WF_GET_PARAM_SUBTYPE (16)
[2] -- result (1 if successful)
[3] -- mac state (not used)
[4] -- data length (length of response data starting at index 6)
[5] -- not used
[6-11] -- Compare Address 0 address
[12] -- Compare Address 0 group
[13] -- Compare Address 0 type
[14] -- Compare Address 0 macBitMask
[15-17] -- Not used
[18-23] -- Compare Address 1 address
[24] -- Compare Address 1 group
[25] -- Compare Address 1 type
[26] -- Compare Address 1 macBitMask
[27-29] -- Not used
[30-35] -- Compare Address 2 address
[36] -- Compare Address 2 group
[37] -- Compare Address 2 type
[38] -- Compare Address 2 macBitMask
[39-41] -- Not used
[42-47] -- Compare Address 3 address
[48] -- Compare Address 3 group
[49] -- Compare Address 3 type
[50] -- Compare Address 3 macBitMask
[51-53] -- Not used
[54-59] -- Compare Address 4 address
[60] -- Compare Address 4 group
[61] -- Compare Address 4 type
[62] -- Compare Address 4 macBitMask
[63-65] -- Not used
[66-71] -- Compare Address 5 address
[72] -- Compare Address 5 group
[73] -- Compare Address 5 type
[74] -- Compare Address 5 macBitMask
[75-77] -- Not used
Precondition:
MACInit must be called first.
Parameters:
filterId -- ID of filter being retrieved. Must be:
WF_MULTICAST_FILTER_1 or WF_MULTICAST_FILTER_2
p_config -- Pointer to config structure filled in by this function.
Returns:
None.
Remarks:
Definition WF_USE_MULTICAST_FUNCTIONS needs to be enabled.
*****************************************************************************/
void WF_MulticastGetConfig(uint8_t filterId, tWFMultiCastConfig *p_config)
{
uint8_t hdr[4];
uint8_t paramData[12];
WF_ASSERT( filterId <= WF_MULTICAST_FILTER_16);
hdr[0] = WF_MGMT_REQUEST_TYPE;
hdr[1] = WF_GET_PARAM_SUBTYPE;
hdr[2] = 0x00; /* MS 8 bits of param Id, always 0 */
hdr[3] = PARAM_COMPARE_ADDRESS; /* LS 8 bits of param ID */
SendMgmtMsg(hdr, /* header */
sizeof(hdr), /* size of header */
&filterId, /* multicast filter id */
1); /* length is 1 */
WaitForMgmtResponseAndReadData(WF_GET_PARAM_SUBTYPE, /* expected subtype */
sizeof(paramData), /* num data bytes to read */
MSG_PARAM_START_DATA_INDEX, /* starting at this index */
paramData); /* write the response data here */
/* put param data into return structure */
p_config->filterId = filterId;
memcpy((void *)p_config->macBytes, (void *)¶mData[0], 6);
p_config->action = paramData[7];
p_config->macBitMask = paramData[8];
//.........这里部分代码省略.........
示例9: ProcessInterruptServiceResult
/*****************************************************************************
* FUNCTION: ProcessInterruptServiceResult
*
* RETURNS: N/A
*
* PARAMS:
* N/A
*
*
* NOTES: Processes EXINT from MRF24W. Called by WFProcess().
*****************************************************************************/
static void ProcessInterruptServiceResult(void)
{
uint8_t hostIntRegValue;
uint8_t hostIntMaskRegValue;
uint8_t hostInt;
/* read hostInt register to determine cause of interrupt */
hostIntRegValue = Read8BitWFRegister(WF_HOST_INTR_REG);
// OR in the saved interrupts during the time when we were waiting for raw complete, set by WFEintHandler()
hostIntRegValue |= g_HostIntSaved;
// done with the saved interrupts, clear variable
g_HostIntSaved = 0;
hostIntMaskRegValue = Read8BitWFRegister(WF_HOST_MASK_REG);
// AND the two registers together to determine which active, enabled interrupt has occurred
hostInt = hostIntRegValue & hostIntMaskRegValue;
// if received a level 2 interrupt (should not happen!)
if((hostInt & WF_HOST_INT_MASK_INT2) == WF_HOST_INT_MASK_INT2)
{
/* read the 16 bit interrupt register */
/* CURRENTLY unhandled interrupt */
WF_ASSERT(false);
WF_EintEnable();
}
// else if got a FIFO 1 Threshold interrupt (Management Fifo)
else if((hostInt & WF_HOST_INT_MASK_FIFO_1_THRESHOLD) == WF_HOST_INT_MASK_FIFO_1_THRESHOLD)
{
/* clear this interrupt */
Write8BitWFRegister(WF_HOST_INTR_REG, WF_HOST_INT_MASK_FIFO_1_THRESHOLD);
// notify MAC state machine that management message needs to be processed
g_MgmtReadMsgReady = true;
}
// else if got a FIFO 0 Threshold Interrupt (Data Fifo)
else if((hostInt & WF_HOST_INT_MASK_FIFO_0_THRESHOLD) == WF_HOST_INT_MASK_FIFO_0_THRESHOLD)
{
/* clear this interrupt */
Write8BitWFRegister(WF_HOST_INTR_REG, WF_HOST_INT_MASK_FIFO_0_THRESHOLD);
g_HostRAWDataPacketReceived = true; /* this global flag is used in MACGetHeader() to determine a received data packet */
}
// else got a Host interrupt that we don't handle
else if(hostInt)
{
/* unhandled interrupt */
/* clear this interrupt */
Write8BitWFRegister(WF_HOST_INTR_REG, hostInt);
WF_EintEnable();
}
// we got a spurious interrupt (no bits set in register)
else
{
/* spurious interrupt */
WF_EintEnable();
}
}
示例10: RawGetByte
/*****************************************************************************
* FUNCTION: RawGetByte
*
* RETURNS: error code
*
* PARAMS:
* rawId - RAW ID
* pBuffer - Buffer to read bytes into
* length - number of bytes to read
*
* NOTES: Reads bytes from the RAW engine
*****************************************************************************/
void RawGetByte(uint16_t rawId, uint8_t *pBuffer, uint16_t length)
{
uint8_t regId;
#if defined(OUTPUT_RAW_TX_RX)
uint16_t i;
#endif
/* if reading a data message do following check */
if (!g_WaitingForMgmtResponse)
{
// if RAW index previously set out of range and caller is trying to do illegal read
if ( (rawId==RAW_RX_ID) &&
g_rxIndexSetBeyondBuffer &&
(GetRawWindowState(RAW_RX_ID) == WF_RAW_DATA_MOUNTED) )
{
WF_ASSERT(false); /* attempting to read past end of RAW buffer */
}
}
regId = (rawId==RAW_ID_0) ? RAW_0_DATA_REG:RAW_1_DATA_REG;
ReadWFArray(regId, pBuffer, length);
#if defined(OUTPUT_RAW_TX_RX)
for (i = 0; i < length; ++i)
{
char buf[16];
sprintf(buf,"R: %#x\r\n", pBuffer[i]);
putsUART(buf);
}
#endif
}
示例11: RawSetByte
/*****************************************************************************
* FUNCTION: RawSetByte
*
* RETURNS: None
*
* PARAMS:
* rawId - RAW ID
* pBuffer - Buffer containing bytes to write
* length - number of bytes to read
*
* NOTES: Writes bytes to RAW window
*****************************************************************************/
void RawSetByte(UINT16 rawId, UINT8 *pBuffer, UINT16 length)
{
UINT8 regId;
#if defined(OUTPUT_RAW_TX_RX)
UINT16 i;
#endif
/* if previously set index past legal range and now trying to write to RAW engine */
if ( (rawId == 0) && g_rxIndexSetBeyondBuffer && (GetRawWindowState(RAW_TX_ID) == WF_RAW_DATA_MOUNTED) )
{
WF_ASSERT(FALSE); /* attempting to write past end of RAW window */
}
/* write RAW data to chip */
regId = (rawId==RAW_ID_0)?RAW_0_DATA_REG:RAW_1_DATA_REG;
WriteWFArray(regId, pBuffer, length);
#if defined(OUTPUT_RAW_TX_RX)
for (i = 0; i < length; ++i)
{
char buf[16];
sprintf(buf,"T: %#x\r\n", pBuffer[i]);
putsUART(buf);
}
#endif
}
示例12: WF_SetMultiCastFilter
/*******************************************************************************
Function:
void WF_SetMultiCastFilter(UINT8 multicastFilterId,
UINT8 multicastAddress[6])
Summary:
Sets a multicast address filter using one of the two multicast filters.
Description:
This function allows the application to configure up to two Multicast
Address Filters on the MRF24WB0M. If two active multicast filters are set
up they are OR’d together – the MRF24WB0M will receive and pass to the Host
CPU received packets from either multicast address.
The allowable values for the multicast filter are:
* WF_MULTICAST_FILTER_1
* WF_MULTICAST_FILTER_2
By default, both Multicast Filters are inactive.
Precondition:
MACInit must be called first.
Parameters:
multicastFilterId - WF_MULTICAST_FILTER_1 or WF_MULTICAST_FILTER_2
multicastAddress - 6-byte address (all 0xFF will inactivate the filter)
Returns:
None.
Remarks:
None.
*****************************************************************************/
void WF_SetMultiCastFilter(UINT8 multicastFilterId,
UINT8 multicastAddress[6])
{
int i;
BOOL deactivateFlag = TRUE;
UINT8 msgData[8];
WF_ASSERT( (multicastFilterId == WF_MULTICAST_FILTER_1) || (multicastFilterId == WF_MULTICAST_FILTER_2) );
/* check if all 6 bytes of the address are 0xff, implying that the caller wants to deactivate */
/* the multicast filter. */
for (i = 0; i < 6; ++i)
{
/* if any byte is not 0xff then a presume a valid multicast address */
if (multicastAddress[i] != 0xff)
{
deactivateFlag = FALSE;
break;
}
}
msgData[0] = multicastFilterId; /* Address Compare Register number to use */
if (deactivateFlag)
{
msgData[1] = ADDRESS_FILTER_DEACTIVATE;
}
else
{
msgData[1] = MULTICAST_ADDRESS; /* type of address being used in the filter */
}
memcpy(&msgData[2], (void *)multicastAddress, WF_MAC_ADDRESS_LENGTH);
SendSetParamMsg(PARAM_COMPARE_ADDRESS, msgData, sizeof(msgData) );
}
示例13: AllocateMgmtTxBuffer
/*****************************************************************************
Function:
BOOL AllocateMgmtTxBuffer(UINT16 bytesNeeded)
Summary:
Allocates a Mgmt Tx buffer
Description:
Determines if WiFi chip has enough memory to allocate a tx mgmt buffer, and,
if so, allocates it.
Precondition:
None
Parameters:
bytesNeeded -- number of bytes needed for the mgmt tx message
Returns:
True if mgmt tx buffer successfully allocated, else False
Remarks:
None
*****************************************************************************/
BOOL AllocateMgmtTxBuffer(UINT16 bytesNeeded)
{
UINT16 bufAvail;
UINT16 byteCount;
/* get total bytes available for MGMT tx memory pool */
bufAvail = Read16BitWFRegister(WF_HOST_WFIFO_BCNT1_REG) & 0x0fff; /* LS 12 bits contain length */
/* if enough bytes available to allocate */
if ( bufAvail >= bytesNeeded )
{
/* allocate and create the new Mgmt Tx buffer */
byteCount = RawMove(RAW_MGMT_TX_ID, RAW_MGMT_POOL, TRUE, bytesNeeded);
WF_ASSERT(byteCount != 0);
return TRUE;
}
/* else not enough bytes available at this time to satisfy request */
else
{
/* if we allocated some bytes, but not enough, then dealloacate what was allocated */
if (bufAvail > 0)
{
RawMove(RAW_MGMT_RX_ID, RAW_MGMT_POOL, FALSE, 0);
}
return FALSE;
}
}
示例14: RawGetByte
/*****************************************************************************
* FUNCTION: RawGetByte
*
* RETURNS: error code
*
* PARAMS:
* rawId - RAW ID
* pBuffer - Buffer to read bytes into
* length - number of bytes to read
*
* NOTES: Reads bytes from the RAW engine
*****************************************************************************/
void RawGetByte(UINT16 rawId, UINT8 *pBuffer, UINT16 length)
{
UINT8 regId;
#if defined(OUTPUT_RAW_TX_RX)
char buf[8];
#endif
/* if reading a data message do following check */
if (!g_WaitingForMgmtResponse)
{
// if RAW index previously set out of range and caller is trying to do illegal read
if ((rawId == RAW_RX_ID) &&
g_rxIndexSetBeyondBuffer &&
(GetRawWindowState(RAW_RX_ID) == WF_RAW_DATA_MOUNTED))
{
WF_ASSERT(FALSE); /* attempting to read past end of RAW buffer */
}
}
regId = (rawId == RAW_ID_0) ? RAW_0_DATA_REG : RAW_1_DATA_REG;
ReadWFArray(regId, pBuffer, length);
#if defined(OUTPUT_RAW_TX_RX)
putrsUART("R:");
while (length-- != 0)
{
sprintf(buf," %02X", *pBuffer++);
putsUART(buf);
}
putrsUART("\r\n");
#endif
}
示例15: AllocateMgmtTxBuffer
BOOL AllocateMgmtTxBuffer(UINT16 bytesNeeded)
{
UINT16 bufAvail;
UINT16 byteCount;
/* get total bytes available for MGMT tx memory pool */
bufAvail = Read16BitWFRegister(WF_HOST_WFIFO_BCNT1_REG) & 0x0fff; /* LS 12 bits contain length */
/* if enough bytes available to allocate */
if ( bufAvail >= bytesNeeded )
{
/* allocate and create the new Tx buffer (mgmt or data) */
byteCount = RawMove(RAW_TX_ID, RAW_MGMT_POOL, TRUE, bytesNeeded);
WF_ASSERT(byteCount != 0);
}
/* else not enough bytes available at this time to satisfy request */
else
{
return FALSE;
}
RawWindowReady[RAW_TX_ID] = TRUE;
SetRawWindowState(RAW_TX_ID, WF_RAW_MGMT_MOUNTED);
return TRUE;
}