NetDev_WiFi_CfgIntCtrl
This function is called by a device driver’s NetDev_Init()
to configure a specific network device’s interrupts and/or interrupt controller on a specific interface.
Files
net_bsp.c
Prototype
static void NetDev_CfgIntCtrl (NET_IF *p_if, NET_ERR *p_err);
Note that since NetDev_WiFi_CfgIntCtrl()
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 device’s interrupts.
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
Each network device’s NetDev_WiFi_CfgIntCtrl()
should configure and enable all required interrupt sources for the network device. This usually means configuring the interrupt vector address of each corresponding network device BSP interrupt service routine (ISR) handler and enabling its corresponding interrupt source. Thus, for most NetDev_WiFi_CfgIntCtrl()
, the following actions should be performed:
- Configure/store each device’s network interface number to be available for all necessary
NetDev_WiFi_ISR_Handler()
functions (see section B-3-13). Even though devices are added dynamically, the device’s interface number must be saved in order for each device’s ISR handlers to callNetIF_ISR_Handler()
with the device’s network interface number.Since each network device maps to a unique network interface number, it is recommended that each instance of network devices’ interface numbers be named using the following convention:
<Board><Device>[Number]_IF_Nbr
<Board>
Development board name
<Device>
Network device name (or type)
[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 network device interface number variable for the #2 RS9110 wireless device on an Atmel AT91SAM9263-EK should be named
AT91SAM9263-EK_RS9110_2_IF_Nbr
.Network device interface number variables should be initialized to
NET_IF_NBR_NONE
at system initialization prior to being configured by their respective devices.
- Configure each of the device’s interrupts on either an external or CPU’s integrated interrupt controller. However, vectored interrupt controllers may not require the explicit configuration and enabling of higher-level interrupt controller sources. In this case, the application developer may need to configure the system’s interrupt vector table with the name of the ISR handler functions declared in
net_bsp.c
.NetDev_WiFi_CfgIntCtrl()
should only enable each devices’ interrupt sources but not the local device-level interrupts themselves, which are enabled by the device driver only after the device has been fully configured and started.Since each network device requires a unique
NetDev_WiFi_CfgIntCtrl()
, it is recommended that each device’sNetDev_WiFi_CfgIntCtrl()
function be named using the following convention:NetDev_WiFi_[Device]CfgIntCtrl[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_CfgIntCtrl()
function for the #2 RS9110 wireless device on an Atmel AT91SAM9263-EK should be namedNetDev_WiFi_RS9110_CfgIntCtrl2()
, orNetDev_WiFi_RS9110_CfgIntCtrl_2()
with additional underscore optional.
See also section Network Board Support Package.
Examples
static void NetDev_WiFi_RS9110_CfgIntCtrl (NET_IF *p_if, NET_ERR *p_err) { /* Configure AT91SAM9263-EK RS9110 #2's specific IF number. */ AT91SAM9263-EK__WiFi_RS9110_2_IF_Nbr = pif->Nbr; /* Configure AT91SAM9263-EK RS9110 #2's interrupts: */ /* Configure interrupt vector. */ BSP_IntVectSet(BSP_INT, &NetDev_WiFi_RS9110_ISR_Handler_2); BSP_IntEn(BSP_INT); /* Enable interrupts. */ *p_err = NET_DEV_ERR_NONE; } static void NetDev_WiFi_RS9110_CfgIntCtrlRx_2 (NET_IF *p_if, NET_ERR *p_err) { /* Configure AT91SAM9263-EK RS9110 #2's specific IF number. */ AT91SAM9263-EK_WiFi_RS9110_2_IF_Nbr = pif->Nbr; /* Configure AT91SAM9263-EK RS9110 #2's receive interrupt: */ /* Configure interrupt vector. */ BSP_IntVectSet(BSP_INT_RX, &NetDev_WiFi_RS9100_ISR_HandlerRx_2); BSP_IntEn(BSP_INT_RX); /* Enable interrupt. */ *p_err = NET_DEV_ERR_NONE; }