Platform Manager#

Hardware capabilities are registered at run-time by the BSP to indicate to Micrium OS what features are available on the board. This information is used by the Micrium OS stacks to configure as much as possible automatically without requiring you to change anything. File System media, Network interfaces, and USB controllers are all referenced the same way, with a simple string, during initialization and configuration.

Registration#

To be able to use an ID to add some hardware peripheral, this ID must first be registered to the platform builder. The preferred way to do this is by using the register macros. In most BSP examples and templates, it is possible to have examples of the detailed usage of these macros. The Hardware Porting Guide page also details how these macros should be used, in order to register your board's hardware capabilities to Micrium OS. The Listing - Register Macros Example in the Platform Manager page also provides a small example showing how to register a given hardware peripheral to the platform manager.

These calls can either be made in the BSP, typically in the BSP_OS_Init() function or in the application, after the Common module has been initialized (by calling Common_Init()), but before referencing the string ID.

Listing - Register Macros Example#
void  BSP_OS_Init (void)
{
                                                        /* Associate MACNet ether interface to "eth0".         */
    NET_CTRLR_ETHER_REG("eth0", &BSP_NetEther_MACNet_HwInfo);
                                                        /* Associate Device and Host USB controller to "usb1". */
    USB_CTRLR_HW_INFO_REG("usb1", &BSP_USBD_USBHS_HwInfo, &BSP_USBH_USBHS_HwInfo);
                                                        /* Associate SPI bus to "spi0".                        */
    IO_SERIAL_CTRLR_REG("spi0", &BSP_Serial_DSPI_Bus2_DrvInfo);
                                                        /* Associate Wi-Fi interface to "wifi0".                */
    NET_CTRLR_WIFI_SPI_REG("wifi0", "spi0", &NetWiFi_Info_QCA400x_AddOn, &BSP_NetWiFi_K70F120M_QCA400x, 0u);
}

Use#

After registration has been successfully completed, an ID can then be used to do certain operations on hardware capabilities registered.

The Listing - Platform Manager Use Example in the Platform Manager page shows how this can be done, typically in the start task.

Listing - Platform Manager Use Example#
static  void  Ex_MainStartTask (void  *p_arg)
{
    RTOS_ERR    err;
    NET_IF_NBR  if_nbr;

    Common_Init(&err);
    if (err.Code != RTOS_ERR_NONE) {
        /* Error handling. */
    }

    BSP_OS_Init();

    if_nbr = NetIF_Ether_Add("eth0",
                              Ex_NetEther_CfgPtr,
                              DEF_NULL,
                             &err);
    if (err.Code != RTOS_ERR_NONE) {
        /* Error handling. */
    }

    (void)USBH_HC_Add("usb1",
                      DEF_NULL,
                     &err);
    if (err.Code != RTOS_ERR_NONE) {
        /* Error handling. */
    }

    (void)SPI_BusAdd("spi0",
               &err);
    if (err.Code != RTOS_ERR_NONE) {
        /* Error handling. */
    }
}

Some configuration function (in addition to the 'Add()' functions) will also take the string ID as parameter. But, in order to make often-used operations more efficient, the stacks also use some kind of handle, number, index or reference to do those functions. Therefore, each stack has a <Module>_<Peripheral><ReferenceType>GetFromName() function that takes the string ID as an argument and returns the correct handle, index or reference for that particular string ID. For example, to obtain the interface number for an Ethernet or WiFi interface, you need to call NetIF_NbrGetFromName(), for USB Host, you should call USBH_HC_HandleGetFromName(), etc. Please refer to each of the stacks's documentation or examples for more details on what these functions are and how to use them.