Пример #1
0
/*****************************************************************************
  Function:
    BOOL AllocateMgmtTxBuffer(uint16_t 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_t bytesNeeded)
{
    uint16_t bufAvail;
    uint16_t 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);
        if (byteCount == 0)
        {
             EventEnqueue(WF_EVENT_ERROR, UD_ERROR_MGMT_BUFFER_ALLOCATION_FAILED);
             return false;
        }
        ClearIndexOutOfBoundsFlag(RAW_MGMT_TX_ID);
        return true;
    }
    /* else not enough bytes available at this time to satisfy request */
    else
    {
        /* if we allocated some bytes, but not enough, then deallocate what was allocated */
        if (bufAvail > 0)
        {
            RawMove(RAW_MGMT_RX_ID, RAW_MGMT_POOL, false, 0);
        }
        return false;
    }
}
Пример #2
0
/*****************************************************************************
  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;
    }
}    
Пример #3
0
/*****************************************************************************
  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;
    }

}    
Пример #4
0
/* If a data message mounted in RAW window then will be transmitted to 802.11 network */
void RawSendTxBuffer(uint16_t len)
{
    RawMove(RAW_TX_ID, RAW_MAC, false, len);
    RawWindowReady[RAW_TX_ID] = false;
    SetRawWindowState(RAW_TX_ID, WF_RAW_UNMOUNTED);

} 
Пример #5
0
bool AllocateDataTxBuffer(uint16_t bytesNeeded)
{
    uint16_t bufAvail;
    uint16_t byteCount;
    
    /* 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_TX_ID, RAW_DATA_POOL, true, bytesNeeded);
        SYS_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_DATA_MOUNTED);
    return true;

}    
Пример #6
0
void DeallocateMgmtRxBuffer(void)
{
     /* Unmount (release) mgmt packet now that we are done with it */
    RawMove(RAW_RX_ID, RAW_MGMT_POOL, false, 0);
    SetRawRxMgmtInProgress(false);
    g_WaitingForMgmtResponse = false;
}    
Пример #7
0
/*****************************************************************************
  Function:
    bool AllocateDataTxBuffer(uint16_t 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_t bytesNeeded)
{
    uint16_t bufAvail;
    uint16_t byteCount;

    /* 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);
        if (byteCount == 0)
        {
            EventEnqueue(WF_EVENT_ERROR, UD_TX_ALLOCATION_FAILED);
            return false;
        }

        /* flag this raw window as mounted (in use) */
        SetRawDataWindowState(RAW_DATA_TX_ID, WF_RAW_DATA_MOUNTED);
        return true;
    }
    /* else not enough bytes available at this time to satisfy request */
    else
    {
        return false;
    }
}
Пример #8
0
/* If a data message mounted in RAW window then will be transmitted to 802.11 network */
void RawSendTxBuffer(UINT16 len)
{
    RawMove(RAW_TX_ID, RAW_MAC, FALSE, len);
    RawWindowReady[RAW_TX_ID] = FALSE;
    SetRawWindowState(RAW_TX_ID, WF_RAW_UNMOUNTED);

} 
Пример #9
0
/*****************************************************************************
  Function:
    void DeallocateDataRxBuffer(void)

  Summary:
    Deallocates a Data Rx buffer

  Description:
    Typically called by MACGetHeader(), the assumption being that when the stack
    is checking for a newly received data message it is finished with the previously
    received data message.  Also called by MACGetHeader() if the SNAP header is invalid
    and the packet is thrown away.

  Precondition:
    None

  Parameters:
    None
                 
  Returns:
    None
      
  Remarks:
    None
*****************************************************************************/
void DeallocateDataRxBuffer(void)
{
    EnsureWFisAwake();

    /* perform deallocation of raw rx buffer */
    RawMove(RAW_DATA_RX_ID, RAW_DATA_POOL, false, 0);
}    
Пример #10
0
/*
 * Mounts RAW scratch window.
 * Returns size, in bytes, of Scratch buffer.
 *
 * The scratch window is not dynamically allocated, but references a static
 * portion of the WiFi device RAM. Thus, the Scratch data is not lost when
 * the scratch window is unmounted.
 *
 * Parameters:
 *  rawId -- RAW window ID being used to mount the scratch data
 */
uint16_t ScratchMount(uint8_t rawId)
{
    uint16_t byteCount;

    byteCount = RawMove(rawId, RAW_SCRATCH_POOL, true, 0);
    return byteCount;
}
Пример #11
0
bool AllocateMgmtTxBuffer(uint16_t bytesNeeded)
{
    uint16_t bufAvail;
    uint16_t 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);
        if (byteCount == 0)
            return false; // just return and let host retry again
    }
    /* 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;
}
Пример #12
0
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;
}    
Пример #13
0
/*
*********************************************************************************************************
*                                   PopRawWindow()
*    
* Description : Pops a RAW window state from the 1-level deep RAW stack.  The RAW window state that was 
*               mounted prior to this call is lost.
*
* Argument(s) : rawId -- RAW window ID that is being popped.
*
* Return(s)   : byte count of the RAW window state that was saved and is now restored.  In other words, the
*               size, in bytes, of the RAW window when it was first created.
*               of the o
*
* Caller(s)   : WF Driver
*
* Notes:      : (1) The RAW architecture supports a 1-level deep stack.  When this fucntion is called the 
*                   RAW window state that had been mounted is lost.  If trying to pop a non-existent RAW
*                   window state (no push has taken place), the the returned byte count is 0.
*
*********************************************************************************************************
*/
uint16_t PopRawWindow(uint8_t rawId)
{
    uint16_t byteCount;

    byteCount = RawMove(rawId, RAW_STACK_MEM, true, 0);

    return byteCount;
}
Пример #14
0
/*****************************************************************************
  Function:
	UINT16 PopRawWindow(UINT8 rawId)

  Summary:
	Pops a Raw window

  Description:
    Each RAW window can have its context saved in a 'stack' that is one level 
    deep.  When this function is called the saved context is restored and reads
    and writes to the window are operational.  The currently mounted window state
    is lost.

  Precondition:
	None

  Parameters:
	rawId -- RAW window that is being popped
	             
  Returns:
  	Byte count of the RAW window buffer being restored.  If no context has 
  	been saved this function returns a 0.
  	
  Remarks:
	None
*****************************************************************************/
UINT16 PopRawWindow(UINT8 rawId)
{
    UINT16 byteCount;

    byteCount = RawMove(rawId, RAW_STACK_MEM, TRUE, 0);

    return byteCount;
}
Пример #15
0
/*****************************************************************************
  Function:
	UINT16 ScratchMount(UINT8 rawId)

  Summary:
	Mounts RAW scratch window

  Description:
    The scratch window is not dynamically allocated, but references a static
    portion of the WiFi device RAM. Thus, the Scratch data is not lost when
    the scratch window is unmounted.

  Precondition:
	None

  Parameters:
	rawId -- RAW window ID being used to mount the scratch data
	             
  Returns:
  	Size, in bytes, of Scratch buffer
  	
  Remarks:
	None
*****************************************************************************/
UINT16 ScratchMount(UINT8 rawId)
{
    UINT16 byteCount;

    byteCount = RawMove(rawId, RAW_SCRATCH_POOL, TRUE, 0);
    WF_ASSERT(byteCount > 0);  /* scratch mount should always return value > 0 */
    
    return byteCount;
}    
Пример #16
0
/*****************************************************************************
  Function:
    void DeallocateDataRxBuffer(void)

  Summary:
    Deallocates a Data Rx buffer

  Description:
    Typically called by MACGetHeader(), the assumption being that when the stack
    is checking for a newly received data message it is finished with the previously
    received data message.  Also called by MACGetHeader() if the SNAP header is invalid
    and the packet is thrown away.

  Precondition:
    None

  Parameters:
    None

  Returns:
    None

  Remarks:
    None
*****************************************************************************/
void DeallocateDataRxBuffer(void)
{
    // TODO: verify data rx is mounted

    SetRawDataWindowState(RAW_DATA_RX_ID, WF_RAW_UNMOUNTED);

    /* perform deallocation of raw rx buffer */
    RawMove(RAW_DATA_RX_ID, RAW_DATA_POOL, false, 0);
}
Пример #17
0
/* mounts the most recent Rx message.  Could be a management or data message. */
uint16_t RawMountRxBuffer(void)
{
    uint16_t length;

    length = RawMove(RAW_RX_ID, RAW_MAC, true, 0);

    RawWindowReady[RAW_RX_ID] = true;
    SetRawWindowState(RAW_RX_ID, WF_RAW_DATA_MOUNTED);

    return length;
}
Пример #18
0
/* mounts the most recent Rx message.  Could be a management or data message. */
UINT16 RawMountRxBuffer(void)
{
    UINT16 length;
    
    length = RawMove(RAW_RX_ID, RAW_MAC, TRUE, 0);
    
    RawWindowReady[RAW_RX_ID] = TRUE;
    SetRawWindowState(RAW_RX_ID, WF_RAW_DATA_MOUNTED);
    
    
    return length;
} 
Пример #19
0
/*****************************************************************************
  Function:
	void RawToRawCopy(UINT8 rawDestId, UINT8 rawSourceId, UINT16 length)

  Summary:
	Performs a data copy from one raw window to another.

  Description:
    There is an additional step needed before invoking RawMove(); need to 
    write the source and destination values to ScratchPad0 register so that
    the information is there before the WiFi chip starts the copy operation.

  Precondition:
	None

  Parameters:
	rawDestId   -- RAW ID that is the destination of copy
	rawSourceId -- RAW ID that is the source of copy
	length      -- number of bytes to copy from source to destination
	             
  Returns:
  	None
  	
  Remarks:
	None
*****************************************************************************/
void RawToRawCopy(UINT8 rawDestId, UINT8 rawSourceId, UINT16 length)
{
    /* write source and destination address to scratchpad 0 register. The WiFi firmware */
    /* will get these values when it starts processing the raw move operation and       */
    /* determines a raw copy operation is taking place.                                 */
    Write16BitWFRegister(WF_INDEX_ADDR_REG, WF_SCRATCHPAD_0_REG);     
    Write16BitWFRegister(WF_INDEX_DATA_REG, (((UINT16)rawSourceId << 8) | (UINT16)rawDestId));

    /* always perform the actual move on RAW 0, the firmware will check the scratchpad register */
    /* for the actual source and destination                                                    */
    RawMove(RAW_ID_0, RAW_COPY, TRUE, length);
}          
Пример #20
0
UINT16 RawCalculateChecksum(UINT16 length)
{
    UINT16 checksum;
    UINT8 rawId;
    
    rawId = GetReadPtrRawWindow(); /* get raw window id for window being pointed to by read pointer */
    
    checksum = RawMove(rawId, RAW_COPY, FALSE, length); /* this raw move instructs the firmware to do a checksum   */
                                                        /* for 'length' bytes starting at current raw window index */
    
    return checksum;
    
} 
Пример #21
0
/*
*********************************************************************************************************
*                                   ScratchUnmount()
*    
* Description : Unmounts Scratch from the specified RAW window.
*
* Argument(s) : rawId -- RAW window ID that scratch had been mounted to.
*
* Return(s)   : None
*
* Caller(s)   : WF Driver
*
* Notes:      : None
*
*********************************************************************************************************
*/
void ScratchUnmount(UINT8 rawId)
{
    RawMove(rawId, RAW_SCRATCH_POOL, FALSE, 0);
    if (rawId == RAW_RX_ID)
    {
        SetRawWindowState(RAW_RX_ID, WF_RAW_UNMOUNTED);
    }
    else
    {
        SetRawWindowState(RAW_TX_ID, WF_RAW_UNMOUNTED);        
    }    
        
}    
Пример #22
0
/*
*********************************************************************************************************
*                                   ScratchUnmount()
*    
* Description : Unmounts Scratch from the specified RAW window.
*
* Argument(s) : rawId -- RAW window ID that scratch had been mounted to.
*
* Return(s)   : None
*
* Caller(s)   : WF Driver
*
* Notes:      : None
*
*********************************************************************************************************
*/
void ScratchUnmount(uint8_t rawId)
{
    RawMove(rawId, RAW_SCRATCH_POOL, false, 0);
    if (rawId == RAW_RX_ID)
    {
        SetRawWindowState(RAW_RX_ID, WF_RAW_UNMOUNTED);
    }
    else
    {
        SetRawWindowState(RAW_TX_ID, WF_RAW_UNMOUNTED);        
    }    
        
}    
Пример #23
0
/*****************************************************************************
  Function:
	void DeallocateDataRxBuffer(void)

  Summary:
	Deallocates a Data Rx buffer

  Description:
    Typically called by MACGetHeader(), the assumption being that when the stack
    is checking for a newly received data message it is finished with the previously
    received data message.  Also called by MACGetHeader() if the SNAP header is invalid
    and the packet is thrown away.

  Precondition:
	None

  Parameters:
	None
	             
  Returns:
  	None
  	
  Remarks:
	None
*****************************************************************************/
void DeallocateDataRxBuffer(void)
{
    WF_ASSERT(GetRawWindowState(RAW_DATA_RX_ID) == WF_RAW_DATA_MOUNTED);
    
    /* perform deallocation of raw rx buffer */
    RawMove(RAW_DATA_RX_ID, RAW_DATA_POOL, FALSE, 0);

    /* set state flag */
    SetRawWindowState(RAW_DATA_RX_ID, WF_RAW_UNMOUNTED);
    
    /* the current length of the Rx data packet is now 0 (used by MAC) */
    SetRxDataPacketLength(0);
}    
Пример #24
0
/*
*********************************************************************************************************
*                                   ScratchMount()
*
* Description : Mounts Scratch using the specified RAW window.
*
* Argument(s) : rawId -- desired RAW window to mount Scratch to.
*
* Return(s)   : None
*
* Caller(s)   : WF Driver
*
* Notes:      : None
*
*********************************************************************************************************
*/
uint16_t ScratchMount(uint8_t rawId)
{
    uint16_t byteCount;

    byteCount = RawMove(rawId, RAW_SCRATCH_POOL, true, 0);
    if (byteCount == 0)
    {
        /* work-around, somehow the scratch was already mounted to the other raw window */
        rawId = !rawId;
        //   WF_ASSERT(byteCount > 0);  /* scratch mount should always return value > 0 */
    }

    SetRawWindowState(rawId, WF_SCRATCH_MOUNTED);
    return byteCount;
}
Пример #25
0
/*
*********************************************************************************************************
*                                   ScratchUnmount()
*
* Description : Unmounts Scratch from the specified RAW window.
*
* Argument(s) : rawId -- RAW window ID that scratch had been mounted to.
*
* Return(s)   : None
*
* Caller(s)   : WF Driver
*
* Notes:      : None
*
*********************************************************************************************************
*/
void ScratchUnmount(uint8_t rawId)
{
    RawMove(rawId, RAW_SCRATCH_POOL, false, 0);

    SetRawWindowState(rawId, WF_RAW_UNMOUNTED);

//    if (rawId == RAW_RX_ID)
//    {
//        SetRawWindowState(RAW_RX_ID, WF_RAW_UNMOUNTED);
//    }
//    else
//    {
//        SetRawWindowState(RAW_TX_ID, WF_RAW_UNMOUNTED);
//    }

}
Пример #26
0
/*****************************************************************************
  Function:
	UINT16 RawMountRxBuffer(UINT8 rawId)

  Summary:
	Mounts most recent Rx message.

  Description:
    This function mounts the most recent Rx message from the WiFi chip, which
    could be either a management or a data message.  

  Precondition:
	None

  Parameters:
	rawId -- RAW ID specifying which raw window to mount the rx packet in.
	             
  Returns:
  	length -- number of bytes in the received message.
  	
  Remarks:
	None
*****************************************************************************/
UINT16 RawMountRxBuffer(UINT8 rawId)
{
    UINT16 length;
    
    length = RawMove(rawId, RAW_MAC, TRUE, 0);
    WF_ASSERT(length > 0);
    
    /* if mounting a Raw Rx data frame */
    if (rawId == RAW_DATA_RX_ID)
    {
        /* notify WiFi driver that an Rx data frame is mounted */
        SetRawWindowState(RAW_DATA_RX_ID, WF_RAW_DATA_MOUNTED);
    }    

    return length;
} 
Пример #27
0
/*****************************************************************************
  Function:
	void SendRAWDataFrame(UINT16 bufLen)

  Summary:
	Sends a data frame to the WiFi chip for transmission to the 802.11 network.

  Description:
    After the TCP/IP stack has created a data frame and called MACFlush() this
    function is called to notify the WiFi chip to transmit the data frame to the 
    802.11 network.  The actual data frame starts at index 4 in the allocated buffer.
    The first 4 bytes (indexes 0 - 3) were reserved, and this function fills them
    in with an internal preamble which notifies the WiFi chip that this is a data
    frame to send (as opposed to a management frame).

  Precondition:
	None

  Parameters:
	bufLen -- number of data bytes that comprise the data frame.
	             
  Returns:
  	None
  	
  Remarks:
	None
*****************************************************************************/
void SendRAWDataFrame(UINT16 bufLen)
{
    /* create internal preamble */
    UINT8 txDataPreamble[4] = { WF_DATA_REQUEST_TYPE, WF_STD_DATA_MSG_SUBTYPE, 1, 0};

    /* write out internal preamble, starting at index 0 in the raw window */
    RawWrite(RAW_DATA_TX_ID, 0, sizeof(txDataPreamble), txDataPreamble);

    /* Notify WiFi device that there is a transmit frame to send .  The frame will */
    /* be automatically deallocated after RF transmission is completed.            */
    RawMove(RAW_DATA_TX_ID, RAW_MAC, FALSE, bufLen);
    
    /* this raw window is logically no longer mounted.  The WiFi chip will  */
    /* automatically deallocate after RF transmission.                      */
    SetRawWindowState(RAW_DATA_TX_ID, WF_RAW_UNMOUNTED);
}
Пример #28
0
/*
 * Mounts most recent Rx message.
 * Returns length, a number of bytes in the received message.
 *
 * This function mounts the most recent Rx message from the WiFi chip, which
 * could be either a management or a data message.
 *
 * Parameters:
 *  rawId -- RAW ID specifying which raw window to mount the rx packet in.
 */
uint16_t RawMountRxBuffer(uint8_t rawId)
{
    uint16_t length;

    length = RawMove(rawId, RAW_MAC, true, 0);

    // the length should never be 0 if notified of an Rx msg
    if (length == 0) {
        EventEnqueue(WF_EVENT_ERROR, UD_ERROR_RAW_RX_MOUNT_FAILED);
    }

    /* if mounting a Raw Rx data frame */
    if (rawId == RAW_DATA_RX_ID) {
        /* notify WiFi driver that an Rx data frame is mounted */
        SetRawDataWindowState(RAW_DATA_RX_ID, WF_RAW_DATA_MOUNTED);
    }
    return length;
}
Пример #29
0
/*****************************************************************************
  Function:
    bool AllocateDataTxBuffer(uint16_t 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_t bytesNeeded)
{
    uint16_t bufAvail;
    
    /* 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 )
    {
        RawMove(RAW_DATA_TX_ID, RAW_DATA_POOL, true, bytesNeeded);
        return true;
    }
    /* else not enough bytes available at this time to satisfy request */
    else
    {
        ////SYS_CONSOLE_MESSAGE("NB\r\n");
        return false;
    }

}    
Пример #30
0
/*****************************************************************************
  Function:
	void ScratchUnmount(UINT8 rawId)

  Summary:
	Unmounts RAW scratch window

  Description:
    The scratch window is not dynamically allocated, but references a static
    portion of the WiFi device RAM. Thus, the Scratch data is not lost when
    the scratch window is unmounted.

  Precondition:
	None

  Parameters:
	rawId -- RAW window ID that was used to mount the scratch window
	             
  Returns:
  	Size, in bytes, of Scratch buffer
  	
  Remarks:
	None
*****************************************************************************/
void ScratchUnmount(UINT8 rawId)
{
    RawMove(rawId, RAW_SCRATCH_POOL, FALSE, 0);
}