Overview

The programming model applies only to projects that are generated by Simplicity Studio v5's project configuration tool. As of this release this is only applicable to Bluetooth and Proprietary SDKs. This section explains the details of how a project generated by Simplicity Studio v5's project configuration tool works, and how you integrate your application to it. This covers both new projects and projects that are migrated to the new SDK version.

The programming model covers several important areas such as hardware initialization, software initialization, and periodic action processing. It covers both baremetal and kernel based applications. For instance, in case of a baremetal application, this programming model will allow you to add processing action functions to the main loop.

If you are migrating an existing application to this new version, be aware that this programming model now handles some hardware initializations (hardware clocks, DCDC, etc) and some software initializations (kernel, stacks, etc) that you may have had to do manually with previous versions.

Using this programming model for your application is important as it will ensure proper hardware initialization and proper SDK software modules initalization. Using this programming model will also ensure proper power management, as power management has to be a centralized service (power requirements can come from different requesters). For more information on power management, refer to Power Manager section.

Features

Initialization

A single function, sl_system_init(), is provided to you. This function initializes all the SDK modules that are selected in your project.

Action Processing

Some of the SDK modules (mostly services and wireless stacks) have actions to process periodically. Functions are also provided to help you with that. The action processing however differs depending on if you are using a kernel or if you have a bare metal application.

Bare Metal

If your application is bare metal, a function called sl_system_process_action() is provided to you. This function contains all the SDK modules "step" functions that must be called in every iteration of the super loop. You must call this function from your super loop.

When Using a Kernel (RTOS)

If you selected a kernel in your project, the SDK modules that have to process periodic actions will automatically create task(s) during initialization. The only thing you must do is start the kernel by calling the function sl_system_kernel_start(). You should ideally also create any task you might need before calling this function.

SDK Component Catalog

The SDK component catalog is a simple header file named sl_component_catalog.h that you can include from anywhere in your project. This file contains #define entries for the different SDK components available in your project. This allows you to enable/disable portions of code depending on whether a SDK component is present in your project or not.

Usage Examples

These are examples of main functions that use the functions described above that you can use as a reference.

Bare Metal

#include "sl_system_init.h"
#include "sl_system_process_action.h"
#include "sl_component_catalog.h"

#ifdef SL_CATALOG_POWER_MANAGER_PRESENT
#include "sl_power_manager.h"
#endif

int main(void)
{
  // Initialize Silicon Labs SDK modules.
  sl_system_init();


 // TODO: Add required initializations for your application

  while (1) {
    // TODO: Add required "step" actions for your application

    // Process periodic actions of Silicon Labs SDK modules
    sl_system_process_action();

#ifdef SL_CATALOG_POWER_MANAGER_PRESENT
    // Let the CPU go to sleep if the system allows it.
    sl_power_manager_sleep();
#endif
  }
}

When Using a Kernel (RTOS)

#include "sl_system_init.h"
#include "sl_system_kernel.h"

int main(void)
{
  // Initialize Silicon Labs SDK modules.
  sl_system_init();


  // TODO: Add required initializations for your application


  // TODO: Create kernel tasks required for your application

  // Start the kernel.
  sl_system_kernel_start();
}

Initializing your Device

When generating your project on a Silicon Labs kit, the project configuration tools will automatically add a component called Device Initialization. This component provides basic hardware configuration functionalities. These functions will automatically be called when calling sl_system_init().

When generating a project for a custom board, the Device Initialization module can be manually selected.

You can customize these basic configurations by modifying the configurations available in the Device Initialization software component. For more information on this component, see Device Initialization.