Skip to content

Commit 3058774

Browse files
committed
[board] Add Nucleo-G070RB
1 parent 623a13b commit 3058774

File tree

4 files changed

+222
-7
lines changed

4 files changed

+222
-7
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -657,40 +657,41 @@ We have out-of-box support for many development boards including documentation.
657657
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f746zg">NUCLEO-F746ZG</a></td>
658658
</tr><tr>
659659
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f767zi">NUCLEO-F767ZI</a></td>
660+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g070rb">NUCLEO-G070RB</a></td>
660661
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g071rb">NUCLEO-G071RB</a></td>
661662
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431kb">NUCLEO-G431KB</a></td>
662-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431rb">NUCLEO-G431RB</a></td>
663663
</tr><tr>
664+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431rb">NUCLEO-G431RB</a></td>
664665
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g474re">NUCLEO-G474RE</a></td>
665666
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h723zg">NUCLEO-H723ZG</a></td>
666667
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h743zi">NUCLEO-H743ZI</a></td>
667-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l031k6">NUCLEO-L031K6</a></td>
668668
</tr><tr>
669+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l031k6">NUCLEO-L031K6</a></td>
669670
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l053r8">NUCLEO-L053R8</a></td>
670671
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l152re">NUCLEO-L152RE</a></td>
671672
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l432kc">NUCLEO-L432KC</a></td>
672-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l452re">NUCLEO-L452RE</a></td>
673673
</tr><tr>
674+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l452re">NUCLEO-L452RE</a></td>
674675
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l476rg">NUCLEO-L476RG</a></td>
675676
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l496zg-p">NUCLEO-L496ZG-P</a></td>
676677
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l552ze-q">NUCLEO-L552ZE-Q</a></td>
677-
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-u575zi-q">NUCLEO-U575ZI-Q</a></td>
678678
</tr><tr>
679+
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-u575zi-q">NUCLEO-U575ZI-Q</a></td>
679680
<td align="center"><a href="https://modm.io/reference/config/modm-olimexino-stm32">OLIMEXINO-STM32</a></td>
680681
<td align="center"><a href="https://modm.io/reference/config/modm-rp-pico">Raspberry Pi Pico</a></td>
681682
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-mini">SAMD21-MINI</a></td>
682-
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-xplained-pro">SAMD21-XPLAINED-PRO</a></td>
683683
</tr><tr>
684+
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-xplained-pro">SAMD21-XPLAINED-PRO</a></td>
684685
<td align="center"><a href="https://modm.io/reference/config/modm-same54-xplained-pro">SAME54-XPLAINED-PRO</a></td>
685686
<td align="center"><a href="https://modm.io/reference/config/modm-same70-xplained">SAME70-XPLAINED</a></td>
686687
<td align="center"><a href="https://modm.io/reference/config/modm-samg55-xplained-pro">SAMG55-XPLAINED-PRO</a></td>
687-
<td align="center"><a href="https://modm.io/reference/config/modm-samv71-xplained-ultra">SAMV71-XPLAINED-ULTRA</a></td>
688688
</tr><tr>
689+
<td align="center"><a href="https://modm.io/reference/config/modm-samv71-xplained-ultra">SAMV71-XPLAINED-ULTRA</a></td>
689690
<td align="center"><a href="https://modm.io/reference/config/modm-srxe">Smart Response XE</a></td>
690691
<td align="center"><a href="https://modm.io/reference/config/modm-stm32_f4ve">STM32-F4VE</a></td>
691692
<td align="center"><a href="https://modm.io/reference/config/modm-stm32f030_demo">STM32F030-DEMO</a></td>
692-
<td align="center"><a href="https://modm.io/reference/config/modm-thingplus-rp2040">THINGPLUS-RP2040</a></td>
693693
</tr><tr>
694+
<td align="center"><a href="https://modm.io/reference/config/modm-thingplus-rp2040">THINGPLUS-RP2040</a></td>
694695
</tr>
695696
</table>
696697
<!--/bsptable-->
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
/*
2+
* Copyright (c) 2019, Niklas Hauser
3+
* Copyright (c) 2023, Christopher Durand
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+
#ifndef MODM_STM32_NUCLEO_G070RB_HPP
13+
#define MODM_STM32_NUCLEO_G070RB_HPP
14+
15+
#include <modm/platform.hpp>
16+
#include <modm/architecture/interface/clock.hpp>
17+
#include <modm/debug/logger.hpp>
18+
/// @ingroup modm_board_nucleo_g070rb
19+
#define MODM_BOARD_HAS_LOGGER
20+
21+
using namespace modm::platform;
22+
23+
namespace Board
24+
{
25+
/// @ingroup modm_board_nucleo_g070rb
26+
/// @{
27+
using namespace modm::literals;
28+
29+
/// STM32G070RB running at 64MHz generated from the internal 16MHz oscillator
30+
struct SystemClock
31+
{
32+
static constexpr uint32_t Frequency = 64_MHz;
33+
static constexpr uint32_t Ahb = Frequency;
34+
static constexpr uint32_t Apb = Frequency;
35+
36+
static constexpr uint32_t Rng = Ahb;
37+
static constexpr uint32_t Crc = Ahb;
38+
static constexpr uint32_t Flash = Ahb;
39+
static constexpr uint32_t Exti = Ahb;
40+
static constexpr uint32_t Rcc = Ahb;
41+
static constexpr uint32_t Dmamux = Ahb;
42+
static constexpr uint32_t Dma = Ahb;
43+
44+
static constexpr uint32_t Dbg = Apb;
45+
static constexpr uint32_t Timer17 = Apb;
46+
static constexpr uint32_t Timer16 = Apb;
47+
static constexpr uint32_t Timer15 = Apb;
48+
static constexpr uint32_t Usart1 = Apb;
49+
static constexpr uint32_t Spi1 = Apb;
50+
static constexpr uint32_t I2s1 = Apb;
51+
static constexpr uint32_t Timer1 = Apb;
52+
static constexpr uint32_t Adc1 = Apb;
53+
static constexpr uint32_t ItLine = Apb;
54+
static constexpr uint32_t SysCfg = Apb;
55+
static constexpr uint32_t Tamp = Apb;
56+
static constexpr uint32_t Bkp = Apb;
57+
static constexpr uint32_t Ucpd2 = Apb;
58+
static constexpr uint32_t Ucpd1 = Apb;
59+
static constexpr uint32_t Dac = Apb;
60+
static constexpr uint32_t Pwr = Apb;
61+
static constexpr uint32_t I2c2 = Apb;
62+
static constexpr uint32_t I2c1 = Apb;
63+
static constexpr uint32_t Usart4 = Apb;
64+
static constexpr uint32_t Usart3 = Apb;
65+
static constexpr uint32_t Usart2 = Apb;
66+
static constexpr uint32_t Spi2 = Apb;
67+
static constexpr uint32_t Iwdg = Apb;
68+
static constexpr uint32_t Wwdg = Apb;
69+
static constexpr uint32_t Rtc = Apb;
70+
static constexpr uint32_t Timer14 = Apb;
71+
static constexpr uint32_t Timer7 = Apb;
72+
static constexpr uint32_t Timer6 = Apb;
73+
static constexpr uint32_t Timer3 = Apb;
74+
75+
static bool inline
76+
enable()
77+
{
78+
Rcc::enableInternalClock(); // 16MHz
79+
// (internal clock / 1_M) * 8_N / 2_R = 128MHz / 2 = 64MHz
80+
const Rcc::PllFactors pllFactors{
81+
.pllM = 1,
82+
.pllN = 8,
83+
.pllR = 2,
84+
};
85+
Rcc::enablePll(Rcc::PllSource::InternalClock, pllFactors);
86+
Rcc::setFlashLatency<Frequency>();
87+
// switch system clock to PLL output
88+
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll);
89+
Rcc::setAhbPrescaler(Rcc::AhbPrescaler::Div1);
90+
Rcc::setApbPrescaler(Rcc::ApbPrescaler::Div1);
91+
// update frequencies for busy-wait delay functions
92+
Rcc::updateCoreFrequency<Frequency>();
93+
94+
return true;
95+
}
96+
};
97+
98+
// Arduino Footprint
99+
using A0 = GpioA0;
100+
using A1 = GpioA1;
101+
using A2 = GpioA4;
102+
using A3 = GpioB1;
103+
using A4 = GpioB11;
104+
using A5 = GpioB12;
105+
106+
using D0 = GpioC5;
107+
using D1 = GpioC4;
108+
using D2 = GpioA10;
109+
using D3 = GpioB3;
110+
using D4 = GpioB5;
111+
using D5 = GpioB4;
112+
using D6 = GpioB14;
113+
using D7 = GpioA8;
114+
using D8 = GpioA9;
115+
using D9 = GpioC7;
116+
using D10 = GpioB0;
117+
using D11 = GpioA7;
118+
using D12 = GpioA6;
119+
using D13 = GpioA5;
120+
using D14 = GpioB9;
121+
using D15 = GpioB8;
122+
123+
using Button = GpioInverted<GpioInputC13>;
124+
using LedD13 = D13;
125+
126+
using Leds = SoftwareGpioPort< LedD13 >;
127+
/// @}
128+
129+
namespace stlink
130+
{
131+
/// @ingroup modm_board_nucleo_g070rb
132+
/// @{
133+
using Rx = GpioInputA3;
134+
using Tx = GpioOutputA2;
135+
using Uart = Usart2;
136+
/// @}
137+
}
138+
139+
/// @ingroup modm_board_nucleo_g070rb
140+
/// @{
141+
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
142+
143+
inline void
144+
initialize()
145+
{
146+
SystemClock::enable();
147+
SysTickTimer::initialize<SystemClock>();
148+
149+
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
150+
stlink::Uart::initialize<SystemClock, 115200_Bd>();
151+
152+
Button::setInput();
153+
}
154+
/// @}
155+
156+
}
157+
158+
#endif // MODM_STM32_NUCLEO_G070RB_HPP
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<library>
2+
<repositories>
3+
<repository>
4+
<path>../../../../repo.lb</path>
5+
</repository>
6+
</repositories>
7+
8+
<options>
9+
<option name="modm:target">stm32g070rbt6</option>
10+
<option name="modm:platform:uart:2:buffer.tx">2Ki</option>
11+
</options>
12+
<modules>
13+
<module>modm:board:nucleo-g070rb</module>
14+
</modules>
15+
</library>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2019, Niklas Hauser
5+
# Copyright (c) 2023, Christopher Durand
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-g070rb"
16+
module.description = """\
17+
# NUCLEO-G070RB
18+
19+
[Nucleo kit for STM32G070RB](https://www.st.com/en/evaluation-tools/nucleo-g070rb.html)
20+
"""
21+
22+
def prepare(module, options):
23+
if not options[":target"].partname.startswith("stm32g070rbt"):
24+
return False
25+
26+
module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:2",
27+
":debug", ":architecture:clock")
28+
return True
29+
30+
def build(env):
31+
env.outbasepath = "modm/src/modm/board"
32+
env.substitutions = {
33+
"with_logger": True,
34+
"with_assert": env.has_module(":architecture:assert")
35+
}
36+
env.template("../board.cpp.in", "board.cpp")
37+
env.copy('.')
38+
39+
env.outbasepath = "modm/openocd/modm/board/"
40+
env.copy(repopath("tools/openocd/modm/st_nucleo_g0.cfg"), "st_nucleo_g0.cfg")
41+
env.collect(":build:openocd.source", "modm/board/st_nucleo_g0.cfg")

0 commit comments

Comments
 (0)