...
- For SPI wireless device, get the access to the SPI bus by performing the following operation:
- Acquire the SPI lock by calling
p_dev_bsp->SPI_Lock().
- Enable the chip select by calling
p_dev_bsp->SPI_ChipSelEn()
.
- Configure the SPI controller for the wireless device by calling
p_dev_bsp->SPI_SetCfg()
.
- Acquire the SPI lock by calling
- Check for receive errors if applicable. If an error should occur during reception, the driver should set
*size
to 0 and*p_data
to(CPU_INT08U *)0
and return. Additional steps may be necessary depending on the device being serviced. - For wireless devices, get the size of the received frame and subtract 4 bytes for the CRC. It is always recommended that the frame size is checked to ensure that it is greater than 4 bytes before performing the subtraction to ensure that an underflow does not occur. Set
*size
equal to the adjusted frame size. - Get a new data buffer area by calling
NetBuf_GetDataPtr()
. If memory is not available, an error will be returned and the device driver should set*size
to 0 and*p_data
to (CPU_INT08U *)0
. - If an error does not occur while getting a new data area, the function should perform the following operations:
- Set the frame type of the data received (
NET_IF_WIFI_MGMT_FRAME
orNET_IF_WIFI_DATA_PKT
) at the beginning of the network buffer. - The data stored within the device should be transferred to the address of the data section (after the frame type) of the network buffer by calling
p_dev_bsp->SPI_WrRd()
and by using a global buffer to write data and set*p_data
equal to the address of the obtained data area.
- Set the frame type of the data received (
- Sidable the device chip select by calling
p_dev_bsp->SPI_ChipSelDis()
and unlock the SPI bus access by callingp_dev_bsp->SPI_Unlock()
. - Set
p_err
toNET_DEV_ERR_NONE
and return from the receive function. Otherwise, setp_err
to an appropriate network device error code.