Skip to content

Commit 2bcff2c

Browse files
committed
[board] Add NUCLEO-F207ZG board and example
1 parent aa3d258 commit 2bcff2c

10 files changed

Lines changed: 327 additions & 13 deletions

File tree

.github/workflows/linux.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ jobs:
151151
if: always()
152152
run: |
153153
(cd examples && ../tools/scripts/examples_compile.py stm32f1_discovery nucleo_f103rb olimexino_stm32 blue_pill_f103 black_pill_f103)
154+
- name: Examples STM32F2 Series
155+
if: always()
156+
run: |
157+
(cd examples && ../tools/scripts/examples_compile.py nucleo_f207zg)
154158
- name: Examples STM32F3 Series
155159
if: always()
156160
run: |

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -755,65 +755,66 @@ We have out-of-box support for many development boards including documentation.
755755
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f091rc">NUCLEO-F091RC</a></td>
756756
</tr><tr>
757757
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f103rb">NUCLEO-F103RB</a></td>
758+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f207zg">NUCLEO-F207ZG</a></td>
758759
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f303k8">NUCLEO-F303K8</a></td>
759760
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f303re">NUCLEO-F303RE</a></td>
760-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f334r8">NUCLEO-F334R8</a></td>
761761
</tr><tr>
762+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f334r8">NUCLEO-F334R8</a></td>
762763
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f401re">NUCLEO-F401RE</a></td>
763764
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f411re">NUCLEO-F411RE</a></td>
764765
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f429zi">NUCLEO-F429ZI</a></td>
765-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f439zi">NUCLEO-F439ZI</a></td>
766766
</tr><tr>
767+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f439zi">NUCLEO-F439ZI</a></td>
767768
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f446re">NUCLEO-F446RE</a></td>
768769
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f446ze">NUCLEO-F446ZE</a></td>
769770
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f722ze">NUCLEO-F722ZE</a></td>
770-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f746zg">NUCLEO-F746ZG</a></td>
771771
</tr><tr>
772+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f746zg">NUCLEO-F746ZG</a></td>
772773
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f767zi">NUCLEO-F767ZI</a></td>
773774
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g070rb">NUCLEO-G070RB</a></td>
774775
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g071rb">NUCLEO-G071RB</a></td>
775-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g0b1re">NUCLEO-G0B1RE</a></td>
776776
</tr><tr>
777+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g0b1re">NUCLEO-G0B1RE</a></td>
777778
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431kb">NUCLEO-G431KB</a></td>
778779
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431rb">NUCLEO-G431RB</a></td>
779780
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g474re">NUCLEO-G474RE</a></td>
780-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h503rb">NUCLEO-H503RB</a></td>
781781
</tr><tr>
782+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h503rb">NUCLEO-H503RB</a></td>
782783
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h723zg">NUCLEO-H723ZG</a></td>
783784
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h743zi">NUCLEO-H743ZI</a></td>
784785
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l031k6">NUCLEO-L031K6</a></td>
785-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l053r8">NUCLEO-L053R8</a></td>
786786
</tr><tr>
787+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l053r8">NUCLEO-L053R8</a></td>
787788
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l152re">NUCLEO-L152RE</a></td>
788789
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l432kc">NUCLEO-L432KC</a></td>
789790
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l452re">NUCLEO-L452RE</a></td>
790-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l476rg">NUCLEO-L476RG</a></td>
791791
</tr><tr>
792+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l476rg">NUCLEO-L476RG</a></td>
792793
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l496zg-p">NUCLEO-L496ZG-P</a></td>
793794
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l552ze-q">NUCLEO-L552ZE-Q</a></td>
794795
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-u083rc">NUCLEO-U083RC</a></td>
795-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-u385rg-q">NUCLEO-U385RG-Q</a></td>
796796
</tr><tr>
797+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-u385rg-q">NUCLEO-U385RG-Q</a></td>
797798
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-u575zi-q">NUCLEO-U575ZI-Q</a></td>
798799
<td align="center"><a href="https://modm.io/reference/config/modm-olimexino-stm32">OLIMEXINO-STM32</a></td>
799800
<td align="center"><a href="https://modm.io/reference/config/modm-rp-pico">Raspberry Pi Pico</a></td>
800-
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-mini">SAMD21-MINI</a></td>
801801
</tr><tr>
802+
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-mini">SAMD21-MINI</a></td>
802803
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-xplained-pro">SAMD21-XPLAINED-PRO</a></td>
803804
<td align="center"><a href="https://modm.io/reference/config/modm-same54-xplained-pro">SAME54-XPLAINED-PRO</a></td>
804805
<td align="center"><a href="https://modm.io/reference/config/modm-same70-xplained">SAME70-XPLAINED</a></td>
805-
<td align="center"><a href="https://modm.io/reference/config/modm-samg55-xplained-pro">SAMG55-XPLAINED-PRO</a></td>
806806
</tr><tr>
807+
<td align="center"><a href="https://modm.io/reference/config/modm-samg55-xplained-pro">SAMG55-XPLAINED-PRO</a></td>
807808
<td align="center"><a href="https://modm.io/reference/config/modm-samv71-xplained-ultra">SAMV71-XPLAINED-ULTRA</a></td>
808809
<td align="center"><a href="https://modm.io/reference/config/modm-srxe">Smart Response XE</a></td>
809810
<td align="center"><a href="https://modm.io/reference/config/modm-stm32_f4ve">STM32-F4VE</a></td>
810-
<td align="center"><a href="https://modm.io/reference/config/modm-stm32f030_demo">STM32F030-DEMO</a></td>
811811
</tr><tr>
812+
<td align="center"><a href="https://modm.io/reference/config/modm-stm32f030_demo">STM32F030-DEMO</a></td>
812813
<td align="center"><a href="https://modm.io/reference/config/modm-thingplus-rp2040">THINGPLUS-RP2040</a></td>
813814
<td align="center"><a href="https://modm.io/reference/config/modm-weact-c011f6">WEACT-C011F6</a></td>
814815
<td align="center"><a href="https://modm.io/reference/config/modm-weact-g0b1cb">WEACT-G0B1CB</a></td>
815-
<td align="center"><a href="https://modm.io/reference/config/modm-weact-h503cb">WEACT-H503CB</a></td>
816816
</tr><tr>
817+
<td align="center"><a href="https://modm.io/reference/config/modm-weact-h503cb">WEACT-H503CB</a></td>
817818
<td align="center"><a href="https://modm.io/reference/config/modm-weact-h562rg">WEACT-H562RG</a></td>
818819
<td align="center"><a href="https://modm.io/reference/config/modm-weact-u585ci">WEACT-U585CI</a></td>
819820
</tr>

examples/generic/delay/project.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<!-- <extends>modm:nucleo-f072rb</extends> -->
66
<!-- <extends>modm:nucleo-f091rc</extends> -->
77
<!-- <extends>modm:nucleo-f103rb</extends> -->
8+
<!-- <extends>modm:nucleo-f207zg</extends> -->
89
<!-- <extends>modm:nucleo-f303k8</extends> -->
910
<!-- <extends>modm:nucleo-f334r8</extends> -->
1011
<!-- <extends>modm:nucleo-f401re</extends> -->

examples/generic/usb/project.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<!-- <extends>modm:disco-f746ng</extends> -->
1313
<!-- <extends>modm:disco-l476vg</extends> -->
1414
<!-- <extends>modm:feather-m0</extends> -->
15+
<!-- <extends>modm:nucleo-f207zg</extends> -->
1516
<!-- <extends>modm:nucleo-f429zi</extends> -->
1617
<!-- <extends>modm:nucleo-h723zg</extends> -->
1718
<!-- <extends>modm:nucleo-h743zi</extends> -->
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2016-2017, Niklas Hauser
3+
*
4+
* This file is part of the modm project.
5+
*
6+
* This Source Code Form is subject to the terms of the Mozilla Public
7+
* License, v. 2.0. If a copy of the MPL was not distributed with this
8+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
*/
10+
// ----------------------------------------------------------------------------
11+
12+
#include <modm/board.hpp>
13+
14+
using namespace Board;
15+
16+
int
17+
main()
18+
{
19+
Board::initialize();
20+
21+
// Use the logging streams to print some messages.
22+
// Change MODM_LOG_LEVEL above to enable or disable these messages
23+
MODM_LOG_DEBUG << "debug" << modm::endl;
24+
MODM_LOG_INFO << "info" << modm::endl;
25+
MODM_LOG_WARNING << "warning" << modm::endl;
26+
MODM_LOG_ERROR << "error" << modm::endl;
27+
28+
uint32_t counter(0);
29+
30+
while (true)
31+
{
32+
Leds::toggle();
33+
modm::delay(Button::read() ? 100ms : 500ms);
34+
35+
MODM_LOG_INFO << "loop: " << counter++ << modm::endl;
36+
}
37+
38+
return 0;
39+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<library>
2+
<extends>modm:nucleo-f207zg</extends>
3+
<options>
4+
<option name="modm:build:build.path">../../../build/nucleo_f207zg/blink</option>
5+
</options>
6+
<modules>
7+
<module>modm:build:scons</module>
8+
</modules>
9+
</library>
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
/*
2+
* Copyright (c) 2016-2017, Sascha Schade
3+
* Copyright (c) 2016-2018, Niklas Hauser
4+
*
5+
* This file is part of the modm project.
6+
*
7+
* This Source Code Form is subject to the terms of the Mozilla Public
8+
* License, v. 2.0. If a copy of the MPL was not distributed with this
9+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
10+
*/
11+
// ----------------------------------------------------------------------------
12+
13+
#pragma once
14+
15+
#include <modm/platform.hpp>
16+
#include <modm/architecture/interface/clock.hpp>
17+
#include <modm/debug/logger.hpp>
18+
19+
using namespace modm::platform;
20+
21+
/// @ingroup modm_board_nucleo_f207zg
22+
#define MODM_BOARD_HAS_LOGGER
23+
24+
namespace Board
25+
{
26+
/// @ingroup modm_board_nucleo_f207zg
27+
/// @{
28+
using namespace modm::literals;
29+
30+
/// STM32F207ZG running at 120MHz from the ST-LINK 8 MHz MCO
31+
struct SystemClock
32+
{
33+
static constexpr uint32_t Hse = 8_MHz;
34+
static constexpr Rcc::PllConfig pll
35+
{
36+
.M = 4, // 8 MHz / 4 = 2 MHz
37+
.N = 240, // 2 MHz * 240 = 480 MHz
38+
.P = 4, // 480 MHz / 4 = 120 MHz = F_cpu
39+
.Q = 10, // 480 MHz / 10 = 48 MHz = F_usb
40+
};
41+
static constexpr uint32_t PllP = Hse / pll.M * pll.N / pll.P;
42+
static constexpr uint32_t PllQ = Hse / pll.M * pll.N / pll.Q;
43+
44+
static constexpr uint32_t Frequency = PllP;
45+
static_assert(Frequency == Rcc::MaxFrequency);
46+
47+
static constexpr uint32_t Ahb = Frequency;
48+
static constexpr uint32_t Apb1 = Frequency / 4;
49+
static constexpr uint32_t Apb2 = Frequency / 2;
50+
static constexpr uint32_t Ahb1 = Ahb;
51+
static constexpr uint32_t Ahb2 = Ahb;
52+
53+
static constexpr uint32_t Crc = Ahb1;
54+
static constexpr uint32_t Flash = Ahb1;
55+
static constexpr uint32_t Dma1 = Ahb1;
56+
static constexpr uint32_t Dma2 = Ahb1;
57+
static constexpr uint32_t Eth = Ahb1;
58+
59+
static constexpr uint32_t Dcmi = Ahb2;
60+
static constexpr uint32_t Rng = Ahb2;
61+
62+
static constexpr uint32_t Spi2 = Apb1;
63+
static constexpr uint32_t Spi3 = Apb1;
64+
static constexpr uint32_t Usart2 = Apb1;
65+
static constexpr uint32_t Usart3 = Apb1;
66+
static constexpr uint32_t Uart4 = Apb1;
67+
static constexpr uint32_t Uart5 = Apb1;
68+
static constexpr uint32_t I2c1 = Apb1;
69+
static constexpr uint32_t I2c2 = Apb1;
70+
static constexpr uint32_t I2c3 = Apb1;
71+
static constexpr uint32_t Can1 = Apb1;
72+
static constexpr uint32_t Can2 = Apb1;
73+
static constexpr uint32_t Pwr = Apb1;
74+
static constexpr uint32_t Dac = Apb1;
75+
static constexpr uint32_t Wwdg = Apb1;
76+
77+
// APB2 domain
78+
static constexpr uint32_t Spi1 = Apb2;
79+
static constexpr uint32_t Usart1 = Apb2;
80+
static constexpr uint32_t Usart6 = Apb2;
81+
static constexpr uint32_t Adc = Apb2;
82+
static constexpr uint32_t Sdio = Apb2;
83+
static constexpr uint32_t Syscfg = Apb2;
84+
85+
static constexpr uint32_t Apb1Timer = Apb1 * 2;
86+
static constexpr uint32_t Apb2Timer = Apb2 * 2;
87+
static constexpr uint32_t Timer1 = Apb2Timer;
88+
static constexpr uint32_t Timer2 = Apb1Timer;
89+
static constexpr uint32_t Timer3 = Apb1Timer;
90+
static constexpr uint32_t Timer4 = Apb1Timer;
91+
static constexpr uint32_t Timer5 = Apb1Timer;
92+
static constexpr uint32_t Timer6 = Apb1Timer;
93+
static constexpr uint32_t Timer7 = Apb1Timer;
94+
static constexpr uint32_t Timer8 = Apb2Timer;
95+
static constexpr uint32_t Timer9 = Apb2Timer;
96+
static constexpr uint32_t Timer10 = Apb2Timer;
97+
static constexpr uint32_t Timer11 = Apb2Timer;
98+
static constexpr uint32_t Timer12 = Apb1Timer;
99+
static constexpr uint32_t Timer13 = Apb1Timer;
100+
static constexpr uint32_t Timer14 = Apb1Timer;
101+
102+
static constexpr uint32_t Usb = PllQ;
103+
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
104+
static constexpr uint32_t Rtc = 32.768_kHz;
105+
106+
static bool inline
107+
enable()
108+
{
109+
Rcc::enableLseCrystal();
110+
Rcc::enableHseClock();
111+
112+
Rcc::setFlashLatency<Frequency>();
113+
Rcc::updateCoreFrequency<Frequency>();
114+
115+
Rcc::setAhbPrescaler(Rcc::AhbPrescaler::Div1);
116+
Rcc::setApb1Prescaler(Rcc::ApbPrescaler::Div4);
117+
Rcc::setApb2Prescaler(Rcc::ApbPrescaler::Div2);
118+
119+
Rcc::enablePll(Rcc::PllSource::Hse, pll);
120+
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll);
121+
Rcc::setRealTimeClockSource(Rcc::RealTimeClockSource::Lse);
122+
123+
return true;
124+
}
125+
};
126+
127+
// Arduino Footprint
128+
#include "nucleo144_arduino.hpp"
129+
130+
using Button = GpioInputC13;
131+
132+
using LedGreen = GpioOutputB0; // LED1 [Green]
133+
using LedBlue = GpioOutputB7; // LED2 [Blue]
134+
using LedRed = GpioOutputB14; // LED3 [Red]
135+
using Leds = SoftwareGpioPort< LedRed, LedBlue, LedGreen >;
136+
/// @}
137+
138+
namespace usb
139+
{
140+
/// @ingroup modm_board_nucleo_f207zg
141+
/// @{
142+
using Vbus = GpioA9;
143+
using Id = GpioA10;
144+
using Dm = GpioA11;
145+
using Dp = GpioA12;
146+
147+
using Overcurrent = GpioInputG7; // OTG_FS_OverCurrent
148+
using Power = GpioOutputG6; // OTG_FS_PowerSwitchOn
149+
150+
using Device = UsbFs;
151+
/// @}
152+
}
153+
154+
namespace stlink
155+
{
156+
/// @ingroup modm_board_nucleo_f207zg
157+
/// @{
158+
using Tx = GpioOutputD8;
159+
using Rx = GpioInputD9;
160+
using Uart = BufferedUart<UsartHal3, UartTxBuffer<2048>>;
161+
/// @}
162+
}
163+
164+
/// @ingroup modm_board_nucleo_f207zg
165+
/// @{
166+
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
167+
168+
inline void
169+
initialize()
170+
{
171+
SystemClock::enable();
172+
SysTickTimer::initialize<SystemClock>();
173+
174+
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
175+
stlink::Uart::initialize<SystemClock, 115200_Bd>();
176+
177+
Leds::setOutput(modm::Gpio::Low);
178+
179+
Button::setInput();
180+
}
181+
182+
inline void
183+
initializeUsb(uint8_t priority=3)
184+
{
185+
usb::Device::initialize<SystemClock>(priority);
186+
usb::Device::connect<usb::Dm::Dm, usb::Dp::Dp, usb::Id::Id>();
187+
188+
usb::Overcurrent::setInput();
189+
usb::Vbus::setInput();
190+
// // Enable VBUS sense (B device) via pin PA9
191+
// USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS;
192+
// USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;
193+
}
194+
/// @}
195+
196+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<library>
2+
<repositories>
3+
<repository>
4+
<path>../../../../repo.lb</path>
5+
</repository>
6+
</repositories>
7+
8+
<options>
9+
<option name="modm:target">stm32f207zgt6</option>
10+
</options>
11+
<modules>
12+
<module>modm:board:nucleo-f207zg</module>
13+
</modules>
14+
</library>

0 commit comments

Comments
 (0)