Skip to content

Commit f37e79d

Browse files
committed
[board] Add NUCLEO-L053R8 board
1 parent 624ce10 commit f37e79d

File tree

4 files changed

+180
-3
lines changed

4 files changed

+180
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,20 +556,21 @@ We have out-of-box support for many development boards including documentation.
556556
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-h743zi">NUCLEO-H743ZI</a></td>
557557
</tr><tr>
558558
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l031k6">NUCLEO-L031K6</a></td>
559+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l053r8">NUCLEO-L053R8</a></td>
559560
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l152re">NUCLEO-L152RE</a></td>
560561
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l432kc">NUCLEO-L432KC</a></td>
561-
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l452re">NUCLEO-L452RE</a></td>
562562
</tr><tr>
563+
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l452re">NUCLEO-L452RE</a></td>
563564
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l476rg">NUCLEO-L476RG</a></td>
564565
<td align="center"><a href="https://modm.io/reference/module/modm-board-nucleo-l496zg-p">NUCLEO-L496ZG-P</a></td>
565566
<td align="center"><a href="https://modm.io/reference/module/modm-board-olimexino-stm32">OLIMEXINO-STM32</a></td>
566-
<td align="center"><a href="https://modm.io/reference/module/modm-board-raspberrypi">Raspberry Pi</a></td>
567567
</tr><tr>
568+
<td align="center"><a href="https://modm.io/reference/module/modm-board-raspberrypi">Raspberry Pi</a></td>
568569
<td align="center"><a href="https://modm.io/reference/module/modm-board-samd21-mini">SAMD21-MINI</a></td>
569570
<td align="center"><a href="https://modm.io/reference/module/modm-board-samg55-xplained-pro">SAMG55-XPLAINED-PRO</a></td>
570571
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32_f4ve">STM32-F4VE</a></td>
571-
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32f030_demo">STM32F030-DEMO</a></td>
572572
</tr><tr>
573+
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32f030_demo">STM32F030-DEMO</a></td>
573574
<td align="center"><a href="https://modm.io/reference/module/modm-board-srxe">Smart Response XE</a></td>
574575
</tr>
575576
</table>
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Copyright (c) 2021, Niklas Hauser
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+
#pragma once
13+
14+
#include <modm/platform.hpp>
15+
#include <modm/architecture/interface/clock.hpp>
16+
#include <modm/debug.hpp>
17+
/// @ingroup modm_board_nucleo_l053r8
18+
#define MODM_BOARD_HAS_LOGGER
19+
20+
using namespace modm::platform;
21+
22+
/// @ingroup modm_board_nucleo_l053r8
23+
namespace Board
24+
{
25+
using namespace modm::literals;
26+
27+
/// STM32L053R8 running at 32MHz generated from 16 MHz HSI16 clock
28+
struct SystemClock
29+
{
30+
static constexpr uint32_t Frequency = 32_MHz;
31+
static constexpr uint32_t Ahb = Frequency;
32+
static constexpr uint32_t Apb1 = Frequency;
33+
static constexpr uint32_t Apb2 = Frequency;
34+
35+
static constexpr uint32_t Adc = Apb2;
36+
37+
static constexpr uint32_t Dac = Apb1;
38+
39+
static constexpr uint32_t Comp1 = Apb2;
40+
static constexpr uint32_t Comp2 = Apb2;
41+
42+
static constexpr uint32_t Spi1 = Apb2;
43+
static constexpr uint32_t Spi2 = Apb1;
44+
45+
static constexpr uint32_t Usart1 = Apb2;
46+
static constexpr uint32_t Usart2 = Apb1;
47+
48+
static constexpr uint32_t Lpuart1 = Apb1;
49+
50+
static constexpr uint32_t I2c1 = Apb1;
51+
static constexpr uint32_t I2c2 = Apb1;
52+
53+
static constexpr uint32_t Usb = Apb1;
54+
55+
static constexpr uint32_t Apb1Timer = Apb1 * 1;
56+
static constexpr uint32_t Apb2Timer = Apb2 * 1;
57+
static constexpr uint32_t Timer2 = Apb1Timer;
58+
static constexpr uint32_t Timer6 = Apb1Timer;
59+
static constexpr uint32_t Timer21 = Apb2Timer;
60+
static constexpr uint32_t Timer22 = Apb2Timer;
61+
62+
static bool inline
63+
enable()
64+
{
65+
Rcc::enableInternalClock(); // 16MHz
66+
// (internal clock / 1) * 4 / 2 = 32MHz
67+
const Rcc::PllFactors pllFactors{
68+
.pllMul = Rcc::PllMultiplier::Mul4,
69+
.pllDiv = 2,
70+
.enableHsiPrediv4 = false
71+
};
72+
Rcc::enablePll(Rcc::PllSource::Hsi16, pllFactors);
73+
// set flash latency for 32MHz
74+
Rcc::setFlashLatency<Frequency>();
75+
// switch system clock to PLL output
76+
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll);
77+
Rcc::setAhbPrescaler(Rcc::AhbPrescaler::Div1);
78+
Rcc::setApb1Prescaler(Rcc::Apb1Prescaler::Div1);
79+
Rcc::setApb2Prescaler(Rcc::Apb2Prescaler::Div1);
80+
// update frequencies for busy-wait delay functions
81+
Rcc::updateCoreFrequency<Frequency>();
82+
83+
return true;
84+
}
85+
};
86+
87+
// Arduino Footprint
88+
#include "nucleo64_arduino.hpp"
89+
90+
using Button = GpioInverted<GpioInputC13>;
91+
using LedD13 = D13;
92+
93+
using Leds = SoftwareGpioPort< LedD13 >;
94+
95+
96+
namespace stlink
97+
{
98+
using Rx = GpioInputA3;
99+
using Tx = GpioOutputA2;
100+
using Uart = Usart2;
101+
}
102+
103+
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
104+
105+
106+
inline void
107+
initialize()
108+
{
109+
SystemClock::enable();
110+
SysTickTimer::initialize<SystemClock>();
111+
112+
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
113+
stlink::Uart::initialize<SystemClock, 115200_Bd>();
114+
115+
Button::setInput();
116+
}
117+
118+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<library>
2+
<repositories>
3+
<repository>
4+
<path>../../../../repo.lb</path>
5+
</repository>
6+
</repositories>
7+
8+
<options>
9+
<option name="modm:target">stm32l053r8t6</option>
10+
11+
<option name="modm:platform:uart:2:buffer.tx">2048</option>
12+
</options>
13+
<modules>
14+
<module>modm:board:nucleo-l053r8</module>
15+
</modules>
16+
</library>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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-l053r8"
16+
module.description = """\
17+
# NUCLEO-L053R8
18+
19+
[Nucleo kit for STM32L053R8](https://www.st.com/en/evaluation-tools/nucleo-l053r8.html)
20+
"""
21+
22+
def prepare(module, options):
23+
if not options[":target"].partname.startswith("stm32l053r8t"):
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+
env.copy("../nucleo64_arduino.hpp", "nucleo64_arduino.hpp")
39+
40+
env.outbasepath = "modm/openocd/modm/board/"
41+
env.copy(repopath("tools/openocd/modm/st_nucleo_l0.cfg"), "st_nucleo_l0.cfg")
42+
env.collect(":build:openocd.source", "modm/board/st_nucleo_l0.cfg")

0 commit comments

Comments
 (0)