Skip to content

Commit

Permalink
[board] Add Nucleo-G070RB
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-durand authored and salkinium committed Feb 2, 2024
1 parent 2e40ab4 commit e5fb526
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 7 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,40 +657,41 @@ We have out-of-box support for many development boards including documentation.
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f746zg">NUCLEO-F746ZG</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f767zi">NUCLEO-F767ZI</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g070rb">NUCLEO-G070RB</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g071rb">NUCLEO-G071RB</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431kb">NUCLEO-G431KB</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431rb">NUCLEO-G431RB</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431rb">NUCLEO-G431RB</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g474re">NUCLEO-G474RE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h723zg">NUCLEO-H723ZG</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h743zi">NUCLEO-H743ZI</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l031k6">NUCLEO-L031K6</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l031k6">NUCLEO-L031K6</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l053r8">NUCLEO-L053R8</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l152re">NUCLEO-L152RE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l432kc">NUCLEO-L432KC</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l452re">NUCLEO-L452RE</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l452re">NUCLEO-L452RE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l476rg">NUCLEO-L476RG</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l496zg-p">NUCLEO-L496ZG-P</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l552ze-q">NUCLEO-L552ZE-Q</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-u575zi-q">NUCLEO-U575ZI-Q</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-u575zi-q">NUCLEO-U575ZI-Q</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-olimexino-stm32">OLIMEXINO-STM32</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-rp-pico">Raspberry Pi Pico</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-mini">SAMD21-MINI</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-xplained-pro">SAMD21-XPLAINED-PRO</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-xplained-pro">SAMD21-XPLAINED-PRO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-same54-xplained-pro">SAME54-XPLAINED-PRO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-same70-xplained">SAME70-XPLAINED</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-samg55-xplained-pro">SAMG55-XPLAINED-PRO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-samv71-xplained-ultra">SAMV71-XPLAINED-ULTRA</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-samv71-xplained-ultra">SAMV71-XPLAINED-ULTRA</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-srxe">Smart Response XE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-stm32_f4ve">STM32-F4VE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-stm32f030_demo">STM32F030-DEMO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-thingplus-rp2040">THINGPLUS-RP2040</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-thingplus-rp2040">THINGPLUS-RP2040</a></td>
</tr>
</table>
<!--/bsptable-->
Expand Down
158 changes: 158 additions & 0 deletions src/modm/board/nucleo_g070rb/board.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
* Copyright (c) 2019, Niklas Hauser
* Copyright (c) 2023, Christopher Durand
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#ifndef MODM_STM32_NUCLEO_G070RB_HPP
#define MODM_STM32_NUCLEO_G070RB_HPP

#include <modm/platform.hpp>
#include <modm/architecture/interface/clock.hpp>
#include <modm/debug/logger.hpp>
/// @ingroup modm_board_nucleo_g070rb
#define MODM_BOARD_HAS_LOGGER

using namespace modm::platform;

namespace Board
{
/// @ingroup modm_board_nucleo_g070rb
/// @{
using namespace modm::literals;

/// STM32G070RB running at 64MHz generated from the internal 16MHz oscillator
struct SystemClock
{
static constexpr uint32_t Frequency = 64_MHz;
static constexpr uint32_t Ahb = Frequency;
static constexpr uint32_t Apb = Frequency;

static constexpr uint32_t Rng = Ahb;
static constexpr uint32_t Crc = Ahb;
static constexpr uint32_t Flash = Ahb;
static constexpr uint32_t Exti = Ahb;
static constexpr uint32_t Rcc = Ahb;
static constexpr uint32_t Dmamux = Ahb;
static constexpr uint32_t Dma = Ahb;

static constexpr uint32_t Dbg = Apb;
static constexpr uint32_t Timer17 = Apb;
static constexpr uint32_t Timer16 = Apb;
static constexpr uint32_t Timer15 = Apb;
static constexpr uint32_t Usart1 = Apb;
static constexpr uint32_t Spi1 = Apb;
static constexpr uint32_t I2s1 = Apb;
static constexpr uint32_t Timer1 = Apb;
static constexpr uint32_t Adc1 = Apb;
static constexpr uint32_t ItLine = Apb;
static constexpr uint32_t SysCfg = Apb;
static constexpr uint32_t Tamp = Apb;
static constexpr uint32_t Bkp = Apb;
static constexpr uint32_t Ucpd2 = Apb;
static constexpr uint32_t Ucpd1 = Apb;
static constexpr uint32_t Dac = Apb;
static constexpr uint32_t Pwr = Apb;
static constexpr uint32_t I2c2 = Apb;
static constexpr uint32_t I2c1 = Apb;
static constexpr uint32_t Usart4 = Apb;
static constexpr uint32_t Usart3 = Apb;
static constexpr uint32_t Usart2 = Apb;
static constexpr uint32_t Spi2 = Apb;
static constexpr uint32_t Iwdg = Apb;
static constexpr uint32_t Wwdg = Apb;
static constexpr uint32_t Rtc = Apb;
static constexpr uint32_t Timer14 = Apb;
static constexpr uint32_t Timer7 = Apb;
static constexpr uint32_t Timer6 = Apb;
static constexpr uint32_t Timer3 = Apb;

static bool inline
enable()
{
Rcc::enableInternalClock(); // 16MHz
// (internal clock / 1_M) * 8_N / 2_R = 128MHz / 2 = 64MHz
const Rcc::PllFactors pllFactors{
.pllM = 1,
.pllN = 8,
.pllR = 2,
};
Rcc::enablePll(Rcc::PllSource::InternalClock, pllFactors);
Rcc::setFlashLatency<Frequency>();
// switch system clock to PLL output
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll);
Rcc::setAhbPrescaler(Rcc::AhbPrescaler::Div1);
Rcc::setApbPrescaler(Rcc::ApbPrescaler::Div1);
// update frequencies for busy-wait delay functions
Rcc::updateCoreFrequency<Frequency>();

return true;
}
};

// Arduino Footprint
using A0 = GpioA0;
using A1 = GpioA1;
using A2 = GpioA4;
using A3 = GpioB1;
using A4 = GpioB11;
using A5 = GpioB12;

using D0 = GpioC5;
using D1 = GpioC4;
using D2 = GpioA10;
using D3 = GpioB3;
using D4 = GpioB5;
using D5 = GpioB4;
using D6 = GpioB14;
using D7 = GpioA8;
using D8 = GpioA9;
using D9 = GpioC7;
using D10 = GpioB0;
using D11 = GpioA7;
using D12 = GpioA6;
using D13 = GpioA5;
using D14 = GpioB9;
using D15 = GpioB8;

using Button = GpioInverted<GpioInputC13>;
using LedD13 = D13;

using Leds = SoftwareGpioPort< LedD13 >;
/// @}

namespace stlink
{
/// @ingroup modm_board_nucleo_g070rb
/// @{
using Rx = GpioInputA3;
using Tx = GpioOutputA2;
using Uart = Usart2;
/// @}
}

/// @ingroup modm_board_nucleo_g070rb
/// @{
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;

inline void
initialize()
{
SystemClock::enable();
SysTickTimer::initialize<SystemClock>();

stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
stlink::Uart::initialize<SystemClock, 115200_Bd>();

Button::setInput();
}
/// @}

}

#endif // MODM_STM32_NUCLEO_G070RB_HPP
15 changes: 15 additions & 0 deletions src/modm/board/nucleo_g070rb/board.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<library>
<repositories>
<repository>
<path>../../../../repo.lb</path>
</repository>
</repositories>

<options>
<option name="modm:target">stm32g070rbt6</option>
<option name="modm:platform:uart:2:buffer.tx">2Ki</option>
</options>
<modules>
<module>modm:board:nucleo-g070rb</module>
</modules>
</library>
41 changes: 41 additions & 0 deletions src/modm/board/nucleo_g070rb/module.lb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2019, Niklas Hauser
# Copyright (c) 2023, Christopher Durand
#
# This file is part of the modm project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -----------------------------------------------------------------------------

def init(module):
module.name = ":board:nucleo-g070rb"
module.description = """\
# NUCLEO-G070RB
[Nucleo kit for STM32G070RB](https://www.st.com/en/evaluation-tools/nucleo-g070rb.html)
"""

def prepare(module, options):
if not options[":target"].partname.startswith("stm32g070rbt"):
return False

module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:2",
":debug", ":architecture:clock")
return True

def build(env):
env.outbasepath = "modm/src/modm/board"
env.substitutions = {
"with_logger": True,
"with_assert": env.has_module(":architecture:assert")
}
env.template("../board.cpp.in", "board.cpp")
env.copy('.')

env.outbasepath = "modm/openocd/modm/board/"
env.copy(repopath("tools/openocd/modm/st_nucleo_g0.cfg"), "st_nucleo_g0.cfg")
env.collect(":build:openocd.source", "modm/board/st_nucleo_g0.cfg")

0 comments on commit e5fb526

Please sign in to comment.