Skip to content

Commit c84e72e

Browse files
chris-durandsalkinium
authored andcommitted
[board] Add NUCLEO-H723ZG BSP
1 parent a495194 commit c84e72e

File tree

5 files changed

+269
-3
lines changed

5 files changed

+269
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,20 +509,21 @@ We have out-of-box support for many development boards including documentation.
509509
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-g431rb">NUCLEO-G431RB</a></td>
510510
</tr><tr>
511511
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-g474re">NUCLEO-G474RE</a></td>
512+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-h723zg">NUCLEO-H723ZG</a></td>
512513
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-h743zi">NUCLEO-H743ZI</a></td>
513514
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l031k6">NUCLEO-L031K6</a></td>
514-
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l152re">NUCLEO-L152RE</a></td>
515515
</tr><tr>
516+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l152re">NUCLEO-L152RE</a></td>
516517
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l432kc">NUCLEO-L432KC</a></td>
517518
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l452re">NUCLEO-L452RE</a></td>
518519
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l476rg">NUCLEO-L476RG</a></td>
519-
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l496zg-p">NUCLEO-L496ZG-P</a></td>
520520
</tr><tr>
521+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l496zg-p">NUCLEO-L496ZG-P</a></td>
521522
<td align="center"><a href="https://modm.io/reference/module/modm-board-olimexino-stm32">OLIMEXINO-STM32</a></td>
522523
<td align="center"><a href="https://modm.io/reference/module/modm-board-raspberrypi">Raspberry Pi</a></td>
523524
<td align="center"><a href="https://modm.io/reference/module/modm-board-samd21-mini">SAMD21-MINI</a></td>
524-
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32_f4ve">STM32-F4VE</a></td>
525525
</tr><tr>
526+
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32_f4ve">STM32-F4VE</a></td>
526527
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32f030_demo">STM32F030-DEMO</a></td>
527528
</tr>
528529
</table>
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/*
2+
* Copyright (c) 2021, Christopher Durand
3+
* Copyright (c) 2021, 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_h723zg
22+
/// @{
23+
#define MODM_BOARD_HAS_LOGGER
24+
25+
namespace Board
26+
{
27+
using namespace modm::literals;
28+
29+
/// STM32H723ZG running at 500MHz from PLL clock generated from 8 MHz HSE
30+
struct SystemClock
31+
{
32+
// Max 550MHz
33+
static constexpr uint32_t SysClk = 550_MHz;
34+
// Max 550MHz
35+
static constexpr uint32_t Hclk = SysClk / 1; // D1CPRE
36+
static constexpr uint32_t Frequency = Hclk;
37+
// Max 275MHz
38+
static constexpr uint32_t Ahb = Hclk / 2; // HPRE
39+
static constexpr uint32_t Ahb1 = Ahb;
40+
static constexpr uint32_t Ahb2 = Ahb;
41+
static constexpr uint32_t Ahb3 = Ahb;
42+
static constexpr uint32_t Ahb4 = Ahb;
43+
// Max 137.5MHz
44+
static constexpr uint32_t Apb1 = Ahb / 2; // D2PPRE1
45+
static constexpr uint32_t Apb2 = Ahb / 2; // D2PPRE2
46+
static constexpr uint32_t Apb3 = Ahb / 2; // D1PPRE
47+
static constexpr uint32_t Apb4 = Ahb / 2; // D3PPRE
48+
49+
static constexpr uint32_t Adc1 = Ahb1;
50+
static constexpr uint32_t Adc2 = Ahb1;
51+
static constexpr uint32_t Adc3 = Ahb4;
52+
53+
static constexpr uint32_t Dac1 = Apb1;
54+
55+
static constexpr uint32_t Spi1 = Apb2;
56+
static constexpr uint32_t Spi2 = Apb1;
57+
static constexpr uint32_t Spi3 = Apb1;
58+
static constexpr uint32_t Spi4 = Apb2;
59+
static constexpr uint32_t Spi5 = Apb2;
60+
static constexpr uint32_t Spi6 = Apb4;
61+
62+
static constexpr uint32_t Usart1 = Apb2;
63+
static constexpr uint32_t Usart2 = Apb1;
64+
static constexpr uint32_t Usart3 = Apb1;
65+
static constexpr uint32_t Uart4 = Apb1;
66+
static constexpr uint32_t Uart5 = Apb1;
67+
static constexpr uint32_t Usart6 = Apb2;
68+
static constexpr uint32_t Uart7 = Apb1;
69+
static constexpr uint32_t Uart8 = Apb1;
70+
static constexpr uint32_t Uart9 = Apb2;
71+
static constexpr uint32_t Usart10 = Apb2;
72+
73+
static constexpr uint32_t LpUart1 = Apb4;
74+
75+
static constexpr uint32_t Can1 = Apb1;
76+
static constexpr uint32_t Can2 = Apb1;
77+
78+
static constexpr uint32_t I2c1 = Apb1;
79+
static constexpr uint32_t I2c2 = Apb1;
80+
static constexpr uint32_t I2c3 = Apb1;
81+
static constexpr uint32_t I2c4 = Apb4;
82+
static constexpr uint32_t I2c5 = Apb1;
83+
84+
static constexpr uint32_t Apb1Timer = Apb1 * 2;
85+
static constexpr uint32_t Apb2Timer = Apb2 * 2;
86+
static constexpr uint32_t Timer1 = Apb2Timer;
87+
static constexpr uint32_t Timer2 = Apb1Timer;
88+
static constexpr uint32_t Timer3 = Apb1Timer;
89+
static constexpr uint32_t Timer4 = Apb1Timer;
90+
static constexpr uint32_t Timer5 = Apb1Timer;
91+
static constexpr uint32_t Timer6 = Apb1Timer;
92+
static constexpr uint32_t Timer7 = Apb1Timer;
93+
static constexpr uint32_t Timer8 = Apb2Timer;
94+
static constexpr uint32_t Timer12 = Apb1Timer;
95+
static constexpr uint32_t Timer13 = Apb1Timer;
96+
static constexpr uint32_t Timer14 = Apb1Timer;
97+
static constexpr uint32_t Timer15 = Apb2Timer;
98+
static constexpr uint32_t Timer16 = Apb2Timer;
99+
static constexpr uint32_t Timer17 = Apb2Timer;
100+
static constexpr uint32_t Timer23 = Apb1Timer;
101+
static constexpr uint32_t Timer24 = Apb1Timer;
102+
103+
static constexpr uint32_t Usb = Ahb1;
104+
105+
static bool inline
106+
enable()
107+
{
108+
// Switch core supply voltage to maximum level
109+
// Required for running at 550 MHz
110+
Rcc::setVoltageScaling(Rcc::VoltageScaling::Scale0);
111+
112+
Rcc::enableExternalClock(); // 8 MHz
113+
const Rcc::PllFactors pllFactors1{
114+
.range = Rcc::PllInputRange::MHz1_2,
115+
.pllM = 4, // 8 MHz / 4 = 2 MHz
116+
.pllN = 275, // 2 MHz * 275 = 550 MHz
117+
.pllP = 1, // 500 MHz / 1 = 550 MHz
118+
.pllQ = 2, // 500 MHz / 2 = 275 MHz
119+
.pllR = 2, // 500 MHz / 2 = 275 MHz
120+
};
121+
Rcc::enablePll1(Rcc::PllSource::Hse, pllFactors1);
122+
Rcc::setFlashLatency<Ahb>();
123+
124+
// max. 275MHz
125+
Rcc::setAhbPrescaler(Rcc::AhbPrescaler::Div2);
126+
// max. 137.5MHz on Apb clocks
127+
Rcc::setApb1Prescaler(Rcc::Apb1Prescaler::Div2);
128+
Rcc::setApb2Prescaler(Rcc::Apb2Prescaler::Div2);
129+
Rcc::setApb3Prescaler(Rcc::Apb3Prescaler::Div2);
130+
Rcc::setApb4Prescaler(Rcc::Apb4Prescaler::Div2);
131+
132+
// update clock frequencies
133+
Rcc::updateCoreFrequency<Frequency>();
134+
// switch system clock to pll
135+
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll1P);
136+
137+
return true;
138+
}
139+
140+
};
141+
142+
// Arduino Footprint
143+
#include "nucleo144_arduino.hpp"
144+
145+
using Button = GpioInputC13;
146+
147+
using LedGreen = GpioOutputB0;
148+
using LedYellow = GpioOutputE1;
149+
using LedRed = GpioOutputB14;
150+
using Leds = SoftwareGpioPort< LedRed, LedYellow, LedGreen >;
151+
152+
namespace stlink
153+
{
154+
using Tx = GpioOutputD8;
155+
using Rx = GpioInputD9;
156+
using Uart = Usart3;
157+
}
158+
159+
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
160+
161+
162+
inline void
163+
initialize()
164+
{
165+
SystemClock::enable();
166+
SysTickTimer::initialize<SystemClock>();
167+
168+
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
169+
stlink::Uart::initialize<SystemClock, 115200_Bd>();
170+
171+
LedGreen::setOutput(modm::Gpio::Low);
172+
LedYellow::setOutput(modm::Gpio::Low);
173+
LedRed::setOutput(modm::Gpio::Low);
174+
175+
Button::setInput();
176+
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge);
177+
Button::enableExternalInterrupt();
178+
// Button::enableExternalInterruptVector(12);
179+
}
180+
181+
}
182+
/// @}
183+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<library>
2+
<repositories>
3+
<repository>
4+
<path>../../../../repo.lb</path>
5+
</repository>
6+
</repositories>
7+
8+
<options>
9+
<option name="modm:target">stm32h723zgt6</option>
10+
11+
<option name="modm:platform:uart:3:buffer.tx">2048</option>
12+
</options>
13+
<modules>
14+
<module>modm:board:nucleo-h723zg</module>
15+
</modules>
16+
</library>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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:nucleo-h723zg"
16+
module.description = """\
17+
# NUCLEO-H723ZG
18+
19+
[Nucleo kit for STM32H723ZG](https://www.st.com/en/evaluation-tools/nucleo-h723zg.html)
20+
"""
21+
22+
def prepare(module, options):
23+
if not options[":target"].partname.startswith("stm32h723zgt"):
24+
return False
25+
26+
module.depends(
27+
":debug",
28+
":architecture:clock",
29+
":platform:core",
30+
":platform:gpio",
31+
":platform:clock",
32+
":platform:uart:3")
33+
34+
return True
35+
36+
def build(env):
37+
env.outbasepath = "modm/src/modm/board"
38+
env.substitutions = {
39+
"with_logger": True,
40+
"with_assert": env.has_module(":architecture:assert")
41+
}
42+
env.template("../board.cpp.in", "board.cpp")
43+
env.copy('.')
44+
env.copy("../nucleo144_arduino.hpp", "nucleo144_arduino.hpp")
45+
env.collect(":build:openocd.source", "board/st_nucleo_h743zi.cfg");
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2021, Christopher Durand
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/platform.hpp>
13+
14+
using namespace modm::platform;
15+
16+
extern "C" void
17+
modm_initialize_platform(void)
18+
{
19+
// Configure internal voltage regulator
20+
Rcc::configurePowerSource(Rcc::PowerSource::Ldo);
21+
}

0 commit comments

Comments
 (0)