Fix USB, DOS line endings, integrate and reorganize project
[rapper.git] / src / usb / lpc_types.h
1 /***********************************************************************//**
2  * @file                lpc_types.h
3  * @brief               Contains the NXP ABL typedefs for C standard types.
4  *                      It is intended to be used in ISO C conforming development
5  *                      environments and checks for this insofar as it is possible
6  *                      to do so.
7  * @version             1.0
8  * @date                27 Jul. 2008
9  * @author              wellsk
10  **************************************************************************
11  * Software that is described herein is for illustrative purposes only
12  * which provides customers with programming information regarding the
13  * products. This software is supplied "AS IS" without any warranties.
14  * NXP Semiconductors assumes no responsibility or liability for the
15  * use of the software, conveys no license or title under any patent,
16  * copyright, or mask work right to the product. NXP Semiconductors
17  * reserves the right to make changes in the software without
18  * notification. NXP Semiconductors also make no representation or
19  * warranty that such application will be suitable for the specified
20  * use without further testing or modification.
21  **************************************************************************/
22
23 /* Type group ----------------------------------------------------------- */
24 /** @defgroup LPC_Types LPC_Types
25  * @ingroup LPC1700CMSIS_FwLib_Drivers
26  * @{
27  */
28
29 #ifndef LPC_TYPES_H
30 #define LPC_TYPES_H
31
32 /* Includes ------------------------------------------------------------------- */
33 #include <stdint.h>
34
35
36 /* Public Types --------------------------------------------------------------- */
37 /** @defgroup LPC_Types_Public_Types LPC_Types Public Types
38  * @{
39  */
40
41 /**
42  * @brief Boolean Type definition
43  */
44 typedef enum {FALSE = 0, TRUE = !FALSE} Bool;
45
46 /**
47  * @brief Flag Status and Interrupt Flag Status type definition
48  */
49 typedef enum {RESET = 0, SET = !RESET} FlagStatus, IntStatus, SetState;
50 #define PARAM_SETSTATE(State) ((State==RESET) || (State==SET))
51
52 /**
53  * @brief Functional State Definition
54  */
55 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
56 #define PARAM_FUNCTIONALSTATE(State) ((State==DISABLE) || (State==ENABLE))
57
58 /**
59  * @ Status type definition
60  */
61 typedef enum {ERROR = 0, SUCCESS = !ERROR} Status;
62
63
64 /**
65  * Read/Write transfer type mode (Block or non-block)
66  */
67 typedef enum
68 {
69         NONE_BLOCKING = 0,              /**< None Blocking type */
70         BLOCKING,                               /**< Blocking type */
71 } TRANSFER_BLOCK_Type;
72
73
74 /** Pointer to Function returning Void (any number of parameters) */
75 typedef void (*PFV)();
76
77 /** Pointer to Function returning int32_t (any number of parameters) */
78 typedef int32_t(*PFI)();
79
80 /**
81  * @}
82  */
83
84
85 /* Public Macros -------------------------------------------------------------- */
86 /** @defgroup LPC_Types_Public_Macros  LPC_Types Public Macros
87  * @{
88  */
89
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
139 /**
140  * @}
141  */
142
143
144 /* Old Type Definition compatibility ------------------------------------------ */
145 /** @addtogroup LPC_Types_Public_Types LPC_Types Public Types
146  * @{
147  */
148
149 /** SMA type for character type */
150 typedef char CHAR;
151
152 /** SMA type for 8 bit unsigned value */
153 typedef uint8_t UNS_8;
154
155 /** SMA type for 8 bit signed value */
156 typedef int8_t INT_8;
157
158 /** SMA type for 16 bit unsigned value */
159 typedef uint16_t UNS_16;
160
161 /** SMA type for 16 bit signed value */
162 typedef int16_t INT_16;
163
164 /** SMA type for 32 bit unsigned value */
165 typedef uint32_t UNS_32;
166
167 /** SMA type for 32 bit signed value */
168 typedef int32_t INT_32;
169
170 /** SMA type for 64 bit signed value */
171 typedef int64_t INT_64;
172
173 /** SMA type for 64 bit unsigned value */
174 typedef uint64_t UNS_64;
175
176 /** 32 bit boolean type */
177 typedef Bool BOOL_32;
178
179 /** 16 bit boolean type */
180 typedef Bool BOOL_16;
181
182 /** 8 bit boolean type */
183 typedef Bool BOOL_8;
184
185 /**
186  * @}
187  */
188
189
190 #endif /* LPC_TYPES_H */
191
192 /**
193  * @}
194  */
195
196 /* --------------------------------- End Of File ------------------------------ */