aboutsummaryrefslogtreecommitdiff
path: root/include/error.h
blob: 6621633abb2f6dc701171ac20bf8fe4d305b5188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdlib.h>
#include <stdint.h>

#ifndef _IOE_ERROR_H_
#define _IOE_ERROR_H_
#ifdef CONFIG_ERRORS

enum ErrorCodes {
	EC_OK = 0, // This is not really error code. It triggers error callback but the error function returns
	EC_FUNC_ARG, // Invalid argument passed to function
	EC_INVALID_PORT, // IO error, requested port is not on your CPU
	EC_BUFFER_FULL, // If configured so, full buffer causes this error
	_EC_LAST = 128 // Not really error code. This reserver error range for library. User can define its error codes by adding
};

#ifdef CONFIG_ERROR_MESSAGES

void _error(enum ErrorCodes ec, const char *msg);
#define error(EC, MSG) _error(EC, MSG)

#ifdef CONFIG_ERROR_CALLBACK
void error_callback(enum ErrorCodes ec, const char *msg);
#endif /* CONFIG_ERROR_CALLBACK */

#else /* CONFIG_ERROR_MESSAGES*/

void _error(enum ErrorCodes ec);
#define error(EC, MSG) _error(EC)

#ifdef CONFIG_ERROR_CALLBACK
void error_callback(enum ErrorCodes ec);
#endif /* CONFIG_ERROR_CALLBACK */

#endif /* CONFIG_ERROR_MESSAGES */


#else /* CONFIG_ERRORS */

// Just dummy definition to suppress all errors
#define error(EC, MSG)

#endif /*  CONFIG_ERRORS */
#endif /* _IOE_ERROR_H_ */