]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_ARCH_MAX/PinNames.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / hal / TARGET_STM / TARGET_STM32F4 / TARGET_ARCH_MAX / PinNames.h
1 /* mbed Microcontroller Library
2 *******************************************************************************
3 * Copyright (c) 2014, STMicroelectronics
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *******************************************************************************
29 */
30 #ifndef MBED_PINNAMES_H
31 #define MBED_PINNAMES_H
32
33 #include "cmsis.h"
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 // See stm32f4xx_hal_gpio.h and stm32f4xx_hal_gpio_ex.h for values of MODE, PUPD and AFNUM
40 #define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((AFNUM) << 7) | ((PUPD) << 4) | ((MODE) << 0)))
41 #define STM_PIN_DATA_EXT(MODE, PUPD, AFNUM, CHANNEL, INVERTED) ((int)(((INVERTED & 0x01) << 15) | ((CHANNEL & 0x0F) << 11) | ((AFNUM & 0x0F) << 7) | ((PUPD & 0x07) << 4) | ((MODE & 0x0F) << 0)))
42 #define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
43 #define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
44 #define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
45 #define STM_PIN_CHANNEL(X) (((X) >> 11) & 0x0F)
46 #define STM_PIN_INVERTED(X) (((X) >> 15) & 0x01)
47 #define STM_MODE_INPUT (0)
48 #define STM_MODE_OUTPUT_PP (1)
49 #define STM_MODE_OUTPUT_OD (2)
50 #define STM_MODE_AF_PP (3)
51 #define STM_MODE_AF_OD (4)
52 #define STM_MODE_ANALOG (5)
53 #define STM_MODE_IT_RISING (6)
54 #define STM_MODE_IT_FALLING (7)
55 #define STM_MODE_IT_RISING_FALLING (8)
56 #define STM_MODE_EVT_RISING (9)
57 #define STM_MODE_EVT_FALLING (10)
58 #define STM_MODE_EVT_RISING_FALLING (11)
59 #define STM_MODE_IT_EVT_RESET (12)
60
61 // High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
62 // Low nibble = pin number
63 #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
64 #define STM_PIN(X) ((uint32_t)(X) & 0xF)
65
66 typedef enum {
67 PIN_INPUT,
68 PIN_OUTPUT
69 } PinDirection;
70
71 typedef enum {
72 PA_0 = 0x00,
73 PA_1 = 0x01,
74 PA_2 = 0x02,
75 PA_3 = 0x03,
76 PA_4 = 0x04,
77 PA_5 = 0x05,
78 PA_6 = 0x06,
79 PA_7 = 0x07,
80 PA_8 = 0x08,
81 PA_9 = 0x09,
82 PA_10 = 0x0A,
83 PA_11 = 0x0B,
84 PA_12 = 0x0C,
85 PA_13 = 0x0D,
86 PA_14 = 0x0E,
87 PA_15 = 0x0F,
88
89 PB_0 = 0x10,
90 PB_1 = 0x11,
91 PB_2 = 0x12,
92 PB_3 = 0x13,
93 PB_4 = 0x14,
94 PB_5 = 0x15,
95 PB_6 = 0x16,
96 PB_7 = 0x17,
97 PB_8 = 0x18,
98 PB_9 = 0x19,
99 PB_10 = 0x1A,
100 PB_11 = 0x1B,
101 PB_12 = 0x1C,
102 PB_13 = 0x1D,
103 PB_14 = 0x1E,
104 PB_15 = 0x1F,
105
106 PC_0 = 0x20,
107 PC_1 = 0x21,
108 PC_2 = 0x22,
109 PC_3 = 0x23,
110 PC_4 = 0x24,
111 PC_5 = 0x25,
112 PC_6 = 0x26,
113 PC_7 = 0x27,
114 PC_8 = 0x28,
115 PC_9 = 0x29,
116 PC_10 = 0x2A,
117 PC_11 = 0x2B,
118 PC_12 = 0x2C,
119 PC_13 = 0x2D,
120 PC_14 = 0x2E,
121 PC_15 = 0x2F,
122
123 PD_0 = 0x30,
124 PD_1 = 0x31,
125 PD_2 = 0x32,
126 PD_3 = 0x33,
127 PD_4 = 0x34,
128 PD_5 = 0x35,
129 PD_6 = 0x36,
130 PD_7 = 0x37,
131 PD_8 = 0x38,
132 PD_9 = 0x39,
133 PD_10 = 0x3A,
134 PD_11 = 0x3B,
135 PD_12 = 0x3C,
136 PD_13 = 0x3D,
137 PD_14 = 0x3E,
138 PD_15 = 0x3F,
139
140 PE_0 = 0x40,
141 PE_1 = 0x41,
142 PE_2 = 0x42,
143 PE_3 = 0x43,
144 PE_4 = 0x44,
145 PE_5 = 0x45,
146 PE_6 = 0x46,
147 PE_7 = 0x47,
148 PE_8 = 0x48,
149 PE_9 = 0x49,
150 PE_10 = 0x4A,
151 PE_11 = 0x4B,
152 PE_12 = 0x4C,
153 PE_13 = 0x4D,
154 PE_14 = 0x4E,
155 PE_15 = 0x4F,
156
157 PF_0 = 0x50,
158 PF_1 = 0x51,
159 PF_2 = 0x52,
160 PF_3 = 0x53,
161 PF_4 = 0x54,
162 PF_5 = 0x55,
163 PF_6 = 0x56,
164 PF_7 = 0x57,
165 PF_8 = 0x58,
166 PF_9 = 0x59,
167 PF_10 = 0x5A,
168 PF_11 = 0x5B,
169 PF_12 = 0x5C,
170 PF_13 = 0x5D,
171 PF_14 = 0x5E,
172 PF_15 = 0x5F,
173
174 PG_0 = 0x60,
175 PG_1 = 0x61,
176 PG_2 = 0x62,
177 PG_3 = 0x63,
178 PG_4 = 0x64,
179 PG_5 = 0x65,
180 PG_6 = 0x66,
181 PG_7 = 0x67,
182 PG_8 = 0x68,
183 PG_9 = 0x69,
184 PG_10 = 0x6A,
185 PG_11 = 0x6B,
186 PG_12 = 0x6C,
187 PG_13 = 0x6D,
188 PG_14 = 0x6E,
189 PG_15 = 0x6F,
190
191 PH_0 = 0x70,
192 PH_1 = 0x71,
193 PH_2 = 0x72,
194 PH_3 = 0x73,
195 PH_4 = 0x74,
196 PH_5 = 0x75,
197 PH_6 = 0x76,
198 PH_7 = 0x77,
199 PH_8 = 0x78,
200 PH_9 = 0x79,
201 PH_10 = 0x7A,
202 PH_11 = 0x7B,
203 PH_12 = 0x7C,
204 PH_13 = 0x7D,
205 PH_14 = 0x7E,
206 PH_15 = 0x7F,
207
208 PI_0 = 0x80,
209 PI_1 = 0x81,
210 PI_2 = 0x82,
211 PI_3 = 0x83,
212 PI_4 = 0x84,
213 PI_5 = 0x85,
214 PI_6 = 0x86,
215 PI_7 = 0x87,
216 PI_8 = 0x88,
217 PI_9 = 0x89,
218 PI_10 = 0x8A,
219 PI_11 = 0x8B,
220 PI_12 = 0x8C,
221 PI_13 = 0x8D,
222 PI_14 = 0x8E,
223 PI_15 = 0x8F,
224
225
226 // Arduino connector namings
227 A0 = PA_0,
228 A1 = PA_3,
229 A2 = PA_4,
230 A3 = PA_5,
231 A4 = PA_6,
232 A5 = PB_0,
233 A6 = PB_1,
234 A7 = PC_0,
235 D0 = PD_3,
236 D1 = PD_6,
237 D2 = PD_11,
238 D3 = PD_12,
239 D4 = PD_13,
240 D5 = PA_8,
241 D6 = PB_6,
242 D7 = PB_7,
243 D8 = PB_15,
244 D9 = PB_14,
245 D10 = PA_15,
246 D11 = PB_5,
247 D12 = PB_4,
248 D13 = PB_3,
249 D14 = PB_9,
250 D15 = PB_8,
251
252 // Generic signals namings
253 LED1 = PB_3,
254 LED2 = PD_8,
255 LED3 = PD_9,
256 LED4 = PD_10,
257 USBTX = PC_6, /* USART6 */
258 USBRX = PC_7,
259 I2C_SCL = PB_8, /* I2C1 */
260 I2C_SDA = PB_9,
261 SPI_MOSI = PC_3,
262 SPI_MISO = PC_2,
263 SPI_SCK = PB_10,
264 SPI_CS = PE_3,
265 SD_MOSI = PC_3,
266 SD_MISO = PC_2,
267 SD_SCK = PB_10,
268 SD_CS = PE_2,
269
270 // Not connected
271 NC = (int)0xFFFFFFFF
272 } PinName;
273
274 typedef enum {
275 PullNone = 0,
276 PullUp = 1,
277 PullDown = 2,
278 OpenDrain = 3,
279 PullDefault = PullNone
280 } PinMode;
281
282 #ifdef __cplusplus
283 }
284 #endif
285
286 #endif
Imprint / Impressum