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