-
Notifications
You must be signed in to change notification settings - Fork 156
[board] Add Nucleo-G070RB #1125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Copyright (c) 2019, Niklas Hauser | ||
| * | ||
| * 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/. | ||
| */ | ||
|
|
||
| #include <modm/board.hpp> | ||
| #include <modm/processing/timer.hpp> | ||
|
|
||
| using namespace Board; | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
| int | ||
| main() | ||
| { | ||
| Board::initialize(); | ||
| LedD13::setOutput(modm::Gpio::Low); | ||
|
|
||
| // Use the logging streams to print some messages. | ||
| // Change MODM_LOG_LEVEL above to enable or disable these messages | ||
| MODM_LOG_DEBUG << "debug" << modm::endl; | ||
| MODM_LOG_INFO << "info" << modm::endl; | ||
| MODM_LOG_WARNING << "warning" << modm::endl; | ||
| MODM_LOG_ERROR << "error" << modm::endl; | ||
|
|
||
| uint32_t counter{0}; | ||
| modm::PeriodicTimer timer{500ms}; | ||
|
|
||
| while (true) | ||
| { | ||
| if (timer.execute()) | ||
| { | ||
| LedD13::toggle(); | ||
|
|
||
| MODM_LOG_INFO << "loop: " << counter++ << modm::endl; | ||
| } | ||
| } | ||
|
|
||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <library> | ||
| <extends>modm:nucleo-g070rb</extends> | ||
| <options> | ||
| <option name="modm:build:build.path">../../../build/nucleo_g070rb/blink</option> | ||
| </options> | ||
| <modules> | ||
| <module>modm:platform:gpio</module> | ||
| <module>modm:processing:timer</module> | ||
| <module>modm:build:scons</module> | ||
| </modules> | ||
| </library> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this should be |
||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.