Skip to content

Commit 46cb036

Browse files
committed
[board] Add Nucleo H755ZI-Q
1 parent a518b9f commit 46cb036

File tree

5 files changed

+434
-0
lines changed

5 files changed

+434
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Copyright (c) 2022, Christopher Durand
3+
* Copyright (c) 2017, 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+
// Nucleo144 Arduino Header Footprint
14+
15+
#ifndef MODM_STM32_NUCLEO144_ARDUINO_H745_55_HPP
16+
#define MODM_STM32_NUCLEO144_ARDUINO_H745_55_HPP
17+
18+
// Arduino Footprint
19+
using A0 = GpioA3;
20+
using A1 = GpioC0;
21+
using A2 = GpioC3;
22+
using A3 = GpioB1;
23+
using A4 = GpioC2;
24+
using A5 = GpioF11;
25+
// Zio Footprint
26+
using A6 = GpioF6;
27+
using A7 = GpioF10;
28+
using A8 = GpioA2; // RMII_MDIO
29+
30+
// Arduino Footprint
31+
using D0 = GpioB7;
32+
using D1 = GpioB6;
33+
using D2 = GpioG14;
34+
using D3 = GpioE13;
35+
using D4 = GpioE14;
36+
using D5 = GpioE11;
37+
using D6 = GpioA8;
38+
using D7 = GpioG12; // SMPS PG
39+
using D8 = GpioG9; // SMPS EN
40+
using D9 = GpioD15;
41+
using D10 = GpioD14;
42+
using D11 = GpioB5;
43+
using D12 = GpioA6;
44+
using D13 = GpioA5;
45+
using D14 = GpioB9;
46+
using D15 = GpioB8;
47+
// Zio Footprint
48+
using D16 = GpioC6;
49+
using D17 = GpioB15;
50+
using D18 = GpioB13; // RMII TXD1
51+
using D19 = GpioB12;
52+
using D20 = GpioA15;
53+
using D21 = GpioC7;
54+
using D22 = GpioB5;
55+
using D23 = GpioB3; // SWO
56+
using D24 = GpioA4;
57+
using D25 = GpioB4;
58+
using D26 = GpioG6;
59+
using D27 = GpioB2;
60+
using D28 = GpioD13;
61+
using D29 = GpioD12;
62+
using D30 = GpioD11;
63+
using D31 = GpioE2;
64+
using D32 = GpioA0;
65+
using D33 = GpioB0;
66+
using D34 = GpioE0;
67+
using D35 = GpioB11;
68+
using D36 = GpioB10;
69+
using D37 = GpioE15;
70+
using D38 = GpioE6;
71+
using D39 = GpioE12;
72+
using D40 = GpioE10;
73+
using D41 = GpioE7;
74+
using D42 = GpioE8;
75+
using D43 = GpioC8;
76+
using D44 = GpioC9;
77+
using D45 = GpioC10;
78+
using D46 = GpioC11;
79+
using D47 = GpioC12;
80+
using D48 = GpioD2;
81+
using D49 = GpioG10; // SMPS_SW
82+
using D50 = GpioG8; // SMPS V1
83+
using D51 = GpioD7;
84+
using D52 = GpioD6;
85+
using D53 = GpioD5;
86+
using D54 = GpioD4;
87+
using D55 = GpioD3;
88+
using D56 = GpioE2;
89+
using D57 = GpioE4;
90+
using D58 = GpioE5;
91+
using D59 = GpioE6;
92+
using D60 = GpioE3;
93+
using D61 = GpioF8;
94+
using D62 = GpioF7;
95+
using D63 = GpioF9;
96+
using D64 = GpioD10; // USB_FS_PWR_EN
97+
using D65 = GpioB14; // LED RED
98+
using D66 = GpioD1;
99+
using D67 = GpioD0;
100+
using D68 = GpioF15;
101+
using D69 = GpioF14;
102+
using D70 = GpioB5;
103+
using D71 = GpioE9;
104+
using D72 = GpioB2;
105+
106+
#endif // MODM_STM32_NUCLEO144_ARDUINO_H745_55_HPP
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
/*
2+
* Copyright (c) 2021-2022, 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_h755zi-q
22+
#define MODM_BOARD_HAS_LOGGER
23+
24+
namespace Board
25+
{
26+
/// @ingroup modm_board_nucleo_h755zi-q
27+
/// @{
28+
using namespace modm::literals;
29+
30+
/// STM32H755 running at 480MHz from the external 8MHz HSE
31+
struct SystemClock
32+
{
33+
static constexpr uint32_t SysClk = 480_MHz;
34+
35+
// Max 480MHz
36+
static constexpr uint32_t Hclk = SysClk / 1; // D1CPRE
37+
// Max 240MHz
38+
static constexpr uint32_t Ahb = Hclk / 2; // HPRE
39+
40+
#ifdef CORE_CM7
41+
static constexpr uint32_t Frequency = Hclk;
42+
#else
43+
static constexpr uint32_t Frequency = Ahb;
44+
#endif
45+
46+
// Max 240MHz
47+
static constexpr uint32_t Ahb1 = Ahb;
48+
static constexpr uint32_t Ahb2 = Ahb;
49+
static constexpr uint32_t Ahb3 = Ahb;
50+
static constexpr uint32_t Ahb4 = Ahb;
51+
// Max 120MHz
52+
static constexpr uint32_t Apb1 = Ahb / 2; // D2PPRE1
53+
static constexpr uint32_t Apb2 = Ahb / 2; // D2PPRE2
54+
static constexpr uint32_t Apb3 = Ahb / 2; // D1PPRE
55+
static constexpr uint32_t Apb4 = Ahb / 2; // D3PPRE
56+
57+
static constexpr uint32_t Adc1 = Ahb1;
58+
static constexpr uint32_t Adc2 = Ahb1;
59+
static constexpr uint32_t Adc3 = Ahb4;
60+
61+
static constexpr uint32_t Dac1 = Apb1;
62+
static constexpr uint32_t Dac2 = Apb1;
63+
64+
static constexpr uint32_t Spi1 = Apb2;
65+
static constexpr uint32_t Spi2 = Apb1;
66+
static constexpr uint32_t Spi3 = Apb1;
67+
static constexpr uint32_t Spi4 = Apb2;
68+
static constexpr uint32_t Spi5 = Apb2;
69+
static constexpr uint32_t Spi6 = Apb4;
70+
71+
static constexpr uint32_t Usart1 = Apb2;
72+
static constexpr uint32_t Usart2 = Apb1;
73+
static constexpr uint32_t Usart3 = Apb1;
74+
static constexpr uint32_t Uart4 = Apb1;
75+
static constexpr uint32_t Uart5 = Apb1;
76+
static constexpr uint32_t Usart6 = Apb2;
77+
static constexpr uint32_t Uart7 = Apb1;
78+
static constexpr uint32_t Uart8 = Apb1;
79+
80+
static constexpr uint32_t LpUart1 = Apb4;
81+
82+
static constexpr uint32_t Can1 = Apb1;
83+
static constexpr uint32_t Can2 = Apb1;
84+
85+
static constexpr uint32_t I2c1 = Apb1;
86+
static constexpr uint32_t I2c2 = Apb1;
87+
static constexpr uint32_t I2c3 = Apb1;
88+
static constexpr uint32_t I2c4 = Apb4;
89+
90+
static constexpr uint32_t Apb1Timer = Apb1 * 2;
91+
static constexpr uint32_t Apb2Timer = Apb2 * 2;
92+
static constexpr uint32_t Timer1 = Apb2Timer;
93+
static constexpr uint32_t Timer2 = Apb1Timer;
94+
static constexpr uint32_t Timer3 = Apb1Timer;
95+
static constexpr uint32_t Timer4 = Apb1Timer;
96+
static constexpr uint32_t Timer5 = Apb1Timer;
97+
static constexpr uint32_t Timer6 = Apb1Timer;
98+
static constexpr uint32_t Timer7 = Apb1Timer;
99+
static constexpr uint32_t Timer8 = Apb2Timer;
100+
static constexpr uint32_t Timer12 = Apb1Timer;
101+
static constexpr uint32_t Timer13 = Apb1Timer;
102+
static constexpr uint32_t Timer14 = Apb1Timer;
103+
static constexpr uint32_t Timer15 = Apb2Timer;
104+
static constexpr uint32_t Timer16 = Apb2Timer;
105+
static constexpr uint32_t Timer17 = Apb2Timer;
106+
107+
static constexpr uint32_t Usb = 48_MHz;
108+
109+
#ifdef CORE_CM7
110+
static bool inline
111+
enable()
112+
{
113+
Rcc::enableExternalClock(); // 8 MHz
114+
Rcc::setVoltageScaling(Rcc::VoltageScaling::Scale0); // required for 480MHz
115+
const Rcc::PllFactors pllFactors {
116+
.range = Rcc::PllInputRange::MHz4_8,
117+
.pllM = 1, // 8MHz / M= 8MHz
118+
.pllN = 120, // 8MHz * N= 960MHz
119+
.pllP = 2, // 960MHz / P= 480MHz = F_cpu
120+
.pllQ = 20, // 960MHz / Q= 48MHz
121+
.pllR = 2, // 960MHz / R= 480MHz
122+
};
123+
Rcc::enablePll1(Rcc::PllSource::ExternalClock, pllFactors);
124+
Rcc::setFlashLatency<Ahb>();
125+
// max 240MHz on AHB
126+
Rcc::setAhbPrescaler(Rcc::AhbPrescaler::Div2);
127+
// max 120MHz on APB
128+
Rcc::setApb1Prescaler(Rcc::Apb1Prescaler::Div2);
129+
Rcc::setApb2Prescaler(Rcc::Apb2Prescaler::Div2);
130+
Rcc::setApb3Prescaler(Rcc::Apb3Prescaler::Div2);
131+
Rcc::setApb4Prescaler(Rcc::Apb4Prescaler::Div2);
132+
// update clock frequencies
133+
Rcc::updateCoreFrequency<Frequency>();
134+
Rcc::enableUsbClockSource(Rcc::UsbClockSource::Pll1Q);
135+
// Switch the main clock source to PLL
136+
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll1P);
137+
return true;
138+
}
139+
#else
140+
static bool inline
141+
enable()
142+
{
143+
Rcc::updateCoreFrequency<Frequency>();
144+
return true;
145+
}
146+
#endif
147+
};
148+
149+
// Arduino Footprint
150+
#include "nucleo144_arduino_h745_55.hpp"
151+
152+
using Button = GpioInputC13;
153+
154+
using LedGreen = GpioOutputB0;
155+
using LedYellow = GpioOutputE1;
156+
using LedRed = GpioOutputB14;
157+
using Leds = SoftwareGpioPort<LedRed, LedYellow, LedGreen>;
158+
159+
namespace usb
160+
{
161+
using Vbus = GpioA9;
162+
using Id = GpioA10;
163+
using Dm = GpioA11;
164+
using Dp = GpioA12;
165+
166+
using Overcurrent = GpioInputG7; // OTG_FS_OverCurrent
167+
using Power = GpioOutputD10; // OTG_FS_PowerSwitchOn
168+
169+
using Device = UsbFs;
170+
}
171+
172+
namespace stlink
173+
{
174+
using Tx = GpioOutputD8;
175+
using Rx = GpioInputD9;
176+
using Uart = Usart3;
177+
}
178+
179+
#ifdef CORE_CM7
180+
using LoggerDevice = modm::IODeviceWrapper<stlink::Uart, modm::IOBuffer::BlockIfFull>;
181+
#endif
182+
183+
inline void
184+
initialize()
185+
{
186+
SystemClock::enable();
187+
SysTickTimer::initialize<SystemClock>();
188+
189+
#ifdef CORE_CM7
190+
Rcc::bootCortexM4();
191+
192+
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
193+
stlink::Uart::initialize<SystemClock, 115200_Bd>();
194+
195+
LedGreen::setOutput(modm::Gpio::Low);
196+
LedYellow::setOutput(modm::Gpio::Low);
197+
LedRed::setOutput(modm::Gpio::Low);
198+
199+
Button::setInput();
200+
#endif
201+
}
202+
203+
inline void
204+
initializeUsbFs(uint8_t priority=3)
205+
{
206+
usb::Device::initialize<SystemClock>(priority);
207+
usb::Device::connect<usb::Dm::Dm, usb::Dp::Dp, usb::Id::Id>();
208+
usb::Id::configure(Gpio::InputType::Floating);
209+
210+
usb::Overcurrent::setInput();
211+
usb::Vbus::setInput();
212+
// Enable VBUS sense (B device) via pin PA9
213+
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
214+
}
215+
216+
}
217+
/// @}
218+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<library>
2+
<repositories>
3+
<repository>
4+
<path>../../../../repo.lb</path>
5+
</repository>
6+
</repositories>
7+
8+
<options>
9+
<!-- target has to be defined in project.xml -->
10+
<!-- <option name="modm:target">stm32h755zit6@m7</option> or -->
11+
<!-- <option name="modm:target">stm32h755zit6@m4</option> -->
12+
13+
<option name="modm:platform:uart:3:buffer.tx">2048</option>
14+
</options>
15+
<modules>
16+
<module>modm:board:nucleo-h755zi-q</module>
17+
</modules>
18+
</library>

0 commit comments

Comments
 (0)