Skip to content

Commit 7e0b471

Browse files
committed
added disco_f411ve
1 parent c47e7b7 commit 7e0b471

File tree

5 files changed

+307
-14
lines changed

5 files changed

+307
-14
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -624,73 +624,74 @@ We have out-of-box support for many development boards including documentation.
624624
<td align="center"><a href="https://modm.io/reference/config/modm-disco-f303vc">DISCO-F303VC</a></td>
625625
<td align="center"><a href="https://modm.io/reference/config/modm-disco-f401vc">DISCO-F401VC</a></td>
626626
<td align="center"><a href="https://modm.io/reference/config/modm-disco-f407vg">DISCO-F407VG</a></td>
627-
<td align="center"><a href="https://modm.io/reference/config/modm-disco-f429zi">DISCO-F429ZI</a></td>
627+
<td align="center"><a href="https://modm.io/reference/config/modm-disco-f411ve">DISCO-F411VE</a></td>
628628
</tr><tr>
629+
<td align="center"><a href="https://modm.io/reference/config/modm-disco-f429zi">DISCO-F429ZI</a></td>
629630
<td align="center"><a href="https://modm.io/reference/config/modm-disco-f469ni">DISCO-F469NI</a></td>
630631
<td align="center"><a href="https://modm.io/reference/config/modm-disco-f746ng">DISCO-F746NG</a></td>
631632
<td align="center"><a href="https://modm.io/reference/config/modm-disco-f769ni">DISCO-F769NI</a></td>
632-
<td align="center"><a href="https://modm.io/reference/config/modm-disco-l152rc">DISCO-L152RC</a></td>
633633
</tr><tr>
634+
<td align="center"><a href="https://modm.io/reference/config/modm-disco-l152rc">DISCO-L152RC</a></td>
634635
<td align="center"><a href="https://modm.io/reference/config/modm-disco-l476vg">DISCO-L476VG</a></td>
635636
<td align="center"><a href="https://modm.io/reference/config/modm-feather-m0">FEATHER-M0</a></td>
636637
<td align="center"><a href="https://modm.io/reference/config/modm-feather-m4">FEATHER-M4</a></td>
637-
<td align="center"><a href="https://modm.io/reference/config/modm-feather-rp2040">FEATHER-RP2040</a></td>
638638
</tr><tr>
639+
<td align="center"><a href="https://modm.io/reference/config/modm-feather-rp2040">FEATHER-RP2040</a></td>
639640
<td align="center"><a href="https://modm.io/reference/config/modm-mega-2560-pro">MEGA-2560-PRO</a></td>
640641
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f031k6">NUCLEO-F031K6</a></td>
641642
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f042k6">NUCLEO-F042K6</a></td>
642-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f072rb">NUCLEO-F072RB</a></td>
643643
</tr><tr>
644+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f072rb">NUCLEO-F072RB</a></td>
644645
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f091rc">NUCLEO-F091RC</a></td>
645646
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f103rb">NUCLEO-F103RB</a></td>
646647
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f303k8">NUCLEO-F303K8</a></td>
647-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f303re">NUCLEO-F303RE</a></td>
648648
</tr><tr>
649+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f303re">NUCLEO-F303RE</a></td>
649650
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f334r8">NUCLEO-F334R8</a></td>
650651
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f401re">NUCLEO-F401RE</a></td>
651652
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f411re">NUCLEO-F411RE</a></td>
652-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f429zi">NUCLEO-F429ZI</a></td>
653653
</tr><tr>
654+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f429zi">NUCLEO-F429ZI</a></td>
654655
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f439zi">NUCLEO-F439ZI</a></td>
655656
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f446re">NUCLEO-F446RE</a></td>
656657
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f446ze">NUCLEO-F446ZE</a></td>
657-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f746zg">NUCLEO-F746ZG</a></td>
658658
</tr><tr>
659+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f746zg">NUCLEO-F746ZG</a></td>
659660
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f767zi">NUCLEO-F767ZI</a></td>
660661
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g070rb">NUCLEO-G070RB</a></td>
661662
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g071rb">NUCLEO-G071RB</a></td>
662-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431kb">NUCLEO-G431KB</a></td>
663663
</tr><tr>
664+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431kb">NUCLEO-G431KB</a></td>
664665
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431rb">NUCLEO-G431RB</a></td>
665666
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g474re">NUCLEO-G474RE</a></td>
666667
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h723zg">NUCLEO-H723ZG</a></td>
667-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h743zi">NUCLEO-H743ZI</a></td>
668668
</tr><tr>
669+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h743zi">NUCLEO-H743ZI</a></td>
669670
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l031k6">NUCLEO-L031K6</a></td>
670671
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l053r8">NUCLEO-L053R8</a></td>
671672
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l152re">NUCLEO-L152RE</a></td>
672-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l432kc">NUCLEO-L432KC</a></td>
673673
</tr><tr>
674+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l432kc">NUCLEO-L432KC</a></td>
674675
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l452re">NUCLEO-L452RE</a></td>
675676
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l476rg">NUCLEO-L476RG</a></td>
676677
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l496zg-p">NUCLEO-L496ZG-P</a></td>
677-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l552ze-q">NUCLEO-L552ZE-Q</a></td>
678678
</tr><tr>
679+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l552ze-q">NUCLEO-L552ZE-Q</a></td>
679680
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-u575zi-q">NUCLEO-U575ZI-Q</a></td>
680681
<td align="center"><a href="https://modm.io/reference/config/modm-olimexino-stm32">OLIMEXINO-STM32</a></td>
681682
<td align="center"><a href="https://modm.io/reference/config/modm-rp-pico">Raspberry Pi Pico</a></td>
682-
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-mini">SAMD21-MINI</a></td>
683683
</tr><tr>
684+
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-mini">SAMD21-MINI</a></td>
684685
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-xplained-pro">SAMD21-XPLAINED-PRO</a></td>
685686
<td align="center"><a href="https://modm.io/reference/config/modm-same54-xplained-pro">SAME54-XPLAINED-PRO</a></td>
686687
<td align="center"><a href="https://modm.io/reference/config/modm-same70-xplained">SAME70-XPLAINED</a></td>
687-
<td align="center"><a href="https://modm.io/reference/config/modm-samg55-xplained-pro">SAMG55-XPLAINED-PRO</a></td>
688688
</tr><tr>
689+
<td align="center"><a href="https://modm.io/reference/config/modm-samg55-xplained-pro">SAMG55-XPLAINED-PRO</a></td>
689690
<td align="center"><a href="https://modm.io/reference/config/modm-samv71-xplained-ultra">SAMV71-XPLAINED-ULTRA</a></td>
690691
<td align="center"><a href="https://modm.io/reference/config/modm-srxe">Smart Response XE</a></td>
691692
<td align="center"><a href="https://modm.io/reference/config/modm-stm32_f4ve">STM32-F4VE</a></td>
692-
<td align="center"><a href="https://modm.io/reference/config/modm-stm32f030_demo">STM32F030-DEMO</a></td>
693693
</tr><tr>
694+
<td align="center"><a href="https://modm.io/reference/config/modm-stm32f030_demo">STM32F030-DEMO</a></td>
694695
<td align="center"><a href="https://modm.io/reference/config/modm-thingplus-rp2040">THINGPLUS-RP2040</a></td>
695696
</tr>
696697
</table>

examples/generic/usb/project.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<!-- <extends>modm:disco-f072rb</extends> -->
66
<!-- <extends>modm:disco-f303vc</extends> -->
77
<!-- <extends>modm:disco-f407vg</extends> -->
8+
<!-- <extends>modm:disco-f411ve</extends> -->
89
<!-- <extends>modm:disco-f429zi</extends> -->
910
<!-- <extends>modm:disco-f469ni</extends> -->
1011
<!-- <extends>modm:disco-f746ng</extends> -->

src/modm/board/disco_f411ve/board.hpp

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
/*
2+
* Copyright (c) 2024, Thomas Sommer
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+
#pragma once
12+
13+
#include <modm/architecture/interface/clock.hpp>
14+
#include <modm/driver/inertial/lis3dsh.hpp>
15+
#include <modm/platform.hpp>
16+
17+
using namespace modm::platform;
18+
19+
namespace Board
20+
{
21+
/// @ingroup modm_board_disco_f411ve
22+
/// @{
23+
using namespace modm::literals;
24+
25+
/// STM32F411 running at 84MHz generated from the external 8MHz crystal
26+
struct SystemClock
27+
{
28+
static constexpr uint32_t Frequency = 84_MHz;
29+
static constexpr uint32_t Ahb = Frequency;
30+
static constexpr uint32_t Apb1 = Frequency / 2;
31+
static constexpr uint32_t Apb2 = Frequency;
32+
33+
static constexpr uint32_t Adc = Apb2;
34+
35+
static constexpr uint32_t Spi1 = Apb2;
36+
static constexpr uint32_t Spi2 = Apb1;
37+
static constexpr uint32_t Spi3 = Apb1;
38+
static constexpr uint32_t Spi4 = Apb2;
39+
static constexpr uint32_t Spi5 = Apb2;
40+
41+
static constexpr uint32_t Usart1 = Apb2;
42+
static constexpr uint32_t Usart2 = Apb1;
43+
static constexpr uint32_t Usart3 = Apb1;
44+
static constexpr uint32_t Uart4 = Apb1;
45+
static constexpr uint32_t Uart5 = Apb1;
46+
static constexpr uint32_t Usart6 = Apb2;
47+
static constexpr uint32_t Uart7 = Apb1;
48+
static constexpr uint32_t Uart8 = Apb1;
49+
50+
static constexpr uint32_t I2c1 = Apb1;
51+
static constexpr uint32_t I2c2 = Apb1;
52+
static constexpr uint32_t I2c3 = Apb1;
53+
54+
static constexpr uint32_t Apb1Timer = Apb1 * 2;
55+
static constexpr uint32_t Apb2Timer = Apb2 * 2;
56+
static constexpr uint32_t Timer1 = Apb2Timer;
57+
static constexpr uint32_t Timer2 = Apb1Timer;
58+
static constexpr uint32_t Timer3 = Apb1Timer;
59+
static constexpr uint32_t Timer4 = Apb1Timer;
60+
static constexpr uint32_t Timer5 = Apb1Timer;
61+
static constexpr uint32_t Timer9 = Apb2Timer;
62+
static constexpr uint32_t Timer10 = Apb2Timer;
63+
static constexpr uint32_t Timer11 = Apb2Timer;
64+
65+
static constexpr uint32_t Usb = 48_MHz;
66+
67+
static bool inline enable()
68+
{
69+
Rcc::enableExternalCrystal(); // 8MHz
70+
const Rcc::PllFactors pllFactors{
71+
.pllM = 8, // 8MHz / M=8 -> 1MHz
72+
.pllN = 336, // 1MHz * N=336 -> 84MHz
73+
.pllP = 4, // 336MHz / P=4 -> 100MHz = F_cpu
74+
.pllQ = 7, // 336MHz / P=7 -> 100MHz = F_cpu
75+
};
76+
Rcc::enablePll(Rcc::PllSource::ExternalCrystal, pllFactors);
77+
// set flash latency for 100MHz
78+
Rcc::setFlashLatency<Frequency>();
79+
// switch system clock to PLL output
80+
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll);
81+
Rcc::setAhbPrescaler(Rcc::AhbPrescaler::Div1);
82+
// APB1 has max. 50MHz
83+
// APB2 has max. 100MHz
84+
Rcc::setApb1Prescaler(Rcc::Apb1Prescaler::Div2);
85+
Rcc::setApb2Prescaler(Rcc::Apb2Prescaler::Div1);
86+
// update frequencies for busy-wait delay functions
87+
Rcc::updateCoreFrequency<Frequency>();
88+
89+
return true;
90+
}
91+
};
92+
93+
using LedUsb = GpioOutputA9;
94+
using ClockOut = GpioOutputA8;
95+
using SystemClockOut = GpioOutputC9;
96+
97+
using Button = GpioInputA0;
98+
99+
// 4 user colored LEDs aligned in a circle
100+
using LedGreen = GpioOutputD12;
101+
using LedOrange = GpioOutputD13;
102+
using LedRed = GpioOutputD14;
103+
using LedBlue = GpioOutputD15;
104+
using Leds = SoftwareGpioPort<LedGreen, LedBlue, LedRed, LedOrange>;
105+
/// @}
106+
107+
namespace lis3
108+
{
109+
/// @ingroup modm_board_disco_f411ve
110+
/// @{
111+
using Int = GpioInputE1; // LIS302DL_INT2
112+
113+
using Cs = GpioOutputE3; // LIS302DL_CS_I2C/SPI
114+
using Sck = GpioOutputA5; // SPI1_SCK
115+
using Mosi = GpioOutputA7; // SPI1_MOSI
116+
using Miso = GpioInputA6; // SPI1_MISO
117+
118+
using SpiMaster = SpiMaster1;
119+
using Transport = modm::Lis3TransportSpi<SpiMaster, Cs>;
120+
/// @}
121+
}
122+
123+
124+
namespace cs43
125+
{
126+
/// @ingroup modm_board_disco_f411ve
127+
/// @{
128+
using Lrck = GpioOutputA4; // I2S3_WS
129+
using Mclk = GpioOutputC7; // I2S3_MCK
130+
using Sclk = GpioOutputC10; // I2S3_SCK
131+
using Sdin = GpioOutputC12; // I2S3_SD
132+
133+
using Reset = GpioOutputD4; // Audio_RST
134+
using Scl = GpioB6; // Audio_SCL
135+
using Sda = GpioB9; // Audio_SDA
136+
137+
using I2cMaster = I2cMaster1;
138+
// using I2sMaster = I2sMaster3;
139+
/// @}
140+
}
141+
142+
143+
namespace mp45
144+
{
145+
/// @ingroup modm_board_disco_f411ve
146+
/// @{
147+
using Clk = GpioOutputB10; // CLK_IN: I2S2_CK
148+
using Dout = GpioInputC3; // PDM_OUT: I2S2_SD
149+
// using I2sMaster = I2sMaster2;
150+
/// @}
151+
}
152+
153+
154+
namespace usb
155+
{
156+
/// @ingroup modm_board_disco_f411ve
157+
/// @{
158+
using Vbus = GpioInputA9; // VBUS_FS: USB_OTG_HS_VBUS
159+
using Id = GpioA10; // OTG_FS_ID: USB_OTG_FS_ID
160+
using Dm = GpioA11; // OTG_FS_DM: USB_OTG_FS_DM
161+
using Dp = GpioA12; // OTG_FS_DP: USB_OTG_FS_DP
162+
163+
using Overcurrent = GpioInputD5; // OTG_FS_OverCurrent
164+
using Power = GpioOutputC0; // OTG_FS_PowerSwitchOn
165+
166+
using Device = UsbFs;
167+
/// @}
168+
}
169+
170+
/// @ingroup modm_board_disco_f411ve
171+
/// @{
172+
inline void
173+
initialize()
174+
{
175+
SystemClock::enable();
176+
SysTickTimer::initialize<SystemClock>();
177+
178+
Leds::setOutput(modm::Gpio::Low);
179+
LedUsb::setOutput(modm::Gpio::Low);
180+
181+
Button::setInput(Gpio::InputType::Floating);
182+
}
183+
184+
inline void
185+
initializeLis3()
186+
{
187+
lis3::Int::setInput();
188+
lis3::Cs::setOutput(modm::Gpio::High);
189+
190+
lis3::SpiMaster::connect<lis3::Sck::Sck, lis3::Mosi::Mosi, lis3::Miso::Miso>();
191+
lis3::SpiMaster::initialize<SystemClock, 5.25_MHz>();
192+
lis3::SpiMaster::setDataMode(lis3::SpiMaster::DataMode::Mode3);
193+
}
194+
195+
/// not supported yet, due to missing I2S driver
196+
inline void
197+
initializeCs43()
198+
{
199+
// cs43::Lrck::connect(cs43::I2sMaster::Ws);
200+
// cs43::Mclk::connect(cs43::I2sMaster::Mck);
201+
// cs43::Sclk::connect(cs43::I2sMaster::Ck);
202+
// cs43::Sdin::connect(cs43::I2sMaster::Sd);
203+
204+
cs43::Reset::setOutput(modm::Gpio::High);
205+
206+
cs43::I2cMaster::connect<cs43::Scl::Scl, cs43::Sda::Sda>();
207+
cs43::I2cMaster::initialize<SystemClock, 100_kHz>();
208+
}
209+
210+
/// not supported yet, due to missing I2S driver
211+
inline void
212+
initializeMp45()
213+
{
214+
// mp45::Clk::connect(mp45::I2sMaster::Ck);
215+
// mp45::Dout::connect(mp45::I2sMaster::Sd);
216+
}
217+
218+
inline void
219+
initializeUsbFs(uint8_t priority=3)
220+
{
221+
usb::Device::initialize<SystemClock>(priority);
222+
usb::Device::connect<usb::Dm::Dm, usb::Dp::Dp, usb::Id::Id>();
223+
224+
usb::Overcurrent::setInput();
225+
usb::Vbus::setInput();
226+
// Enable VBUS sense (B device) via pin PA9
227+
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS;
228+
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;
229+
}
230+
/// @}
231+
}

src/modm/board/disco_f411ve/board.xml

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">stm32f411vet6</option>
10+
</options>
11+
<modules>
12+
<module>modm:board:disco-f411ve</module>
13+
</modules>
14+
</library>

src/modm/board/disco_f411ve/module.lb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2024, Thomas Sommer
5+
#
6+
# This file is part of the modm project.
7+
#
8+
# This Source Code Form is subject to the terms of the Mozilla Public
9+
# License, v. 2.0. If a copy of the MPL was not distributed with this
10+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
11+
# -----------------------------------------------------------------------------
12+
13+
def init(module):
14+
module.name = ":board:disco-f411ve"
15+
module.description = """\
16+
# STM32F4DISCOVERY
17+
18+
[Discovery kit for STM32F411](https://www.st.com/en/evaluation-tools/32f411ediscovery.html)
19+
"""
20+
21+
def prepare(module, options):
22+
if not options[":target"].partname.startswith("stm32f411ve"):
23+
return False
24+
25+
module.depends(
26+
":architecture:clock",
27+
":driver:lis3dsh",
28+
":driver:lsm303a",
29+
":driver:l3gd20",
30+
":platform:clock",
31+
":platform:core",
32+
":platform:gpio",
33+
":platform:i2c:1",
34+
":platform:spi:1",
35+
":platform:usb:fs")
36+
return True
37+
38+
def build(env):
39+
env.outbasepath = "modm/src/modm/board"
40+
env.substitutions = {
41+
"with_logger": False,
42+
"with_assert": env.has_module(":architecture:assert")
43+
}
44+
env.template("../board.cpp.in", "board.cpp")
45+
env.copy('.')
46+
env.collect(":build:openocd.source", "board/stm32f4discovery.cfg");

0 commit comments

Comments
 (0)