Dependencies:   mbed

Committer:
lynxeyed_atsu
Date:
Fri Jan 21 08:39:48 2011 +0000
Revision:
0:63ed631d8c3a

        

Who changed what in which revision?

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