eLooM for STM32 application  v3.3.0
A framework for multitasking low power embedded applications powerd by STM32
Loading...
Searching...
No Matches
syserror.h
Go to the documentation of this file.
1
27#ifndef SYSERROR_H_
28#define SYSERROR_H_
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include <assert.h>
35#include <stdint.h>
36#include "events/sysevent.h"
37
41typedef uint16_t sys_error_code_t;
42
43#define SYS_ERR_EVT_SRC_IAED 0x1U
44// IApplicationErrorDelegate parameters
45#define SYS_ERR_EVT_PARAM_CHECK_TASKS 0x1U
46#define SYS_ERR_EVT_PARAM_EFT 0x2U
47#define SYS_ERR_EVT_PARAM_EFT_TIMEOUT 0x3U
48#define SYS_ERR_EVT_PARAM_NOP 0x4U
49
56#define SYS_ERR_MAKE_EVENT(src, params) ((((src) & 0X7U) | (((params)<<3) & 0xF8U) | (0x1U<<31)) & 0x800000FF)
57
64#define SYS_IS_ERROR_EVENT(evt) ((evt).xEvent.nEventType == 1U)
65
66#ifndef SysPostEvent
67#define SysPostErrorEvent SysPostEvent
68#endif
69
78sys_error_code_t SysPostErrorEvent(SysEvent xEvent);
79
87void SysResetAEDCounter(void);
88
89
93typedef union _sys_error_t {
97 unsigned long error_code;
98
102 struct {
106 unsigned int low_level_e: 16;
107
111 unsigned int service_level_e: 16;
114
119
120#if (SYS_TRACE > 1)
121void sys_check_error_code(sys_error_code_t xError);
122#endif
123
129
130
131#define SYS_CLEAR_ERROR() {g_nSysError.error_code = 0;}
132#define SYS_CLEAR_LOW_LEVEL_ERROR() {g_nSysError.type.low_level_e = 0;}
133#define SYS_IS_ERROR(e) ((e).error_code != 0U)
134#define SYS_IS_ERROR_CODE(e) ((e)!=0U)
135#define SYS_IS_LOW_LEVEL_ERROR(e) ( (e).type.low_level_e )
136#define SYS_IS_SERVICE_LEVEL_ERROR(e) ( (e).type.service_level_e )
137#define SYS_SET_LOW_LEVEL_ERROR_CODE(e) {g_nSysError.type.low_level_e = (e);}
138#define SYS_SET_SERVICE_LEVEL_ERROR_CODE(e) {g_nSysError.type.service_level_e = (e);}
139#define SYS_GET_LAST_ERROR() g_nSysError
140#define SYS_GET_LAST_LOW_LEVEL_ERROR_CODE() (sys_error_code_t)(g_nSysError.type.low_level_e)
141#define SYS_GET_LAST_SERVICE_LEVEL_ERROR_CODE() (sys_error_code_t)(g_nSysError.type.service_level_e)
142#define SYS_GET_LOW_LEVEL_ERROR_CODE(e) (sys_error_code_t)((e).type.low_level_))
143#define SYS_GET_SERVICE_LEVEL_ERROR_CODE(e) (sys_error_code_t)((e).type.service_level_e)
144
145#define SYS_GENERIC_LOW_LEVEL_ERROR ((sys_error_t){0x1})
146
147#define SYS_NO_ERROR ((sys_error_t){0x0})
148#define SYS_NO_ERROR_CODE (sys_error_code_t)(0x0)
149#define SYS_GROUP_ERROR_COUNT (sys_error_code_t)(200)
150
151// Low Level API error constants
152#define SYS_BASE_LOW_LEVEL_ERROR ((sys_error_t){0x1})
153#define SYS_BASE_LOW_LEVEL_ERROR_CODE (sys_error_code_t)(0x1)
154
155// Task Level Service error constants
156#define SYS_BASE_SERVICE_LEVEL_ERROR ((sys_error_t){0x10000})
157#define SYS_BASE_SERVICE_LEVEL_ERROR_CODE (sys_error_code_t)(0x1)
158
159/* Error Code definition */
160/*************************/
161
162/* General SYS error code */
163/**************************/
164#define SYS_BASE_ERROR_CODE (sys_error_code_t)(0x1)
165#define SYS_UNDEFINED_ERROR_CODE (sys_error_code_t)(SYS_BASE_ERROR_CODE + (uint16_t)1)
166#define SYS_OUT_OF_MEMORY_ERROR_CODE (sys_error_code_t)(SYS_BASE_ERROR_CODE + (uint16_t)2)
167#define SYS_INVALID_PARAMETER_ERROR_CODE (sys_error_code_t)(SYS_BASE_ERROR_CODE + (uint16_t)3)
168#define SYS_INVALID_FUNC_CALL_ERROR_CODE (sys_error_code_t)(SYS_BASE_ERROR_CODE + (uint16_t)4)
169#define SYS_TIMEOUT_ERROR_CODE (sys_error_code_t)(SYS_BASE_ERROR_CODE + (uint16_t)5)
170#define SYS_NOT_IMPLEMENTED_ERROR_CODE (sys_error_code_t)(SYS_BASE_ERROR_CODE + (uint16_t)6)
171
172
173/* Low Level API error code */
174/****************************/
175
176
177/* Service Level error code */
178/****************************/
179
180// ApplicationContext error
181#define SYS_BASE_AC_ERROR_CODE (sys_error_code_t)(SYS_BASE_ERROR_CODE + SYS_GROUP_ERROR_COUNT)
182#define SYS_AC_TASK_ALREADY_ADDED_ERROR_CODE (sys_error_code_t)(SYS_BASE_AC_ERROR_CODE + (uint16_t)1)
183
184// IEventSrc error code
185#define SYS_BASE_IEVTSRC_ERROR_CODE (sys_error_code_t)(SYS_BASE_AC_ERROR_CODE + SYS_GROUP_ERROR_COUNT)
186#define SYS_IEVTSRC_FULL_ERROR_CODE (sys_error_code_t)(SYS_BASE_IEVTSRC_ERROR_CODE + (uint16_t)1)
187
188// SysTimestamp error
189#define SYS_BASE_TS_ERROR_CODE (sys_error_code_t)(SYS_BASE_IEVTSRC_ERROR_CODE + SYS_GROUP_ERROR_COUNT)
190#define SYS_TS_SERVICE_ISSUE_ERROR_CODE (sys_error_code_t)(SYS_BASE_TS_ERROR_CODE + (uint16_t)1)
191
192
193/* Task Level Service error code */
194/*********************************/
195
196#define SYS_BASE_TASK_ERROR_CODE (sys_error_code_t)(SYS_BASE_TS_ERROR_CODE + SYS_GROUP_ERROR_COUNT)
197#define SYS_TASK_HEAP_OUT_OF_MEMORY_ERROR_CODE (sys_error_code_t)(SYS_BASE_TASK_ERROR_CODE + (uint16_t)1)
198#define SYS_TASK_INVALID_CALL_ERROR_CODE (sys_error_code_t)(SYS_BASE_TASK_ERROR_CODE + (uint16_t)2)
199#define SYS_TASK_INVALID_PARAM_ERROR_CODE (sys_error_code_t)(SYS_BASE_TASK_ERROR_CODE + (uint16_t)3)
200#define SYS_TASK_QUEUE_FULL_ERROR_CODE (sys_error_code_t)(SYS_BASE_TASK_ERROR_CODE + (uint16_t)4)
201
202/* Init Task error code */
203/************************/
204#define SYS_BASE_INIT_TASK_ERROR_CODE (sys_error_code_t)(SYS_BASE_TASK_ERROR_CODE + SYS_GROUP_ERROR_COUNT)
205#define SYS_INIT_TASK_FAILURE_ERROR_CODE (sys_error_code_t)(SYS_BASE_INIT_TASK_ERROR_CODE + (uint16_t)1)
206#define SYS_INIT_TASK_POWER_MODE_NOT_ENABLE_ERROR_CODE (sys_error_code_t)(SYS_BASE_INIT_TASK_ERROR_CODE + (uint16_t)2)
207
208#define SYS_LAST_ERROR_CODE (sys_error_code_t)SYS_INIT_TASK_POWER_MODE_NOT_ENABLE_ERROR_CODE
209
210#define APP_BASE_ERROR_CODE SYS_LAST_ERROR_CODE + ((sys_error_code_t)1)
211
212/*
213 * MISRAC2012-Rule-20. #include is not at the top of the source file, preceding all code.
214 * This include must be here by design.
215 */
216#include "apperror.h"
217
218#ifdef __cplusplus
219}
220#endif
221
222#endif /* SYSERROR_H_ */
union _sys_error_t sys_error_t
void SysResetAEDCounter(void)
Definition sysinit.c:319
uint16_t sys_error_code_t
Definition syserror.h:41
sys_error_t g_nSysError
void sys_error_handler(void)
<DESCRIPTIOM>
Definition sysevent.h:41
Definition syserror.h:93
unsigned int low_level_e
Definition syserror.h:106
unsigned int service_level_e
Definition syserror.h:111
struct _sys_error_t::@0 type
unsigned long error_code
Definition syserror.h:97