Starting a Network Device (Wireless)
NetDev_Start()
is called each time an interface is started. It performs the following actions:
- Call the
NetOS_Dev_CfgTxRdySignal()
function to configure the transmit ready semaphore count. This function call is optional and is performed if the hardware device supports queuing multiple transmit frames. By default, the semaphore count is initialized to one. However, wireless devices should set the semaphore count equal to the number of configured transmit queues size for optimal performance. - Power up the wireless module, this is performed via the network device’s BSP function pointer,
NetDev_WiFi_Start()
. - The wireless device driver must initialize and start the communication between the host and the wireless module.
- The device driver should validate the current firmware loaded in the wireless device and upgrade the device firmware if required.
Note: After a firmware upgrade, most of the time the wireless device will require being reset, reinitialized and restarted.
- Initialize the device MAC address, if applicable. For wireless devices, this step is mandatory. The MAC address data may come from one of three sources and should be set using the following priority scheme:
- Configure the MAC address using the string found within the device configuration structure. This is a form of static MAC address configuration and may be performed by calling
NetASCII_Str_to_MAC()
andNetIF_AddrHW_SetHandler()
. If the device configuration string has been left empty, or is specified as all 0’s, an error will be returned and the next method should be attempted. - Check if the application developer has called
NetIF_AddrHW_Set()
by making a call toNetIF_AddrHW_GetHandler()
andNetIF_AddrHW_IsValidHandler()
in order to check if the specified MAC address is valid. This method may be used as a static method for configuring the MAC address during run-time, or a dynamic method should a pre-programmed external memory device exist. If the acquired MAC address does not pass the check function, then: - Call
NetIF_AddrHW_SetHandler()
using the data found within the individual MAC address registers. If an auto-loading EEPROM is attached to the MAC, the registers will contain valid data. If not, then a configuration error has occurred. This method is often used with a production process where the MAC supports automatically loading individual address registers from a serial EEPROM. When using this method, you should specify an empty string for the MAC address within the device configuration, and refrain from callingNetIF_AddrHW_Set()
from within the application. - Initialize additional MAC registers required by the MAC for proper operation.
- Clear all interrupt flags.
- Locally enable interrupts on the hardware device. This is performed via the network device’s BSP function pointer,
NetDev_WiFi_IntCtrl()
. The host interrupt controller should have already been configured within the device driverNetDev_Init()
function. - Enable the receiver and transmitter.
- Set
perr
equal toNET_DEV_ERR_NONE
if no errors have occurred. Otherwise, setperr
to an appropriate network device error code
Some wireless module return result of commands via a response. The device’s Wireless Manager function pointer, NetWiFiMgr_Mgmt()
should be used to perform these type of command since it will return only when the response is received and processed.