Versions Compared

Key

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

...

For each wireless interface/device, an application must implement (in net_bsp_wifi.c) a unique device-specific implementation of each of the following BSP functions:

Since each of these functions is called from a unique instantiation of its corresponding device driver, a pointer to the corresponding network interface ( p_if ) is passed in order to access the specific interface's device configuration or data.

Network device driver BSP functions may be arbitrarily named but since development boards with multiple devices require unique BSP functions for each device, it is recommended that each device’s BSP functions be named using the following convention:

NetDev_[Device]<Function>[Number]()

[Device]

Network device name or type. For example, MACB (optional if the development board does not support multiple devices).

<Function>

Network device BSP function. For example, CfgClk

[Number]

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

For example, the NetDev_CfgGPIO() function for the #2 RS9110-N-21 wireless module on an Atmel AT91SAM9263-EK should be named NetDev_RS9110N21_CfgGPIO2(), or NetDev_RS9110N21_CfgGPIO_2() with additional underscore optional.

Similarly, network devices’ BSP-level interrupt service routine (ISR) handlers should be named using the following convention:

NetDev_[Device]ISR_Handler[Type][Number]()

[Device]

Network device name or type. For example, MACB. (Optional if the development board does not support multiple devices.)

[Type]

Network device interrupt type. For example, receive interrupt. (Optional if interrupt type is generic or unknown.)

[Number]

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

For example, the receive ISR handler for the #2 RS9110-N-21 wireless module on an Atmel AT91SAM9263-EK should be named NetDev_RS9110N21_ISR_HandlerRx2(), or NetDev_RS9110N21_ISR_HandlerRx_2() with additional underscore optional.

Next, each device’s/interface’s BSP functions must be organized into an interface structure used by the device driver to call specific devices’ BSP functions via function pointer instead of by name. This allows applications to add, initialize, and configure any number of instances of various devices and drivers by creating similar but unique BSP functions and interface structures for each network device/interface. (See section Interface Programming for details on how applications add interfaces to µC/TCP-IP.)

Each device’s/interface’s BSP interface structure must be declared in the application’s/ development board’s network BSP source file, net_bsp.c, as well as externally declared in the network BSP header file, net_bsp.h, with the exact same name and type as declared in net_bsp.c. These BSP interface structures and their corresponding functions must be uniquely named and should clearly identify the development board, device name, function name, and possibly the specific device number (assuming the development board supports multiple instances of any given device). BSP interface structures may be arbitrarily named but it is recommended that they be named using the following convention:

NetDev_BSP_<Board><Device>[Number]{}

<Board>

Development board name. For example, Atmel AT91SAM9263-EK.

<Device>

Network device name (or type). For example, RS9110-N-21.

[Number]

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

For example, a BSP interface structure for the #2 RS9110-N21 wireless module on an Atmel AT91SAM9263-EK board should be named NetDev_BSP_AT91SAM9263-EK_RS9110N21_2{} and declared in the AT91SAM9263-EK board’s net_bsp.c:

And in order for the application to configure an interface with this BSP interface structure, the structure must be externally declared in the AT91SAM9263-EK board’s net_bsp.h :

extern const NET_DEV_BSP_WIFI_SPI NetDev_BSP_AT91SAM9263-EK_RS9110N21_2;

Lastly, the board’s RS9110-N-21 #2 BSP functions must also be declared in net_bsp.c:

Code Block
languagecpp
void NetDev_WiFi_Start         (NET_IF                          *p_if,
                                NET_ERR                         *p_err);

void NetDev_WiFi_Stop          (NET_IF                          *p_if,
                                NET_ERR                         *p_err);

void NetDev_WiFi_CfgGPIO       (NET_IF                          *p_if,
                                NET_ERR                         *p_err);

void NetDev_WiFi_CfgIntCtrl    (NET_IF                          *p_if,
                                NET_ERR                         *p_err);

void NetDev_WiFi_IntCtrl       (NET_IF                          *p_if,
                                CPU_BOOLEAN                      en,
                                NET_ERR                         *p_err);

void NetDev_WiFi_SPI_Init      (NET_IF                          *p_if,
                                NET_ERR                         *p_err);

void NetDev_WiFi_SPI_Lock      (NET_IF                          *p_if,
                                NET_ERR                         *p_err);

void NetDev_WiFi_SPI_Unlock    (NET_IF                          *p_if);
 
void NetDev_WiFi_SPI_WrRd      (NET_IF                          *p_if,
                                CPU_INT08U                      *p_buf_wr,
                                CPU_INT08U                      *p_buf_rd,
                                CPU_INT16U                       len,
                                NET_ERR                         *p_err);

void NetDev_WiFi_SPI_ChipSelEn (NET_IF                          *p_if,
                                NET_ERR                         *p_err);

void NetDev_WiFi_SPI_ChipSelDis(NET_IF                          *p_if);

void 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);


Since each of these functions is called from a unique instantiation of its corresponding device driver, a pointer to the corresponding network interface ( p_if ) is passed in order to access the specific interface's device configuration or data.

Network device driver BSP functions may be arbitrarily named but since development boards with multiple devices require unique BSP functions for each device, it is recommended that each device’s BSP functions be named using the following convention:

NetDev_[Device]<Function>[Number]()

[Device]

Network device name or type. For example, MACB (optional if the development board does not support multiple devices).

<Function>

Network device BSP function. For example, CfgClk

[Number]

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

For example, the NetDev_CfgGPIO() function for the #2 RS9110-N-21 wireless module on an Atmel AT91SAM9263-EK should be named NetDev_RS9110N21_CfgGPIO2(), or NetDev_RS9110N21_CfgGPIO_2() with additional underscore optional.

Similarly, network devices’ BSP-level interrupt service routine (ISR) handlers should be named using the following convention:

NetDev_[Device]ISR_Handler[Type][Number]()

[Device]

Network device name or type. For example, MACB. (Optional if the development board does not support multiple devices.)

[Type]

Network device interrupt type. For example, receive interrupt. (Optional if interrupt type is generic or unknown.)

[Number]

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

For example, the receive ISR handler for the #2 RS9110-N-21 wireless module on an Atmel AT91SAM9263-EK should be named NetDev_RS9110N21_ISR_HandlerRx2(), or NetDev_RS9110N21_ISR_HandlerRx_2() with additional underscore optional.

Next, each device’s/interface’s BSP functions must be organized into an interface structure used by the device driver to call specific devices’ BSP functions via function pointer instead of by name. This allows applications to add, initialize, and configure any number of instances of various devices and drivers by creating similar but unique BSP functions and interface structures for each network device/interface. (See section Interface Programming for details on how applications add interfaces to µC/TCP-IP.)

Each device’s/interface’s BSP interface structure must be declared in the application’s/ development board’s network BSP source file, net_bsp.c, as well as externally declared in the network BSP header file, net_bsp.h, with the exact same name and type as declared in net_bsp.c. These BSP interface structures and their corresponding functions must be uniquely named and should clearly identify the development board, device name, function name, and possibly the specific device number (assuming the development board supports multiple instances of any given device). BSP interface structures may be arbitrarily named but it is recommended that they be named using the following convention:

NetDev_BSP_<Board><Device>[Number]{}

<Board>

Development board name. For example, Atmel AT91SAM9263-EK.

<Device>

Network device name (or type). For example, RS9110-N-21.

[Number]

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

For example, a BSP interface structure for the #2 RS9110-N21 wireless module on an Atmel AT91SAM9263-EK board should be named NetDev_BSP_AT91SAM9263-EK_RS9110N21_2{} and declared in the AT91SAM9263-EK board’s net_bsp.c:

Code Block
languagecpp
themeConfluence
firstline1
linenumberstrue
                                                                     /* AT91SAM9263-EK RS9110-N21 #2's BSP fnct ptrs : */
const NET_DEV_BSP_WIFI_SPI NetDev_BSP_AT91SAM9263-EK_RS9110N21_2 = {
                                                                     NetDev_RS9110N21_Start_2
                                                                     NetDev_RS9110N21_Stop_2,
                                                                     NetDev_RS9110N21_CfgGPIO_2,
                                                                     NetDev_RS9110N21_CfgExtIntCtrl_2
                                                                     NetDev_RS9110N21_ExtIntCtrl_2,
                                                                     NetDev_RS9110N21_SPI_Cfg_2,
                                                                     NetDev_RS9110N21_SPI_Lock_2,
                                                                     NetDev_RS9110N21_SPI_Unlock_2,
                                                                     NetDev_RS9110N21_SPI_WrRd_2,
                                                                     NetDev_RS9110N21_SPI_ChipSelEn_2,
                                                                     NetDev_RS9110N21_SPI_ChipSelDis_2,
                                                                     NetDev_RS9110N21_SetCfg_2
                                                                   };


And in order for the application to configure an interface with this BSP interface structure, the structure must be externally declared in the AT91SAM9263-EK board’s net_bsp.h :

extern const NET_DEV_BSP_WIFI_SPI NetDev_BSP_AT91SAM9263-EK_RS9110N21_2;

Lastly, the board’s RS9110-N-21 #2 BSP functions must also be declared in net_bsp.c:

Code Block
languagecpp
themeConfluence
firstline1
linenumberstrue
static void NetDev_RS9110N21_Start_2         (NET_IF                          *p_if,
                                              NET_ERR                         *p_err);
 
static void NetDev_RS9110N21_Stop_2          (NET_IF                          *p_if,
                                              NET_ERR                         *p_err);
 
static void NetDev_RS9110N21_CfgGPIO_2       (NET_IF                          *p_if,
                                              NET_ERR                         *p_err);
 
static void NetDev_RS9110N21_CfgIntCtrl_2    (NET_IF                          *p_if,
                                              NET_ERR                         *p_err);

static void NetDev_RS9110N21_IntCtrl_2       (NET_IF                          *p_if,
                                              CPU_BOOLEAN                      en,
                                              NET_ERR                         *p_err);

static void NetDev_RS9110N21_SPI_Init_2      (NET_IF                          *p_if,
                                              NET_ERR                         *p_err);

static void NetDev_RS9110N21_SPI_Lock_2      (NET_IF                          *p_if,
                                              NET_ERR                         *p_err);

static void NetDev_RS9110N21_SPI_Unlock_2    (NET_IF                          *p_if);

static void NetDev_RS9110N21_SPI_WrRd_2      (NET_IF                          *p_if,
                                              CPU_INT08U                      *p_buf_wr,
                                              CPU_INT08U                      *p_buf_rd,
                                              CPU_INT16U                       len,
                                              NET_ERR                         *p_err);

static void NetDev_RS9110N21_SPI_ChipSelEn_2 (NET_IF                          *p_if,
                                              NET_ERR                         *p_err);

static void NetDev_RS9110N21_SPI_ChipSelDis_2(NET_IF                          *p_if);

static void NetDev_RS9110N21_SPI_Cfg_2       (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 all network device BSP functions are accessed only by function pointer via their corresponding BSP interface structure, they don’t need to be globally available and should therefore be declared as static .

...

Each network device's NetDev_WiFi_CfgGPIO() should configure all required GPIO pins for the network device. For wireless devices, this function is necessary to configure the power, reset and interrupt pins.

See function NetDev_WiFi_CfgGPIO for more information.

Starting a Wireless Device

...

Each network device’s NetDev_WiFi_Start() must set GPIO pins to power up and reset the wireless device. For wireless devices, this function is necessary to configure the power pin and other required pins to power up the wireless chip. Note that a wireless device could require the toggle on the Reset pin to be started or restarted correctly.

See function NetDev_WiFi_Start for more information.

Stopping a Wireless Device

...

Each network device's NetDev_WiFi_Start() must set GPIO pins to power down the wireless chip to reduce the power consumption. For wireless devices, this function is necessary to configure the power pin and other required pins to power down the wireless chip.

See funciton function NetDev_WiFi_Stop for more information.

Configuring the Interrupt Controller for a Wireless Device

...

NetDev_WiFi_CfgIntCtrl() should disable only each devices’ interrupt sources. See function NetDev_WiFi_CfgIntCtrl for more information.

Enabling and Disabling Wireless Interrupt

Each network device’s NetDev_WiFi_IntCtrl() function must enable or disable all external required interrupt sources for the wireless device. This means enable or disable its corresponding interrupt source following the enable argument received.

See function NetDev_WiFi_IntCtrl for more information.

Configuring the SPI Interface

...

If the SPI bus is not shared with other devices, it is recommended that NetDev_WiFi_SPI_Init() configures the SPI controller following the SPI device’s communication settings and keep NetDev_WiFi_SPI_Cfg() empty.

See NetDev_WiFi_SPI_Cfg for more information.

Setting SPI Controller for a Wireless device

...