The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 156:ff21514d8981 1 /*******************************************************************************
AnnaBridge 156:ff21514d8981 2 * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved.
AnnaBridge 156:ff21514d8981 3 *
AnnaBridge 156:ff21514d8981 4 * Permission is hereby granted, free of charge, to any person obtaining a
AnnaBridge 156:ff21514d8981 5 * copy of this software and associated documentation files (the "Software"),
AnnaBridge 156:ff21514d8981 6 * to deal in the Software without restriction, including without limitation
AnnaBridge 156:ff21514d8981 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
AnnaBridge 156:ff21514d8981 8 * and/or sell copies of the Software, and to permit persons to whom the
AnnaBridge 156:ff21514d8981 9 * Software is furnished to do so, subject to the following conditions:
AnnaBridge 156:ff21514d8981 10 *
AnnaBridge 156:ff21514d8981 11 * The above copyright notice and this permission notice shall be included
AnnaBridge 156:ff21514d8981 12 * in all copies or substantial portions of the Software.
AnnaBridge 156:ff21514d8981 13 *
AnnaBridge 156:ff21514d8981 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
AnnaBridge 156:ff21514d8981 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
AnnaBridge 156:ff21514d8981 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
AnnaBridge 156:ff21514d8981 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
AnnaBridge 156:ff21514d8981 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
AnnaBridge 156:ff21514d8981 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
AnnaBridge 156:ff21514d8981 20 * OTHER DEALINGS IN THE SOFTWARE.
AnnaBridge 156:ff21514d8981 21 *
AnnaBridge 156:ff21514d8981 22 * Except as contained in this notice, the name of Maxim Integrated
AnnaBridge 156:ff21514d8981 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
AnnaBridge 156:ff21514d8981 24 * Products, Inc. Branding Policy.
AnnaBridge 156:ff21514d8981 25 *
AnnaBridge 156:ff21514d8981 26 * The mere transfer of this software does not imply any licenses
AnnaBridge 156:ff21514d8981 27 * of trade secrets, proprietary technology, copyrights, patents,
AnnaBridge 156:ff21514d8981 28 * trademarks, maskwork rights, or any other form of intellectual
AnnaBridge 156:ff21514d8981 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
AnnaBridge 156:ff21514d8981 30 * ownership rights.
AnnaBridge 156:ff21514d8981 31 *******************************************************************************
AnnaBridge 156:ff21514d8981 32 */
AnnaBridge 156:ff21514d8981 33
AnnaBridge 156:ff21514d8981 34 #ifndef MBED_PINNAMES_H
AnnaBridge 156:ff21514d8981 35 #define MBED_PINNAMES_H
AnnaBridge 156:ff21514d8981 36
AnnaBridge 156:ff21514d8981 37 #include "cmsis.h"
AnnaBridge 156:ff21514d8981 38 #include "gpio_regs.h"
AnnaBridge 156:ff21514d8981 39
AnnaBridge 156:ff21514d8981 40 #ifdef __cplusplus
AnnaBridge 156:ff21514d8981 41 extern "C" {
AnnaBridge 156:ff21514d8981 42 #endif
AnnaBridge 156:ff21514d8981 43
AnnaBridge 156:ff21514d8981 44 typedef enum {
AnnaBridge 156:ff21514d8981 45 PIN_INPUT = MXC_V_GPIO_OUT_MODE_HIGH_Z,
AnnaBridge 156:ff21514d8981 46 PIN_OUTPUT = MXC_V_GPIO_OUT_MODE_NORMAL_DRIVE
AnnaBridge 156:ff21514d8981 47 } PinDirection;
AnnaBridge 156:ff21514d8981 48
AnnaBridge 156:ff21514d8981 49 #define PORT_SHIFT 12
AnnaBridge 156:ff21514d8981 50 #define PINNAME_TO_PORT(name) ((unsigned int)(name) >> PORT_SHIFT)
AnnaBridge 156:ff21514d8981 51 #define PINNAME_TO_PIN(name) ((unsigned int)(name) & ~(0xFFFFFFFF << PORT_SHIFT))
AnnaBridge 156:ff21514d8981 52
AnnaBridge 156:ff21514d8981 53 typedef enum {
AnnaBridge 156:ff21514d8981 54 P0_0 = (0 << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 55 P0_1 = (0 << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 56 P0_2 = (0 << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 57 P0_3 = (0 << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 58 P0_4 = (0 << PORT_SHIFT) | 4,
AnnaBridge 156:ff21514d8981 59 P0_5 = (0 << PORT_SHIFT) | 5,
AnnaBridge 156:ff21514d8981 60 P0_6 = (0 << PORT_SHIFT) | 6,
AnnaBridge 156:ff21514d8981 61 P0_7 = (0 << PORT_SHIFT) | 7,
AnnaBridge 156:ff21514d8981 62
AnnaBridge 156:ff21514d8981 63 P1_0 = (1 << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 64 P1_1 = (1 << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 65 P1_2 = (1 << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 66 P1_3 = (1 << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 67 P1_4 = (1 << PORT_SHIFT) | 4,
AnnaBridge 156:ff21514d8981 68 P1_5 = (1 << PORT_SHIFT) | 5,
AnnaBridge 156:ff21514d8981 69 P1_6 = (1 << PORT_SHIFT) | 6,
AnnaBridge 156:ff21514d8981 70 P1_7 = (1 << PORT_SHIFT) | 7,
AnnaBridge 156:ff21514d8981 71
AnnaBridge 156:ff21514d8981 72 P2_0 = (2 << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 73 P2_1 = (2 << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 74 P2_2 = (2 << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 75 P2_3 = (2 << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 76 P2_4 = (2 << PORT_SHIFT) | 4,
AnnaBridge 156:ff21514d8981 77 P2_5 = (2 << PORT_SHIFT) | 5,
AnnaBridge 156:ff21514d8981 78 P2_6 = (2 << PORT_SHIFT) | 6,
AnnaBridge 156:ff21514d8981 79 P2_7 = (2 << PORT_SHIFT) | 7,
AnnaBridge 156:ff21514d8981 80
AnnaBridge 156:ff21514d8981 81 P3_0 = (3 << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 82 P3_1 = (3 << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 83 P3_2 = (3 << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 84 P3_3 = (3 << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 85 P3_4 = (3 << PORT_SHIFT) | 4,
AnnaBridge 156:ff21514d8981 86 P3_5 = (3 << PORT_SHIFT) | 5,
AnnaBridge 156:ff21514d8981 87 P3_6 = (3 << PORT_SHIFT) | 6,
AnnaBridge 156:ff21514d8981 88 P3_7 = (3 << PORT_SHIFT) | 7,
AnnaBridge 156:ff21514d8981 89
AnnaBridge 156:ff21514d8981 90 P4_0 = (4 << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 91 P4_1 = (4 << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 92 P4_2 = (4 << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 93 P4_3 = (4 << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 94 P4_4 = (4 << PORT_SHIFT) | 4,
AnnaBridge 156:ff21514d8981 95 P4_5 = (4 << PORT_SHIFT) | 5,
AnnaBridge 156:ff21514d8981 96 P4_6 = (4 << PORT_SHIFT) | 6,
AnnaBridge 156:ff21514d8981 97 P4_7 = (4 << PORT_SHIFT) | 7,
AnnaBridge 156:ff21514d8981 98
AnnaBridge 156:ff21514d8981 99 P5_0 = (5 << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 100 P5_1 = (5 << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 101 P5_2 = (5 << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 102 P5_3 = (5 << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 103 P5_4 = (5 << PORT_SHIFT) | 4,
AnnaBridge 156:ff21514d8981 104 P5_5 = (5 << PORT_SHIFT) | 5,
AnnaBridge 156:ff21514d8981 105 P5_6 = (5 << PORT_SHIFT) | 6,
AnnaBridge 156:ff21514d8981 106 P5_7 = (5 << PORT_SHIFT) | 7,
AnnaBridge 156:ff21514d8981 107
AnnaBridge 156:ff21514d8981 108 P6_0 = (6 << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 109 P6_1 = (6 << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 110 P6_2 = (6 << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 111 P6_3 = (6 << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 112 P6_4 = (6 << PORT_SHIFT) | 4,
AnnaBridge 156:ff21514d8981 113 P6_5 = (6 << PORT_SHIFT) | 5,
AnnaBridge 156:ff21514d8981 114 P6_6 = (6 << PORT_SHIFT) | 6,
AnnaBridge 156:ff21514d8981 115 P6_7 = (6 << PORT_SHIFT) | 7,
AnnaBridge 156:ff21514d8981 116
AnnaBridge 156:ff21514d8981 117 P7_0 = (7 << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 118 P7_1 = (7 << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 119 P7_2 = (7 << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 120 P7_3 = (7 << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 121 P7_4 = (7 << PORT_SHIFT) | 4,
AnnaBridge 156:ff21514d8981 122 P7_5 = (7 << PORT_SHIFT) | 5,
AnnaBridge 156:ff21514d8981 123 P7_6 = (7 << PORT_SHIFT) | 6,
AnnaBridge 156:ff21514d8981 124 P7_7 = (7 << PORT_SHIFT) | 7,
AnnaBridge 156:ff21514d8981 125
AnnaBridge 156:ff21514d8981 126 // Analog ADC pins
AnnaBridge 156:ff21514d8981 127 AIN_0P = (0xA << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 128 AIN_1P = (0xA << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 129 AIN_2P = (0xA << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 130 AIN_3P = (0xA << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 131 AIN_4P = (0xA << PORT_SHIFT) | 4,
AnnaBridge 156:ff21514d8981 132 AIN_5P = (0xA << PORT_SHIFT) | 5,
AnnaBridge 156:ff21514d8981 133 AIN_6P = (0xA << PORT_SHIFT) | 6,
AnnaBridge 156:ff21514d8981 134 AIN_7P = (0xA << PORT_SHIFT) | 7,
AnnaBridge 156:ff21514d8981 135
AnnaBridge 156:ff21514d8981 136 AIN_0N = (0xB << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 137 AIN_1N = (0xB << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 138 AIN_2N = (0xB << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 139 AIN_3N = (0xB << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 140 AIN_4N = (0xB << PORT_SHIFT) | 4,
AnnaBridge 156:ff21514d8981 141 AIN_5N = (0xB << PORT_SHIFT) | 5,
AnnaBridge 156:ff21514d8981 142 AIN_6N = (0xB << PORT_SHIFT) | 6,
AnnaBridge 156:ff21514d8981 143 AIN_7N = (0xB << PORT_SHIFT) | 7,
AnnaBridge 156:ff21514d8981 144
AnnaBridge 156:ff21514d8981 145 // Analog differential ADC
AnnaBridge 156:ff21514d8981 146 AIN_0D = (0xC << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 147 AIN_1D = (0xC << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 148 AIN_2D = (0xC << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 149 AIN_3D = (0xC << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 150 AIN_4D = (0xC << PORT_SHIFT) | 4,
AnnaBridge 156:ff21514d8981 151 AIN_5D = (0xC << PORT_SHIFT) | 5,
AnnaBridge 156:ff21514d8981 152 AIN_6D = (0xC << PORT_SHIFT) | 6,
AnnaBridge 156:ff21514d8981 153 AIN_7D = (0xC << PORT_SHIFT) | 7,
AnnaBridge 156:ff21514d8981 154
AnnaBridge 156:ff21514d8981 155 // OPAMP Positive supply pins
AnnaBridge 156:ff21514d8981 156 AOUT_AP = (0xD << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 157 AOUT_BP = (0xD << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 158 AOUT_CP = (0xD << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 159 AOUT_DP = (0xD << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 160
AnnaBridge 156:ff21514d8981 161 // OPAMP Negative supply pins
AnnaBridge 156:ff21514d8981 162 AOUT_AN = (0xE << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 163 AOUT_BN = (0xE << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 164 AOUT_CN = (0xE << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 165 AOUT_DN = (0xE << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 166
AnnaBridge 156:ff21514d8981 167 // DAC Output pins
AnnaBridge 156:ff21514d8981 168 AOUT_AO = (0xF << PORT_SHIFT) | 0,
AnnaBridge 156:ff21514d8981 169 AOUT_BO = (0xF << PORT_SHIFT) | 1,
AnnaBridge 156:ff21514d8981 170 AOUT_CO = (0xF << PORT_SHIFT) | 2,
AnnaBridge 156:ff21514d8981 171 AOUT_DO = (0xF << PORT_SHIFT) | 3,
AnnaBridge 156:ff21514d8981 172
AnnaBridge 156:ff21514d8981 173 LED_GREEN = P6_6,
AnnaBridge 156:ff21514d8981 174 LED_RED = P7_1,
AnnaBridge 156:ff21514d8981 175 LED_YELLOW = P7_0,
AnnaBridge 156:ff21514d8981 176 LED_BLUE = P6_7,
AnnaBridge 156:ff21514d8981 177
AnnaBridge 156:ff21514d8981 178 // mbed original LED naming
AnnaBridge 156:ff21514d8981 179 LED1 = LED_RED,
AnnaBridge 156:ff21514d8981 180 LED2 = LED_GREEN,
AnnaBridge 156:ff21514d8981 181 LED3 = LED_BLUE,
AnnaBridge 156:ff21514d8981 182 LED4 = LED_YELLOW,
AnnaBridge 156:ff21514d8981 183
AnnaBridge 156:ff21514d8981 184 // Push button
AnnaBridge 156:ff21514d8981 185 SW2 = P6_4,
AnnaBridge 156:ff21514d8981 186 SW3 = P6_5,
AnnaBridge 156:ff21514d8981 187 // Standardized button names
AnnaBridge 156:ff21514d8981 188 BUTTON1 = SW2,
AnnaBridge 156:ff21514d8981 189 BUTTON2 = SW3,
AnnaBridge 156:ff21514d8981 190
AnnaBridge 156:ff21514d8981 191 // UART pins
AnnaBridge 156:ff21514d8981 192 USBTX = P7_3,
AnnaBridge 156:ff21514d8981 193 USBRX = P7_2,
AnnaBridge 156:ff21514d8981 194 STDIO_UART_TX = USBTX,
AnnaBridge 156:ff21514d8981 195 STDIO_UART_RX = USBRX,
AnnaBridge 156:ff21514d8981 196
AnnaBridge 156:ff21514d8981 197 // I2C pins
AnnaBridge 156:ff21514d8981 198 I2C0_SCL = P2_5,
AnnaBridge 156:ff21514d8981 199 I2C0_SDA = P2_4,
AnnaBridge 156:ff21514d8981 200
AnnaBridge 156:ff21514d8981 201 I2C1_SCL = P2_7,
AnnaBridge 156:ff21514d8981 202 I2C1_SDA = P2_6,
AnnaBridge 156:ff21514d8981 203
AnnaBridge 156:ff21514d8981 204 // UART pins
AnnaBridge 156:ff21514d8981 205 UART0_RX = P1_0,
AnnaBridge 156:ff21514d8981 206 UART0_TX = P1_1,
AnnaBridge 156:ff21514d8981 207 UART0_CTS = P1_2,
AnnaBridge 156:ff21514d8981 208 UART0_RTS = P1_3,
AnnaBridge 156:ff21514d8981 209
AnnaBridge 156:ff21514d8981 210 UART1_RX = P1_2,
AnnaBridge 156:ff21514d8981 211 UART1_TX = P1_3,
AnnaBridge 156:ff21514d8981 212 UART1_CTS = P2_6,
AnnaBridge 156:ff21514d8981 213 UART1_RTS = P2_7,
AnnaBridge 156:ff21514d8981 214
AnnaBridge 156:ff21514d8981 215 // SPI pins
AnnaBridge 156:ff21514d8981 216 SPI0_SCK = P6_0,
AnnaBridge 156:ff21514d8981 217 SPI0_MOSI = P6_1,
AnnaBridge 156:ff21514d8981 218 SPI0_MISO = P6_2,
AnnaBridge 156:ff21514d8981 219 SPI0_SS = P6_3,
AnnaBridge 156:ff21514d8981 220
AnnaBridge 156:ff21514d8981 221 SPI2_SCK = P2_0,
AnnaBridge 156:ff21514d8981 222 SPI2_MOSI = P2_1,
AnnaBridge 156:ff21514d8981 223 SPI2_MISO = P2_2,
AnnaBridge 156:ff21514d8981 224 SPI2_SS = P2_3,
AnnaBridge 156:ff21514d8981 225
AnnaBridge 156:ff21514d8981 226 // Arduino Headers
AnnaBridge 156:ff21514d8981 227 D0 = P1_0,
AnnaBridge 156:ff21514d8981 228 D1 = P1_1,
AnnaBridge 156:ff21514d8981 229 D2 = P1_2,
AnnaBridge 156:ff21514d8981 230 D3 = P1_3,
AnnaBridge 156:ff21514d8981 231 D4 = P1_4,
AnnaBridge 156:ff21514d8981 232 D5 = P1_5,
AnnaBridge 156:ff21514d8981 233 D6 = P1_6,
AnnaBridge 156:ff21514d8981 234 D7 = P1_7,
AnnaBridge 156:ff21514d8981 235 D8 = P2_5,
AnnaBridge 156:ff21514d8981 236 D9 = P2_4,
AnnaBridge 156:ff21514d8981 237 D10 = P2_3,
AnnaBridge 156:ff21514d8981 238 D11 = P2_1,
AnnaBridge 156:ff21514d8981 239 D12 = P2_2,
AnnaBridge 156:ff21514d8981 240 D13 = P2_0,
AnnaBridge 156:ff21514d8981 241 D14 = P2_6,
AnnaBridge 156:ff21514d8981 242 D15 = P2_7,
AnnaBridge 156:ff21514d8981 243 A0 = AIN_0P,
AnnaBridge 156:ff21514d8981 244 A1 = AIN_1P,
AnnaBridge 156:ff21514d8981 245 A2 = AIN_2P,
AnnaBridge 156:ff21514d8981 246 A3 = AIN_3P,
AnnaBridge 156:ff21514d8981 247 A4 = AIN_4P,
AnnaBridge 156:ff21514d8981 248 A5 = AIN_5P,
AnnaBridge 156:ff21514d8981 249
AnnaBridge 156:ff21514d8981 250 // Not connected
AnnaBridge 156:ff21514d8981 251 NC = (int)0xFFFFFFFF
AnnaBridge 156:ff21514d8981 252 } PinName;
AnnaBridge 156:ff21514d8981 253
AnnaBridge 156:ff21514d8981 254 typedef enum {
AnnaBridge 156:ff21514d8981 255 PullUp,
AnnaBridge 156:ff21514d8981 256 OpenDrain,
AnnaBridge 156:ff21514d8981 257 PullNone,
AnnaBridge 156:ff21514d8981 258 PullDefault = PullUp
AnnaBridge 156:ff21514d8981 259 } PinMode;
AnnaBridge 156:ff21514d8981 260
AnnaBridge 156:ff21514d8981 261 typedef enum {
AnnaBridge 156:ff21514d8981 262 LED_ON = 0,
AnnaBridge 156:ff21514d8981 263 LED_OFF = 1
AnnaBridge 156:ff21514d8981 264 } LedStates;
AnnaBridge 156:ff21514d8981 265
AnnaBridge 156:ff21514d8981 266 #ifdef __cplusplus
AnnaBridge 156:ff21514d8981 267 }
AnnaBridge 156:ff21514d8981 268 #endif
AnnaBridge 156:ff21514d8981 269
AnnaBridge 156:ff21514d8981 270 #endif