eLooM for STM32 application
v3.3.0
|
This file declare the Managed task Interface. More...
Go to the source code of this file.
Macros | |
#define | MT_MAX_ERROR_COUNT 0x3U |
#define | MT_ALLOWED_ERROR_COUNT 0x2U |
Typedefs | |
typedef struct _AManagedTask | AManagedTask |
typedef sys_error_code_t() | ExecuteStepFunc_t(AManagedTask *_this) |
typedef sys_error_code_t(* | pExecuteStepFunc_t) (AManagedTask *_this) |
Functions | |
static sys_error_code_t | AMTHardwareInit (AManagedTask *_this, void *pParams) |
static sys_error_code_t | AMTOnCreateTask (AManagedTask *_this, tx_entry_function_t *pvTaskCode, CHAR **pcName, VOID **pvStackStart, ULONG *pnStackSize, UINT *pnPriority, UINT *pnPreemptThreshold, ULONG *pnTimeSlice, ULONG *pnAutoStart, ULONG *pnParams) |
static sys_error_code_t | AMTDoEnterPowerMode (AManagedTask *_this, const EPowerMode eActivePowerMode, const EPowerMode eNewPowerMode) |
static sys_error_code_t | AMTHandleError (AManagedTask *_this, SysEvent xError) |
static sys_error_code_t | AMTOnEnterTaskControlLoop (AManagedTask *_this) |
static sys_error_code_t | AMTInit (AManagedTask *_this) |
static EPowerMode | AMTGetSystemPowerMode (void) |
static EPowerMode | AMTGetTaskPowerMode (AManagedTask *_this) |
static sys_error_code_t | AMTNotifyIsStillRunning (AManagedTask *_this, sys_error_code_t nStepError) |
static void | AMTReportErrOnStepExecution (AManagedTask *_this, sys_error_code_t nStepError) |
static void | AMTResetAEDCounter (AManagedTask *_this) |
static boolean_t | AMTIsPowerModeSwitchPending (AManagedTask *_this) |
static sys_error_code_t | AMTSetPMStateRemapFunc (AManagedTask *_this, const EPowerMode *pPMState2PMStateMap) |
VOID | AMTRun (ULONG pParams) |
This file declare the Managed task Interface.
TODO - STF - what is a managed task?
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.
#define MT_ALLOWED_ERROR_COUNT 0x2U |
Specifies the maximum number of error a task can report before resetting the nIsTaskStillRunning flag. If the AEM (::AppErrorManager) is used it will in turn trigger a system reset due to the WWDG.
#define MT_MAX_ERROR_COUNT 0x3U |
Specifies the maximum number of errors that can be tracked by a managed task.
typedef struct _AManagedTask AManagedTask |
Create type name for _AManagedTask.
typedef sys_error_code_t() ExecuteStepFunc_t(AManagedTask *_this) |
Create a type name for the step execution function.
typedef sys_error_code_t(* pExecuteStepFunc_t) (AManagedTask *_this) |
Create a type name for a pointer to a step execution function.
|
inlinestatic |
Task specific function called by the framework when the system is entering a specific power mode, in order to implement the transaction in the power mode state machine. This function is executed in the INIT task execution flow. A managed task should modify its internal state to be ready to execute steps in the new power mode. The implementation of the managed task control loop, provided with the framework template, suspend the task after this function is called. The INIT task is in charge to resume the task when all the tasks are ready and the new power mode become actual.
_this | [IN] specifies a task object pointer. |
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. |
|
inlinestatic |
Utility function to retrieve the current power mode of the system.
|
inlinestatic |
Utility function to retrieve the current power mode of the managed task.
_this | [IN] specifies a task object pointer. |
|
inlinestatic |
Called by the framework to handle a system wide error. This function is executed in the INIT task execution flow.
_this | [IN] specifies a task object pointer. |
xError | [IN] specifies a system error |
|
inlinestatic |
Task specific function called by the framework to initialize task related hardware resources. This function is called by the INIT task.
_this | [IN] specifies a task object pointer. |
pParams | [IN] specifies a pointer to task specific hardware initialization parameters. |
|
inlinestatic |
Initialize a managed task structure. The application is responsible to allocate a managed task in memory. This method must be called after the allocation.
_this | [IN] specifies a task object pointer. |
|
inlinestatic |
Check if the INIT task has requested a power mode switch.
_this | [IN] specifies a task object pointer. |
TRUE
if there is power mode switch pending request, FALSE
otherwise.
|
inlinestatic |
Notify the system that the task is still running. If an application error manage delegate is installed (_IApplicationErrorDelegate), then a managed task must notify the system that it is working fine in order to prevent a system reset.
_this | [IN] specifies a task object pointer. |
nStepError | [IN] specifies an error code. Usually it is the error code reported during the task step execution. |
|
inlinestatic |
Task specific function called by the framework before the task is created. An application should use this function in order to perform task specific software initialization and pass task specific parameters to the INIT task.
_this | [IN] specifies a task object pointer. |
pvTaskCode | [OUT] used by the application to specify the task main function. |
pcName | [OUT] used by the application to specify a descriptive name for the task. |
pvStackStart | [OUT] used by the application to specify the start address of the stack. If it is NULL, the the stack is allocated in the system main memory pool. |
pnStackSize | [OUT] used by the application to specify the task stack size. |
pnPriority | [OUT] used by the application to specify the task priority. Legal values range from 0 through (TX_MAX_PRIORITIES-1), where a value of 0 represents the highest priority. |
pnPreemptThreshold | [OUT] used by the application to specify the task preemptive threshold. Highest priority level (0 through (TX_MAX_PRIORITIES-1)) of disabled preemption. Only priorities higher than this level are allowed to preempt this thread. This value must be less than or equal to the specified priority. A value equal to the thread priority disables preemption-threshold. |
pnTimeSlice | [OUT] Number of timer-ticks this thread is allowed to run before other ready threads of the same priority are given a chance to run. Note that using preemption-threshold disables time-slicing. Legal time-slice values range from 1 to 0xFFFFFFFF (inclusive). A value of TX_NO_TIME_SLICE (a value of 0) disables time-slicing of this thread. |
pnAutoStart | [OUT] Specifies whether the thread starts immediately or is placed in a suspended state. Legal options are TX_AUTO_START (0x01) and TX_DONT_START (0x00). If TX_DONT_START is specified, the application must later call tx_thread_resume in order for the thread to run. |
npParams | [OUT] A 32-bit value that is passed to the thread's entry function when it first executes. The use for this input is determined exclusively by the application. |
|
inlinestatic |
Called by the framework before the task enters the main control loop. At this moment the system is up and running, a managed task can do some delayed initialization, if needed. This function is executed in the INIT task execution flow.
_this | [IN] specifies a task object. |
|
inlinestatic |
A managed task can handle an error during the step execution by itself. Another option is to let the error navigate up to the main control loop of the task where it will be reported to the system using the AMTNotifyIsStillRunning() function. But if an error occurs and the managed task want to ignore the error and proceed with the step execution, it should notify the system using this function before the error is overwritten. For example:
xRes = HCPExeuteCommand(&_this->m_xProtocol, xReport.outputReport11.nCommandID, NULL, _this->m_pxDriver); if (SYS_IS_ERROR_CODE(xRes)) { AMTReportErrOnStepExecution(_this, xRes); } // continue with the step execution.
In this why the error is logged and the AED count the error when it check if the task is still running properly.
_this | [IN] specifies a task object pointer. |
nStepError | [IN] specifies an error code. |
|
inlinestatic |
This function is a convenient method to call the call the system function SysResetAEDCounter() from a task code.
_this | [IN] specifies a task object pointer. |
VOID AMTRun | ( | ULONG | pParams | ) |
This is the default control loop of a managed task.
pParams | [IN] specify a pointer to the task object: AManagedTask pTask = (AManagedTask)pParams; |
|
inlinestatic |
Set the PM state remapping function for a managed task object. It is used by the application to re-map the behavior of an AManagedTask during a power mode switch. Image a developer that want to use an existing managed task (MyManagedTask1) in a new application. Probably the new application has a different PM (PM_SM_2) state machine than the one used to design and implement the managed task MyManagedTask1 (PM_SM_1). In this scenario it is possible to reuse the managed task as it is if exist a subjective function f(x) -> (PM_SM_2, PM_SM_1), that map all states of PM_SM_1 in one or more states of PM_SM_2. It is possible to set this member to NULL, and, in this case no remapping is done.
_this | [IN] specifies a task object pointer. |
pPMState2PMStateMap | specifies a map (PMState, PMState). The map must be implemented with an array. The number of elements of the array must be equal to the number of states of the PM state machine. |