1 /**********************************************************************
2 * $Id$      lpc_types.h         2011-06-02
3 *//**
4 * @file     lpc_types.h
5 * @brief    Contains the NXP ABL typedefs for C standard types.
6 *           It is intended to be used in ISO C conforming development
7 *           environments and checks for this insofar as it is possible
8 *           to do so.
9 * @version  1.0
10 * @date     02. June. 2011
11 * @author   NXP MCU SW Application Team
12 *
13 * Copyright(C) 2011, NXP Semiconductor
14 * All rights reserved.
15 *
16 ***********************************************************************
17 * Software that is described herein is for illustrative purposes only
18 * which provides customers with programming information regarding the
19 * products. This software is supplied "AS IS" without any warranties.
20 * NXP Semiconductors assumes no responsibility or liability for the
21 * use of the software, conveys no license or title under any patent,
22 * copyright, or mask work right to the product. NXP Semiconductors
23 * reserves the right to make changes in the software without
24 * notification. NXP Semiconductors also make no representation or
25 * warranty that such application will be suitable for the specified
26 * use without further testing or modification.
27 **********************************************************************/
28 
29 /* Type group ----------------------------------------------------------- */
30 #ifndef __LPC_TYPES_H
31 #define __LPC_TYPES_H
32 
33 /* Includes ------------------------------------------------------------------- */
34 #include <stdint.h>
35 
36 /** @defgroup LPC_Type_Def Data Types Definitions
37  * @ingroup LPC177x_8xCMSIS_FwLib_Drivers
38  * @{
39  */
40 
41 /* Public Types --------------------------------------------------------------- */
42 /** @defgroup LPC_Types_Public_Types Basic Public Data Types
43  * @{
44  */
45 
46 /**
47  * @brief Boolean Type definition
48  */
49 typedef enum {FALSE = 0, TRUE = !FALSE} Bool;
50 
51 /**
52  * @brief Flag Status and Interrupt Flag Status type definition
53  */
54 typedef enum {RESET = 0, SET = !RESET} FlagStatus, IntStatus, SetState;
55 #define PARAM_SETSTATE(State) ((State==RESET) || (State==SET))
56 
57 /**
58  * @brief Functional State Definition
59  */
60 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
61 #define PARAM_FUNCTIONALSTATE(State) ((State==DISABLE) || (State==ENABLE))
62 
63 /**
64  * @ Status type definition
65  */
66 typedef enum {ERROR = 0, SUCCESS = !ERROR} Status;
67 
68 
69 /**
70  * Read/Write transfer type mode (Block or non-block)
71  */
72 typedef enum
73 {
74     NONE_BLOCKING = 0,      /**< None Blocking type */
75     BLOCKING,               /**< Blocking type */
76 } TRANSFER_BLOCK_Type;
77 
78 
79 /** Pointer to Function returning Void (any number of parameters) */
80 typedef void (*PFV)();
81 
82 /** Pointer to Function returning int32_t (any number of parameters) */
83 typedef int32_t(*PFI)();
84 
85 /**
86  * @}
87  */
88 
89 
90 /* Public Macros -------------------------------------------------------------- */
91 /** @defgroup LPC_Types_Public_Macros  Basic Public Macros
92  * @{
93  */
94 
95 /** _BIT(n) sets the bit at position "n"
96  * _BIT(n) is intended to be used in "OR" and "AND" expressions:
97  * e.g., "(_BIT(3) | _BIT(7))".
98  */
99 #undef _BIT
100 /** Set bit macro */
101 #define _BIT(n) (1<<n)
102 
103 /** _SBF(f,v) sets the bit field starting at position "f" to value "v".
104  * _SBF(f,v) is intended to be used in "OR" and "AND" expressions:
105  * e.g., "((_SBF(5,7) | _SBF(12,0xF)) & 0xFFFF)"
106  */
107 #undef _SBF
108 /* Set bit field macro */
109 #define _SBF(f,v) (v<<f)
110 
111 /* _BITMASK constructs a symbol with 'field_width' least significant
112  * bits set.
113  * e.g., _BITMASK(5) constructs '0x1F', _BITMASK(16) == 0xFFFF
114  * The symbol is intended to be used to limit the bit field width
115  * thusly:
116  * <a_register> = (any_expression) & _BITMASK(x), where 0 < x <= 32.
117  * If "any_expression" results in a value that is larger than can be
118  * contained in 'x' bits, the bits above 'x - 1' are masked off.  When
119  * used with the _SBF example above, the example would be written:
120  * a_reg = ((_SBF(5,7) | _SBF(12,0xF)) & _BITMASK(16))
121  * This ensures that the value written to a_reg is no wider than
122  * 16 bits, and makes the code easier to read and understand.
123  */
124 #undef _BITMASK
125 /* Bitmask creation macro */
126 #define _BITMASK(field_width) ( _BIT(field_width) - 1)
127 
128 /* NULL pointer */
129 #ifndef NULL
130 #define NULL ((void*) 0)
131 #endif
132 
133 /* Number of elements in an array */
134 #define NELEMENTS(array)  (sizeof (array) / sizeof (array[0]))
135 
136 /* Static data/function define */
137 #define STATIC static
138 /* External data/function define */
139 #define EXTERN extern
140 
141 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
142 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
143 
144 /**
145  * @}
146  */
147 
148 
149 /* Old Type Definition compatibility ------------------------------------------ */
150 /** @addtogroup LPC_Types_Public_Types LPC_Types Public Types
151  * @{
152  */
153 
154 /** SMA type for character type */
155 typedef char CHAR;
156 
157 /** SMA type for 8 bit unsigned value */
158 typedef uint8_t UNS_8;
159 
160 /** SMA type for 8 bit signed value */
161 typedef int8_t INT_8;
162 
163 /** SMA type for 16 bit unsigned value */
164 typedef uint16_t UNS_16;
165 
166 /** SMA type for 16 bit signed value */
167 typedef int16_t INT_16;
168 
169 /** SMA type for 32 bit unsigned value */
170 typedef uint32_t UNS_32;
171 
172 /** SMA type for 32 bit signed value */
173 typedef int32_t INT_32;
174 
175 /** SMA type for 64 bit signed value */
176 typedef int64_t INT_64;
177 
178 /** SMA type for 64 bit unsigned value */
179 typedef uint64_t UNS_64;
180 
181 /** 32 bit boolean type */
182 typedef Bool BOOL_32;
183 
184 /** 16 bit boolean type */
185 typedef Bool BOOL_16;
186 
187 /** 8 bit boolean type */
188 typedef Bool BOOL_8;
189 
190 /**
191  * @}
192  */
193 
194 
195 #endif /* __LPC_TYPES_H */
196 
197 /**
198  * @}
199  */
200 
201 /* --------------------------------- End Of File ------------------------------ */
202