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:

  1. For SPI wireless device, get the access to the SPI bus by performing the following operation:
    1. Acquire the SPI lock by calling p_dev_bsp->SPI_Lock().
    2. Enable the chip select by calling p_dev_bsp->SPI_ChipSelEn().
    3. Configure the SPI controller for the wireless device by calling p_dev_bsp->SPI_SetCfg().
  2. 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.
  3. The driver should then take all necessary steps to initiate transmission of the data.
  4. Set perr to NET_DEV_ERR_NONE and return from the transmit function.