Ejemplo n.º 1
0
void SendMgmtMsg(uint8_t *p_header,
                 uint8_t headerLength,
                 uint8_t *p_data,
                 uint8_t dataLength)
{
    if (DRV_WIFI_InHibernateMode())
    {
        DRV_WIFI_UserEventSet(DRV_WIFI_EVENT_ERROR, DRV_WIFI_ERROR_IN_HIBERNATE_MODE, true);
        return;
    }

    WF_MGMTMSG_MUTEX_LOCK();

    EnsureWFisAwake();

    /* write out management header */
    RawSetIndex(RAW_SCRATCH_ID, MGMT_TX_BASE);
    RawSetByte(RAW_SCRATCH_ID, p_header, headerLength);

    /* write out data (if any) */
    if (dataLength > 0)
    {
        RawSetByte(RAW_SCRATCH_ID, p_data, dataLength);
    }

    /* Signal MRF24WG that mgmt message ready to process */
    Write16BitWFRegister(WF_HOST_MAIL_BOX_0_MSW_REG, 0x0400);
    Write16BitWFRegister(WF_HOST_MAIL_BOX_0_LSW_REG, 0x0000);
}
Ejemplo n.º 2
0
/*
*********************************************************************************************************
*                                   RawWrite()
*    
* Description : Writes the specified number of bytes to a mounted RAW window at the specified starting
*               index
*
* Argument(s) : rawId      -- RAW window ID being written to
*               startIndex -- start index within RAW window to write to
*               length     -- number of bytes to write to RAW window
*               p_src      -- pointer to Host buffer write data
*
* Return(s)   : None
*
* Caller(s)   : WF Driver
*
* Notes:      : None
*
*********************************************************************************************************
*/
void RawWrite(UINT8 rawId, UINT16 startIndex, UINT16 length, UINT8 *p_src)
{
    /*set raw index in dest memory */
    RawSetIndex(rawId, startIndex);

    /* write data to RAW window */
    RawSetByte(rawId, p_src, length);
}    
Ejemplo n.º 3
0
/*
*********************************************************************************************************
*                                   RawWrite()
*    
* Description : Writes the specified number of bytes to a mounted RAW window at the specified starting
*               index
*
* Argument(s) : rawId      -- RAW window ID being written to
*               startIndex -- start index within RAW window to write to
*               length     -- number of bytes to write to RAW window
*               p_src      -- pointer to Host buffer write data
*
* Return(s)   : None
*
* Caller(s)   : WF Driver
*
* Notes:      : None
*
*********************************************************************************************************
*/
void RawWrite(uint8_t rawId, uint16_t startIndex, uint16_t length, uint8_t *p_src)
{
    /*set raw index in dest memory */
    RawSetIndex(rawId, startIndex);

    /* write data to RAW window */
    RawSetByte(rawId, p_src, length);
}    
Ejemplo n.º 4
0
/*
*********************************************************************************************************
*                                   WF_TxDataSendPacket()
*
* Description : Directs the MRF24WB0M to transmit a Tx data packet to the 802.11 network.
*
* Argument(s) : length - length, in bytes, of data packet
*
* Return(s)   : Error code
*
* Caller(s)   : Application
*
* Notes:      : (1) MRF24WB0M Tx data block must first be allocated via WF_TxDataAllocateBuffer()
*
*               (2) Current support only for full length Tx data messaages. In other words, startIndex
*                   must be 0, and length must be the total length of the Tx data packet.
*
*********************************************************************************************************
*/
void WF_TxDataSendPacket(uint16_t length)
{
    tTxDataPreamble txPreamble;

    /* fill in tx data preamble with correct header */
    txPreamble.type    = WF_DATA_REQUEST_TYPE;
    txPreamble.subType = WF_STD_DATA_MSG_SUBTYPE;
    txPreamble.h2      = 1;
    txPreamble.h3      = 0;

    /* Ensure the MRF24WB0M is awake (only applies if PS-Poll was enabled) */
    EnsureWFisAwake();

    /* write out preamble to MRF24WB0M buffer to the two extra bytes at start of allocated buffer */
    RawSetIndex(RAW_TX_ID, 0);
    WriteWFArray(RAW_1_DATA_REG, (uint8_t *)&txPreamble, WF_SIZE_OF_TX_DATA_PREAMBLE );

    /* now tell MRF24WB0M to transmit the tx data packet */
    RawSendTxBuffer(length);
}
Ejemplo n.º 5
0
/*
*********************************************************************************************************
*                                   WF_TxDataWrite()
*
* Description : Writes Tx packet data from Host CPU to MRF24WB0M tx buffer
*
* Argument(s) : p_txData   - Pointer to Tx data
*               length     - length, in bytes, of Tx data
*               startIndex - Index within MRF24WB0M Tx data block to start writing
*
* Return(s)   : None
*
* Caller(s)   : Application
*
* Notes:      : (1) MRF24WB0M Tx data block must first be allocated via WF_TxDataAllocateBuffer()
*
*               (2) Current support only for full length Tx data messaages. In other words, startIndex
*                   must be 0, and length must be the total length of the Tx data packet.
*
*********************************************************************************************************
*/
void WF_TxDataWrite(uint8_t  *p_txData,
                    uint16_t  length,
                    uint16_t  startIndex)
{
    WF_ASSERT(startIndex == 0);

    if (length == 0)
    {
        return;
    }

    /* Ensure the MRF24WB0M is awake (only applies if PS-Poll was enabled) */
    EnsureWFisAwake();

    /* set the RAW index to desired location, offset by the Tx data preamble */
    RawSetIndex(RAW_TX_ID, startIndex + WF_SIZE_OF_TX_DATA_PREAMBLE);

    /* write tx data to chip */
    WriteWFArray(RAW_1_DATA_REG, p_txData, length);
}
Ejemplo n.º 6
0
/*
*********************************************************************************************************
*                                   RawRead()
*    
* Description : Reads the specified number of bytes from a mounted RAW window from the specified starting
*               index;
*
* Argument(s) : rawId      -- RAW window ID being read from
*               startIndex -- start index within RAW window to read from
*               length     -- number of bytes to read from the RAW window
*               p_dest     -- pointer to Host buffer where read data is copied
*
* Return(s)   : error code
*
* Caller(s)   : WF Driver
*
* Notes:      : None
*
*********************************************************************************************************
*/
void RawRead(UINT8 rawId, UINT16 startIndex, UINT16 length, UINT8 *p_dest)
{
    RawSetIndex(rawId, startIndex);
    RawGetByte(rawId, p_dest, length);
}
Ejemplo n.º 7
0
void RawCopyTest()
{
    BOOL res;
    UINT8 i;
    UINT8 byte;
    UINT16 rawIndex;
    UINT16 bufAvail;
    UINT16 srcRawId = 5;
    UINT16 byteCount;
    
    /* get total bytes available for MGMT tx memory pool */
    bufAvail = Read16BitWFRegister(WF_HOST_WFIFO_BCNT1_REG) & 0x0fff; /* LS 12 bits contain length */                    
    
    /* verify we can read and write from scratch buffer (already mounted) */
    RawSetIndex(RAW_SCRATCH_ID, 0);
    rawIndex = RawGetIndex(RAW_SCRATCH_ID);  
    WF_ASSERT(rawIndex == 0);
    for (i = 0; i < 128; ++i)
    {
        RawSetByte(RAW_SCRATCH_ID, &i, 1);
        rawIndex = RawGetIndex(RAW_SCRATCH_ID);
        WF_ASSERT(rawIndex == i + 1);
    }       
    rawIndex = RawGetIndex(RAW_SCRATCH_ID);  /* raw index should be at 128 */
    WF_ASSERT(rawIndex == 128);
    
    RawSetIndex(RAW_SCRATCH_ID, 0);
    rawIndex = RawGetIndex(RAW_SCRATCH_ID);  
    WF_ASSERT(rawIndex == 0);

    for (i = 0; i < 128; ++i)
    {
        RawGetByte(RAW_SCRATCH_ID, &byte, 1); 
        WF_ASSERT(byte == i);  
    }    
    RawSetIndex(RAW_SCRATCH_ID, 0);
    rawIndex = RawGetIndex(RAW_SCRATCH_ID);  
    WF_ASSERT(rawIndex == 0);
    
    /* now zero out scratch */
    byte = 0;
    for (i = 0; i < 128; ++i)
    {
        RawSetByte(RAW_SCRATCH_ID, &byte, 1);
        rawIndex = RawGetIndex(RAW_SCRATCH_ID);
        WF_ASSERT(rawIndex == i + 1);
    }   
    RawSetIndex(RAW_SCRATCH_ID, 0);
    rawIndex = RawGetIndex(RAW_SCRATCH_ID);  
    WF_ASSERT(rawIndex == 0);
    
    /* verify scratch is zeroed out */ 
    for (i = 0; i < 128; ++i)
    {
        RawGetByte(RAW_SCRATCH_ID, &byte, 1); 
        WF_ASSERT(byte == 0);  
    }    
    RawSetIndex(RAW_SCRATCH_ID, 0);
    rawIndex = RawGetIndex(RAW_SCRATCH_ID);  
    WF_ASSERT(rawIndex == 0);
    
    
    /* allocate raw buffer of 128 bytes */
    byteCount = RawMove(srcRawId, RAW_MGMT_POOL, TRUE, 128);
    WF_ASSERT(byteCount >= 128);

    /* fill up buffer with known values */
    for (i = 0; i < 128; ++i)
    {
        RawSetByte(srcRawId, &i, 1);
    } 
    rawIndex = RawGetIndex(srcRawId);  /* raw index should be at 128 */
    WF_ASSERT(rawIndex == 128);
      
    /* put raw index back to 0 and verify */
    res = RawSetIndex(srcRawId, 0);
    WF_ASSERT(res == TRUE);
    rawIndex = RawGetIndex(srcRawId);
    WF_ASSERT(rawIndex == 0);   
    
    /* read back from source buffer to ensure write was successful */
    for (i = 0; i < 128; ++i)
    {
        RawGetByte(srcRawId, &byte, 1);
        rawIndex = RawGetIndex(srcRawId);
        WF_ASSERT(rawIndex == i + 1);
        if (byte != i)
        {
            WF_ASSERT(FALSE);
        }            
    }          

    /* put raw index back to 0 and verify */
    res = RawSetIndex(srcRawId, 0);
    WF_ASSERT(res == TRUE);
    rawIndex = RawGetIndex(srcRawId);
    WF_ASSERT(rawIndex == 0);   
    
    /* set the Scratch index to 0 and verify */
    RawSetIndex(RAW_SCRATCH_ID, 0);
    rawIndex = RawGetIndex(RAW_SCRATCH_ID);  
    WF_ASSERT(rawIndex == 0);   

    /* set the raw source index to 0 and verify */
    RawSetIndex(srcRawId, 0);
    rawIndex = RawGetIndex(srcRawId);  
    WF_ASSERT(rawIndex == 0);   

    /* perform raw to raw copy and verify raw indexes*/
    RawToRawCopy(RAW_SCRATCH_ID, srcRawId, 128);
    rawIndex = RawGetIndex(RAW_SCRATCH_ID);
    WF_ASSERT(rawIndex == 128);
    rawIndex = RawGetIndex(srcRawId);
    WF_ASSERT(rawIndex == 128);
    
    /* put scratch raw index back to 0 */
    res = RawSetIndex(RAW_SCRATCH_ID, 0);
    WF_ASSERT(res == TRUE);
    rawIndex = RawGetIndex(RAW_SCRATCH_ID);
    WF_ASSERT(rawIndex == 0);
    
    /* read data from scratch and see if it matches what was copied */   
    for (i = 0; i < 128; ++i)
    {
        RawGetByte(RAW_SCRATCH_ID, &byte, 1);
        rawIndex = RawGetIndex(RAW_SCRATCH_ID);
        WF_ASSERT(rawIndex == (i+1));
        if (byte != i)
        {
            WF_ASSERT(FALSE);
        }    
    }    
   
   
        
}    
Ejemplo n.º 8
0
/*
*********************************************************************************************************
*                                   RawRead()
*    
* Description : Reads the specified number of bytes from a mounted RAW window from the specified starting
*               index;
*
* Argument(s) : rawId      -- RAW window ID being read from
*               startIndex -- start index within RAW window to read from
*               length     -- number of bytes to read from the RAW window
*               p_dest     -- pointer to Host buffer where read data is copied
*
* Return(s)   : error code
*
* Caller(s)   : WF Driver
*
* Notes:      : None
*
*********************************************************************************************************
*/
void RawRead(uint8_t rawId, uint16_t startIndex, uint16_t length, uint8_t *p_dest)
{
    RawSetIndex(rawId, startIndex);
    RawGetByte(rawId, p_dest, length);
}