DolphinV4 API  1.6.1.0
DolphinV4 API Initialization

Before the member function of an API modul can be used the library and some of the sw modules have to be initialised. The modul initialisation function was the following structure (there are some exceptions read notes below):

modulename_init(uint8 *pu8Param, uint8 u8ParamToSet)

The init parameters of a module are defined with a parameter list. Each index of an array corresponds to a parameter from the parameter list. The parameter list for the sw modules are defined in the EO3100I_API.h interface file (e.g. UART_PARAM_IDX). An array containing the parameter values are passed to the init functions using the *pu8Param There is a possibility to change the parameter initialization during runtime using the u8ParamToSet variable (exception io_init). For more information how to do this read dynamic_configuration below.

The init parameters and function calls to the module inits are generated by DolphinV4 Suite DolphinV4APIConfigurator and are stored in the EO3100I_CFG.c, EO3100I_CFG.h, startup.a51 files.

dolphin-to-keil.png

DolphinV4 Suite DolphinV4APIConfigurator generates the two following init functions in the EO3100I_CFG.c and the initialisation process is separated in 2 steps:

startupInit();
This function is called from startup.a51 immediately after reset (wakeup) before the C51 compiler init sequence. As default DolphinV4 Suite DolphinV4APIConfigurator always places the following functions here:

  • pwr_enableXTAL(DEFAULT_DELAY); - enables the XTAL
  • io_init(io_param); initializes the I/O ports here.
    Do not use other API functions here, because global variables will be initialized later on. Custom application functions can be also placed here. These function are not allowed to use global initialised variables.

mainInit();
This function has to be called from main.c. As default DolphinV4 Suite DolphinV4APIConfigurator always places the following functions here:

  • radio_init_mod(CFG_ALL); - initialise radio settings
  • radio_init (RADIO_BUFF_NUM, RADIO_MATURITY_TIME); - initialise radio module
  • misc_init(); - enabling interrupts
  • pwr_selectXTAL(); - selecting XTAL

Additional initialisations are placed here depending on which sw modules where activated in DolphinV4 Suite DolphinV4APIConfigurator.

The DolphinV4 API init process is displayed on the picture below:


initprocess.png

Dynamic module initialization
Those SW modules whose init function has a second parameter u8ParamToSet offer the possibility to set the init parameters selective or during runtime. To set 1 parameter the u8ParamToSet has to contain the index of the parameter. The same functionality is ensured by the module_setConfig macro (example uart_setConfig, filter_setConfig, timer1_setConfig etc.). Parameters which can't be changed are signed with an (ro) tag in the documentation.


Example:
Changing the baudrate parameter of the UART function during runtime:



Note:
The pwr, mem modul does not need to be initialised
The init of the time modul and scheduler is different. Make sure to read Scheduler chapter
Be sure to enable in DolphinV4 Suite DolphinV4APIConfigurator only those sw modules which you definitely will use in your application
If the application is not changing the init values during execution, using the code specifier the initialization array can be place to the Flash thus saving RAM. Make sure to read MemoryTypeVariableSpecifier.
When a module is initialised with all parameters u8ParamToSet value is SET_ALL_PARAM.
The parameters of the init functions are not prooved for correctness as these are generated by DolphinV4 Suite DolphinV4APIConfigurator. This method saves execution speed and flash. Make sure always provide correct parameters for the init functions.