eLooM for STM32 application  v3.3.0
Loading...
Searching...
No Matches
AManagedTaskEx_vtbl.h
Go to the documentation of this file.
1
23#ifndef INCLUDE_SERVICES_AMANAGEDTASKEX_VTBL_H_
24#define INCLUDE_SERVICES_AMANAGEDTASKEX_VTBL_H_
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
31
32
36typedef struct _AManagedTaskEx_vtbl AManagedTaskEx_vtbl;
37
38struct _AManagedTaskEx_vtbl {
39 sys_error_code_t (*HardwareInit)(AManagedTask *_this, void *pParams);
40 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);
41 sys_error_code_t (*DoEnterPowerMode)(AManagedTask *_this, const EPowerMode eActivePowerMode, const EPowerMode eNewPowerMode);
42 sys_error_code_t (*HandleError)(AManagedTask *_this, SysEvent xError);
43 sys_error_code_t (*OnEnterTaskControlLoop)(AManagedTask *_this);
44 sys_error_code_t (*ForceExecuteStep)(AManagedTaskEx *_this, EPowerMode eActivePowerMode);
45 sys_error_code_t (*OnEnterPowerMode)(AManagedTaskEx *_this, const EPowerMode eActivePowerMode, const EPowerMode eNewPowerMode);
46};
47
52typedef struct _AMTStatusEx {
53 uint8_t nIsWaitingNoTimeout : 1;
54 uint8_t nPowerModeClass: 2;
55
56 uint8_t nUnused: 4;
57 uint8_t nReserved : 1;
59
69
73 TX_THREAD m_xTaskHandle;
74
79
85
89 const EPowerMode *m_pPMState2PMStateMap;
90
95
100};
101
102extern EPowerMode SysGetPowerMode(void);
103
104// Inline functions definition
105// ***************************
106
108sys_error_code_t AMTExForceExecuteStep(AManagedTaskEx *_this, EPowerMode eActivePowerMode) {
109 assert_param(_this != NULL);
110 EPowerMode eObjeActivePowerMode = eActivePowerMode;
111
112 if (_this->m_pPMState2PMStateMap != NULL) {
113 /* remap the PM states. */
114 eObjeActivePowerMode = _this->m_pPMState2PMStateMap[(uint8_t)eActivePowerMode];
115 }
116
117 return _this->vptr->ForceExecuteStep(_this, eObjeActivePowerMode);
118}
119
121sys_error_code_t AMTExOnEnterPowerMode(AManagedTaskEx *_this, const EPowerMode eActivePowerMode, const EPowerMode eNewPowerMode) {
122 assert_param(_this != NULL);
123 EPowerMode eObjeActivePowerMode = eActivePowerMode;
124 EPowerMode eObjNewPowerMode = eNewPowerMode;
125
126 if (_this->m_pPMState2PMStateMap != NULL) {
127 /* remap the PM states. */
128 eObjeActivePowerMode = _this->m_pPMState2PMStateMap[(uint8_t)eActivePowerMode];
129 eObjNewPowerMode = _this->m_pPMState2PMStateMap[(uint8_t)eNewPowerMode];
130 }
131
132 return _this->vptr->OnEnterPowerMode(_this, eObjeActivePowerMode, eObjNewPowerMode);
133}
134
137
138 _this->m_pNext = NULL;
139 _this->m_pfPMState2FuncMap = NULL;
140 _this->m_pPMState2PMStateMap = NULL;
141 _this->m_pfPMState2FuncMap = NULL;
142 _this->m_pPMState2PMStateMap = NULL;
147 _this->m_xStatus.nErrorCount = 0;
148 _this->m_xStatus.nAutoStart = 0;
149 _this->m_xStatus.nReserved = 1; // this identifies the task as an AManagedTaskEx.
150 _this->m_xStatusEx.nIsWaitingNoTimeout = 0;
151 _this->m_xStatusEx.nPowerModeClass = E_PM_CLASS_0;
152 _this->m_xStatusEx.nUnused = 0;
153 _this->m_xStatusEx.nReserved = 0;
154
155 return SYS_NO_ERROR_CODE;
156}
157
159sys_error_code_t AMTExSetInactiveState(AManagedTaskEx *_this, boolean_t bBlockedSuspended) {
160 assert_param(_this);
161
162 _this->m_xStatusEx.nIsWaitingNoTimeout = (uint8_t)bBlockedSuspended;
163
164 return SYS_NO_ERROR_CODE;
165}
166
169 assert_param(_this);
170
171 return (boolean_t)_this->m_xStatusEx.nIsWaitingNoTimeout;
172}
173
176 assert_param(_this);
177
178 _this->m_xStatusEx.nPowerModeClass = (uint8_t)eNewPMClass;
179
180 return SYS_NO_ERROR_CODE;
181}
182
185 assert_param(_this);
186
187 return (EPMClass)_this->m_xStatusEx.nPowerModeClass;
188}
189
190
191#ifdef __cplusplus
192}
193#endif
194
195
196#endif /* INCLUDE_SERVICES_AMANAGEDTASKEX_VTBL_H_ */
sys_error_code_t(* pExecuteStepFunc_t)(AManagedTask *_this)
Definition AManagedTask.h:66
TODO - insert here the file description.
enum _EPMClass EPMClass
@ E_PM_CLASS_0
Definition AManagedTaskEx.h:44
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTExOnEnterPowerMode(AManagedTaskEx *_this, const EPowerMode eActivePowerMode, const EPowerMode eNewPowerMode)
Definition AManagedTaskEx_vtbl.h:121
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTExForceExecuteStep(AManagedTaskEx *_this, EPowerMode eActivePowerMode)
Definition AManagedTaskEx_vtbl.h:108
struct _AMTStatusEx AMTStatusEx
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTInitEx(AManagedTaskEx *_this)
Definition AManagedTaskEx_vtbl.h:136
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTExSetInactiveState(AManagedTaskEx *_this, boolean_t bBlockedSuspended)
Definition AManagedTaskEx_vtbl.h:159
struct _AManagedTaskEx_vtbl AManagedTaskEx_vtbl
Definition AManagedTaskEx_vtbl.h:36
SYS_DEFINE_STATIC_INLINE EPMClass AMTExGetPMClass(AManagedTaskEx *_this)
Definition AManagedTaskEx_vtbl.h:184
SYS_DEFINE_STATIC_INLINE boolean_t AMTExIsTaskInactive(AManagedTaskEx *_this)
Definition AManagedTaskEx_vtbl.h:168
SYS_DEFINE_STATIC_INLINE sys_error_code_t AMTExSetPMClass(AManagedTaskEx *_this, EPMClass eNewPMClass)
Definition AManagedTaskEx_vtbl.h:175
Definition AManagedTaskEx_vtbl.h:52
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 AManagedTaskEx_vtbl.h:64
TX_THREAD m_xTaskHandle
Definition AManagedTaskEx_vtbl.h:73
AMTStatus m_xStatus
Definition AManagedTaskEx_vtbl.h:94
const EPowerMode * m_pPMState2PMStateMap
Definition AManagedTaskEx_vtbl.h:89
struct _AManagedTaskEx * m_pNext
Definition AManagedTaskEx_vtbl.h:78
const AManagedTaskEx_vtbl * vptr
Definition AManagedTaskEx_vtbl.h:68
const pExecuteStepFunc_t * m_pfPMState2FuncMap
Definition AManagedTaskEx_vtbl.h:84
AMTStatusEx m_xStatusEx
Definition AManagedTaskEx_vtbl.h:99
Definition AManagedTask_vtbl.h:94
uint16_t sys_error_code_t
Definition syserror.h:41
#define SYS_DEFINE_STATIC_INLINE
Definition systp.h:95
Definition sysevent.h:41