Skip to content

Commit ac77f72

Browse files
committed
[board] Add STM32F723E-DISCOVERY board
1 parent 9769ac3 commit ac77f72

4 files changed

Lines changed: 313 additions & 0 deletions

File tree

examples/generic/usb/project.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<!-- <extends>modm:disco-f411ve</extends> -->
99
<!-- <extends>modm:disco-f429zi</extends> -->
1010
<!-- <extends>modm:disco-f469ni</extends> -->
11+
<!-- <extends>modm:disco-f723ie</extends> -->
1112
<!-- <extends>modm:disco-f746ng</extends> -->
1213
<!-- <extends>modm:disco-l476vg</extends> -->
1314
<!-- <extends>modm:feather-m0</extends> -->
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
/*
2+
* Copyright (c) 2015-2018, Niklas Hauser
3+
* Copyright (c) 2016, Fabian Greif
4+
* Copyright (c) 2016-2017, Sascha Schade
5+
* Copyright (c) 2018, Antal Szabó
6+
*
7+
* This file is part of the modm project.
8+
*
9+
* This Source Code Form is subject to the terms of the Mozilla Public
10+
* License, v. 2.0. If a copy of the MPL was not distributed with this
11+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
12+
*/
13+
// ----------------------------------------------------------------------------
14+
15+
#pragma once
16+
17+
#include <modm/platform.hpp>
18+
#include <modm/architecture/interface/clock.hpp>
19+
#include <modm/debug/logger.hpp>
20+
21+
/// @ingroup modm_board_disco_f723ie
22+
#define MODM_BOARD_HAS_LOGGER
23+
24+
using namespace modm::platform;
25+
26+
namespace Board
27+
{
28+
/// @ingroup modm_board_disco_f723ie
29+
/// @{
30+
using namespace modm::literals;
31+
32+
/// STM32F7 running at 216MHz from the external 25MHz clock
33+
struct SystemClock
34+
{
35+
static constexpr uint32_t Frequency = 216_MHz;
36+
static constexpr uint32_t Apb1 = Frequency / 4;
37+
static constexpr uint32_t Apb2 = Frequency / 2;
38+
39+
static constexpr uint32_t Adc1 = Apb2;
40+
static constexpr uint32_t Adc2 = Apb2;
41+
static constexpr uint32_t Adc3 = Apb2;
42+
43+
static constexpr uint32_t Spi1 = Apb2;
44+
static constexpr uint32_t Spi2 = Apb1;
45+
static constexpr uint32_t Spi3 = Apb1;
46+
static constexpr uint32_t Spi4 = Apb2;
47+
48+
static constexpr uint32_t Usart1 = Apb2;
49+
static constexpr uint32_t Usart2 = Apb1;
50+
static constexpr uint32_t Usart3 = Apb1;
51+
static constexpr uint32_t Uart4 = Apb1;
52+
static constexpr uint32_t Uart5 = Apb1;
53+
static constexpr uint32_t Usart6 = Apb2;
54+
static constexpr uint32_t Uart7 = Apb1;
55+
static constexpr uint32_t Uart8 = Apb1;
56+
57+
static constexpr uint32_t Can1 = Apb1;
58+
static constexpr uint32_t Can2 = Apb1;
59+
60+
static constexpr uint32_t I2c1 = Apb1;
61+
static constexpr uint32_t I2c2 = Apb1;
62+
static constexpr uint32_t I2c3 = Apb1;
63+
static constexpr uint32_t I2c4 = Apb1;
64+
65+
static constexpr uint32_t Apb1Timer = Apb1 * 2;
66+
static constexpr uint32_t Apb2Timer = Apb2 * 2;
67+
static constexpr uint32_t Timer1 = Apb2Timer;
68+
static constexpr uint32_t Timer2 = Apb1Timer;
69+
static constexpr uint32_t Timer3 = Apb1Timer;
70+
static constexpr uint32_t Timer4 = Apb1Timer;
71+
static constexpr uint32_t Timer5 = Apb1Timer;
72+
static constexpr uint32_t Timer6 = Apb1Timer;
73+
static constexpr uint32_t Timer7 = Apb1Timer;
74+
static constexpr uint32_t Timer8 = Apb2Timer;
75+
static constexpr uint32_t Timer10 = Apb2Timer;
76+
static constexpr uint32_t Timer11 = Apb2Timer;
77+
static constexpr uint32_t Timer12 = Apb1Timer;
78+
static constexpr uint32_t Timer13 = Apb1Timer;
79+
static constexpr uint32_t Timer14 = Apb1Timer;
80+
81+
static constexpr uint32_t Usb = 48_MHz;
82+
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
83+
static constexpr uint32_t Rtc = 32.768_kHz;
84+
85+
static bool inline
86+
enable()
87+
{
88+
Rcc::enableLowSpeedExternalCrystal();
89+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::LowSpeedExternalCrystal);
90+
91+
Rcc::enableExternalClock(); // 25 MHz
92+
const Rcc::PllFactors pllFactors{
93+
.pllM = 25, // 25MHz / M=25 -> 1MHz
94+
.pllN = 432, // 1MHz * N=432 -> 432MHz
95+
.pllP = 2, // 432MHz / P=2 -> 216MHz = F_cpu
96+
.pllQ = 9 // 432MHz / Q=9 -> 48MHz = F_usb
97+
};
98+
Rcc::enablePll(Rcc::PllSource::ExternalClock, pllFactors);
99+
// Required for 216 MHz clock
100+
Rcc::enableOverdriveMode();
101+
102+
Rcc::setFlashLatency<Frequency>();
103+
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll);
104+
// APB1 is running at 54MHz
105+
Rcc::setApb1Prescaler(Rcc::Apb1Prescaler::Div4);
106+
// APB2 is running at 108MHz
107+
Rcc::setApb2Prescaler(Rcc::Apb2Prescaler::Div2);
108+
Rcc::updateCoreFrequency<Frequency>();
109+
110+
return true;
111+
}
112+
};
113+
114+
// Arduino footprint
115+
using A0 = GpioA6;
116+
using A1 = GpioA4;
117+
using A2 = GpioC4;
118+
using A3 = GpioF10;
119+
using A4 = GpioC0;
120+
using A5 = GpioC1;
121+
122+
using D0 = GpioA3;
123+
using D1 = GpioA2;
124+
using D2 = GpioC5;
125+
using D3 = GpioE5;
126+
using D4 = GpioH3;
127+
using D5 = GpioB0;
128+
using D6 = GpioE6;
129+
using D7 = GpioE3;
130+
using D8 = GpioE4;
131+
using D9 = GpioH6;
132+
using D10 = GpioA1;
133+
using D11 = GpioB5;
134+
using D12 = GpioB4;
135+
using D13 = GpioOutputA5;
136+
using D14 = GpioH5;
137+
using D15 = GpioH4;
138+
139+
using Button = GpioInputA0; // User Button
140+
using LedRed = GpioOutputA7; // User Red LED
141+
using LedGreen = GpioOutputB1; // User Green LED
142+
using LedD13 = D13; // User Blue LED (Arduino D13)
143+
144+
using Leds = SoftwareGpioPort< LedD13, LedGreen, LedRed >;
145+
/// @}
146+
147+
namespace usb_fs
148+
{
149+
/// @ingroup modm_board_disco_f723ie
150+
/// @{
151+
using Vbus = GpioA9;
152+
using Id = GpioA10;
153+
using Dm = GpioA11;
154+
using Dp = GpioA12;
155+
using Overcurrent = GpioB10;
156+
using Power = GpioG8;
157+
158+
using Device = UsbFs;
159+
/// @}
160+
}
161+
162+
namespace usb_hs
163+
{
164+
/// @ingroup modm_board_disco_f723ie
165+
/// @{
166+
167+
using Vbus = GpioB13;
168+
using Id = GpioB12;
169+
using Dm = GpioB14;
170+
using Dp = GpioB15;
171+
using Overcurrent = GpioH10;
172+
using Power = GpioH12;
173+
174+
using Device = UsbHs;
175+
/// @}
176+
}
177+
178+
namespace stlink
179+
{
180+
/// @ingroup modm_board_disco_f723ie
181+
/// @{
182+
using Tx = GpioOutputC6;
183+
using Rx = GpioInputC7;
184+
using Uart = BufferedUart<UsartHal6, UartTxBuffer<2048>>;
185+
/// @}
186+
}
187+
188+
/// @ingroup modm_board_disco_f723ie
189+
/// @{
190+
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
191+
192+
inline void
193+
initialize()
194+
{
195+
SystemClock::enable();
196+
SysTickTimer::initialize<SystemClock>();
197+
198+
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
199+
stlink::Uart::initialize<SystemClock, 115200_Bd>();
200+
201+
Button::setInput();
202+
}
203+
204+
inline void
205+
initializeUsb(uint8_t priority=3)
206+
{
207+
// Full-speed USB port
208+
usb_fs::Device::initialize<SystemClock>(priority);
209+
usb_fs::Device::connect<usb_fs::Dm::Dm, usb_fs::Dp::Dp, usb_fs::Id::Id>();
210+
usb_fs::Overcurrent::setInput();
211+
212+
// Enable VBUS Sensing B
213+
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
214+
215+
// High-speed USB port
216+
usb_hs::Device::initialize<SystemClock>(priority);
217+
usb_hs::Device::connect<usb_hs::Dm::Dm, usb_hs::Dp::Dp, usb_hs::Id::Id>();
218+
usb_hs::Overcurrent::setInput();
219+
220+
// Enable VBUS Sensing B
221+
USB_OTG_HS->GCCFG |= USB_OTG_GCCFG_VBDEN;
222+
}
223+
/// @}
224+
225+
}
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">stm32f723iek6</option>
10+
</options>
11+
<modules>
12+
<module>modm:board:disco-f723ie</module>
13+
</modules>
14+
</library>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2016-2018, Niklas Hauser
5+
# Copyright (c) 2017, Fabian Greif
6+
#
7+
# This file is part of the modm project.
8+
#
9+
# This Source Code Form is subject to the terms of the Mozilla Public
10+
# License, v. 2.0. If a copy of the MPL was not distributed with this
11+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
12+
# -----------------------------------------------------------------------------
13+
14+
def init(module):
15+
module.name = ":board:disco-f723ie"
16+
module.description = """\
17+
# STM32F723E DISCOVERY
18+
19+
[Discovery kit for STM32F723E](https://www.st.com/en/evaluation-tools/32f723ediscovery.html)
20+
21+
## TinyUSB
22+
23+
This board has two USB ports: one with Full Speed support and another with true
24+
High Speed support. By default, TinyUSB runs the device classes on the FS port,
25+
however, you can reassign it to HS via this option:
26+
27+
```xml
28+
<options>
29+
<option name="modm:tinyusb:config">device.cdc,device.msc</option>
30+
<option name="modm:tinyusb:device:port">hs</option>
31+
</options>
32+
```
33+
34+
Note that can use TinyUSB with both the device and host classes at the same time
35+
if you assign them to different ports:
36+
37+
```xml
38+
```xml
39+
<options>
40+
<option name="modm:tinyusb:config">device.cdc,device.msc</option>
41+
<option name="modm:tinyusb:device:port">fs</option>
42+
<option name="modm:tinyusb:host:port">hs</option>
43+
</options>
44+
```
45+
"""
46+
47+
def prepare(module, options):
48+
if not options[":target"].partname.startswith("stm32f723iek"):
49+
return False
50+
51+
module.depends(
52+
":architecture:clock",
53+
":debug",
54+
":platform:clock",
55+
":platform:core",
56+
":platform:gpio",
57+
":platform:uart:6",
58+
":platform:usb:fs",
59+
":platform:usb:hs")
60+
return True
61+
62+
def build(env):
63+
env.outbasepath = "modm/src/modm/board"
64+
env.substitutions = {
65+
"with_logger": True,
66+
"with_assert": env.has_module(":architecture:assert")
67+
}
68+
env.template("../board.cpp.in", "board.cpp")
69+
env.copy('.')
70+
env.collect(":build:openocd.source", "board/stm32f7discovery.cfg")
71+
# Required for TinyUSB to enable the internal HS PHY
72+
env.collect(":build:cppdefines", "HSE_VALUE=25000000")
73+

0 commit comments

Comments
 (0)