ESP32-P4 OBC Firmware
ESP-IDF firmware for Plant-B CubeSat OBC
 
Loading...
Searching...
No Matches
pal_err.h
Go to the documentation of this file.
1#ifndef __PAL_ERR_H__
2#define __PAL_ERR_H__
3
4#ifdef ESP_PLATFORM
5#include "pal_err_esp.h"
6#endif
7
8#ifndef pal_err_t
9typedef int pal_err_t;
10#endif
11
12#ifndef PAL_OK
13#define PAL_OK 0
14#endif
15
16#ifndef PAL_FAIL
17#define PAL_FAIL -1
18#endif
19
20#ifndef PAL_ERR_NO_MEM
21#define PAL_ERR_NO_MEM -2
22#endif
23
24#ifndef PAL_ERR_INVALID_ARG
25#define PAL_ERR_INVALID_ARG -3
26#endif
27
28#ifndef PAL_ERR_INVALID_STATE
29#define PAL_ERR_INVALID_STATE -4
30#endif
31
32#ifndef PAL_ERR_INVALID_SIZE
33#define PAL_ERR_INVALID_SIZE -5
34#endif
35
36#ifndef PAL_ERR_NOT_FOUND
37#define PAL_ERR_NOT_FOUND -6
38#endif
39
40#ifndef PAL_ERR_NOT_SUPPORTED
41#define PAL_ERR_NOT_SUPPORTED -7
42#endif
43
44#ifndef PAL_ERR_TIMEOUT
45#define PAL_ERR_TIMEOUT -8
46#endif
47
48#ifndef PAL_ERR_INVALID_CRC
49#define PAL_ERR_INVALID_CRC -9
50#endif
51
52#ifndef PAL_ERR_NOT_FINISHED
53#define PAL_ERR_NOT_FINISHED -10
54#endif
55
56#ifndef PAL_ERR_NOT_ALLOWED
57#define PAL_ERR_NOT_ALLOWED -11
58#endif
59
60#ifndef PAL_ERR_TO_NAME
61static inline const char *_pal_err_to_name(pal_err_t err) {
62 switch (err) {
63 case PAL_OK: return "PAL_OK";
64 case PAL_FAIL: return "PAL_FAIL";
65 case PAL_ERR_NO_MEM: return "PAL_ERR_NO_MEM";
66 case PAL_ERR_INVALID_ARG: return "PAL_ERR_INVALID_ARG";
67 case PAL_ERR_INVALID_STATE: return "PAL_ERR_INVALID_STATE";
68 case PAL_ERR_INVALID_SIZE: return "PAL_ERR_INVALID_SIZE";
69 case PAL_ERR_NOT_FOUND: return "PAL_ERR_NOT_FOUND";
70 case PAL_ERR_NOT_SUPPORTED: return "PAL_ERR_NOT_SUPPORTED";
71 case PAL_ERR_TIMEOUT: return "PAL_ERR_TIMEOUT";
72 case PAL_ERR_INVALID_CRC: return "PAL_ERR_INVALID_CRC";
73 case PAL_ERR_NOT_FINISHED: return "PAL_ERR_NOT_FINISHED";
74 case PAL_ERR_NOT_ALLOWED: return "PAL_ERR_NOT_ALLOWED";
75 default: return "unknown";
76 }
77}
78#define PAL_ERR_TO_NAME(err) _pal_err_to_name(err)
79#endif
80
81#define PAL_CHECK(x, tag, msg) \
82 do { \
83 pal_err_t __; \
84 if ((__ = (x)) != PAL_OK) { \
85 PAL_LOGE(tag, "%s (%s)", msg, PAL_ERR_TO_NAME(__)); \
86 return __; \
87 } \
88 } while (0)
89
90#define PAL_CHECK_COND(cond, tag, msg) \
91 do { \
92 if (!(cond)) { \
93 PAL_LOGE(tag, msg); \
94 return PAL_ERR_INVALID_ARG; \
95 } \
96 } while (0)
97
98#endif // __PAL_ERR_H__
#define PAL_OK
Definition pal_err.h:13
#define PAL_ERR_NOT_ALLOWED
Definition pal_err.h:57
#define PAL_ERR_INVALID_CRC
Definition pal_err.h:49
#define PAL_ERR_NOT_FOUND
Definition pal_err.h:37
#define PAL_ERR_NOT_SUPPORTED
Definition pal_err.h:41
#define PAL_ERR_NO_MEM
Definition pal_err.h:21
int pal_err_t
Definition pal_err.h:9
#define PAL_ERR_TIMEOUT
Definition pal_err.h:45
static const char * _pal_err_to_name(pal_err_t err)
Definition pal_err.h:61
#define PAL_ERR_NOT_FINISHED
Definition pal_err.h:53
#define PAL_ERR_INVALID_ARG
Definition pal_err.h:25
#define PAL_FAIL
Definition pal_err.h:17
#define PAL_ERR_INVALID_SIZE
Definition pal_err.h:33
#define PAL_ERR_INVALID_STATE
Definition pal_err.h:29