Firmware development - extending SOC EMPTY project

Introduction 

Silicon Labs provides with several templates to get started with firmware development targeting BGM220 modules. The templates can be imported within Simplicity Studio. In order to extend the functionality of the templates the developers might need to add a new functions or modify the existent ones. Here we will be discussing the steps of modifying the provided by SOC-EMPTY template functions sl_bt_on_event() and app_init()
 

Steps/recommendations to modify the functions from template (example: SOC-EMPTY)

The template project SOC EMPTY has several C source and header files. The functions are implemented in the source files and declared in the header file. To extend the functionality of the project and add project specific functions the recommendation is to add [unique_name]_app.c file to the original template, where application specific functions should be implemented. All the template's provided files should remain unchanged with the exception of the the declaration of the sl_bt_on_event() function in app.c   

sl_bt_on_event()

sl_bt_on_event() function is implemented in app.c  and declared in autogenerated sl_bluetooth.h header file. Due to the auto-generation and "sl - silicon labs"  prefix is not recommended to change the original declaration of this function or modify the original body. If this function needs to be updated the recommendation is to change the original function definition in app.c  to SL_WEAK void sl_bt_on_event(sl_bt_msg_t *evt) , and in the added to the project [unique_name]_app.c  file the function definition for this function should be: void sl_bt_on_event(sl_bt_msg_t *evt) with required changes in the function body.
 

app_init() 
 

app_init() is declared in the app.h C header file of the project's template. The original definition of this function is in app.c SL_WEAK void app_init(void). It should remain unchanged. If this function needs to be updated the recommendation is to define a new function void app_init(void) in the unique_name]_app.c. Project specific initialization procedures, welcome message and etc... can be implemented in the body of this function.
 

Summary  
 

In the  steps above were described several recommendations for extending the functionality of the original templates for two functions: app_init() and sl_bt_on_event(). Similar approach can be taken to extend other provided in the  template functions, example: app_process_action(void) if required. SL_WEAK is defined in em_common.h as follows: 
/** @brief A macro for defining a weak symbol. */
#define SL_WEAK __attribute__ ((weak)) 

  • Did you find this helpful?
  • Yes
  • No