eLooM for STM32 application  v3.3.0
Loading...
Searching...
No Matches
AManagedTask_vtbl.h
Go to the documentation of this file.
1
23#ifndef INCLUDE_SERVICES_AMANAGEDTASKVTBL_H_
24#define INCLUDE_SERVICES_AMANAGEDTASKVTBL_H_
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
31/* MISRA messages linked to FreeRTOS include are ignored */
32/*cstat -MISRAC2012-* */
33#include "tx_api.h"
34/*cstat +MISRAC2012-* */
35
39typedef struct _AManagedTask_vtbl AManagedTask_vtbl;
40
41struct _AManagedTask_vtbl {
42 sys_error_code_t (*HardwareInit)(AManagedTask *_this, void *pParams);
43 sys_error_code_t (*OnCreateTask)(AManagedTask *_this, tx_entry_function_t *pvTaskCode, CHAR **pcName, VOID **pvStackStart, ULONG *pnStackSize, UINT *pnPriority, UINT *pnPreemptThreshold, ULONG *pnTimeSlice, ULONG *pnAutoStart, ULONG *pnParams);
44 sys_error_code_t (*DoEnterPowerMode)(AManagedTask *_this, const EPowerMode eActivePowerMode, const EPowerMode eNewPowerMode);
45 sys_error_code_t (*HandleError)(AManagedTask *_this, SysEvent xError);
46 sys_error_code_t (*OnEnterTaskControlLoop)(AManagedTask *_this);
47};
48
53typedef struct _AMTStatus {
59
64
70
75
79 uint8_t nErrorCount: 2;
80
85 uint8_t nAutoStart: 1;
86
87 uint8_t nReserved : 1;
89
99
103 TX_THREAD m_xTaskHandle;
104
109
115
124 const EPowerMode *m_pPMState2PMStateMap;
125
130};
131
132extern EPowerMode SysGetPowerMode(void);
133
134
135// Inline functions definition
136// ***************************
137
140 return _this->vptr->HardwareInit(_this, pParams);
141}
142
144sys_error_code_t AMTOnCreateTask(AManagedTask *_this, tx_entry_function_t *pvTaskCode, CHAR **pcName,
145 VOID **pvStackStart, ULONG *pnStackSize,
146 UINT *pnPriority, UINT *pnPreemptThreshold,
147 ULONG *pnTimeSlice, ULONG *pnAutoStart,
148 ULONG *pnParams) {
149 return _this->vptr->OnCreateTask(_this, pvTaskCode, pcName, pvStackStart, pnStackSize, pnPriority, pnPreemptThreshold, pnTimeSlice, pnAutoStart, pnParams);
150}
151
153sys_error_code_t AMTDoEnterPowerMode(AManagedTask *_this, const EPowerMode eActivePowerMode, const EPowerMode eNewPowerMode) {
154 assert_param(_this != NULL);
155 EPowerMode eObjeActivePowerMode = eActivePowerMode;
156 EPowerMode eObjNewPowerMode = eNewPowerMode;
157
158 if (_this->m_pPMState2PMStateMap != NULL) {
159 /* remap the PM states. */
160 eObjeActivePowerMode = _this->m_pPMState2PMStateMap[(uint8_t)eActivePowerMode];
161 eObjNewPowerMode = _this->m_pPMState2PMStateMap[(uint8_t)eNewPowerMode];
162 }
163
164 return _this->vptr->DoEnterPowerMode(_this, eObjeActivePowerMode, eObjNewPowerMode);
165}
166
169 return _this->vptr->HandleError(_this, xError);
170}
171
174 return _this->vptr->OnEnterTaskControlLoop(_this);
175}
176
179 _this->m_pNext = NULL;
180 _this->m_pfPMState2FuncMap = NULL;
181 _this->m_pPMState2PMStateMap = NULL;
186 _this->m_xStatus.nErrorCount = 0;
187 _this->m_xStatus.nAutoStart = 0;
188 _this->m_xStatus.nReserved = 0;
189
190 return SYS_NO_ERROR_CODE;
191}
192
195 return SysGetPowerMode();
196}
197
200 assert_param(_this != NULL);
201
202 EPowerMode eTaskPowrMode = (_this->m_pPMState2PMStateMap != NULL) ?
203 _this->m_pPMState2PMStateMap[(uint8_t)SysGetPowerMode()] :
204 SysGetPowerMode();
205
206 return eTaskPowrMode;
207}
208
211
212 if (SYS_IS_ERROR_CODE(nStepError) && (_this->m_xStatus.nErrorCount < MT_MAX_ERROR_COUNT)) {
213 _this->m_xStatus.nErrorCount++;
214 }
217 }
218
219 return SYS_NO_ERROR_CODE;
220}
221
224 UNUSED(_this);
226}
227
230 assert_param(_this != NULL);
231
232 return (boolean_t)_this->m_xStatus.nPowerModeSwitchPending;
233}
234
237 UNUSED(nStepError);
238
240 _this->m_xStatus.nErrorCount++;
241 }
242}
243
245sys_error_code_t AMTSetPMStateRemapFunc(AManagedTask *_this, const EPowerMode *pPMState2PMStateMap) {
246 assert_param(_this != NULL);
247
248 _this->m_pPMState2PMStateMap = pPMState2PMStateMap;
249
250 return SYS_NO_ERROR_CODE;
251}
252
253#ifdef __cplusplus
254}
255#endif
256
257
258#endif /* INCLUDE_SERVICES_AMANAGEDTASKVTBL_H_ */
#define MT_ALLOWED_ERROR_COUNT
Definition AManagedTask.h:47
#define MT_MAX_ERROR_COUNT
Definition AManagedTask.h:40
sys_error_code_t(* pExecuteStepFunc_t)(AManagedTask *_this)
Definition AManagedTask.h:66
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTSetPMStateRemapFunc(AManagedTask *_this, const EPowerMode *pPMState2PMStateMap)
Definition AManagedTask_vtbl.h:245
struct _AMTStatus AMTStatus
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTNotifyIsStillRunning(AManagedTask *_this, sys_error_code_t nStepError)
Definition AManagedTask_vtbl.h:210
SYS_DEFINE_STATIC_INLINE 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)
Definition AManagedTask_vtbl.h:144
SYS_DEFINE_STATIC_INLINE boolean_t AMTIsPowerModeSwitchPending(AManagedTask *_this)
Definition AManagedTask_vtbl.h:229
SYS_DEFINE_STATIC_INLINE EPowerMode AMTGetTaskPowerMode(AManagedTask *_this)
Definition AManagedTask_vtbl.h:199
struct _AManagedTask_vtbl AManagedTask_vtbl
Definition AManagedTask_vtbl.h:39
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTInit(AManagedTask *_this)
Definition AManagedTask_vtbl.h:178
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTDoEnterPowerMode(AManagedTask *_this, const EPowerMode eActivePowerMode, const EPowerMode eNewPowerMode)
Definition AManagedTask_vtbl.h:153
SYS_DEFINE_STATIC_INLINE void AMTReportErrOnStepExecution(AManagedTask *_this, sys_error_code_t nStepError)
Definition AManagedTask_vtbl.h:236
SYS_DEFINE_STATIC_INLINE EPowerMode AMTGetSystemPowerMode()
Definition AManagedTask_vtbl.h:194
SYS_DEFINE_STATIC_INLINE void AMTResetAEDCounter(AManagedTask *_this)
Definition AManagedTask_vtbl.h:223
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTHandleError(AManagedTask *_this, SysEvent xError)
Definition AManagedTask_vtbl.h:168
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTHardwareInit(AManagedTask *_this, void *pParams)
Definition AManagedTask_vtbl.h:139
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTOnEnterTaskControlLoop(AManagedTask *_this)
Definition AManagedTask_vtbl.h:173
Umbrella header for the basic system features.
Definition AManagedTask_vtbl.h:53
uint8_t nAutoStart
Definition AManagedTask_vtbl.h:85
uint8_t nIsTaskStillRunning
Definition AManagedTask_vtbl.h:74
uint8_t nPowerModeSwitchDone
Definition AManagedTask_vtbl.h:69
uint8_t nDelayPowerModeSwitch
Definition AManagedTask_vtbl.h:58
uint8_t nErrorCount
Definition AManagedTask_vtbl.h:79
uint8_t nPowerModeSwitchPending
Definition AManagedTask_vtbl.h:63
Definition AManagedTask_vtbl.h:94
const EPowerMode * m_pPMState2PMStateMap
Definition AManagedTask_vtbl.h:124
TX_THREAD m_xTaskHandle
Definition AManagedTask_vtbl.h:103
const AManagedTask_vtbl * vptr
Definition AManagedTask_vtbl.h:98
AMTStatus m_xStatus
Definition AManagedTask_vtbl.h:129
const pExecuteStepFunc_t * m_pfPMState2FuncMap
Definition AManagedTask_vtbl.h:114
struct _AManagedTask * m_pNext
Definition AManagedTask_vtbl.h:108
void SysResetAEDCounter(void)
Definition sysinit.c:319
uint16_t sys_error_code_t
Definition syserror.h:41
#define SYS_DEFINE_STATIC_INLINE
Definition systp.h:95
Definition sysevent.h:41