2 * @brief Common types used in LPC functions
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\r
9 * Software that is described herein is for illustrative purposes only
\r
10 * which provides customers with programming information regarding the
\r
11 * LPC products. This software is supplied "AS IS" without any warranties of
\r
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
13 * all warranties, express or implied, including all implied warranties of
\r
14 * merchantability, fitness for a particular purpose and non-infringement of
\r
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
16 * or liability for the use of the software, conveys no license or rights under any
\r
17 * patent, copyright, mask work right, or any other intellectual property rights in
\r
18 * or to any products. NXP Semiconductors reserves the right to make changes
\r
19 * in the software without notification. NXP Semiconductors also makes no
\r
20 * representation or warranty that such application will be suitable for the
\r
21 * specified use without further testing or modification.
\r
24 * Permission to use, copy, modify, and distribute this software and its
\r
25 * documentation is hereby granted, under NXP Semiconductors' and its
\r
26 * licensor's relevant copyrights in the software, without fee, provided that it
\r
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
28 * copyright, permission, and disclaimer notice must appear in all copies of
\r
32 #ifndef __LPC_TYPES_H_
\r
33 #define __LPC_TYPES_H_
\r
36 #include <stdbool.h>
\r
38 /** @defgroup LPC_Types IP: LPC Common Types
\r
39 * @ingroup IP_Drivers
\r
43 /** @defgroup LPC_Types_Public_Types LPC Public Types
\r
48 * @brief Boolean Type definition
\r
50 typedef enum {FALSE = 0, TRUE = !FALSE} Bool;
\r
53 * @brief Boolean Type definition
\r
55 #if !defined(__cplusplus)
\r
56 // typedef enum {false = 0, true = !false} bool;
\r
60 * @brief Flag Status and Interrupt Flag Status type definition
\r
62 typedef enum {RESET = 0, SET = !RESET} FlagStatus, IntStatus, SetState;
\r
63 #define PARAM_SETSTATE(State) ((State == RESET) || (State == SET))
\r
66 * @brief Functional State Definition
\r
68 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
\r
69 #define PARAM_FUNCTIONALSTATE(State) ((State == DISABLE) || (State == ENABLE))
\r
72 * @ Status type definition
\r
74 typedef enum {ERROR = 0, SUCCESS = !ERROR} Status;
\r
77 * Read/Write transfer type mode (Block or non-block)
\r
80 NONE_BLOCKING = 0, /**< None Blocking type */
\r
81 BLOCKING, /**< Blocking type */
\r
84 /** Pointer to Function returning Void (any number of parameters) */
\r
85 typedef void (*PFV)();
\r
87 /** Pointer to Function returning int32_t (any number of parameters) */
\r
88 typedef int32_t (*PFI)();
\r
94 /** @defgroup LPC_Types_Public_Macros LPC Public Macros
\r
98 /* _BIT(n) sets the bit at position "n"
\r
99 * _BIT(n) is intended to be used in "OR" and "AND" expressions:
\r
100 * e.g., "(_BIT(3) | _BIT(7))".
\r
103 /* Set bit macro */
\r
104 #define _BIT(n) (1 << (n))
\r
106 /* _SBF(f,v) sets the bit field starting at position "f" to value "v".
\r
107 * _SBF(f,v) is intended to be used in "OR" and "AND" expressions:
\r
108 * e.g., "((_SBF(5,7) | _SBF(12,0xF)) & 0xFFFF)"
\r
111 /* Set bit field macro */
\r
112 #define _SBF(f, v) ((v) << (f))
\r
114 /* _BITMASK constructs a symbol with 'field_width' least significant
\r
116 * e.g., _BITMASK(5) constructs '0x1F', _BITMASK(16) == 0xFFFF
\r
117 * The symbol is intended to be used to limit the bit field width
\r
119 * <a_register> = (any_expression) & _BITMASK(x), where 0 < x <= 32.
\r
120 * If "any_expression" results in a value that is larger than can be
\r
121 * contained in 'x' bits, the bits above 'x - 1' are masked off. When
\r
122 * used with the _SBF example above, the example would be written:
\r
123 * a_reg = ((_SBF(5,7) | _SBF(12,0xF)) & _BITMASK(16))
\r
124 * This ensures that the value written to a_reg is no wider than
\r
125 * 16 bits, and makes the code easier to read and understand.
\r
128 /* Bitmask creation macro */
\r
129 #define _BITMASK(field_width) ( _BIT(field_width) - 1)
\r
133 #define NULL ((void *) 0)
\r
136 /* Number of elements in an array */
\r
137 #define NELEMENTS(array) (sizeof(array) / sizeof(array[0]))
\r
139 /* Static data/function define */
\r
140 #define STATIC static
\r
141 /* External data/function define */
\r
142 #define EXTERN extern
\r
145 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
\r
148 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
\r
155 /* Old Type Definition compatibility */
\r
156 /** @addtogroup LPC_Types_Public_Types
\r
160 /** LPC type for character type */
\r
163 /** LPC type for 8 bit unsigned value */
\r
164 typedef uint8_t UNS_8;
\r
166 /** LPC type for 8 bit signed value */
\r
167 typedef int8_t INT_8;
\r
169 /** LPC type for 16 bit unsigned value */
\r
170 typedef uint16_t UNS_16;
\r
172 /** LPC type for 16 bit signed value */
\r
173 typedef int16_t INT_16;
\r
175 /** LPC type for 32 bit unsigned value */
\r
176 typedef uint32_t UNS_32;
\r
178 /** LPC type for 32 bit signed value */
\r
179 typedef int32_t INT_32;
\r
181 /** LPC type for 64 bit signed value */
\r
182 typedef int64_t INT_64;
\r
184 /** LPC type for 64 bit unsigned value */
\r
185 typedef uint64_t UNS_64;
\r
188 #define BOOL_32 bool
\r
189 #define BOOL_16 bool
\r
190 #define BOOL_8 bool
\r
192 /** 32 bit boolean type */
\r
193 typedef bool BOOL_32;
\r
195 /** 16 bit boolean type */
\r
196 typedef bool BOOL_16;
\r
198 /** 8 bit boolean type */
\r
199 typedef bool BOOL_8;
\r
203 #define INLINE __inline
\r
205 #define INLINE inline
\r
216 #endif /* __LPC_TYPES_H_ */
\r