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
24
25#ifndef __PAL_ERR_H__
26#define __PAL_ERR_H__
27
28#ifdef ESP_PLATFORM
29#include "pal_err_esp.h"
30#endif
31
43#ifndef pal_err_t
44typedef int pal_err_t;
45#endif
46
50
51#ifndef PAL_OK
53#define PAL_OK 0
54#endif
55
56#ifndef PAL_FAIL
58#define PAL_FAIL -1
59#endif
60
61#ifndef PAL_ERR_NO_MEM
63#define PAL_ERR_NO_MEM -2
64#endif
65
66#ifndef PAL_ERR_INVALID_ARG
68#define PAL_ERR_INVALID_ARG -3
69#endif
70
71#ifndef PAL_ERR_INVALID_STATE
73#define PAL_ERR_INVALID_STATE -4
74#endif
75
76#ifndef PAL_ERR_INVALID_SIZE
78#define PAL_ERR_INVALID_SIZE -5
79#endif
80
81#ifndef PAL_ERR_NOT_FOUND
83#define PAL_ERR_NOT_FOUND -6
84#endif
85
86#ifndef PAL_ERR_NOT_SUPPORTED
88#define PAL_ERR_NOT_SUPPORTED -7
89#endif
90
91#ifndef PAL_ERR_TIMEOUT
93#define PAL_ERR_TIMEOUT -8
94#endif
95
96#ifndef PAL_ERR_INVALID_CRC
98#define PAL_ERR_INVALID_CRC -9
99#endif
100
101#ifndef PAL_ERR_NOT_FINISHED
103#define PAL_ERR_NOT_FINISHED -10
104#endif
105
106#ifndef PAL_ERR_NOT_ALLOWED
108#define PAL_ERR_NOT_ALLOWED -11
109#endif
110 // end of Error Codes
112
113#ifndef PAL_ERR_TO_NAME
126static inline const char *_pal_err_to_name(pal_err_t err) {
127 switch (err) {
128 case PAL_OK: return "PAL_OK";
129 case PAL_FAIL: return "PAL_FAIL";
130 case PAL_ERR_NO_MEM: return "PAL_ERR_NO_MEM";
131 case PAL_ERR_INVALID_ARG: return "PAL_ERR_INVALID_ARG";
132 case PAL_ERR_INVALID_STATE: return "PAL_ERR_INVALID_STATE";
133 case PAL_ERR_INVALID_SIZE: return "PAL_ERR_INVALID_SIZE";
134 case PAL_ERR_NOT_FOUND: return "PAL_ERR_NOT_FOUND";
135 case PAL_ERR_NOT_SUPPORTED: return "PAL_ERR_NOT_SUPPORTED";
136 case PAL_ERR_TIMEOUT: return "PAL_ERR_TIMEOUT";
137 case PAL_ERR_INVALID_CRC: return "PAL_ERR_INVALID_CRC";
138 case PAL_ERR_NOT_FINISHED: return "PAL_ERR_NOT_FINISHED";
139 case PAL_ERR_NOT_ALLOWED: return "PAL_ERR_NOT_ALLOWED";
140 default: return "unknown";
141 }
142}
143
151#define PAL_ERR_TO_NAME(err) _pal_err_to_name(err)
152#endif
153
165#define PAL_CHECK(x, tag, msg) \
166 do { \
167 pal_err_t __; \
168 if ((__ = (x)) != PAL_OK) { \
169 PAL_LOGE(tag, "%s (%s)", msg, PAL_ERR_TO_NAME(__)); \
170 return __; \
171 } \
172 } while (0)
173
186#define PAL_CHECK_COND(cond, tag, msg) \
187 do { \
188 if (!(cond)) { \
189 PAL_LOGE(tag, msg); \
190 return PAL_ERR_INVALID_ARG; \
191 } \
192 } while (0)
193 // end of pal_err group
195
196#endif // __PAL_ERR_H__
197
#define PAL_OK
Operation completed successfully.
Definition pal_err.h:53
#define PAL_ERR_NOT_ALLOWED
Operation is not permitted in the current context.
Definition pal_err.h:108
#define PAL_ERR_INVALID_CRC
CRC check failed.
Definition pal_err.h:98
#define PAL_ERR_NOT_FOUND
Requested resource was not found.
Definition pal_err.h:83
#define PAL_ERR_NOT_SUPPORTED
Operation or feature is not supported.
Definition pal_err.h:88
#define PAL_ERR_NO_MEM
Memory allocation failed.
Definition pal_err.h:63
int pal_err_t
Definition pal_err.h:44
#define PAL_ERR_TIMEOUT
Operation timed out.
Definition pal_err.h:93
static const char * _pal_err_to_name(pal_err_t err)
Convert a pal_err_t code to its human-readable name.
Definition pal_err.h:126
#define PAL_ERR_NOT_FINISHED
Operation has not finished yet.
Definition pal_err.h:103
#define PAL_ERR_INVALID_ARG
One or more arguments are invalid.
Definition pal_err.h:68
#define PAL_FAIL
Generic failure.
Definition pal_err.h:58
#define PAL_ERR_INVALID_SIZE
A size value is out of the valid range.
Definition pal_err.h:78
#define PAL_ERR_INVALID_STATE
The current state does not permit this operation.
Definition pal_err.h:73
ESP32 platform aliases for PAL error codes.