PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Dependents:   YATTT sd_map_test cPong SnowDemo ... more

PokittoLib

Library for programming Pokitto hardware

How to Use

  1. Import this library to online compiler (see button "import" on the right hand side
  2. DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
  3. Change My_settings.h according to your project
  4. Start coding!
Committer:
Pokitto
Date:
Wed Dec 25 23:59:52 2019 +0000
Revision:
71:531419862202
Parent:
30:796f9611d2ac
Changed Mode2 C++ refresh code (graphical errors)

Who changed what in which revision?

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