NetDev_WiFi_SPI_Cfg

This function is called by a device driver to configure the SPI controller accordingly with device’s SPI setting.

Files

net_bsp.c

Prototype

          static CPU_INT32U NetDev_WiFi_SPI_Cfg (NET_IF                         *p_if,
                                                 NET_DEV_CFG_SPI_CLK_FREQ        freq,
                                                 NET_DEV_CFG_SPI_CLK_POL         pol,
                                                 NET_DEV_CFG_SPI_CLK_PHASE       phase,
                                                 NET_DEV_CFG_SPI_XFER_UNIT_LEN   xfer_unit_len,
                                                 NET_DEV_CFG_SPI_XFER_SHIFT_DIR  xfer_shift_dir,
                                                 NET_ERR                        *p_err);

Note that since NetDev_WiFi_SPI_Cfg() is accessed only by function pointer via a BSP interface structure, it doesn’t need to be globally available and should therefore be declared as ‘static’.

Arguments

p_if

Pointer to specific interface to configure the SPI controller.

freq

SPI system clock frequency in hertz.

pol

SPI clock polarity:

NET_DEV_SPI_CLK_POL_INACTIVE_LOW
NET_DEV_SPI_CLK_POL_INACTIVE_HIGH

phase

SPI clock phase:

NET_DEV_SPI_CLK_PHASE_FALLING_EDGE
NET_DEV_SPI_CLK_PHASE_RASING_EDGE

xfer_unit_len

SPI Transfer unit length:

NET_DEV_SPI_XFER_UNIT_LEN_8_BITS
NET_DEV_SPI_XFER_UNIT_LEN_16_BITS
NET_DEV_SPI_XFER_UNIT_LEN_32_BITS
NET_DEV_SPI_XFER_UNIT_LEN_64_BITS

xfer_shift_dir

SPI transfer shift direction:

NET_DEV_SPI_XFER_SHIFT_DIR_FIRST_MSB
NET_DEV_SPI_XFER_SHIFT_DIR_FIRST_LSB

p_err

Pointer to variable that will receive the return error code from this function:

NET_DEV_ERR_NONE
NET_DEV_ERR_FAULT

This is not an exclusive list of return errors and specific network device’s or device BSP functions may return any other specific errors as required.

Returned Value

None.

Required Configuration

None.

Notes / Warnings

  • NetDev_WiFi_SPI_Cfg() should be called only after the SPI lock has been acquired by calling NetDev_WiFi_SPI_Lock().
  • If no other device’s hardware share the same SPI controller, the configuration can be applied only at the initialization when NetDev_WiFi_SPI_Init() is called.
  • Since each network device requires a unique NetDev_WiFi_SPI_ChipSelEn(), it is recommended that each device’s NetDev_WiFi_SPI_ChipSelEn() function be named using the following convention:

    NetDev_WiFi_[Device]SPI_ChipSelEn[Number]()
    [Device]

    Network device name or type, e.g. RS9110 (optional if the development board does not support multiple devices)

[Number]

Network device number for each specific instance of device (optional if the development board does not support multiple instances of the specific device)

For example, the NetDev_WiFi_SPI_ChipSelEn() function for the #2 RS9110 wireless device on an Atmel AT91SAM9263-EK should be named NetDev_WiFi_RS9110_SPI_ChipSelEn2(), or NetDev_WiFi_RS9110_SPI_ChipSelEn_2() with additional underscore optional.

See also section Network Board Support Package.