| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lpc_types.h
Go to the documentation of this file.
1 /*
2 * @brief Common types used in LPC functions
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * All rights reserved.
7 *
8 * @par
9 * Software that is described herein is for illustrative purposes only
10 * which provides customers with programming information regarding the
11 * LPC products. This software is supplied "AS IS" without any warranties of
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
13 * all warranties, express or implied, including all implied warranties of
14 * merchantability, fitness for a particular purpose and non-infringement of
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
16 * or liability for the use of the software, conveys no license or rights under any
17 * patent, copyright, mask work right, or any other intellectual property rights in
18 * or to any products. NXP Semiconductors reserves the right to make changes
19 * in the software without notification. NXP Semiconductors also makes no
20 * representation or warranty that such application will be suitable for the
21 * specified use without further testing or modification.
22 *
23 * @par
24 * Permission to use, copy, modify, and distribute this software and its
25 * documentation is hereby granted, under NXP Semiconductors' and its
26 * licensor's relevant copyrights in the software, without fee, provided that it
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
28 * copyright, permission, and disclaimer notice must appear in all copies of
29 * this code.
30 */
31
32 #ifndef __LPC_TYPES_H_
33 #define __LPC_TYPES_H_
34
35 #include <stdint.h>
36 #include <stdbool.h>
37
50 typedef enum {FALSE = 0, TRUE = !FALSE} Bool;
51
55 #if !defined(__cplusplus)
56 // typedef enum {false = 0, true = !false} bool;
57 #endif
58
62 typedef enum {RESET = 0, SET = !RESET} FlagStatus, IntStatus, SetState;
63 #define PARAM_SETSTATE(State) ((State == RESET) || (State == SET))
64
68 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
69 #define PARAM_FUNCTIONALSTATE(State) ((State == DISABLE) || (State == ENABLE))
70
74 typedef enum {ERROR = 0, SUCCESS = !ERROR} Status;
75
79 typedef enum {
80 NONE_BLOCKING = 0,
81 BLOCKING,
82 } TRANSFER_BLOCK_T;
83
85 typedef void (*PFV)();
86
88 typedef int32_t (*PFI)();
89
98 /* _BIT(n) sets the bit at position "n"
99 * _BIT(n) is intended to be used in "OR" and "AND" expressions:
100 * e.g., "(_BIT(3) | _BIT(7))".
101 */
102 #undef _BIT
103 /* Set bit macro */
104 #define _BIT(n) (1 << (n))
105
106 /* _SBF(f,v) sets the bit field starting at position "f" to value "v".
107 * _SBF(f,v) is intended to be used in "OR" and "AND" expressions:
108 * e.g., "((_SBF(5,7) | _SBF(12,0xF)) & 0xFFFF)"
109 */
110 #undef _SBF
111 /* Set bit field macro */
112 #define _SBF(f, v) ((v) << (f))
113
114 /* _BITMASK constructs a symbol with 'field_width' least significant
115 * bits set.
116 * e.g., _BITMASK(5) constructs '0x1F', _BITMASK(16) == 0xFFFF
117 * The symbol is intended to be used to limit the bit field width
118 * thusly:
119 * <a_register> = (any_expression) & _BITMASK(x), where 0 < x <= 32.
120 * If "any_expression" results in a value that is larger than can be
121 * contained in 'x' bits, the bits above 'x - 1' are masked off. When
122 * used with the _SBF example above, the example would be written:
123 * a_reg = ((_SBF(5,7) | _SBF(12,0xF)) & _BITMASK(16))
124 * This ensures that the value written to a_reg is no wider than
125 * 16 bits, and makes the code easier to read and understand.
126 */
127 #undef _BITMASK
128 /* Bitmask creation macro */
129 #define _BITMASK(field_width) ( _BIT(field_width) - 1)
130
131 /* NULL pointer */
132 #ifndef NULL
133 #define NULL ((void *) 0)
134 #endif
135
136 /* Number of elements in an array */
137 #define NELEMENTS(array) (sizeof(array) / sizeof(array[0]))
138
139 /* Static data/function define */
140 #define STATIC static
141 /* External data/function define */
142 #define EXTERN extern
143
144 #if !defined(MAX)
145 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
146 #endif
147 #if !defined(MIN)
148 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
149 #endif
150
155 /* Old Type Definition compatibility */
161 typedef char CHAR;
162
164 typedef uint8_t UNS_8;
165
167 typedef int8_t INT_8;
168
170 typedef uint16_t UNS_16;
171
173 typedef int16_t INT_16;
174
176 typedef uint32_t UNS_32;
177
179 typedef int32_t INT_32;
180
182 typedef int64_t INT_64;
183
185 typedef uint64_t UNS_64;
186
187 #ifdef __CODE_RED
188 #define BOOL_32 bool
189 #define BOOL_16 bool
190 #define BOOL_8 bool
191 #else
192
193 typedef bool BOOL_32;
194
196 typedef bool BOOL_16;
197
199 typedef bool BOOL_8;
200 #endif
201
202 #ifdef __CC_ARM
203 #define INLINE __inline
204 #else
205 #define INLINE inline
206 #endif
207
216 #endif /* __LPC_TYPES_H_ */