NetDev_Tx() (Wireless)
The next function in the device API structure is the transmit/Tx()
function.
Files
Every device driver’s net_dev.c
Prototype
static void NetDev_Tx (NET_IF *p_if, CPU_INT08U *p_data, CPU_INT16U size, NET_ERR *p_err);
Note that since every device driver’s Tx()
function is accessed only by function pointer via the device driver’s API structure, it doesn’t need to be globally available and should therefore be declared as ‘static
’.
Arguments
p_if
Pointer to the interface to start a network device.
p_data
Pointer to address of the data to transmit.
size
Size of the data to transmit.
p_err
Pointer to variable that will receive the return error code from this function.
Returned Value
None.
Required Configuration
None.
Notes / Warnings
The transmit function should perform the following actions:
- 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
- Write data to the device by calling
p_dev_bsp->SPI_WrRd()
and by using the network buffer passed as argument and by using a global buffer to read data. - The driver should then take all necessary steps to initiate transmission of the data.
- Set
perr
toNET_DEV_ERR_NONE
and return from the transmit function.