Versions Compared

Key

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

...

Note: This function relies heavily on the implementation of several network device board support package (BSP) functions. See Chapter 6, “Network Board Support Package” and Appendix A, “Device Device Driver BSP Functions” for Functions for more information on network device BSP functions.

...

Every device driver’s net_dev.c

Prototype

...

Code Block
          static void NetDev_Init (NET_IF  *pif,
                                   NET_ERR *perr);

Note that since every device driver’s Init() 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’.

...

  1. Configure clock gating to the MAC device, if applicable. This is generally performed via the network device’s BSP function pointer, CfgClk(), implemented in net_bsp.c (see section A-3-1 NetDev_CfgClk).
  2. Configure all necessary I/O pins for both an internal or external MAC and PHY, if present. This is generally performed via the network device’s BSP function pointer, CfgGPIO(), implemented in net_bsp.c (see section A-3-2 NetDev_CfgGPIO).

    Configure the host interrupt controller for receive and transmit complete interrupts. Additional interrupt services may be initialized depending on the device and driver requirements. This is generally performed via the network device’s BSP function pointer, CfgIntCtrl(), implemented in net_bsp.c (

    see section A-3-3

    see NetDev_CfgIntCtrl).

     

  3. For DMA devices: Allocate memory for all necessary descriptors. This is performed via calls to µC/LIB’s memory module.
  4. For DMA devices: Initialize all descriptors to their ready states. This may be performed via calls to locally-declared, ‘static’ functions.
  5. Initialize the (R)MII bus interface, if applicable. This generally entails configuring the (R)MII bus frequency which is dependent on the system clock. Static values for clock frequencies should never be used when determining clock dividers. Instead, the driver should reference the associated clock function(s) for getting the system clock or peripheral bus frequencies, and use these values to compute the correct (R)MII bus clock divider(s). This is generally performed via the network device’s BSP function pointer, ClkFreqGet(), implemented in net_bsp.c (see section A-3-4see NetDev_ClkGetFreq).
  6. Disable the transmitted and receiver (should already be disabled).
  7. Disable and clear pending interrupts (should already be cleared).
  8. Set perr to NET_DEV_ERR_NONE if initialization proceeded as expected. Otherwise, set perr to an appropriate network device error code.