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