eLooM for STM32 application  v3.3.0
A framework for multitasking low power embedded applications powerd by STM32
Loading...
Searching...
No Matches
sysinit.c File Reference

System global initialization. More...

#include "services/sysinit.h"
#include "services/syslowpower.h"
#include "services/sysdebug.h"
#include "services/NullErrorDelegate.h"
#include "services/SysDefPowerModeHelper.h"
#include "services/SysTimestamp.h"
#include "tx_api.h"
#include "tx_timer.h"
#include <string.h>
+ Include dependency graph for sysinit.c:

Data Structures

struct  _System
 

Typedefs

typedef struct _System System
 

Functions

void SystemClock_Config (void)
 
__weak void SystemPower_Config (void)
 
sys_error_code_t SysTsInit (SysTimestamp_t *_this, const void *pxDrvCfg)
 
static void InitTaskRun (ULONG thread_input)
 
static uint16_t InitTaskDoEnterPowerModeForPMClass (ApplicationContext *pxContext, EPMClass ePowerModeClass, const EPowerMode eActivePowerMode, const EPowerMode eNewPowerMode)
 
__weak sys_error_code_t SysLoadApplicationContext (ApplicationContext *pAppContext)
 
__weak sys_error_code_t SysOnStartApplication (ApplicationContext *pAppContext)
 
sys_error_code_t SysInit (boolean_t bEnableBootIF)
 
EPowerMode SysGetPowerMode (void)
 
sys_error_code_t SysTaskErrorHandler (AManagedTask *pxTask)
 
SysPowerStatus SysGetPowerStatus (void)
 
void SysResetAEDCounter (void)
 
boolean_t SysEventsPending (void)
 
void * SysAlloc (size_t nSize)
 
void SysFree (void *pvData)
 
__weak IApplicationErrorDelegateSysGetErrorDelegate (void)
 
__weak IBootSysGetBootIF (void)
 
__weak IAppPowerModeHelperSysGetPowerModeHelper (void)
 
APIVersion SysGetAPIVersion ()
 

Variables

static System s_xTheSystem
 

Detailed Description

System global initialization.

Author
STMicroelectronics - ST-Korea - MCD Team
Version
3.0.0
Date
Sep 6, 2016
Attention

Copyright (c) 2016 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Typedef Documentation

◆ System

typedef struct _System System

Create a type name for _System.

Function Documentation

◆ InitTaskDoEnterPowerModeForPMClass()

static uint16_t InitTaskDoEnterPowerModeForPMClass ( ApplicationContext pxContext,
EPMClass  ePowerModeClass,
const EPowerMode  eActivePowerMode,
const EPowerMode  eNewPowerMode 
)
static

Execute the power mode transaction for all managed tasks belonging to a given PMClass.

Parameters
pxContext[IN] specifies the Application Context.
ePowerModeClass[IN] specifies the a power mode class.
eActivePowerMode[IN] specifies the current power mode of the system.
eNewPowerMode[IN] specifies the new power mode that is to be activated by the system.
Returns
the number of tasks that did the PM transaction.
+ Here is the call graph for this function:

◆ InitTaskRun()

static void InitTaskRun ( ULONG  thread_input)
static

INIT task control loop. The INIT task is in charge of the system initialization.

Parameters
thread_inputnot used.

INIT task control function. The INIT task is the first created and running task. It is responsible to complete the system initialization and to create all other system task.

Parameters
pParamsnot used
+ Here is the call graph for this function:

◆ SysAlloc()

void * SysAlloc ( size_t  nSize)

Allocate a block of memory of a specific size.

Parameters
nSize[IN] specifies the size in byte of the requested memory.
Returns
a pointer to the allocated memory if success, NULL otherwise.

◆ SysEventsPending()

boolean_t SysEventsPending ( void  )

Check if there are pending SysEvent.

Returns
TRUE if there are SysEvent pending (that means to be served by the INIT task), FALSE otherwise.

◆ SysFree()

void SysFree ( void *  pvData)

Release a block of memory.

Parameters
pvData[IN] specifies the start of teh block of memory to release.

◆ SysGetAPIVersion()

APIVersion SysGetAPIVersion ( )

Get the API version of the framework.

Returns
the API version of eLooM framework.

◆ SysGetBootIF()

__weak IBoot * SysGetBootIF ( void  )

Get the Application defined Boot interface. A boot loader application should implement this interface. The default implementation is defined as weak so the application can provide its specific implementation. The default implementation does nothing.

Returns
a pointer to an IBoot object.

◆ SysGetErrorDelegate()

__weak IApplicationErrorDelegate * SysGetErrorDelegate ( void  )

Get the Application manager error delegate. This function is used by the system during the application startup in order to get an application specific object that implements the IApplicationErrorDelegate. The default implementation is defined as weak so the application can provide its specific implementation. The default implementation does nothing.

Returns
a pointer to an IApplicationErrorDelegate object.
+ Here is the call graph for this function:

◆ SysGetPowerMode()

EPowerMode SysGetPowerMode ( void  )

Get the current system power mode.

Returns
the current system power mode.
+ Here is the call graph for this function:

◆ SysGetPowerModeHelper()

__weak IAppPowerModeHelper * SysGetPowerModeHelper ( void  )

Get the Application Power Mode Helper. This function is used by the system during the application startup in order to get an application specific object that implements the IAppPowerModeHelper. The default implementation is defined as weak so the application can provide its specific implementation. For more information about the default implementation see TODO: STF ...

Returns
a pointer to an IAppPowerModeHelper object.
+ Here is the call graph for this function:

◆ SysGetPowerStatus()

SysPowerStatus SysGetPowerStatus ( void  )

Get a copy of the system status related to the power management.

Returns
copy of the system status related to the power management.
+ Here is the call graph for this function:

◆ SysInit()

sys_error_code_t SysInit ( boolean_t  bEnableBootIF)

It initialize the minimum set of resources, hardware and software, in order to start the scheduler, and create the INIT task. If bEnableBootIF == TRUE the system enable the Boot Interface. It is useful to develop a bootloader.

Parameters
bEnableBootIFspecifies if the system has to enable the Boot Interface.
Returns
SYS_NO_ERROR_CODE if success, SYS_OUT_OF_MEMORY_ERROR_CODE if it is not possible to instantiate the INIT task.
+ Here is the call graph for this function:

◆ SysLoadApplicationContext()

__weak sys_error_code_t SysLoadApplicationContext ( ApplicationContext pAppContext)

This function is used by the system in order to add all the managed tasks to the application context. It is defined as weak in order to allow the user application to redefine it.

Parameters
pAppContext[IN] specifies a pointer to the application context to load with the application specific managed tasks.
Returns
SYS_NO_ERROR_CODE if success, an error code otherwise.

◆ SysOnStartApplication()

__weak sys_error_code_t SysOnStartApplication ( ApplicationContext pAppContext)

This function is called by the framework at the end of the initialization process and before the Init task releases the control to the application tasks. At this point all managed task has been created and the hardware is initialized. The application has a chance to execute some other initialization code before the scheduler runs the first application task.

Parameters
pAppContext[IN] specifies a pointer to the application context to load with the application specific managed tasks.
Returns
SYS_NO_ERROR_CODE if success, an error code otherwise.

◆ SysResetAEDCounter()

void SysResetAEDCounter ( void  )

Reset the counter of the AED. Usually an AED use some kind of timeout to check that all managed tasks are working fine. A task should call this method before a critical operation, that is for example a write operation in FLASH or EEPROM, or a long critical section. For convenience the managed task interface has a function IMTResetAEDCounter() that can be used by a task instead of call directly the system function.

+ Here is the call graph for this function:

◆ SysTaskErrorHandler()

sys_error_code_t SysTaskErrorHandler ( AManagedTask pxTask)

Not used yet.

Parameters
pxTask
Returns

◆ SystemClock_Config()

void SystemClock_Config ( void  )

System Clock configuration procedure. It is provided by the CubeMX project.

◆ SystemPower_Config()

__weak void SystemPower_Config ( void  )

Application defined function used to Used to configure the MCU for the low power mode. E.g. configure the unused PIN in analog to minimize the power consumption, and enable the ultra low power mode.

◆ SysTsInit()

sys_error_code_t SysTsInit ( SysTimestamp_t _this,
const void *  pxDrvCfg 
)

Initialize the system timestamp service. This function, even if it is not static, is not declared in the header file because it should be used only by the INIT task.

Parameters
_this[IN] specifies a system timestamp object.
pxDrvCfg[IN] specify the configuration structure of an hardware timer or SYS_TS_USE_SW_TSDRIVER to use the RTOS tick.
Returns
SYS_NO_ERROR_CODE if success, SYS_TS_SERVICE_ISSUE_ERROR_CODE otherwise.

Variable Documentation

◆ s_xTheSystem

System s_xTheSystem
static

The only instance of System object.