PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)
Embed:
(wiki syntax)
Show/hide line numbers
lpc_types.h
00001 /* 00002 * @brief Common types used in LPC functions 00003 * 00004 * @note 00005 * Copyright(C) NXP Semiconductors, 2012 00006 * All rights reserved. 00007 * 00008 * @par 00009 * Software that is described herein is for illustrative purposes only 00010 * which provides customers with programming information regarding the 00011 * LPC products. This software is supplied "AS IS" without any warranties of 00012 * any kind, and NXP Semiconductors and its licensor disclaim any and 00013 * all warranties, express or implied, including all implied warranties of 00014 * merchantability, fitness for a particular purpose and non-infringement of 00015 * intellectual property rights. NXP Semiconductors assumes no responsibility 00016 * or liability for the use of the software, conveys no license or rights under any 00017 * patent, copyright, mask work right, or any other intellectual property rights in 00018 * or to any products. NXP Semiconductors reserves the right to make changes 00019 * in the software without notification. NXP Semiconductors also makes no 00020 * representation or warranty that such application will be suitable for the 00021 * specified use without further testing or modification. 00022 * 00023 * @par 00024 * Permission to use, copy, modify, and distribute this software and its 00025 * documentation is hereby granted, under NXP Semiconductors' and its 00026 * licensor's relevant copyrights in the software, without fee, provided that it 00027 * is used in conjunction with NXP Semiconductors microcontrollers. This 00028 * copyright, permission, and disclaimer notice must appear in all copies of 00029 * this code. 00030 */ 00031 00032 #ifndef __LPC_TYPES_H_ 00033 #define __LPC_TYPES_H_ 00034 00035 #include <stdint.h> 00036 #include <stdbool.h> 00037 00038 /** @defgroup LPC_Types CHIP: LPC Common Types 00039 * @ingroup CHIP_Common 00040 * @{ 00041 */ 00042 00043 /** @defgroup LPC_Types_Public_Types LPC Public Types 00044 * @{ 00045 */ 00046 00047 /** 00048 * @brief Boolean Type definition 00049 */ 00050 typedef enum {FALSE = 0, TRUE = !FALSE} Bool; 00051 00052 /** 00053 * @brief Boolean Type definition 00054 */ 00055 #if !defined(__cplusplus) 00056 // typedef enum {false = 0, true = !false} bool; 00057 #endif 00058 00059 /** 00060 * @brief Flag Status and Interrupt Flag Status type definition 00061 */ 00062 typedef enum {RESET = 0, SET = !RESET} FlagStatus, IntStatus, SetState; 00063 #define PARAM_SETSTATE(State) ((State == RESET) || (State == SET)) 00064 00065 /** 00066 * @brief Functional State Definition 00067 */ 00068 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState; 00069 #define PARAM_FUNCTIONALSTATE(State) ((State == DISABLE) || (State == ENABLE)) 00070 00071 /** 00072 * @ Status type definition 00073 */ 00074 typedef enum {ERROR = 0, SUCCESS = !ERROR} Status; 00075 00076 /** 00077 * Read/Write transfer type mode (Block or non-block) 00078 */ 00079 typedef enum { 00080 NONE_BLOCKING = 0, /**< None Blocking type */ 00081 BLOCKING, /**< Blocking type */ 00082 } TRANSFER_BLOCK_T; 00083 00084 /** Pointer to Function returning Void (any number of parameters) */ 00085 typedef void (*PFV)(); 00086 00087 /** Pointer to Function returning int32_t (any number of parameters) */ 00088 typedef int32_t (*PFI)(); 00089 00090 /** 00091 * @} 00092 */ 00093 00094 /** @defgroup LPC_Types_Public_Macros LPC Public Macros 00095 * @{ 00096 */ 00097 00098 /* _BIT(n) sets the bit at position "n" 00099 * _BIT(n) is intended to be used in "OR" and "AND" expressions: 00100 * e.g., "(_BIT(3) | _BIT(7))". 00101 */ 00102 #undef _BIT 00103 /* Set bit macro */ 00104 #define _BIT(n) (1 << (n)) 00105 00106 /* _SBF(f,v) sets the bit field starting at position "f" to value "v". 00107 * _SBF(f,v) is intended to be used in "OR" and "AND" expressions: 00108 * e.g., "((_SBF(5,7) | _SBF(12,0xF)) & 0xFFFF)" 00109 */ 00110 #undef _SBF 00111 /* Set bit field macro */ 00112 #define _SBF(f, v) ((v) << (f)) 00113 00114 /* _BITMASK constructs a symbol with 'field_width' least significant 00115 * bits set. 00116 * e.g., _BITMASK(5) constructs '0x1F', _BITMASK(16) == 0xFFFF 00117 * The symbol is intended to be used to limit the bit field width 00118 * thusly: 00119 * <a_register> = (any_expression) & _BITMASK(x), where 0 < x <= 32. 00120 * If "any_expression" results in a value that is larger than can be 00121 * contained in 'x' bits, the bits above 'x - 1' are masked off. When 00122 * used with the _SBF example above, the example would be written: 00123 * a_reg = ((_SBF(5,7) | _SBF(12,0xF)) & _BITMASK(16)) 00124 * This ensures that the value written to a_reg is no wider than 00125 * 16 bits, and makes the code easier to read and understand. 00126 */ 00127 #undef _BITMASK 00128 /* Bitmask creation macro */ 00129 #define _BITMASK(field_width) ( _BIT(field_width) - 1) 00130 00131 /* NULL pointer */ 00132 #ifndef NULL 00133 #define NULL ((void *) 0) 00134 #endif 00135 00136 /* Number of elements in an array */ 00137 #define NELEMENTS(array) (sizeof(array) / sizeof(array[0])) 00138 00139 /* Static data/function define */ 00140 #define STATIC static 00141 /* External data/function define */ 00142 #define EXTERN extern 00143 00144 #if !defined(MAX) 00145 #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 00146 #endif 00147 #if !defined(MIN) 00148 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 00149 #endif 00150 00151 /** 00152 * @} 00153 */ 00154 00155 /* Old Type Definition compatibility */ 00156 /** @addtogroup LPC_Types_Public_Types 00157 * @{ 00158 */ 00159 00160 /** LPC type for character type */ 00161 //typedef char CHAR; 00162 00163 /** LPC type for 8 bit unsigned value */ 00164 typedef uint8_t UNS_8; 00165 00166 /** LPC type for 8 bit signed value */ 00167 typedef int8_t INT_8; 00168 00169 /** LPC type for 16 bit unsigned value */ 00170 typedef uint16_t UNS_16; 00171 00172 /** LPC type for 16 bit signed value */ 00173 typedef int16_t INT_16; 00174 00175 /** LPC type for 32 bit unsigned value */ 00176 typedef uint32_t UNS_32; 00177 00178 /** LPC type for 32 bit signed value */ 00179 typedef int32_t INT_32; 00180 00181 /** LPC type for 64 bit signed value */ 00182 typedef int64_t INT_64; 00183 00184 /** LPC type for 64 bit unsigned value */ 00185 typedef uint64_t UNS_64; 00186 00187 #ifdef __CODE_RED 00188 #define BOOL_32 bool 00189 #define BOOL_16 bool 00190 #define BOOL_8 bool 00191 #else 00192 /** 32 bit boolean type */ 00193 typedef bool BOOL_32; 00194 00195 /** 16 bit boolean type */ 00196 typedef bool BOOL_16; 00197 00198 /** 8 bit boolean type */ 00199 typedef bool BOOL_8; 00200 #endif 00201 00202 #ifdef __CC_ARM 00203 #define INLINE __inline 00204 #else 00205 #define INLINE inline 00206 #endif 00207 00208 /** 00209 * @} 00210 */ 00211 00212 /** 00213 * @} 00214 */ 00215 00216 #endif /* __LPC_TYPES_H_ */ 00217
Generated on Tue Jul 12 2022 21:03:50 by 1.7.2