Skip to content

Commit 3f251f2

Browse files
committed
variant(F4): add Nucleo F412ZG support
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 8d6acd4 commit 3f251f2

File tree

4 files changed

+494
-0
lines changed

4 files changed

+494
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
8787
| Status | Device(s) | Name | Release | Notes |
8888
| :----: | :-------: | ---- | :-----: | :---- |
8989
| :green_heart: | STM32F207ZG | [Nucleo F207ZG](http://www.st.com/en/evaluation-tools/nucleo-f207zg.html) | *0.2.0* | |
90+
| :yellow_heart: | STM32F412ZG | [Nucleo F412ZG](http://www.st.com/en/evaluation-tools/nucleo-f412zg.html) | **2.6.0** | |
9091
| :green_heart: | STM32F429ZI | [Nucleo F429ZI](http://www.st.com/en/evaluation-tools/nucleo-f429zi.html) | *0.1.0* | |
9192
| :green_heart: | STM32F722ZE | [Nucleo F722ZE](http://www.st.com/en/evaluation-tools/nucleo-f722ze.html) | *2.4.0* | |
9293
| :green_heart: | STM32F767ZI | [Nucleo F767ZI](http://www.st.com/en/evaluation-tools/nucleo-f767zi.html) | *1.4.0* | |

boards.txt

+14
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ Nucleo_144.menu.pnum.NUCLEO_F207ZG.build.variant=STM32F2xx/F207Z(C-E-F-G)T_F217Z
3737
Nucleo_144.menu.pnum.NUCLEO_F207ZG.build.peripheral_pins=-DCUSTOM_PERIPHERAL_PINS
3838
Nucleo_144.menu.pnum.NUCLEO_F207ZG.build.cmsis_lib_gcc=arm_cortexM3l_math
3939

40+
# NUCLEO_F412ZG board
41+
Nucleo_144.menu.pnum.NUCLEO_F412ZG=Nucleo F412ZG
42+
Nucleo_144.menu.pnum.NUCLEO_F412ZG.node=NODE_F412ZG
43+
Nucleo_144.menu.pnum.NUCLEO_F412ZG.upload.maximum_size=1048576
44+
Nucleo_144.menu.pnum.NUCLEO_F412ZG.upload.maximum_data_size=262144
45+
Nucleo_144.menu.pnum.NUCLEO_F412ZG.build.mcu=cortex-m4
46+
Nucleo_144.menu.pnum.NUCLEO_F412ZG.build.fpu=-mfpu=fpv4-sp-d16
47+
Nucleo_144.menu.pnum.NUCLEO_F412ZG.build.float-abi=-mfloat-abi=hard
48+
Nucleo_144.menu.pnum.NUCLEO_F412ZG.build.board=NUCLEO_F412ZG
49+
Nucleo_144.menu.pnum.NUCLEO_F412ZG.build.series=STM32F4xx
50+
Nucleo_144.menu.pnum.NUCLEO_F412ZG.build.product_line=STM32F412Zx
51+
Nucleo_144.menu.pnum.NUCLEO_F412ZG.build.variant=STM32F4xx/F412Z(E-G)(J-T)
52+
Nucleo_144.menu.pnum.NUCLEO_F412ZG.build.cmsis_lib_gcc=arm_cortexM4lf_math
53+
4054
# NUCLEO_F413ZH board
4155
Nucleo_144.menu.pnum.NUCLEO_F413ZH=Nucleo F413ZH
4256
Nucleo_144.menu.pnum.NUCLEO_F413ZH.node=NODE_F413ZH
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2023, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
*/
13+
#if defined(ARDUINO_NUCLEO_F412ZG)
14+
#include "pins_arduino.h"
15+
16+
// Digital PinName array
17+
// This array allows to wrap Arduino pin number(Dx or x)
18+
// to STM32 PinName (PX_n)
19+
const PinName digitalPin[] = {
20+
PG_9, //D0
21+
PG_14, //D1
22+
PF_15, //D2
23+
PE_13, //D3
24+
PF_14, //D4
25+
PE_11, //D5
26+
PE_9, //D6
27+
PF_13, //D7
28+
PF_12, //D8
29+
PD_15, //D9
30+
PD_14, //D10
31+
PA_7, //D11/A10
32+
PA_6, //D12/A11
33+
PA_5, //D13/A12
34+
PB_9, //D14
35+
PB_8, //D15
36+
PC_6, //D16
37+
PB_15, //D17
38+
PB_13, //D18
39+
PB_12, //D19
40+
PA_15, //D20
41+
PC_7, //D21
42+
PB_5, //D22
43+
PB_3, //D23
44+
PA_4, //D24/A13
45+
PB_4, //D25
46+
PB_6, //D26
47+
PB_2, //D27
48+
PD_13, //D28
49+
PD_12, //D29
50+
PD_11, //D30
51+
PE_2, //D31
52+
PA_0, //D32/A14
53+
PB_0, //D33/A15 - LED_GREEN
54+
PE_0, //D34
55+
PB_11, //D35
56+
PB_10, //D36
57+
PE_15, //D37
58+
PE_14, //D38
59+
PE_12, //D39
60+
PE_10, //D40
61+
PE_7, //D41
62+
PE_8, //D42
63+
PC_8, //D43
64+
PC_9, //D44
65+
PC_10, //D45
66+
PC_11, //D46
67+
PC_12, //D47
68+
PD_2, //D48
69+
PG_2, //D49
70+
PG_3, //D50
71+
PD_7, //D51
72+
PD_6, //D52
73+
PD_5, //D53
74+
PD_4, //D54
75+
PD_3, //D55
76+
PE_2, //D56
77+
PE_4, //D57
78+
PE_5, //D58
79+
PE_6, //D59
80+
PE_3, //D60
81+
PF_8, //D61
82+
PF_7, //D62
83+
PF_9, //D63
84+
PG_1, //D64
85+
PG_0, //D65
86+
PD_1, //D66
87+
PD_0, //D67
88+
PF_0, //D68
89+
PF_1, //D69
90+
PF_2, //D70
91+
PB_7, //D71 - LED_BLUE
92+
PB_14, //D72 - LED_RED
93+
PC_13, //D73 - USER_BTN
94+
PD_9, //D74 - Serial Rx
95+
PD_8, //D75 - Serial Tx
96+
PA_3, //D76/A0
97+
PC_0, //D77/A1
98+
PC_3, //D78/A2
99+
PC_1, //D79/A3
100+
PC_4, //D80/A4
101+
PC_5, //D81/A5
102+
PB_1, //D82/A6
103+
PC_2, //D83/A7
104+
PA_2, //D84/A8
105+
PF_6, //D85
106+
PA_1, //D86/A9
107+
PF_4, //D87
108+
PA_8, //D88
109+
PA_9, //D89
110+
PA_10, //D90
111+
PA_11, //D91
112+
PA_12, //D92
113+
PA_13, //D93
114+
PA_14, //D94
115+
PF_3, //D95/A20
116+
PF_5, //D96/A21
117+
PF_10, //D97/A22
118+
PC_14, //D98
119+
PC_15, //D99
120+
PD_10, //D100
121+
PE_1, //D101
122+
PF_11, //D102
123+
PG_4, //D103
124+
PG_5, //D104
125+
PG_6, //D105
126+
PG_7, //D106
127+
PG_8, //D107
128+
PG_10, //D108
129+
PG_11, //D109
130+
PG_12, //D110
131+
PG_13, //D111
132+
PG_15, //D112
133+
PH_0, //D113
134+
PH_1 //D114
135+
};
136+
137+
// Analog (Ax) pin number array
138+
const uint32_t analogInputPin[] = {
139+
76, //A0
140+
77, //A1
141+
78, //A2
142+
79, //A3
143+
80, //A4
144+
81, //A5
145+
82, //A6
146+
83, //A7
147+
84, //A8
148+
86, //A9
149+
11, //A10
150+
12, //A11
151+
13, //A12
152+
24, //A13
153+
32, //A14
154+
33 //A15
155+
};
156+
157+
// ----------------------------------------------------------------------------
158+
159+
#ifdef __cplusplus
160+
extern "C" {
161+
#endif
162+
163+
/**
164+
* @brief System Clock Configuration
165+
* @param None
166+
* @retval None
167+
*/
168+
WEAK void SystemClock_Config(void)
169+
{
170+
RCC_OscInitTypeDef RCC_OscInitStruct = {};
171+
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
172+
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {};
173+
174+
/** Configure the main internal regulator output voltage
175+
*/
176+
__HAL_RCC_PWR_CLK_ENABLE();
177+
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
178+
179+
/** Initializes the RCC Oscillators according to the specified parameters
180+
* in the RCC_OscInitTypeDef structure.
181+
*/
182+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
183+
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
184+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
185+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
186+
RCC_OscInitStruct.PLL.PLLM = 8;
187+
RCC_OscInitStruct.PLL.PLLN = 384;
188+
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
189+
RCC_OscInitStruct.PLL.PLLQ = 8;
190+
RCC_OscInitStruct.PLL.PLLR = 2;
191+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
192+
Error_Handler();
193+
}
194+
195+
/** Initializes the CPU, AHB and APB buses clocks
196+
*/
197+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
198+
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
199+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
200+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
201+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
202+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
203+
204+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) {
205+
Error_Handler();
206+
}
207+
208+
/** Initializes the peripherals clock
209+
*/
210+
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SDIO | RCC_PERIPHCLK_CLK48;
211+
PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48CLKSOURCE_PLLQ;
212+
PeriphClkInitStruct.SdioClockSelection = RCC_SDIOCLKSOURCE_CLK48;
213+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
214+
Error_Handler();
215+
}
216+
}
217+
218+
#ifdef __cplusplus
219+
}
220+
#endif
221+
222+
#endif /* ARDUINO_NUCLEO_F412ZG */

0 commit comments

Comments
 (0)