Skip to content

Commit 554c0b5

Browse files
TomSawsalkinium
authored andcommitted
[board] Add NUCLEO-F072RB BSP
1 parent 7d7490d commit 554c0b5

File tree

8 files changed

+229
-9
lines changed

8 files changed

+229
-9
lines changed

.github/workflows/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
- name: Examples STM32F0 Series
9191
if: always()
9292
run: |
93-
(cd examples && ../tools/scripts/examples_compile.py stm32f0_discovery stm32f072_discovery nucleo_f031k6 nucleo_f042k6 stm32f030f4p6_demo_board)
93+
(cd examples && ../tools/scripts/examples_compile.py stm32f0_discovery stm32f072_discovery nucleo_f031k6 nucleo_f072rb nucleo_f042k6 stm32f030f4p6_demo_board)
9494
- name: Examples STM32F1 Series
9595
if: always()
9696
run: |

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,38 +467,39 @@ We have out-of-box support for many development boards including documentation.
467467
<td align="center"><a href="https://modm.io/reference/module/modm-board-mega-2560-pro">MEGA-2560-PRO</a></td>
468468
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f031k6">NUCLEO-F031K6</a></td>
469469
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f042k6">NUCLEO-F042K6</a></td>
470-
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f103rb">NUCLEO-F103RB</a></td>
470+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f072rb">NUCLEO-F072RB</a></td>
471471
</tr><tr>
472+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f103rb">NUCLEO-F103RB</a></td>
472473
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f303k8">NUCLEO-F303K8</a></td>
473474
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f303re">NUCLEO-F303RE</a></td>
474475
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f334r8">NUCLEO-F334R8</a></td>
475-
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f401re">NUCLEO-F401RE</a></td>
476476
</tr><tr>
477+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f401re">NUCLEO-F401RE</a></td>
477478
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f411re">NUCLEO-F411RE</a></td>
478479
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f429zi">NUCLEO-F429ZI</a></td>
479480
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f439zi">NUCLEO-F439ZI</a></td>
480-
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f446re">NUCLEO-F446RE</a></td>
481481
</tr><tr>
482+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f446re">NUCLEO-F446RE</a></td>
482483
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f446ze">NUCLEO-F446ZE</a></td>
483484
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f746zg">NUCLEO-F746ZG</a></td>
484485
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-f767zi">NUCLEO-F767ZI</a></td>
485-
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-g071rb">NUCLEO-G071RB</a></td>
486486
</tr><tr>
487+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-g071rb">NUCLEO-G071RB</a></td>
487488
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-g431kb">NUCLEO-G431KB</a></td>
488489
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-g431rb">NUCLEO-G431RB</a></td>
489490
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-g474re">NUCLEO-G474RE</a></td>
490-
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l031k6">NUCLEO-L031K6</a></td>
491491
</tr><tr>
492+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l031k6">NUCLEO-L031K6</a></td>
492493
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l152re">NUCLEO-L152RE</a></td>
493494
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l432kc">NUCLEO-L432KC</a></td>
494495
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l452re">NUCLEO-L452RE</a></td>
495-
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l476rg">NUCLEO-L476RG</a></td>
496496
</tr><tr>
497+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l476rg">NUCLEO-L476RG</a></td>
497498
<td align="center"><a href="https://modm.io/reference/module/modm-board-olimexino-stm32">OLIMEXINO-STM32</a></td>
498499
<td align="center"><a href="https://modm.io/reference/module/modm-board-raspberrypi">Raspberry Pi</a></td>
499500
<td align="center"><a href="https://modm.io/reference/module/modm-board-samd21-mini">SAMD21-MINI</a></td>
500-
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32_f4ve">STM32-F4VE</a></td>
501501
</tr><tr>
502+
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32_f4ve">STM32-F4VE</a></td>
502503
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32f030_demo">STM32F030-DEMO</a></td>
503504
</tr>
504505
</table>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2021, Thomas Sommer
3+
*
4+
* This file is part of the modm project.
5+
*
6+
* This Source Code Form is subject to the terms of the Mozilla Public
7+
* License, v. 2.0. If a copy of the MPL was not distributed with this
8+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
*/
10+
// ----------------------------------------------------------------------------
11+
12+
#include <modm/board.hpp>
13+
#include <modm/processing.hpp>
14+
15+
using namespace Board;
16+
17+
int
18+
main()
19+
{
20+
Board::initialize();
21+
LedD13::setOutput();
22+
23+
// Use the logging streams to print some messages.
24+
// Change MODM_LOG_LEVEL above to enable or disable these messages
25+
MODM_LOG_DEBUG << "debug" << modm::endl;
26+
MODM_LOG_INFO << "info" << modm::endl;
27+
MODM_LOG_WARNING << "warning" << modm::endl;
28+
MODM_LOG_ERROR << "error" << modm::endl;
29+
30+
uint32_t counter(0);
31+
modm::ShortPeriodicTimer timer(1s);
32+
33+
while (true)
34+
{
35+
if (timer.execute())
36+
{
37+
LedD13::toggle();
38+
39+
MODM_LOG_INFO << "loop: " << counter++ << modm::endl;
40+
}
41+
}
42+
43+
return 0;
44+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<library>
2+
<extends>modm:nucleo-f072rb</extends>
3+
<options>
4+
<option name="modm:build:build.path">../../../build/nucleo_f072rb/blink</option>
5+
</options>
6+
<modules>
7+
<module>modm:build:scons</module>
8+
<module>modm:processing:timer</module>
9+
</modules>
10+
</library>

src/modm/board/disco_f072rb/board.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct SystemClock
6565
static bool inline
6666
enable()
6767
{
68-
// Enable the interal 48MHz clock
68+
// Enable the internal 48MHz clock
6969
Rcc::enableInternalClockMHz48();
7070
// set flash latency for 48MHz
7171
Rcc::setFlashLatency<Frequency>();
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* Copyright (c) 2016-2018, Niklas Hauser
3+
* Copyright (c) 2017, Nick Sarten
4+
* Copyright (c) 2017, Sascha Schade
5+
*
6+
* This file is part of the modm project.
7+
*
8+
* This Source Code Form is subject to the terms of the Mozilla Public
9+
* License, v. 2.0. If a copy of the MPL was not distributed with this
10+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
11+
*/
12+
13+
#ifndef MODM_STM32_NUCLEO_F072RB_HPP
14+
#define MODM_STM32_NUCLEO_F072RB_HPP
15+
16+
#include <modm/platform.hpp>
17+
#include <modm/architecture/interface/clock.hpp>
18+
#include <modm/debug/logger.hpp>
19+
/// @ingroup modm_board_nucleo_f072rb
20+
#define MODM_BOARD_HAS_LOGGER
21+
22+
using namespace modm::platform;
23+
24+
/// @ingroup modm_board_nucleo_f072rb
25+
namespace Board
26+
{
27+
using namespace modm::literals;
28+
29+
/// STM32f072rb running at 48MHz generated from the internal 8MHz crystal
30+
// Dummy clock for devices
31+
struct SystemClock
32+
{
33+
static constexpr int Frequency = 48_MHz;
34+
static constexpr uint32_t Ahb = Frequency;
35+
static constexpr uint32_t Apb = Frequency;
36+
37+
static constexpr uint32_t Adc = Apb;
38+
static constexpr uint32_t Can = Apb;
39+
40+
static constexpr uint32_t Spi1 = Apb;
41+
static constexpr uint32_t Spi2 = Apb;
42+
43+
static constexpr uint32_t Usart1 = Apb;
44+
static constexpr uint32_t Usart2 = Apb;
45+
static constexpr uint32_t Usart3 = Apb;
46+
static constexpr uint32_t Usart4 = Apb;
47+
48+
static constexpr uint32_t I2c1 = Apb;
49+
static constexpr uint32_t I2c2 = Apb;
50+
51+
static constexpr uint32_t Timer1 = Apb;
52+
static constexpr uint32_t Timer2 = Apb;
53+
static constexpr uint32_t Timer3 = Apb;
54+
static constexpr uint32_t Timer6 = Apb;
55+
static constexpr uint32_t Timer7 = Apb;
56+
static constexpr uint32_t Timer14 = Apb;
57+
static constexpr uint32_t Timer15 = Apb;
58+
static constexpr uint32_t Timer16 = Apb;
59+
static constexpr uint32_t Timer17 = Apb;
60+
61+
static constexpr uint32_t Usb = 48_MHz;
62+
63+
static bool inline
64+
enable()
65+
{
66+
// Enable the internal 48MHz clock
67+
Rcc::enableInternalClockMHz48();
68+
// set flash latency for 48MHz
69+
Rcc::setFlashLatency<Frequency>();
70+
// Switch to the 48MHz clock
71+
Rcc::enableSystemClock(Rcc::SystemClockSource::InternalClockMHz48);
72+
// update frequencies for busy-wait delay functions
73+
Rcc::updateCoreFrequency<Frequency>();
74+
75+
return true;
76+
}
77+
};
78+
79+
// Arduino Uno Footprint
80+
#include "nucleo64_arduino.hpp"
81+
82+
using Button = GpioInverted<GpioInputC13>;
83+
using LedD13 = D13;
84+
85+
using Leds = SoftwareGpioPort< LedD13 >;
86+
87+
88+
namespace stlink
89+
{
90+
using Rx = GpioInputA3;
91+
using Tx = GpioOutputA2;
92+
using Uart = Usart2;
93+
}
94+
95+
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
96+
97+
98+
inline void
99+
initialize()
100+
{
101+
SystemClock::enable();
102+
SysTickTimer::initialize<SystemClock>();
103+
104+
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
105+
stlink::Uart::initialize<SystemClock, 115200_Bd>();
106+
}
107+
108+
}
109+
110+
#endif // MODM_STM32_NUCLEO_F072RB_HPP
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<library>
2+
<repositories>
3+
<repository>
4+
<path>../../../../repo.lb</path>
5+
</repository>
6+
</repositories>
7+
8+
<options>
9+
<option name="modm:target">stm32f072rbt6</option>
10+
</options>
11+
<modules>
12+
<module>modm:board:nucleo-f072rb</module>
13+
</modules>
14+
</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) 2016-2018, Niklas Hauser
5+
# Copyright (c) 2017, Fabian Greif
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-f072rb"
16+
module.description = """\
17+
# NUCLEO-F072RB
18+
19+
[Nucleo kit for STM32F072RB](https://www.st.com/en/evaluation-tools/nucleo-f072rb.html)
20+
"""
21+
22+
def prepare(module, options):
23+
if not options[":target"].partname.startswith("stm32f072rbt"):
24+
return False
25+
26+
module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:2",
27+
":debug", ":architecture:clock", ":architecture:clock")
28+
return True
29+
30+
31+
def build(env):
32+
env.outbasepath = "modm/src/modm/board"
33+
env.substitutions = {
34+
"with_logger": True,
35+
"with_assert": env.has_module(":architecture:assert"),
36+
"has_gpio_c14_c15": False
37+
}
38+
env.template("../board.cpp.in", "board.cpp")
39+
env.copy('.')
40+
env.copy("../nucleo64_arduino.hpp", "nucleo64_arduino.hpp")
41+
env.collect(":build:openocd.source", "board/st_nucleo_f0.cfg")

0 commit comments

Comments
 (0)