Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Include Page
css.uC-TCP-IP Wireless Device Driver APIs.css
css.uC-TCP-IP Wireless Device Driver APIs.css
Include Page
css.webworks.css
css.webworks.css

...

HTML Table
summary
classCode_Listing
Table Row (tr)
Table Cell (td)
rowspan2

Anchor
1109809
1109809
static void NetDev_Rx (NET_IF *pifp_if,

Anchor
113587711514191135877
1151419
CPU_INT08U **p_data,

Anchor
113587811514201135878
1151420
CPU_INT16U *p_size,

Anchor
113587911514211135879
1151421
NET_ERR *perrp_err);

Table Row (tr)

Anchor
1109814
1109814
Note that since every device driver’s Rx() 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’.

Anchor
1109815
1109815
Arguments

Anchor
1110366
1110366
pif p_if

Anchor
114927111516741149271
1151674
Pointer to the interface to receive data from a network device.

Anchor
1096219
1096219
p_data

Anchor
114927411516821149274
1151682
Pointer to return the address of the received data.

Anchor
1128935
1128935
p_size

Anchor
114927711516901149277
1151690
Pointer to return the size of the received data.

Anchor
1128936
1128936
perr p_err

Anchor
114928011516981149280
1151698
Pointer to variable that will receive the return error code from this function.

...

Anchor
1110401
1110401
Notes / Warnings

Anchor
109116311345611091163
1134561
The receive function should perform the following actions:

  1. Anchor
    1134562
    1134562
    For SPI wireless device, get the access to the SPI bus by performing the following operation:

Anchor
1134563
1134563
a. Acquire the SPI lock by calling p_dev_bsp->SPI_Lock().

Anchor
1134564
1134564
b. Enable the chip select by calling p_dev_bsp->SPI_ChipSelEn().

Anchor
1134565
1134565
c. Configure the SPI controller for the wireless device by calling p_dev_bsp->SPI_SetCfg().

  1. Anchor
    109117011345581091170
    1134558
    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.
  2. Anchor
    1091177
    1091177
    For Ethernet wireless devices, get the size of the received frame and subtract 4 bytes for the CRC. It 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.
  3. Anchor
    109118411337781091184
    1133778
    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. For DMA devices, the current receive descriptor should be marked as available or owned by hardware. The device driver should then return from the receive function.
  4. Anchor
    109119111338931091191
    1133893
    If an error does not occur while getting a new data area, DMA devices the function should perform the following operations:

Anchor
109119811338941091198
1133894
a. Set *p_data equal to the address of the data area within the descriptor being servicedthe frame type of the data received (NET_IF_WIFI_MGMT_FRAME or NET_IF_WIFI_DATA_PKT) at the beginning of the network buffer.

Anchor
109120511338001091205
1133800
b. Set the The data area pointer stored within the receive descriptor device should be transferred to the address of the data area obtained by calling NetBuf_GetDataPtr(). Anchor10912121091212 c. Update any descriptor ring pointers if applicable.

...

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.

  1. Anchor
    1133746
    1133746
    Sidable the device chip select by calling p_dev_bsp->SPI_ChipSelDis() and unlock the SPI bus access by calling p_dev_bsp->SPI_Unlock().
  2. Anchor
    109122611345801091226
    1134580
    Set perr p_err to NET_DEV_ERR_NONE and return from the receive function. Otherwise, set perr p_err to an appropriate network device error code.