Skip to content

Commit 38411e9

Browse files
authored
Merge pull request #3366 from bcostm/dev_nucleo_f412zg
NUCLEO_F412ZG - Add new platform
2 parents c60f134 + 73ff944 commit 38411e9

27 files changed

+12522
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2016 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 MBED_PERIPHERALNAMES_H
17+
#define MBED_PERIPHERALNAMES_H
18+
19+
#include "cmsis.h"
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
typedef enum {
26+
ADC_1 = (int)ADC1_BASE
27+
} ADCName;
28+
29+
typedef enum {
30+
UART_1 = (int)USART1_BASE,
31+
UART_2 = (int)USART2_BASE,
32+
UART_3 = (int)USART3_BASE,
33+
UART_6 = (int)USART6_BASE
34+
} UARTName;
35+
36+
#define STDIO_UART_TX PD_8
37+
#define STDIO_UART_RX PD_9
38+
#define STDIO_UART UART_3
39+
40+
typedef enum {
41+
SPI_1 = (int)SPI1_BASE,
42+
SPI_2 = (int)SPI2_BASE,
43+
SPI_3 = (int)SPI3_BASE,
44+
SPI_4 = (int)SPI4_BASE,
45+
SPI_5 = (int)SPI5_BASE
46+
} SPIName;
47+
48+
typedef enum {
49+
I2C_1 = (int)I2C1_BASE,
50+
I2C_2 = (int)I2C2_BASE,
51+
I2C_3 = (int)I2C3_BASE,
52+
FMPI2C_1 = (int)FMPI2C1_BASE
53+
} I2CName;
54+
55+
typedef enum {
56+
PWM_1 = (int)TIM1_BASE,
57+
PWM_2 = (int)TIM2_BASE,
58+
PWM_3 = (int)TIM3_BASE,
59+
PWM_4 = (int)TIM4_BASE,
60+
PWM_5 = (int)TIM5_BASE,
61+
PWM_8 = (int)TIM8_BASE,
62+
PWM_9 = (int)TIM9_BASE,
63+
PWM_10 = (int)TIM10_BASE,
64+
PWM_11 = (int)TIM11_BASE,
65+
PWM_12 = (int)TIM12_BASE,
66+
PWM_13 = (int)TIM13_BASE,
67+
PWM_14 = (int)TIM14_BASE
68+
} PWMName;
69+
70+
typedef enum {
71+
CAN_1 = (int)CAN1_BASE,
72+
CAN_2 = (int)CAN2_BASE
73+
} CANName;
74+
75+
#ifdef __cplusplus
76+
}
77+
#endif
78+
79+
#endif

targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F412ZG/PeripheralPins.c

Lines changed: 322 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2016 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 MBED_PINNAMES_H
17+
#define MBED_PINNAMES_H
18+
19+
#include "cmsis.h"
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
#define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((MODE & 0x0F) << 0) |\
26+
((PUPD & 0x07) << 4) |\
27+
((AFNUM & 0x0F) << 7)))
28+
29+
#define STM_PIN_DATA_EXT(MODE, PUPD, AFNUM, CHANNEL, INVERTED) ((int)(((MODE & 0x0F) << 0) |\
30+
((PUPD & 0x07) << 4) |\
31+
((AFNUM & 0x0F) << 7) |\
32+
((CHANNEL & 0x1F) << 11) |\
33+
((INVERTED & 0x01) << 16)))
34+
35+
#define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
36+
#define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
37+
#define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
38+
#define STM_PIN_CHANNEL(X) (((X) >> 11) & 0x1F)
39+
#define STM_PIN_INVERTED(X) (((X) >> 16) & 0x01)
40+
41+
#define STM_MODE_INPUT (0)
42+
#define STM_MODE_OUTPUT_PP (1)
43+
#define STM_MODE_OUTPUT_OD (2)
44+
#define STM_MODE_AF_PP (3)
45+
#define STM_MODE_AF_OD (4)
46+
#define STM_MODE_ANALOG (5)
47+
#define STM_MODE_IT_RISING (6)
48+
#define STM_MODE_IT_FALLING (7)
49+
#define STM_MODE_IT_RISING_FALLING (8)
50+
#define STM_MODE_EVT_RISING (9)
51+
#define STM_MODE_EVT_FALLING (10)
52+
#define STM_MODE_EVT_RISING_FALLING (11)
53+
#define STM_MODE_IT_EVT_RESET (12)
54+
55+
// High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
56+
// Low nibble = pin number
57+
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
58+
#define STM_PIN(X) ((uint32_t)(X) & 0xF)
59+
60+
typedef enum {
61+
PIN_INPUT,
62+
PIN_OUTPUT
63+
} PinDirection;
64+
65+
typedef enum {
66+
PA_0 = 0x00,
67+
PA_1 = 0x01,
68+
PA_2 = 0x02,
69+
PA_3 = 0x03,
70+
PA_4 = 0x04,
71+
PA_5 = 0x05,
72+
PA_6 = 0x06,
73+
PA_7 = 0x07,
74+
PA_8 = 0x08,
75+
PA_9 = 0x09,
76+
PA_10 = 0x0A,
77+
PA_11 = 0x0B,
78+
PA_12 = 0x0C,
79+
PA_13 = 0x0D,
80+
PA_14 = 0x0E,
81+
PA_15 = 0x0F,
82+
83+
PB_0 = 0x10,
84+
PB_1 = 0x11,
85+
PB_2 = 0x12,
86+
PB_3 = 0x13,
87+
PB_4 = 0x14,
88+
PB_5 = 0x15,
89+
PB_6 = 0x16,
90+
PB_7 = 0x17,
91+
PB_8 = 0x18,
92+
PB_9 = 0x19,
93+
PB_10 = 0x1A,
94+
PB_11 = 0x1B,
95+
PB_12 = 0x1C,
96+
PB_13 = 0x1D,
97+
PB_14 = 0x1E,
98+
PB_15 = 0x1F,
99+
100+
PC_0 = 0x20,
101+
PC_1 = 0x21,
102+
PC_2 = 0x22,
103+
PC_3 = 0x23,
104+
PC_4 = 0x24,
105+
PC_5 = 0x25,
106+
PC_6 = 0x26,
107+
PC_7 = 0x27,
108+
PC_8 = 0x28,
109+
PC_9 = 0x29,
110+
PC_10 = 0x2A,
111+
PC_11 = 0x2B,
112+
PC_12 = 0x2C,
113+
PC_13 = 0x2D,
114+
PC_14 = 0x2E,
115+
PC_15 = 0x2F,
116+
117+
PD_0 = 0x30,
118+
PD_1 = 0x31,
119+
PD_2 = 0x32,
120+
PD_3 = 0x33,
121+
PD_4 = 0x34,
122+
PD_5 = 0x35,
123+
PD_6 = 0x36,
124+
PD_7 = 0x37,
125+
PD_8 = 0x38,
126+
PD_9 = 0x39,
127+
PD_10 = 0x3A,
128+
PD_11 = 0x3B,
129+
PD_12 = 0x3C,
130+
PD_13 = 0x3D,
131+
PD_14 = 0x3E,
132+
PD_15 = 0x3F,
133+
134+
PE_0 = 0x40,
135+
PE_1 = 0x41,
136+
PE_2 = 0x42,
137+
PE_3 = 0x43,
138+
PE_4 = 0x44,
139+
PE_5 = 0x45,
140+
PE_6 = 0x46,
141+
PE_7 = 0x47,
142+
PE_8 = 0x48,
143+
PE_9 = 0x49,
144+
PE_10 = 0x4A,
145+
PE_11 = 0x4B,
146+
PE_12 = 0x4C,
147+
PE_13 = 0x4D,
148+
PE_14 = 0x4E,
149+
PE_15 = 0x4F,
150+
151+
PF_0 = 0x50,
152+
PF_1 = 0x51,
153+
PF_2 = 0x52,
154+
PF_3 = 0x53,
155+
PF_4 = 0x54,
156+
PF_5 = 0x55,
157+
PF_6 = 0x56,
158+
PF_7 = 0x57,
159+
PF_8 = 0x58,
160+
PF_9 = 0x59,
161+
PF_10 = 0x5A,
162+
PF_11 = 0x5B,
163+
PF_12 = 0x5C,
164+
PF_13 = 0x5D,
165+
PF_14 = 0x5E,
166+
PF_15 = 0x5F,
167+
168+
PG_0 = 0x60,
169+
PG_1 = 0x61,
170+
PG_2 = 0x62,
171+
PG_3 = 0x63,
172+
PG_4 = 0x64,
173+
PG_5 = 0x65,
174+
PG_6 = 0x66,
175+
PG_7 = 0x67,
176+
PG_8 = 0x68,
177+
PG_9 = 0x69,
178+
PG_10 = 0x6A,
179+
PG_11 = 0x6B,
180+
PG_12 = 0x6C,
181+
PG_13 = 0x6D,
182+
PG_14 = 0x6E,
183+
PG_15 = 0x6F,
184+
185+
PH_0 = 0x70,
186+
PH_1 = 0x71,
187+
188+
// ADC internal channels
189+
ADC_TEMP = 0xF0,
190+
ADC_VREF = 0xF1,
191+
ADC_VBAT = 0xF2,
192+
193+
// Arduino connector namings
194+
A0 = PA_3,
195+
A1 = PC_0,
196+
A2 = PC_3,
197+
A3 = PC_1,
198+
A4 = PC_4,
199+
A5 = PC_5,
200+
D0 = PG_9,
201+
D1 = PG_14,
202+
D2 = PF_15,
203+
D3 = PE_13,
204+
D4 = PF_14,
205+
D5 = PE_11,
206+
D6 = PE_9,
207+
D7 = PF_13,
208+
D8 = PF_12,
209+
D9 = PD_15,
210+
D10 = PD_14,
211+
D11 = PA_7,
212+
D12 = PA_6,
213+
D13 = PA_5,
214+
D14 = PB_9,
215+
D15 = PB_8,
216+
217+
// Generic signals namings
218+
LED1 = PB_0,
219+
LED2 = PB_7,
220+
LED3 = PB_14,
221+
LED4 = LED1,
222+
LED_RED = LED1,
223+
USER_BUTTON = PC_13,
224+
SERIAL_TX = PD_8,
225+
SERIAL_RX = PD_9,
226+
USBTX = SERIAL_TX,
227+
USBRX = SERIAL_RX,
228+
I2C_SCL = D15,
229+
I2C_SDA = D14,
230+
SPI_MOSI = D11,
231+
SPI_MISO = D12,
232+
SPI_SCK = D13,
233+
SPI_CS = D10,
234+
PWM_OUT = D9,
235+
236+
// Not connected
237+
NC = (int)0xFFFFFFFF
238+
} PinName;
239+
240+
typedef enum {
241+
PullNone = 0,
242+
PullUp = 1,
243+
PullDown = 2,
244+
OpenDrain = 3,
245+
PullDefault = PullNone
246+
} PinMode;
247+
248+
#ifdef __cplusplus
249+
}
250+
#endif
251+
252+
#endif
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2016 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 MBED_PORTNAMES_H
17+
#define MBED_PORTNAMES_H
18+
19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
23+
typedef enum {
24+
PortA = 0,
25+
PortB = 1,
26+
PortC = 2,
27+
PortD = 3,
28+
PortE = 4,
29+
PortF = 5,
30+
PortG = 6,
31+
PortH = 7
32+
} PortName;
33+
34+
#ifdef __cplusplus
35+
}
36+
#endif
37+
#endif

0 commit comments

Comments
 (0)