|
| 1 | +/* mbed Microcontroller Library |
| 2 | + * Copyright (c) 2006-2013 ARM Limited |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +#ifndef _PINNAMES_H_ |
| 17 | +#define _PINNAMES_H_ |
| 18 | + |
| 19 | +#include "cmsis.h" |
| 20 | + |
| 21 | +#ifdef __cplusplus |
| 22 | +extern "C" { |
| 23 | +#endif |
| 24 | + |
| 25 | +typedef enum { |
| 26 | + PORT_A = 0, |
| 27 | + PORT_B = 1, |
| 28 | + PORT_C = 2, |
| 29 | + PORT_D = 3, |
| 30 | + PORT_E = 4, |
| 31 | + PORT_F = 5, |
| 32 | + PORT_G = 6, |
| 33 | + PORT_H = 7, |
| 34 | + PORT_I = 8, |
| 35 | + PORT_J = 9, |
| 36 | + PORT_K = 10, |
| 37 | + |
| 38 | + PORT_V = 11, |
| 39 | + PORT_U = 12, |
| 40 | + PORT_MAX |
| 41 | +} GPIO_PORT; |
| 42 | + |
| 43 | +#define RTL_PIN_PERI(FUN, IDX, SEL) ((int)(((FUN) << 8) | ((IDX)<<4) | (SEL))) |
| 44 | +#define RTL_PIN_FUNC(FUN, SEL) ((int)(((FUN) << 7) | (SEL))) |
| 45 | +#define RTL_GET_PERI_SEL(peri) ((int)((peri)&0x0F)) |
| 46 | +#define RTL_GET_PERI_IDX(peri) ((int)(((peri) >> 4)&0x0F)) |
| 47 | +#define NOT_CONNECTED (int)0xFFFFFFFF |
| 48 | + |
| 49 | +typedef enum { |
| 50 | + PIN_INPUT=0, |
| 51 | + PIN_OUTPUT |
| 52 | +} PinDirection; |
| 53 | + |
| 54 | + |
| 55 | +typedef enum { |
| 56 | + PA_0 = (PORT_A<<4|0), |
| 57 | + PA_1 = (PORT_A<<4|1), |
| 58 | + PA_2 = (PORT_A<<4|2), |
| 59 | + PA_3 = (PORT_A<<4|3), |
| 60 | + PA_4 = (PORT_A<<4|4), |
| 61 | + PA_5 = (PORT_A<<4|5), |
| 62 | + PA_6 = (PORT_A<<4|6), |
| 63 | + PA_7 = (PORT_A<<4|7), |
| 64 | + |
| 65 | + PB_0 = (PORT_B<<4|0), |
| 66 | + PB_1 = (PORT_B<<4|1), |
| 67 | + PB_2 = (PORT_B<<4|2), |
| 68 | + PB_3 = (PORT_B<<4|3), |
| 69 | + PB_4 = (PORT_B<<4|4), |
| 70 | + PB_5 = (PORT_B<<4|5), |
| 71 | + PB_6 = (PORT_B<<4|6), |
| 72 | + PB_7 = (PORT_B<<4|7), |
| 73 | + |
| 74 | + PC_0 = (PORT_C<<4|0), |
| 75 | + PC_1 = (PORT_C<<4|1), |
| 76 | + PC_2 = (PORT_C<<4|2), |
| 77 | + PC_3 = (PORT_C<<4|3), |
| 78 | + PC_4 = (PORT_C<<4|4), |
| 79 | + PC_5 = (PORT_C<<4|5), |
| 80 | + PC_6 = (PORT_C<<4|6), |
| 81 | + PC_7 = (PORT_C<<4|7), |
| 82 | + PC_8 = (PORT_C<<4|8), |
| 83 | + PC_9 = (PORT_C<<4|9), |
| 84 | + |
| 85 | + PD_0 = (PORT_D<<4|0), |
| 86 | + PD_1 = (PORT_D<<4|1), |
| 87 | + PD_2 = (PORT_D<<4|2), |
| 88 | + PD_3 = (PORT_D<<4|3), |
| 89 | + PD_4 = (PORT_D<<4|4), |
| 90 | + PD_5 = (PORT_D<<4|5), |
| 91 | + PD_6 = (PORT_D<<4|6), |
| 92 | + PD_7 = (PORT_D<<4|7), |
| 93 | + PD_8 = (PORT_D<<4|8), |
| 94 | + PD_9 = (PORT_D<<4|9), |
| 95 | + |
| 96 | + PE_0 = (PORT_E<<4|0), |
| 97 | + PE_1 = (PORT_E<<4|1), |
| 98 | + PE_2 = (PORT_E<<4|2), |
| 99 | + PE_3 = (PORT_E<<4|3), |
| 100 | + PE_4 = (PORT_E<<4|4), |
| 101 | + PE_5 = (PORT_E<<4|5), |
| 102 | + PE_6 = (PORT_E<<4|6), |
| 103 | + PE_7 = (PORT_E<<4|7), |
| 104 | + PE_8 = (PORT_E<<4|8), |
| 105 | + PE_9 = (PORT_E<<4|9), |
| 106 | + PE_A = (PORT_E<<4|10), |
| 107 | + |
| 108 | + PF_0 = (PORT_F<<4|0), |
| 109 | + PF_1 = (PORT_F<<4|1), |
| 110 | + PF_2 = (PORT_F<<4|2), |
| 111 | + PF_3 = (PORT_F<<4|3), |
| 112 | + PF_4 = (PORT_F<<4|4), |
| 113 | + PF_5 = (PORT_F<<4|5), |
| 114 | + /* unavailable pins */ |
| 115 | +// PF_6 = (PORT_F<<4|6), |
| 116 | +// PF_7 = (PORT_F<<4|7), |
| 117 | + |
| 118 | + PG_0 = (PORT_G<<4|0), |
| 119 | + PG_1 = (PORT_G<<4|1), |
| 120 | + PG_2 = (PORT_G<<4|2), |
| 121 | + PG_3 = (PORT_G<<4|3), |
| 122 | + PG_4 = (PORT_G<<4|4), |
| 123 | + PG_5 = (PORT_G<<4|5), |
| 124 | + PG_6 = (PORT_G<<4|6), |
| 125 | + PG_7 = (PORT_G<<4|7), |
| 126 | + |
| 127 | + PH_0 = (PORT_H<<4|0), |
| 128 | + PH_1 = (PORT_H<<4|1), |
| 129 | + PH_2 = (PORT_H<<4|2), |
| 130 | + PH_3 = (PORT_H<<4|3), |
| 131 | + PH_4 = (PORT_H<<4|4), |
| 132 | + PH_5 = (PORT_H<<4|5), |
| 133 | + PH_6 = (PORT_H<<4|6), |
| 134 | + PH_7 = (PORT_H<<4|7), |
| 135 | + |
| 136 | + PI_0 = (PORT_I<<4|0), |
| 137 | + PI_1 = (PORT_I<<4|1), |
| 138 | + PI_2 = (PORT_I<<4|2), |
| 139 | + PI_3 = (PORT_I<<4|3), |
| 140 | + PI_4 = (PORT_I<<4|4), |
| 141 | + PI_5 = (PORT_I<<4|5), |
| 142 | + PI_6 = (PORT_I<<4|6), |
| 143 | + PI_7 = (PORT_I<<4|7), |
| 144 | + |
| 145 | + PJ_0 = (PORT_J<<4|0), |
| 146 | + PJ_1 = (PORT_J<<4|1), |
| 147 | + PJ_2 = (PORT_J<<4|2), |
| 148 | + PJ_3 = (PORT_J<<4|3), |
| 149 | + PJ_4 = (PORT_J<<4|4), |
| 150 | + PJ_5 = (PORT_J<<4|5), |
| 151 | + PJ_6 = (PORT_J<<4|6), |
| 152 | + /* unavailable pins */ |
| 153 | +// PJ_7 = (PORT_J<<4|7), |
| 154 | + |
| 155 | + PK_0 = (PORT_K<<4|0), |
| 156 | + PK_1 = (PORT_K<<4|1), |
| 157 | + PK_2 = (PORT_K<<4|2), |
| 158 | + PK_3 = (PORT_K<<4|3), |
| 159 | + PK_4 = (PORT_K<<4|4), |
| 160 | + PK_5 = (PORT_K<<4|5), |
| 161 | + PK_6 = (PORT_K<<4|6), |
| 162 | + /* unavailable pins */ |
| 163 | + // PK_7 = (PORT_K<<4|7), |
| 164 | + |
| 165 | + AD_1 = (PORT_V<<4|1), |
| 166 | + AD_2 = (PORT_V<<4|2), |
| 167 | + AD_3 = (PORT_V<<4|3), |
| 168 | + |
| 169 | + DA_0 = (PORT_U<<4|0), |
| 170 | + DA_1 = (PORT_U<<4|1), |
| 171 | + |
| 172 | + // Analog |
| 173 | + A0 = AD_1, |
| 174 | + A1 = AD_2, |
| 175 | + A2 = DA_0, |
| 176 | + A3 = NOT_CONNECTED, |
| 177 | + |
| 178 | + // General Pin Input Output (GPIO) |
| 179 | + GPIO0 = PD_6, |
| 180 | + GPIO1 = PD_7, |
| 181 | + GPIO2 = PB_4, |
| 182 | + GPIO3 = PB_5, |
| 183 | + GPIO4 = PE_5, |
| 184 | + //GPIO5 = NFC_IP, |
| 185 | + //GPIO6 = NFC_IN, |
| 186 | + |
| 187 | + // LEDs |
| 188 | + LED0 = GPIO0, |
| 189 | + LED1 = GPIO1, |
| 190 | + LED2 = GPIO2, |
| 191 | + |
| 192 | + LED_RED = LED0, |
| 193 | + LED_GREEN = LED1, |
| 194 | + LED_BLUE = LED2, |
| 195 | + |
| 196 | + // USB bridge and SWD UART connected UART pins |
| 197 | + USBTX = PB_0, |
| 198 | + USBRX = PB_1, |
| 199 | + |
| 200 | + // UART pins |
| 201 | + UART0_RX = PA_0, |
| 202 | + UART0_TX = PA_4, |
| 203 | + UART0_CTS = PA_1, |
| 204 | + UART0_RTS = PA_2, |
| 205 | + |
| 206 | + UART1_RX = USBRX, |
| 207 | + UART1_TX = USBTX, |
| 208 | + UART1_CTS = NOT_CONNECTED, |
| 209 | + UART1_RTS = NOT_CONNECTED, |
| 210 | + |
| 211 | + UART2_RX = PA_6, |
| 212 | + UART2_TX = PA_7, |
| 213 | + UART2_CTS = PA_5, |
| 214 | + UART2_RTS = PA_3, |
| 215 | + |
| 216 | + // I2C pins |
| 217 | + I2C0_SCL = PD_5, |
| 218 | + I2C0_SDA = PD_4, |
| 219 | + |
| 220 | + I2C1_SCL = PB_2, |
| 221 | + I2C1_SDA = PB_3, |
| 222 | + |
| 223 | + I2C2_SCL = NOT_CONNECTED, |
| 224 | + I2C2_SDA = NOT_CONNECTED, |
| 225 | + |
| 226 | + // SPI pins |
| 227 | + SPI0_SCK = PC_1, |
| 228 | + SPI0_MOSI = PC_2, |
| 229 | + SPI0_MISO = PC_3, |
| 230 | + SPI0_SS0 = PC_0, |
| 231 | + SPI0_SS1 = PC_4, |
| 232 | + SPI0_SS2 = PC_5, |
| 233 | + |
| 234 | + SPI1_SCK = NOT_CONNECTED, |
| 235 | + SPI1_MOSI = NOT_CONNECTED, |
| 236 | + SPI1_MISO = NOT_CONNECTED, |
| 237 | + SPI1_SS0 = NOT_CONNECTED, |
| 238 | + SPI1_SS1 = NOT_CONNECTED, |
| 239 | + SPI1_SS2 = NOT_CONNECTED, |
| 240 | + |
| 241 | + SPI2_SCK = NOT_CONNECTED, |
| 242 | + SPI2_MOSI = NOT_CONNECTED, |
| 243 | + SPI2_MISO = NOT_CONNECTED, |
| 244 | + SPI2_SS0 = NOT_CONNECTED, |
| 245 | + SPI2_SS1 = NOT_CONNECTED, |
| 246 | + SPI2_SS2 = NOT_CONNECTED, |
| 247 | + |
| 248 | + SPI3_SCK = NOT_CONNECTED, |
| 249 | + SPI3_MOSI = NOT_CONNECTED, |
| 250 | + SPI3_MISO = NOT_CONNECTED, |
| 251 | + SPI3_SS0 = NOT_CONNECTED, |
| 252 | + SPI3_SS1 = NOT_CONNECTED, |
| 253 | + SPI3_SS2 = NOT_CONNECTED, |
| 254 | + |
| 255 | + // SWD UART |
| 256 | + SWD_TGT_TX = UART1_TX, |
| 257 | + SWD_TGT_RX = UART1_RX, |
| 258 | + SWD_TGT_CTS = NOT_CONNECTED, |
| 259 | + SWD_TGT_RTS = NOT_CONNECTED, |
| 260 | + |
| 261 | + // Not connected |
| 262 | + NC = NOT_CONNECTED |
| 263 | + |
| 264 | +} PinName; |
| 265 | + |
| 266 | +typedef enum { |
| 267 | + PullNone = 0, |
| 268 | + PullUp = 1, |
| 269 | + PullDown = 2, |
| 270 | + OpenDrain = 3, |
| 271 | + PullDefault = PullNone |
| 272 | +} PinMode; |
| 273 | + |
| 274 | +#define PORT_NUM(pin) (((uint32_t)(pin) >> 4) & 0xF) |
| 275 | +#define PIN_NUM(pin) ((uint32_t)(pin) & 0xF) |
| 276 | + |
| 277 | +#ifdef __cplusplus |
| 278 | +} |
| 279 | +#endif |
| 280 | + |
| 281 | +#endif |
0 commit comments