-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherr.h
executable file
·87 lines (73 loc) · 2.09 KB
/
err.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* @file err.h
*
* @date 2020-03-12
* @author twatorowski ([email protected])
*
* @brief Error codes definitions
*/
#ifndef ERR_H
#define ERR_H
#include <stdint.h>
/* offset error code from the base error code value */
#define FROM_BASE(base, offset) ((base) - (offset))
/* base error code values */
enum err_base {
/* usb errors base error code */
EUSB_BASE = -20,
/* i2c errors base error code */
EI2C_BASE = -40
};
/** error codes present in system */
typedef enum err {
/** secure the size of enum */
_MAX_VAL = INT32_MAX,
/* general errors */
/** no error */
EOK = 0,
/** fatal error */
EFATAL = -1,
/** resource busy */
EBUSY = -2,
/** argument value error */
EARGVAL = -3,
/** routine is to be called again (polled upon) */
EAGAIN = -4,
/** timeout has occured */
ETIMEOUT = -5,
/** task cancelled */
ECANCEL = -6,
/** unknown protocol */
EUNKPROT = -7,
/** unknown request */
EUNKREQ = -8,
/** malformed packet */
EMALFORMED = -8,
/** unknown address */
EUNKADDR = -9,
/** address unreachable */
EUNREACHABLE = -10,
/** no connection is established */
ENOCONNECT = -11,
/* usb errors */
/* usb reset has occured */
EUSB_RESET = FROM_BASE(EUSB_BASE, 0),
/* usb endpoint disabled */
EUSB_EP_DIS = FROM_BASE(EUSB_BASE, 1),
/* usb endpoint disabled */
EUSB_INACTIVE = FROM_BASE(EUSB_BASE, 2),
/** i2c errors */
/** bus arbitration lost */
EI2C_ARB_LOST = FROM_BASE(EI2C_BASE, 0),
/** bus timeout while waiting for scl to free up */
EI2C_BUS_TIMEOUT = FROM_BASE(EI2C_BASE, 1),
/** nack received */
EI2C_NACK = FROM_BASE(EI2C_BASE, 2),
/** error during start condition state */
EI2C_START = FROM_BASE(EI2C_BASE, 3),
/** error during arressing phase */
EI2C_ADDR = FROM_BASE(EI2C_BASE, 4),
/** error during stop condition */
EI2C_STOP = FROM_BASE(EI2C_BASE, 5),
} err_t;
#endif /** ERR_H */