NetDev_Start() (Wireless)

The second function is the device driver Start() function. This function is called once each time an interface is started.

Files

Every device driver’s net_dev.c

Prototype

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


Note that since every device driver’s Start() function is accessed only by function pointer via the device driver’s API structure, it doesn’t need to be globally available and should therefore be declared as ‘static’.

Arguments

p_if

Pointer to the interface to start a network device.

p_err

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

Returned Value

None.

Required Configuration

None.

Notes / Warnings

The Start() function performs the following items:

  1. Configure the transmit ready semaphore count via a call to NetOS_Dev_CfgTxRdySignal(). This function call is optional and is generally performed when the hardware device supports the queuing of multiple transmit frames. By default, the count is initialized to one.
  2. Send command to start and initialize wireless device. If a specific firmware must be loaded on the device, the firmware should be validated and updated if necessary.
  3. Initialize the device MAC address if applicable. For Ethernet 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:
    1. 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() and NetIF_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.
    2. Check if the application developer has called NetIF_AddrHW_Set() by making a call to NetIF_AddrHW_GetHandler() and NetIF_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:
    3. Call NetIF_AddrHW_SetHandler() using the data found within the MAC individual 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 the automatic loading of individual address registers from a serial EEPROM. When using this method, the developer should specify an empty string for the MAC address within the device configuration and refrain from calling NetIF_AddrHW_Set() from within the application.
  4. Initialize additional MAC registers required by the MAC for proper operation.
  5. Clear all interrupt flags.
  6. Locally enable interrupts on the hardware device. The host interrupt controller should have already been configured within the device driver Init() function.
  7. Enable the receiver and transmitter.
  8. Set p_err equal to NET_DEV_ERR_NONE if no errors have occurred. Otherwise, set p_err to an appropriate network device error code.