Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Initializing a Network Device

NetDev_Init() is called by NetIF_Add() exactly once for each specific network device added by the application. If multiple instances of the same network device are present on the board, then this function is called for each instance of the device. However, applications should not try to add the same specific device more than once. If a network device fails to initialize, we recommend debugging to find and correct the cause of the failure.

NetDev_Init() performs the following operations. However, depending on the device being initialized, functionality may need to be added or removed:

...

  1. Perform device configuration validation. Since some devices require special configuration, the configuration structure received should be examined at the initialization of the device

...

  1. along with setting *p_

...

  1. err to return NET_DEV_ERR_INVALID_CFG

...

  1.   if an unacceptable value has been specified.

...

  1. Configure all necessary I/O pins for SPI, external interrupt, power pin

...

  1. and reset pin. This is performed via the network

...

  1. device’s BSP function pointer, NetDev_WiFi_CfgGPIO(), implemented in net_bsp.c.
  2. Configure the host interrupt controller

...

  1. to receive and transmit complete interrupts. Additional interrupt services may be initialized depending on the device and driver requirements. This is performed via the network

...

  1. device’s BSP function pointer, NetDev_WiFi_CfgIntCtrl(), implemented in net_bsp.c. However, receive

...

  1. interrupts should not be enabled before starting the interface.

...

  1. Allocate memory for all necessary local buffers. This is performed via calls to

...

  1. μC/

...

  1. LIB’s memory module.

...

  1. Initialize the SPI controller. This is performed via the network

...

  1. device’s BSP function pointer, NetDev_WiFi_SPI_Init(). The communication between the host and the wireless module should not be initialized, the wireless device should be powered down during and after the initialization.

...

  1. Set p_err to NET_DEV_ERR_NONE if

...

  1. initializations proceeded as expected. Otherwise, set p_err to an appropriate network device error code.

...

Warning

NetDev_Init() can access the SPI bus for a command that doesn’t require receiving the command result via a response. Since it’s not possible to receive Network packets and management frames before the interface has been started.