uc-sdk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lpc_types.h
Go to the documentation of this file.
1 /***********************************************************************/
23 /* Type group ----------------------------------------------------------- */
29 #ifndef LPC_TYPES_H
30 #define LPC_TYPES_H
31 
32 /* Includes ------------------------------------------------------------------- */
33 #include <stdint.h>
34 
35 
36 /* Public Types --------------------------------------------------------------- */
44 typedef enum {FALSE = 0, TRUE = !FALSE} Bool;
45 
49 typedef enum {RESET = 0, SET = !RESET} FlagStatus, IntStatus, SetState;
50 #define PARAM_SETSTATE(State) ((State==RESET) || (State==SET))
51 
55 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
56 #define PARAM_FUNCTIONALSTATE(State) ((State==DISABLE) || (State==ENABLE))
57 
61 typedef enum {ERROR = 0, SUCCESS = !ERROR} Status;
62 
63 
67 typedef enum
68 {
72 
73 
75 typedef void (*PFV)();
76 
78 typedef int32_t(*PFI)();
79 
85 /* Public Macros -------------------------------------------------------------- */
90 /* _BIT(n) sets the bit at position "n"
91  * _BIT(n) is intended to be used in "OR" and "AND" expressions:
92  * e.g., "(_BIT(3) | _BIT(7))".
93  */
94 #undef _BIT
95 /* Set bit macro */
96 #define _BIT(n) (1<<n)
97 
98 /* _SBF(f,v) sets the bit field starting at position "f" to value "v".
99  * _SBF(f,v) is intended to be used in "OR" and "AND" expressions:
100  * e.g., "((_SBF(5,7) | _SBF(12,0xF)) & 0xFFFF)"
101  */
102 #undef _SBF
103 /* Set bit field macro */
104 #define _SBF(f,v) (v<<f)
105 
106 /* _BITMASK constructs a symbol with 'field_width' least significant
107  * bits set.
108  * e.g., _BITMASK(5) constructs '0x1F', _BITMASK(16) == 0xFFFF
109  * The symbol is intended to be used to limit the bit field width
110  * thusly:
111  * <a_register> = (any_expression) & _BITMASK(x), where 0 < x <= 32.
112  * If "any_expression" results in a value that is larger than can be
113  * contained in 'x' bits, the bits above 'x - 1' are masked off. When
114  * used with the _SBF example above, the example would be written:
115  * a_reg = ((_SBF(5,7) | _SBF(12,0xF)) & _BITMASK(16))
116  * This ensures that the value written to a_reg is no wider than
117  * 16 bits, and makes the code easier to read and understand.
118  */
119 #undef _BITMASK
120 /* Bitmask creation macro */
121 #define _BITMASK(field_width) ( _BIT(field_width) - 1)
122 
123 /* NULL pointer */
124 #ifndef NULL
125 #define NULL ((void*) 0)
126 #endif
127 
128 /* Number of elements in an array */
129 #define NELEMENTS(array) (sizeof (array) / sizeof (array[0]))
130 
131 /* Static data/function define */
132 #define STATIC static
133 /* External data/function define */
134 #define EXTERN extern
135 
136 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
137 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
138 
144 /* Old Type Definition compatibility ------------------------------------------ */
150 typedef char CHAR;
151 
153 typedef uint8_t UNS_8;
154 
156 typedef int8_t INT_8;
157 
159 typedef uint16_t UNS_16;
160 
162 typedef int16_t INT_16;
163 
165 typedef uint32_t UNS_32;
166 
168 typedef int32_t INT_32;
169 
171 typedef int64_t INT_64;
172 
174 typedef uint64_t UNS_64;
175 
177 typedef Bool BOOL_32;
178 
180 typedef Bool BOOL_16;
181 
183 typedef Bool BOOL_8;
184 
190 #endif /* LPC_TYPES_H */
191 
196 /* --------------------------------- End Of File ------------------------------ */