Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4ad0860

Browse files
committedJan 20, 2020
Add generic F446Rx pinout
This pinout is formatted the same way as the Generic F401Rx and F411Rx pinout, and is used with the STM32F446RC and STM32F446RE chips
1 parent 30d6f5b commit 4ad0860

File tree

6 files changed

+1011
-0
lines changed

6 files changed

+1011
-0
lines changed
 

‎boards.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,22 @@ GenF4.menu.pnum.FEATHER_F405.build.board=FEATHER_F405
10251025
GenF4.menu.pnum.FEATHER_F405.build.product_line=STM32F405xx
10261026
GenF4.menu.pnum.FEATHER_F405.build.variant=FEATHER_F405
10271027

1028+
# Generic F446RE
1029+
GenF4.menu.pnum.Generic_F446RE=Generic F446RE
1030+
GenF4.menu.pnum.Generic_F446RE.upload.maximum_size=524288
1031+
GenF4.menu.pnum.Generic_F446RE.upload.maximum_data_size=131072
1032+
GenF4.menu.pnum.Generic_F446RE.build.board=GENERIC_F446RE
1033+
GenF4.menu.pnum.Generic_F446RE.build.product_line=STM32F446xx
1034+
GenF4.menu.pnum.Generic_F446RE.build.variant=Generic_F446Rx
1035+
1036+
# Generic F446RC
1037+
GenF4.menu.pnum.Generic_F446RC=Generic F446RC
1038+
GenF4.menu.pnum.Generic_F446RC.upload.maximum_size=262144
1039+
GenF4.menu.pnum.Generic_F446RC.upload.maximum_data_size=131072
1040+
GenF4.menu.pnum.Generic_F446RC.build.board=GENERIC_F446RC
1041+
GenF4.menu.pnum.Generic_F446RC.build.product_line=STM32F446xx
1042+
GenF4.menu.pnum.Generic_F446RC.build.variant=Generic_F446Rx
1043+
10281044
# Generic F411RE
10291045
GenF4.menu.pnum.Generic_F411RE=Generic F411RE
10301046
GenF4.menu.pnum.Generic_F411RE.upload.maximum_size=524288

‎variants/Generic_F446Rx/PeripheralPins.c

Lines changed: 375 additions & 0 deletions
Large diffs are not rendered by default.

‎variants/Generic_F446Rx/PinNamesVar.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* SYS_WKUP */
2+
#ifdef PWR_WAKEUP_PIN1
3+
SYS_WKUP1 = PA_0, /* SYS_WKUP0 */
4+
#endif
5+
#ifdef PWR_WAKEUP_PIN2
6+
SYS_WKUP2 = PC_13, /* SYS_WKUP1 */
7+
#endif
8+
#ifdef PWR_WAKEUP_PIN3
9+
SYS_WKUP3 = NC,
10+
#endif
11+
#ifdef PWR_WAKEUP_PIN4
12+
SYS_WKUP4 = NC,
13+
#endif
14+
#ifdef PWR_WAKEUP_PIN5
15+
SYS_WKUP5 = NC,
16+
#endif
17+
#ifdef PWR_WAKEUP_PIN6
18+
SYS_WKUP6 = NC,
19+
#endif
20+
#ifdef PWR_WAKEUP_PIN7
21+
SYS_WKUP7 = NC,
22+
#endif
23+
#ifdef PWR_WAKEUP_PIN8
24+
SYS_WKUP8 = NC,
25+
#endif
26+
/* USB */
27+
#ifdef USBCON
28+
USB_OTG_FS_SOF = PA_8,
29+
USB_OTG_FS_VBUS = PA_9,
30+
USB_OTG_FS_ID = PA_10,
31+
USB_OTG_FS_DM = PA_11,
32+
USB_OTG_FS_DP = PA_12,
33+
USB_OTG_HS_ULPI_D0 = PA_3,
34+
USB_OTG_HS_SOF = PA_4,
35+
USB_OTG_HS_ULPI_CK = PA_5,
36+
USB_OTG_HS_ULPI_D1 = PB_0,
37+
USB_OTG_HS_ULPI_D2 = PB_1,
38+
USB_OTG_HS_ULPI_D4 = PB_2,
39+
USB_OTG_HS_ULPI_D7 = PB_5,
40+
USB_OTG_HS_ULPI_D3 = PB_10,
41+
USB_OTG_HS_ID = PB_12,
42+
USB_OTG_HS_ULPI_D5 = PB_12,
43+
USB_OTG_HS_ULPI_D6 = PB_13,
44+
USB_OTG_HS_VBUS = PB_13,
45+
USB_OTG_HS_DM = PB_14,
46+
USB_OTG_HS_DP = PB_15,
47+
USB_OTG_HS_ULPI_STP = PC_0,
48+
USB_OTG_HS_ULPI_DIR = PC_2,
49+
USB_OTG_HS_ULPI_NXT = PC_3,
50+
#endif

‎variants/Generic_F446Rx/ldscript.ld

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/*
2+
*****************************************************************************
3+
**
4+
5+
** File : LinkerScript.ld
6+
**
7+
** Abstract : Linker script for STM32F446RETx Device with
8+
** 512KByte FLASH, 128KByte RAM
9+
**
10+
** Set heap size, stack size and stack location according
11+
** to application requirements.
12+
**
13+
** Set memory bank area and size if external memory is used.
14+
**
15+
** Target : STMicroelectronics STM32
16+
**
17+
**
18+
** Distribution: The file is distributed as is, without any warranty
19+
** of any kind.
20+
**
21+
*****************************************************************************
22+
** @attention
23+
**
24+
** <h2><center>&copy; COPYRIGHT(c) 2014 Ac6</center></h2>
25+
**
26+
** Redistribution and use in source and binary forms, with or without modification,
27+
** are permitted provided that the following conditions are met:
28+
** 1. Redistributions of source code must retain the above copyright notice,
29+
** this list of conditions and the following disclaimer.
30+
** 2. Redistributions in binary form must reproduce the above copyright notice,
31+
** this list of conditions and the following disclaimer in the documentation
32+
** and/or other materials provided with the distribution.
33+
** 3. Neither the name of Ac6 nor the names of its contributors
34+
** may be used to endorse or promote products derived from this software
35+
** without specific prior written permission.
36+
**
37+
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38+
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39+
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40+
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
41+
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43+
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
44+
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45+
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
46+
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47+
**
48+
*****************************************************************************
49+
*/
50+
51+
/* Entry Point */
52+
ENTRY(Reset_Handler)
53+
54+
/* Highest address of the user mode stack */
55+
_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of RAM */
56+
/* Generate a link error if heap and stack don't fit into RAM */
57+
_Min_Heap_Size = 0x200; /* required amount of heap */
58+
_Min_Stack_Size = 0x400; /* required amount of stack */
59+
60+
/* Specify the memory areas */
61+
MEMORY
62+
{
63+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
64+
FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
65+
}
66+
67+
/* Define output sections */
68+
SECTIONS
69+
{
70+
/* The startup code goes first into FLASH */
71+
.isr_vector :
72+
{
73+
. = ALIGN(4);
74+
KEEP(*(.isr_vector)) /* Startup code */
75+
. = ALIGN(4);
76+
} >FLASH
77+
78+
/* The program code and other data goes into FLASH */
79+
.text ALIGN(4):
80+
{
81+
. = ALIGN(4);
82+
*(.text) /* .text sections (code) */
83+
*(.text*) /* .text* sections (code) */
84+
*(.glue_7) /* glue arm to thumb code */
85+
*(.glue_7t) /* glue thumb to arm code */
86+
*(.eh_frame)
87+
88+
KEEP (*(.init))
89+
KEEP (*(.fini))
90+
91+
. = ALIGN(4);
92+
_etext = .; /* define a global symbols at end of code */
93+
} >FLASH
94+
95+
/* Constant data goes into FLASH */
96+
.rodata :
97+
{
98+
. = ALIGN(4);
99+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
100+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
101+
. = ALIGN(4);
102+
} >FLASH
103+
104+
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
105+
.ARM : {
106+
__exidx_start = .;
107+
*(.ARM.exidx*)
108+
__exidx_end = .;
109+
} >FLASH
110+
111+
.preinit_array :
112+
{
113+
PROVIDE_HIDDEN (__preinit_array_start = .);
114+
KEEP (*(.preinit_array*))
115+
PROVIDE_HIDDEN (__preinit_array_end = .);
116+
} >FLASH
117+
.init_array :
118+
{
119+
PROVIDE_HIDDEN (__init_array_start = .);
120+
KEEP (*(SORT(.init_array.*)))
121+
KEEP (*(.init_array*))
122+
PROVIDE_HIDDEN (__init_array_end = .);
123+
} >FLASH
124+
.fini_array :
125+
{
126+
PROVIDE_HIDDEN (__fini_array_start = .);
127+
KEEP (*(SORT(.fini_array.*)))
128+
KEEP (*(.fini_array*))
129+
PROVIDE_HIDDEN (__fini_array_end = .);
130+
} >FLASH
131+
132+
/* used by the startup to initialize data */
133+
_sidata = LOADADDR(.data);
134+
135+
/* Initialized data sections goes into RAM, load LMA copy after code */
136+
.data :
137+
{
138+
. = ALIGN(4);
139+
_sdata = .; /* create a global symbol at data start */
140+
*(.data) /* .data sections */
141+
*(.data*) /* .data* sections */
142+
143+
. = ALIGN(4);
144+
_edata = .; /* define a global symbol at data end */
145+
} >RAM AT> FLASH
146+
147+
148+
/* Uninitialized data section */
149+
. = ALIGN(4);
150+
.bss :
151+
{
152+
/* This is used by the startup in order to initialize the .bss secion */
153+
_sbss = .; /* define a global symbol at bss start */
154+
__bss_start__ = _sbss;
155+
*(.bss)
156+
*(.bss*)
157+
*(COMMON)
158+
159+
. = ALIGN(4);
160+
_ebss = .; /* define a global symbol at bss end */
161+
__bss_end__ = _ebss;
162+
} >RAM
163+
164+
/* User_heap_stack section, used to check that there is enough RAM left */
165+
._user_heap_stack :
166+
{
167+
. = ALIGN(8);
168+
PROVIDE ( end = . );
169+
PROVIDE ( _end = . );
170+
. = . + _Min_Heap_Size;
171+
. = . + _Min_Stack_Size;
172+
. = ALIGN(8);
173+
} >RAM
174+
175+
176+
177+
/* Remove information from the standard libraries */
178+
/DISCARD/ :
179+
{
180+
libc.a ( * )
181+
libm.a ( * )
182+
libgcc.a ( * )
183+
}
184+
185+
.ARM.attributes 0 : { *(.ARM.attributes) }
186+
}
187+
188+

‎variants/Generic_F446Rx/variant.cpp

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
/*
2+
Copyright (c) 2011 Arduino. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#include "pins_arduino.h"
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
// Digital PinName array
26+
const PinName digitalPin[] = {
27+
PA_0, // Digital pin 0
28+
PA_1, // Digital pin 1
29+
PA_2, // Digital pin 2
30+
PA_3, // Digital pin 3
31+
PA_4, // Digital pin 4
32+
PA_5, // Digital pin 5
33+
PA_6, // Digital pin 6
34+
PA_7, // Digital pin 7
35+
PA_8, // Digital pin 8
36+
PA_9, // Digital pin 9
37+
PA_10, // Digital pin 10
38+
PA_11, // Digital pin 11
39+
PA_12, // Digital pin 12
40+
PA_13, // Digital pin 13
41+
PA_14, // Digital pin 14
42+
PA_15, // Digital pin 15
43+
44+
PB_0, // Digital pin 16
45+
PB_1, // Digital pin 17
46+
PB_2, // Digital pin 18
47+
PB_3, // Digital pin 19
48+
PB_4, // Digital pin 20
49+
PB_5, // Digital pin 21
50+
PB_6, // Digital pin 22
51+
PB_7, // Digital pin 23
52+
PB_8, // Digital pin 24
53+
PB_9, // Digital pin 25
54+
PB_10, // Digital pin 26
55+
PB_12, // Digital pin 27
56+
PB_13, // Digital pin 28
57+
PB_14, // Digital pin 29
58+
PB_15, // Digital pin 30
59+
60+
PC_0, // Digital pin 31
61+
PC_1, // Digital pin 32
62+
PC_2, // Digital pin 33
63+
PC_3, // Digital pin 34
64+
PC_4, // Digital pin 35
65+
PC_5, // Digital pin 36
66+
PC_6, // Digital pin 37
67+
PC_7, // Digital pin 38
68+
PC_8, // Digital pin 39
69+
PC_9, // Digital pin 40
70+
PC_10, // Digital pin 41
71+
PC_11, // Digital pin 42
72+
PC_12, // Digital pin 43
73+
PC_13, // Digital pin 44
74+
PC_14, // Digital pin 45
75+
PC_15, // Digital pin 46
76+
77+
PD_2, // Digital pin 47
78+
79+
PH_0, // Digital pin 48, used by the external oscillator
80+
PH_1 // Digital pin 49, used by the external oscillator
81+
};
82+
83+
// Analog (Ax) pin number array
84+
const uint32_t analogInputPin[] = {
85+
0, // A0, PA0
86+
1, // A1, PA1
87+
2, // A2, PA2
88+
3, // A3, PA3
89+
4, // A4, PA4
90+
5, // A5, PA5
91+
6, // A6, PA6
92+
7, // A7, PA7
93+
16, // A8, PB0
94+
17, // A9, PB1
95+
31, // A10, PC0
96+
32, // A11, PC1
97+
33, // A12, PC2
98+
34, // A13, PC3
99+
35, // A14, PC4
100+
36 // A15, PC5
101+
};
102+
103+
#ifdef __cplusplus
104+
}
105+
#endif
106+
107+
// ----------------------------------------------------------------------------
108+
109+
#ifdef __cplusplus
110+
extern "C" {
111+
#endif
112+
113+
/*
114+
* @brief Configures the System clock source, PLL Multiplier and Divider factors,
115+
* AHB/APBx prescalers and Flash settings
116+
* @note This function should be called only once the RCC clock configuration
117+
* is reset to the default reset state (done in SystemInit() function).
118+
* @param None
119+
* @retval None
120+
*/
121+
122+
/******************************************************************************/
123+
/* PLL (clocked by HSE) used as System clock source */
124+
/******************************************************************************/
125+
static uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
126+
{
127+
RCC_OscInitTypeDef RCC_OscInitStruct;
128+
RCC_ClkInitTypeDef RCC_ClkInitStruct;
129+
130+
/* The voltage scaling allows optimizing the power consumption when the device is
131+
clocked below the maximum system frequency, to update the voltage scaling value
132+
regarding system frequency refer to product datasheet. */
133+
__HAL_RCC_PWR_CLK_ENABLE();
134+
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
135+
136+
// Enable HSE oscillator and activate PLL with HSE as source
137+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
138+
if (bypass == 0) {
139+
RCC_OscInitStruct.HSEState = RCC_HSE_ON; // External 8 MHz xtal on OSC_IN/OSC_OUT
140+
} else {
141+
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External 8 MHz clock on OSC_IN
142+
}
143+
144+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
145+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
146+
RCC_OscInitStruct.PLL.PLLM = 8; // VCO input clock = 1 MHz (8 MHz / 8)
147+
RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336)
148+
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 84 MHz (336 MHz / 4)
149+
RCC_OscInitStruct.PLL.PLLQ = 7; // USB clock = 48 MHz (336 MHz / 7) --> OK for USB
150+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
151+
return 0; // FAIL
152+
}
153+
154+
// Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers
155+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
156+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 84 MHz
157+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 84 MHz
158+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 42 MHz
159+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 84 MHz
160+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
161+
return 0; // FAIL
162+
}
163+
164+
/* Output clock on MCO1 pin(PA8) for debugging purpose */
165+
/*
166+
if (bypass == 0)
167+
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_2); // 4 MHz
168+
else
169+
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz
170+
*/
171+
172+
return 1; // OK
173+
}
174+
175+
/******************************************************************************/
176+
/* PLL (clocked by HSI) used as System clock source */
177+
/******************************************************************************/
178+
uint8_t SetSysClock_PLL_HSI(void)
179+
{
180+
RCC_OscInitTypeDef RCC_OscInitStruct;
181+
RCC_ClkInitTypeDef RCC_ClkInitStruct;
182+
183+
/* The voltage scaling allows optimizing the power consumption when the device is
184+
clocked below the maximum system frequency, to update the voltage scaling value
185+
regarding system frequency refer to product datasheet. */
186+
__HAL_RCC_PWR_CLK_ENABLE();
187+
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
188+
189+
// Enable HSI oscillator and activate PLL with HSI as source
190+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
191+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
192+
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
193+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
194+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
195+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
196+
RCC_OscInitStruct.PLL.PLLM = 16; // VCO input clock = 1 MHz (16 MHz / 16)
197+
RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336)
198+
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 84 MHz (336 MHz / 4)
199+
RCC_OscInitStruct.PLL.PLLQ = 7; // USB clock = 48 MHz (336 MHz / 7) --> freq is ok but not precise enough
200+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
201+
return 0; // FAIL
202+
}
203+
204+
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
205+
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
206+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 84 MHz
207+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 84 MHz
208+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 42 MHz
209+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 84 MHz
210+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
211+
return 0; // FAIL
212+
}
213+
214+
/* Output clock on MCO1 pin(PA8) for debugging purpose */
215+
//HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz
216+
217+
return 1; // OK
218+
}
219+
220+
WEAK void SystemClock_Config(void)
221+
{
222+
/* 1- If fail try to start with HSE and external xtal */
223+
if (SetSysClock_PLL_HSE(0) == 0) {
224+
/* 2- Try to start with HSE and external clock */
225+
if (SetSysClock_PLL_HSE(1) == 0) {
226+
/* 3- If fail start with HSI clock */
227+
if (SetSysClock_PLL_HSI() == 0) {
228+
Error_Handler();
229+
}
230+
}
231+
}
232+
/* Output clock on MCO2 pin(PC9) for debugging purpose */
233+
//HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_4);
234+
}
235+
236+
#ifdef __cplusplus
237+
}
238+
#endif

‎variants/Generic_F446Rx/variant.h

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
Copyright (c) 2011 Arduino. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#ifndef _VARIANT_ARDUINO_STM32_
20+
#define _VARIANT_ARDUINO_STM32_
21+
22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif // __cplusplus
25+
26+
/*----------------------------------------------------------------------------
27+
* Pins
28+
*----------------------------------------------------------------------------*/
29+
30+
// | DIGITAL | ANALOG IN | ANALOG OUT | UART/USART | TWI | SPI | SPECIAL |
31+
// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
32+
#define PA0 A0 // | 0 | A0 (ADC1) | | UART4_TX | | | |
33+
#define PA1 A1 // | 1 | A1 (ADC1) | | UART4_RX | | | |
34+
#define PA2 A2 // | 2 | A2 (ADC1) | | USART2_TX | | | |
35+
#define PA3 A3 // | 3 | A3 (ADC1) | | USART2_RX | | | |
36+
#define PA4 A4 // | 4 | A4 (ADC1) | DAC_OUT1 | | | SPI1_SS, (SPI3_SS) | |
37+
#define PA5 A5 // | 5 | A5 (ADC1) | DAC_OUT2 | | | SPI1_SCK | |
38+
#define PA6 A6 // | 6 | A6 (ADC1) | | | | SPI1_MISO | |
39+
#define PA7 A7 // | 7 | A7 (ADC1) | | | | SPI1_MOSI | |
40+
#define PA8 8 // | 8 | | | | TWI3_SCL | | |
41+
#define PA9 9 // | 9 | | | USART1_TX | | SPI2_SCK | |
42+
#define PA10 10 // | 10 | | | USART1_RX | | | |
43+
#define PA11 11 // | 11 | | | | | | |
44+
#define PA12 12 // | 12 | | | | | | |
45+
#define PA13 13 // | 13 | | | | | | SWD_SWDIO |
46+
#define PA14 14 // | 14 | | | | | | SWD_SWCLK |
47+
#define PA15 15 // | 15 | | | | | SPI3_SS, (SPI1_SS) | |
48+
// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
49+
#define PB0 A8 // | 16 | A8 (ADC1) | | | | SPI3_MOSI | |
50+
#define PB1 A9 // | 17 | A9 (ADC1) | | | | | |
51+
#define PB2 18 // | 18 | | | | | SPI3_MOSI | BOOT1 |
52+
#define PB3 19 // | 19 | | | | TWI2_SDA | SPI3_SCK, (SPI1_SCK) | |
53+
#define PB4 20 // | 20 | | | | TWI3_SDA | SPI3_MISO, (SPI1_MISO), (SPI2_SS) | |
54+
#define PB5 21 // | 21 | | | | | SPI3_MOSI, (SPI1_MOSI) | |
55+
#define PB6 22 // | 22 | | | USART1_TX | TWI1_SCL | | |
56+
#define PB7 23 // | 23 | | | USART1_RX | TWI1_SDA | | |
57+
#define PB8 24 // | 24 | | | | TWI1_SCL | | |
58+
#define PB9 25 // | 25 | | | | TWI1_SDA | SPI2_SS | |
59+
#define PB10 26 // | 26 | | | USART3_TX, (UART4_TX) | TWI2_SCL | SPI2_SCK | |
60+
#define PB12 27 // | 27 | | | | | SPI3_SCK | |
61+
#define PB13 28 // | 28 | | | | | SPI2_SCK | |
62+
#define PB14 29 // | 29 | | | | | SPI2_MISO | |
63+
#define PB15 30 // | 30 | | | | | SPI2_MOSI | |
64+
// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
65+
#define PC0 A10 // | 31 | A10 (ADC1) | | | | | |
66+
#define PC1 A11 // | 32 | A11 (ADC1) | | | | SPI2_MOSI, (SPI3_MOSI) | |
67+
#define PC2 A12 // | 33 | A12 (ADC1) | | | | SPI2_MISO | |
68+
#define PC3 A13 // | 34 | A13 (ADC1) | | | | SPI2_MOSI | |
69+
#define PC4 A14 // | 35 | A14 (ADC1) | | | | | |
70+
#define PC5 A15 // | 36 | A15 (ADC1) | | USART3_RX | | | |
71+
#define PC6 37 // | 37 | | | USART6_TX | FMP_TWI1_SCL | | |
72+
#define PC7 38 // | 38 | | | USART6_RX | FMP_TWI1_SDA | SPI2_SCK | |
73+
#define PC8 39 // | 39 | | | | | | |
74+
#define PC9 40 // | 40 | | | USART3_TX | TWI3_SDA | | |
75+
#define PC10 41 // | 41 | | | | | SPI3_SCK | |
76+
#define PC11 42 // | 42 | | | USART3_RX, (UART4_RX) | | SPI3_MISO | |
77+
#define PC12 43 // | 43 | | | UART5_TX | TWI2_SDA | SPI3_MOSI | |
78+
#define PC13 44 // | 44 | | | | | | |
79+
#define PC14 45 // | 45 | | | | | | OSC32_IN |
80+
#define PC15 46 // | 46 | | | | | | OSC32_OUT |
81+
// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
82+
#define PD2 47 // | 47 | | | UART5_RX | | | |
83+
// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
84+
#define PH0 48 // | 48 | | | | | | OSC_IN |
85+
#define PH1 49 // | 49 | | | | | | OSC_OUT |
86+
// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
87+
88+
/// This must be a literal
89+
#define NUM_DIGITAL_PINS 50
90+
#define NUM_ANALOG_INPUTS 16
91+
92+
// On-board LED pin number
93+
#ifndef LED_BUILTIN
94+
#define LED_BUILTIN PA5
95+
#endif
96+
#define LED_GREEN LED_BUILTIN
97+
98+
// On-board user button
99+
#define USER_BTN PC13
100+
101+
// Timer Definitions
102+
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
103+
#define TIMER_TONE TIM6
104+
#define TIMER_SERVO TIM7
105+
106+
// UART Definitions
107+
#define SERIAL_UART_INSTANCE 2 // Connected to ST-Link
108+
109+
// Default pin used for 'Serial' instance (ex: ST-Link)
110+
// Mandatory for Firmata
111+
#define PIN_SERIAL_RX PA3
112+
#define PIN_SERIAL_TX PA2
113+
114+
/* Extra HAL modules */
115+
#define HAL_DAC_MODULE_ENABLED
116+
117+
#ifdef __cplusplus
118+
} // extern "C"
119+
#endif
120+
/*----------------------------------------------------------------------------
121+
* Arduino objects - C++ only
122+
*----------------------------------------------------------------------------*/
123+
124+
#ifdef __cplusplus
125+
// These serial port names are intended to allow libraries and architecture-neutral
126+
// sketches to automatically default to the correct port name for a particular type
127+
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
128+
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
129+
//
130+
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
131+
//
132+
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
133+
//
134+
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
135+
//
136+
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
137+
//
138+
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
139+
// pins are NOT connected to anything by default.
140+
#define SERIAL_PORT_MONITOR Serial
141+
#define SERIAL_PORT_HARDWARE Serial
142+
#endif
143+
144+
#endif /* _VARIANT_ARDUINO_STM32_ */

0 commit comments

Comments
 (0)
Please sign in to comment.