-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[stm32] Add support for STM32G0 device family
- Loading branch information
Showing
22 changed files
with
363 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,40 @@ | ||
/* | ||
* 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> | ||
|
||
using namespace Board; | ||
|
||
// ---------------------------------------------------------------------------- | ||
int | ||
main() | ||
{ | ||
Board::initialize(); | ||
|
||
// 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; | ||
|
||
LedD13::setOutput(); | ||
static uint8_t counter{0}; | ||
|
||
while (true) | ||
{ | ||
LedD13::toggle(); | ||
modm::delayMilliseconds(Button::read() ? 500 : 1000); | ||
|
||
MODM_LOG_INFO << "loop: " << counter++ << modm::endl; | ||
} | ||
|
||
return 0; | ||
} |
This file contains 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,10 @@ | ||
<library> | ||
<extends>modm:nucleo-g071rb</extends> | ||
<options> | ||
<option name="modm:build:build.path">../../../build/nucleo_g071rb/blink</option> | ||
</options> | ||
<modules> | ||
<module>modm:platform:gpio</module> | ||
<module>modm:build:scons</module> | ||
</modules> | ||
</library> |
This file contains 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
Submodule stm32
updated
11 files
+1 −1 | README.md | |
+142 −0 | patches/g0-2.patch | |
+118 −0 | patches/g0-3.patch | |
+88 −0 | patches/g0-4.patch | |
+118 −0 | patches/g0.patch | |
+22 −1 | stm32g0xx/Include/stm32g030xx.h | |
+22 −1 | stm32g0xx/Include/stm32g031xx.h | |
+22 −1 | stm32g0xx/Include/stm32g041xx.h | |
+22 −1 | stm32g0xx/Include/stm32g070xx.h | |
+22 −1 | stm32g0xx/Include/stm32g071xx.h | |
+22 −1 | stm32g0xx/Include/stm32g081xx.h |
This file contains 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 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,163 @@ | ||
/* | ||
* 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/. | ||
*/ | ||
|
||
#ifndef MODM_STM32_NUCLEO_G071RB_HPP | ||
#define MODM_STM32_NUCLEO_G071RB_HPP | ||
|
||
#include <modm/platform.hpp> | ||
#include <modm/architecture/interface/clock.hpp> | ||
#include <modm/debug/logger.hpp> | ||
/// @ingroup modm_board_nucleo_g071rb | ||
#define MODM_BOARD_HAS_LOGGER | ||
|
||
using namespace modm::platform; | ||
|
||
/// @ingroup modm_board_nucleo_g071rb | ||
namespace Board | ||
{ | ||
using namespace modm::literals; | ||
|
||
/// STM32G071RB running at 64MHz generated from the internal 16MHz crystal | ||
// Dummy clock for devices | ||
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 Aes = Ahb; | ||
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 Adc = Apb; | ||
static constexpr uint32_t Comp = Apb; | ||
static constexpr uint32_t ItLine = Apb; | ||
static constexpr uint32_t VrefBuf = 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 LpTimer2 = Apb; | ||
static constexpr uint32_t LpUart1 = Apb; | ||
static constexpr uint32_t LpTimer1 = Apb; | ||
static constexpr uint32_t HdmiCec = 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 constexpr uint32_t Timer2 = Apb; | ||
|
||
static bool inline | ||
enable() | ||
{ | ||
Rcc::enableInternalClock(); // 16MHz | ||
// (internal clock / 1_M) * 8_N / 2_R = 128MHz / 2 = 64MHz | ||
Rcc::enablePll( | ||
Rcc::PllSource::InternalClock, | ||
1, // Pll_M | ||
8, // Pll_N | ||
2 // Pll_R | ||
); | ||
// set flash latency for 64MHz | ||
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 | ||
{ | ||
using Rx = GpioInputA3; | ||
using Tx = GpioOutputA2; | ||
using Uart = Usart2; | ||
} | ||
|
||
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(); | ||
Button::setInputTrigger(Gpio::InputTrigger::RisingEdge); | ||
Button::enableExternalInterrupt(); | ||
// Button::enableExternalInterruptVector(12); | ||
} | ||
|
||
} | ||
|
||
#endif // MODM_STM32_NUCLEO_G071RB_HPP |
This file contains 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">stm32g071rbt</option> | ||
<option name="modm:platform:uart:2:buffer.tx">2048</option> | ||
</options> | ||
<modules> | ||
<module>modm:board:nucleo-g071rb</module> | ||
</modules> | ||
</library> |
This file contains 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,40 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# | ||
# 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/. | ||
# ----------------------------------------------------------------------------- | ||
|
||
def init(module): | ||
module.parent = "board" | ||
module.name = "nucleo-g071rb" | ||
module.description = """\ | ||
# NUCLEO-G071RB | ||
Nucleo kit for STM32G071RB | ||
http://www.st.com/en/evaluation-tools/nucleo-g071rb.html | ||
""" | ||
|
||
def prepare(module, options): | ||
if options[":target"].partname != "stm32g071rbt": | ||
return False | ||
|
||
module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:2", | ||
":debug", ":architecture:clock", ":architecture:clock") | ||
return True | ||
|
||
def build(env): | ||
env.outbasepath = "modm/src/modm/board" | ||
env.substitutions = {"board_has_logger": True} | ||
env.template("../board.cpp.in", "board.cpp") | ||
env.copy('.') | ||
|
||
# Waiting on this patch to OpenOCD http://openocd.zylin.com/#/c/4807 | ||
# 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") |
Oops, something went wrong.