]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/types.h
ab784abe98141ab99951398f9fed323fbcac8e7a
[pes-rpp/rpp-lib.git] / rpp / include / types.h
1 /**
2  * RPP API types definition header file.
3  *
4  * @file types.h
5  *
6  * @copyright Copyright (C) 2013, 2014, 2015 Czech Technical University in Prague
7  *
8  * @author Carlos Jenkins <carlos@jenkins.co.cr>
9  */
10
11 #ifndef __RPP_TYPES_H
12 #define __RPP_TYPES_H
13
14
15 #ifndef NULL
16 /**
17  * NULL definition
18  */
19 #define NULL ((void *)0U)
20 #endif
21
22
23 #ifndef TRUE
24 /**
25  * Boolean definition for TRUE
26  */
27 #define TRUE 1
28 #endif
29
30
31 #ifndef FALSE
32 /**
33  * Boolean definition for FALSE
34  */
35 #define FALSE 0
36 #endif
37
38
39 /**
40  * Logic definition for logic HIGH
41  */
42 #define HIGH TRUE
43
44
45 /**
46  * Logic definition for logic LOW
47  */
48 #define LOW FALSE
49
50
51 /**
52  * Value indicating a closed switch
53  */
54 #define RPP_CLOSED TRUE
55
56
57 /**
58  * Value indicating an open switch
59  */
60 #define RPP_OPEN FALSE
61
62
63 /**
64  * Definition for SUCCESS
65  */
66 #define SUCCESS 0
67
68
69 /**
70  * Definition for FAILURE (oldschool code)
71  */
72 #define FAILURE -1
73
74
75 // Error codes used instead of FAILURE in new code (as negative numbers)
76 #define RPP_EINVAL  2           /**< Input value error */
77 #define RPP_EBUSY   3           /**< Hardware is busy */
78 #define RPP_ENOMEM  4           /**< Not enough memory */
79 #define RPP_ENODATA 5           /**< No data were reveived */
80 #define RPP_ENODEV  6           /**< Specified device does not exist */
81
82 // Note: Sadly <stdint.h> is not available with CCS tools.
83 #ifdef __GNUC__
84
85 #include <stdint.h>
86 #include <stdbool.h>
87 typedef bool boolean_t;
88
89 #else
90
91 /**
92  * Unsigned 64 bits integer datatype definition.
93  */
94 typedef unsigned long long uint64_t;
95
96
97 /**
98  * Unsigned 32 bits integer datatype definition.
99  */
100 typedef unsigned int uint32_t;
101
102
103 /**
104  * Unsigned 16 bits integer datatype definition.
105  */
106 typedef unsigned short uint16_t;
107
108
109 /**
110  * Unsigned 8 bits integer datatype definition.
111  */
112 typedef unsigned char uint8_t;
113
114
115 /**
116  * Signed 64 bits integer datatype definition.
117  */
118 typedef signed long long int64_t;
119
120
121 /**
122  * Signed 32 bits integer datatype definition.
123  */
124 typedef signed int int32_t;
125
126
127 /**
128  * Signed 16 bits integer datatype definition.
129  */
130 typedef signed short int16_t;
131
132
133 /**
134  * Signed 8 bits integer datatype definition.
135  */
136 typedef signed char int8_t;
137
138
139 /**
140  * Boolean datatype definition.
141  */
142 typedef unsigned char boolean_t;
143
144 #endif /* __GNUC__ */
145
146 #endif /* __RPP_TYPES_H */