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 171:3a7713b1edbc 1 /*******************************************************************************
AnnaBridge 171:3a7713b1edbc 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
AnnaBridge 171:3a7713b1edbc 3 *
AnnaBridge 171:3a7713b1edbc 4 * Permission is hereby granted, free of charge, to any person obtaining a
AnnaBridge 171:3a7713b1edbc 5 * copy of this software and associated documentation files (the "Software"),
AnnaBridge 171:3a7713b1edbc 6 * to deal in the Software without restriction, including without limitation
AnnaBridge 171:3a7713b1edbc 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
AnnaBridge 171:3a7713b1edbc 8 * and/or sell copies of the Software, and to permit persons to whom the
AnnaBridge 171:3a7713b1edbc 9 * Software is furnished to do so, subject to the following conditions:
AnnaBridge 171:3a7713b1edbc 10 *
AnnaBridge 171:3a7713b1edbc 11 * The above copyright notice and this permission notice shall be included
AnnaBridge 171:3a7713b1edbc 12 * in all copies or substantial portions of the Software.
AnnaBridge 171:3a7713b1edbc 13 *
AnnaBridge 171:3a7713b1edbc 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
AnnaBridge 171:3a7713b1edbc 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
AnnaBridge 171:3a7713b1edbc 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
AnnaBridge 171:3a7713b1edbc 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
AnnaBridge 171:3a7713b1edbc 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
AnnaBridge 171:3a7713b1edbc 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
AnnaBridge 171:3a7713b1edbc 20 * OTHER DEALINGS IN THE SOFTWARE.
AnnaBridge 171:3a7713b1edbc 21 *
AnnaBridge 171:3a7713b1edbc 22 * Except as contained in this notice, the name of Maxim Integrated
AnnaBridge 171:3a7713b1edbc 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
AnnaBridge 171:3a7713b1edbc 24 * Products, Inc. Branding Policy.
AnnaBridge 171:3a7713b1edbc 25 *
AnnaBridge 171:3a7713b1edbc 26 * The mere transfer of this software does not imply any licenses
AnnaBridge 171:3a7713b1edbc 27 * of trade secrets, proprietary technology, copyrights, patents,
AnnaBridge 171:3a7713b1edbc 28 * trademarks, maskwork rights, or any other form of intellectual
AnnaBridge 171:3a7713b1edbc 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
AnnaBridge 171:3a7713b1edbc 30 * ownership rights.
AnnaBridge 171:3a7713b1edbc 31 *******************************************************************************
AnnaBridge 171:3a7713b1edbc 32 */
AnnaBridge 171:3a7713b1edbc 33
AnnaBridge 171:3a7713b1edbc 34 #ifndef MBED_PINNAMES_H
AnnaBridge 171:3a7713b1edbc 35 #define MBED_PINNAMES_H
AnnaBridge 171:3a7713b1edbc 36
AnnaBridge 171:3a7713b1edbc 37 #include "cmsis.h"
AnnaBridge 171:3a7713b1edbc 38 #include "gpio_regs.h"
AnnaBridge 171:3a7713b1edbc 39
AnnaBridge 171:3a7713b1edbc 40 #ifdef __cplusplus
AnnaBridge 171:3a7713b1edbc 41 extern "C" {
AnnaBridge 171:3a7713b1edbc 42 #endif
AnnaBridge 171:3a7713b1edbc 43
AnnaBridge 171:3a7713b1edbc 44 typedef enum {
AnnaBridge 171:3a7713b1edbc 45 PIN_INPUT = 0, /* MXC_V_GPIO_OUT_MODE_HIGH_Z,*/
AnnaBridge 171:3a7713b1edbc 46 PIN_OUTPUT = 1 /* MXC_V_GPIO_OUT_MODE_NORMAL_DRIVE */
AnnaBridge 171:3a7713b1edbc 47 } PinDirection;
AnnaBridge 171:3a7713b1edbc 48
AnnaBridge 171:3a7713b1edbc 49 #define PORT_SHIFT 12
AnnaBridge 171:3a7713b1edbc 50 #define PINNAME_TO_PORT(name) ((unsigned int)(name) >> PORT_SHIFT)
AnnaBridge 171:3a7713b1edbc 51 #define PINNAME_TO_PIN(name) ((unsigned int)(name) & ~(0xFFFFFFFF << PORT_SHIFT))
AnnaBridge 171:3a7713b1edbc 52
AnnaBridge 171:3a7713b1edbc 53 #define NOT_CONNECTED (int)0xFFFFFFFF
AnnaBridge 171:3a7713b1edbc 54
AnnaBridge 171:3a7713b1edbc 55 typedef enum {
AnnaBridge 171:3a7713b1edbc 56 P0_0 = (0 << PORT_SHIFT), P0_1, P0_2, P0_3, P0_4, P0_5, P0_6, P0_7,
AnnaBridge 171:3a7713b1edbc 57 P1_0 = (1 << PORT_SHIFT), P1_1, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7,
AnnaBridge 171:3a7713b1edbc 58 P2_0 = (2 << PORT_SHIFT), P2_1, P2_2, P2_3, P2_4, P2_5, P2_6, P2_7,
AnnaBridge 171:3a7713b1edbc 59 P3_0 = (3 << PORT_SHIFT), P3_1, P3_2, P3_3, P3_4, P3_5, P3_6, P3_7,
AnnaBridge 171:3a7713b1edbc 60 P4_0 = (4 << PORT_SHIFT), P4_1, P4_2, P4_3, P4_4, P4_5, P4_6, P4_7,
AnnaBridge 171:3a7713b1edbc 61
AnnaBridge 171:3a7713b1edbc 62 // Analog input pins
AnnaBridge 171:3a7713b1edbc 63 AIN_0 = (0xA << PORT_SHIFT), AIN_1, AIN_2, AIN_3, AIN_4, AIN_5, AIN_6, AIN_7, AIN_8, AIN_9,
AnnaBridge 171:3a7713b1edbc 64
AnnaBridge 171:3a7713b1edbc 65 // Analog
AnnaBridge 171:3a7713b1edbc 66 A0 = AIN_0,
AnnaBridge 171:3a7713b1edbc 67 A1 = AIN_1,
AnnaBridge 171:3a7713b1edbc 68 A2 = AIN_2,
AnnaBridge 171:3a7713b1edbc 69 A3 = AIN_3,
AnnaBridge 171:3a7713b1edbc 70
AnnaBridge 171:3a7713b1edbc 71 // General Pin Input Output (GPIO)
AnnaBridge 171:3a7713b1edbc 72 GPIO0 = P1_4,
AnnaBridge 171:3a7713b1edbc 73 GPIO1 = P1_5,
AnnaBridge 171:3a7713b1edbc 74 GPIO2 = P4_0,
AnnaBridge 171:3a7713b1edbc 75 GPIO3 = P4_1,
AnnaBridge 171:3a7713b1edbc 76 GPIO4 = P4_2,
AnnaBridge 171:3a7713b1edbc 77 GPIO5 = P4_3,
AnnaBridge 171:3a7713b1edbc 78 GPIO6 = NOT_CONNECTED,
AnnaBridge 171:3a7713b1edbc 79
AnnaBridge 171:3a7713b1edbc 80 //Purse Width Modulation (PWM)
AnnaBridge 171:3a7713b1edbc 81 PWM0 = GPIO2,
AnnaBridge 171:3a7713b1edbc 82 PWM1 = GPIO3,
AnnaBridge 171:3a7713b1edbc 83 PWM2 = GPIO0,
AnnaBridge 171:3a7713b1edbc 84 PWM3 = GPIO1,
AnnaBridge 171:3a7713b1edbc 85
AnnaBridge 171:3a7713b1edbc 86 // LEDs
AnnaBridge 171:3a7713b1edbc 87 LED0 = GPIO0,
AnnaBridge 171:3a7713b1edbc 88 LED1 = GPIO1,
AnnaBridge 171:3a7713b1edbc 89 LED2 = GPIO2,
AnnaBridge 171:3a7713b1edbc 90 LED3 = NOT_CONNECTED,
AnnaBridge 171:3a7713b1edbc 91 LED4 = NOT_CONNECTED,
AnnaBridge 171:3a7713b1edbc 92
AnnaBridge 171:3a7713b1edbc 93 LED_RED = LED0,
AnnaBridge 171:3a7713b1edbc 94 LED_GREEN = LED1,
AnnaBridge 171:3a7713b1edbc 95 LED_BLUE = LED2,
AnnaBridge 171:3a7713b1edbc 96
AnnaBridge 171:3a7713b1edbc 97 // USB bridge and SWD UART connected UART pins
AnnaBridge 171:3a7713b1edbc 98 USBTX = P2_1,
AnnaBridge 171:3a7713b1edbc 99 USBRX = P2_0,
AnnaBridge 171:3a7713b1edbc 100 STDIO_UART_TX = USBTX,
AnnaBridge 171:3a7713b1edbc 101 STDIO_UART_RX = USBRX,
AnnaBridge 171:3a7713b1edbc 102
AnnaBridge 171:3a7713b1edbc 103 // UART pins
AnnaBridge 171:3a7713b1edbc 104 UART0_RX = P0_0,
AnnaBridge 171:3a7713b1edbc 105 UART0_TX = P0_1,
AnnaBridge 171:3a7713b1edbc 106 UART0_CTS = P0_2,
AnnaBridge 171:3a7713b1edbc 107 UART0_RTS = P0_3,
AnnaBridge 171:3a7713b1edbc 108
AnnaBridge 171:3a7713b1edbc 109 UART1_RX = P2_0,
AnnaBridge 171:3a7713b1edbc 110 UART1_TX = P2_1,
AnnaBridge 171:3a7713b1edbc 111 UART1_CTS = P2_2,
AnnaBridge 171:3a7713b1edbc 112 UART1_RTS = P2_3,
AnnaBridge 171:3a7713b1edbc 113
AnnaBridge 171:3a7713b1edbc 114 UART2_RX = P3_0,
AnnaBridge 171:3a7713b1edbc 115 UART2_TX = P3_1,
AnnaBridge 171:3a7713b1edbc 116 UART2_CTS = P3_2,
AnnaBridge 171:3a7713b1edbc 117 UART2_RTS = P3_3,
AnnaBridge 171:3a7713b1edbc 118
AnnaBridge 171:3a7713b1edbc 119 // I2C pins
AnnaBridge 171:3a7713b1edbc 120 I2C0_SCL = P1_7,
AnnaBridge 171:3a7713b1edbc 121 I2C0_SDA = P1_6,
AnnaBridge 171:3a7713b1edbc 122
AnnaBridge 171:3a7713b1edbc 123 I2C1_SCL = P3_5,
AnnaBridge 171:3a7713b1edbc 124 I2C1_SDA = P3_4,
AnnaBridge 171:3a7713b1edbc 125
AnnaBridge 171:3a7713b1edbc 126 I2C2_SCL = NOT_CONNECTED,
AnnaBridge 171:3a7713b1edbc 127 I2C2_SDA = NOT_CONNECTED,
AnnaBridge 171:3a7713b1edbc 128
AnnaBridge 171:3a7713b1edbc 129 // SPI pins
AnnaBridge 171:3a7713b1edbc 130 SPI0_SCK = P0_4,
AnnaBridge 171:3a7713b1edbc 131 SPI0_MOSI = P0_5,
AnnaBridge 171:3a7713b1edbc 132 SPI0_MISO = P0_6,
AnnaBridge 171:3a7713b1edbc 133 SPI0_SS0 = P0_7,
AnnaBridge 171:3a7713b1edbc 134 SPI0_SS1 = P4_4,
AnnaBridge 171:3a7713b1edbc 135 SPI0_SS2 = P4_5,
AnnaBridge 171:3a7713b1edbc 136
AnnaBridge 171:3a7713b1edbc 137 SPI1_SCK = P1_0,
AnnaBridge 171:3a7713b1edbc 138 SPI1_MOSI = P1_1,
AnnaBridge 171:3a7713b1edbc 139 SPI1_MISO = P1_2,
AnnaBridge 171:3a7713b1edbc 140 SPI1_SS0 = P1_3,
AnnaBridge 171:3a7713b1edbc 141 SPI1_SS1 = P3_6,
AnnaBridge 171:3a7713b1edbc 142 SPI1_SS2 = P3_7,
AnnaBridge 171:3a7713b1edbc 143
AnnaBridge 171:3a7713b1edbc 144 SPI2_SCK = P2_4,
AnnaBridge 171:3a7713b1edbc 145 SPI2_MOSI = P2_5,
AnnaBridge 171:3a7713b1edbc 146 SPI2_MISO = P2_6,
AnnaBridge 171:3a7713b1edbc 147 SPI2_SS0 = P2_7,
AnnaBridge 171:3a7713b1edbc 148 SPI2_SS1 = P4_6,
AnnaBridge 171:3a7713b1edbc 149 SPI2_SS2 = P4_7,
AnnaBridge 171:3a7713b1edbc 150
AnnaBridge 171:3a7713b1edbc 151 SPI3_SCK = NOT_CONNECTED,
AnnaBridge 171:3a7713b1edbc 152 SPI3_MOSI = NOT_CONNECTED,
AnnaBridge 171:3a7713b1edbc 153 SPI3_MISO = NOT_CONNECTED,
AnnaBridge 171:3a7713b1edbc 154 SPI3_SS0 = NOT_CONNECTED,
AnnaBridge 171:3a7713b1edbc 155 SPI3_SS1 = NOT_CONNECTED,
AnnaBridge 171:3a7713b1edbc 156 SPI3_SS2 = NOT_CONNECTED,
AnnaBridge 171:3a7713b1edbc 157
AnnaBridge 171:3a7713b1edbc 158 // SWD UART
AnnaBridge 171:3a7713b1edbc 159 SWD_TGT_TX = UART1_TX,
AnnaBridge 171:3a7713b1edbc 160 SWD_TGT_RX = UART1_RX,
AnnaBridge 171:3a7713b1edbc 161 SWD_TGT_CTS = UART1_CTS,
AnnaBridge 171:3a7713b1edbc 162 SWD_TGT_RTS = UART1_RTS,
AnnaBridge 171:3a7713b1edbc 163
AnnaBridge 171:3a7713b1edbc 164 // Generics
AnnaBridge 171:3a7713b1edbc 165 SERIAL_TX = UART0_TX,
AnnaBridge 171:3a7713b1edbc 166 SERIAL_RX = UART0_RX,
AnnaBridge 171:3a7713b1edbc 167 I2C_SCL = I2C0_SCL,
AnnaBridge 171:3a7713b1edbc 168 I2C_SDA = I2C0_SDA,
AnnaBridge 171:3a7713b1edbc 169 SPI_MOSI = SPI0_MOSI,
AnnaBridge 171:3a7713b1edbc 170 SPI_MISO = SPI0_MISO,
AnnaBridge 171:3a7713b1edbc 171 SPI_SCK = SPI0_SCK,
AnnaBridge 171:3a7713b1edbc 172 SPI_CS = SPI0_SS0,
AnnaBridge 171:3a7713b1edbc 173 PWM_OUT = PWM0,
AnnaBridge 171:3a7713b1edbc 174
AnnaBridge 171:3a7713b1edbc 175 // Not connected
AnnaBridge 171:3a7713b1edbc 176 NC = NOT_CONNECTED
AnnaBridge 171:3a7713b1edbc 177 } PinName;
AnnaBridge 171:3a7713b1edbc 178
AnnaBridge 171:3a7713b1edbc 179 typedef enum {
AnnaBridge 171:3a7713b1edbc 180 PullUp,
AnnaBridge 171:3a7713b1edbc 181 PullDown,
AnnaBridge 171:3a7713b1edbc 182 OpenDrain,
AnnaBridge 171:3a7713b1edbc 183 PullNone,
AnnaBridge 171:3a7713b1edbc 184 PullDefault = PullUp
AnnaBridge 171:3a7713b1edbc 185 } PinMode;
AnnaBridge 171:3a7713b1edbc 186
AnnaBridge 171:3a7713b1edbc 187 typedef enum {
AnnaBridge 171:3a7713b1edbc 188 LED_ON = 0,
AnnaBridge 171:3a7713b1edbc 189 LED_OFF = 1
AnnaBridge 171:3a7713b1edbc 190 } LedStates;
AnnaBridge 171:3a7713b1edbc 191
AnnaBridge 171:3a7713b1edbc 192 #ifdef __cplusplus
AnnaBridge 171:3a7713b1edbc 193 }
AnnaBridge 171:3a7713b1edbc 194 #endif
AnnaBridge 171:3a7713b1edbc 195
AnnaBridge 171:3a7713b1edbc 196 #endif