]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/PinNames.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / hal / TARGET_STM / TARGET_STM32F4 / TARGET_NUCLEO_F401RE / 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_AFNUM(X)    (((X) >> 7)  & 0x0F)
46 #define STM_PIN_CHANNEL(X)  (((X) >> 11) & 0x0F)
47 #define STM_PIN_INVERTED(X) (((X) >> 15) & 0x01)
48 #define STM_MODE_INPUT              (0)
49 #define STM_MODE_OUTPUT_PP          (1)
50 #define STM_MODE_OUTPUT_OD          (2)
51 #define STM_MODE_AF_PP              (3)
52 #define STM_MODE_AF_OD              (4)
53 #define STM_MODE_ANALOG             (5)
54 #define STM_MODE_IT_RISING          (6)
55 #define STM_MODE_IT_FALLING         (7)
56 #define STM_MODE_IT_RISING_FALLING  (8)
57 #define STM_MODE_EVT_RISING         (9)
58 #define STM_MODE_EVT_FALLING        (10)
59 #define STM_MODE_EVT_RISING_FALLING (11)
60 #define STM_MODE_IT_EVT_RESET       (12)
61
62 // High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
63 // Low nibble  = pin number
64 #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
65 #define STM_PIN(X)  ((uint32_t)(X) & 0xF)
66
67 typedef enum {
68     PIN_INPUT,
69     PIN_OUTPUT
70 } PinDirection;
71
72 typedef enum {
73     PA_0  = 0x00,
74     PA_1  = 0x01,
75     PA_2  = 0x02,
76     PA_3  = 0x03,
77     PA_4  = 0x04,
78     PA_5  = 0x05,
79     PA_6  = 0x06,
80     PA_7  = 0x07,
81     PA_8  = 0x08,
82     PA_9  = 0x09,
83     PA_10 = 0x0A,
84     PA_11 = 0x0B,
85     PA_12 = 0x0C,
86     PA_13 = 0x0D,
87     PA_14 = 0x0E,
88     PA_15 = 0x0F,
89
90     PB_0  = 0x10,
91     PB_1  = 0x11,
92     PB_2  = 0x12,
93     PB_3  = 0x13,
94     PB_4  = 0x14,
95     PB_5  = 0x15,
96     PB_6  = 0x16,
97     PB_7  = 0x17,
98     PB_8  = 0x18,
99     PB_9  = 0x19,
100     PB_10 = 0x1A,
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_2  = 0x32,
124
125     PH_0  = 0x70,
126     PH_1  = 0x71,
127
128     // Arduino connector namings
129     A0          = PA_0,
130     A1          = PA_1,
131     A2          = PA_4,
132     A3          = PB_0,
133     A4          = PC_1,
134     A5          = PC_0,
135     D0          = PA_3,
136     D1          = PA_2,
137     D2          = PA_10,
138     D3          = PB_3,
139     D4          = PB_5,
140     D5          = PB_4,
141     D6          = PB_10,
142     D7          = PA_8,
143     D8          = PA_9,
144     D9          = PC_7,
145     D10         = PB_6,
146     D11         = PA_7,
147     D12         = PA_6,
148     D13         = PA_5,
149     D14         = PB_9,
150     D15         = PB_8,
151
152     // Generic signals namings
153     LED1        = PA_5,
154     LED2        = PA_5,
155     LED3        = PA_5,
156     LED4        = PA_5,
157     USER_BUTTON = PC_13,
158     SERIAL_TX   = PA_2,
159     SERIAL_RX   = PA_3,
160     USBTX       = PA_2,
161     USBRX       = PA_3,
162     I2C_SCL     = PB_8,
163     I2C_SDA     = PB_9,
164     SPI_MOSI    = PA_7,
165     SPI_MISO    = PA_6,
166     SPI_SCK     = PA_5,
167     SPI_CS      = PB_6,
168     PWM_OUT     = PB_3,
169
170     // Not connected
171     NC = (int)0xFFFFFFFF
172 } PinName;
173
174 typedef enum {
175     PullNone  = 0,
176     PullUp    = 1,
177     PullDown  = 2,
178     OpenDrain = 3,
179     PullDefault = PullNone
180 } PinMode;
181
182 #ifdef __cplusplus
183 }
184 #endif
185
186 #endif