Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ jobs:
- name: Examples STM32H5 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_h503rb weact_h503cb weact_h562rg)
(cd examples && ../tools/scripts/examples_compile.py nucleo_h503rb weact_h503cb weact_h523ce weact_h562rg)
- name: Examples STM32H7 Series
if: always()
run: |
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,10 @@ We have out-of-box support for many development boards including documentation.
<td align="center"><a href="https://modm.io/reference/config/modm-weact-g0b1cb">WEACT-G0B1CB</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-weact-h503cb">WEACT-H503CB</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-weact-h523ce">WEACT-H523CE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-weact-h562rg">WEACT-H562RG</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-weact-u585ci">WEACT-U585CI</a></td>
</tr><tr>
</tr>
</table>
<!--/bsptable-->
Expand Down
1 change: 1 addition & 0 deletions examples/generic/usb/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<!-- <extends>modm:weact-u585ci</extends> -->
<!-- <extends>modm:nucleo-h503rb</extends> -->
<!-- <extends>modm:weact-h503cb</extends> -->
<!-- <extends>modm:weact-h523ce</extends> -->
<!-- <extends>modm:weact-h562rg</extends> -->
<!-- <extends>modm:nucleo-u385rg-q</extends> -->
<options>
Expand Down
26 changes: 26 additions & 0 deletions examples/weact_h523ce/blink/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2017, Niklas Hauser
* Copyright (c) 2017, Sascha Schade
*
* 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>

int main()
{
Board::initialize();
Board::Leds::setOutput();

while (true)
{
Board::Leds::toggle();
modm::delay(Board::Button::read() ? 250ms : 500ms);
static uint32_t counter(0);
MODM_LOG_INFO << "Loop counter: " << (counter++) << modm::endl;
}
return 0;
}
14 changes: 14 additions & 0 deletions examples/weact_h523ce/blink/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<library>
<extends>modm:weact-h523ce</extends>
<options>
<option name="modm:build:build.path">../../../build/weact_h523ce/blink</option>
<option name="modm:board:weact-h523ce:with_rtt">yes</option>
</options>
<modules>
<module>modm:architecture:delay</module>
<module>modm:build:scons</module>
</modules>
<collectors>
<collect name="modm:build:openocd.source">interface/stlink-dap.cfg</collect>
</collectors>
</library>
169 changes: 169 additions & 0 deletions src/modm/board/weact_h523c/board.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
/*
* Copyright (c) 2026, 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/.
*/
// ----------------------------------------------------------------------------

#pragma once

#include <modm/platform.hpp>
#include <modm/architecture.hpp>
#include <modm/debug.hpp>

using namespace modm::platform;
%#
%% if with_logger
/// @ingroup modm_board_weact_h523ce
#define MODM_BOARD_HAS_LOGGER
%#
%% endif
namespace Board
{
/// @ingroup modm_board_weact_h523ce
/// @{
using namespace modm::literals;

/// STM32H523Cx running at 250MHz from PLL clock generated from 8 MHz HSE
struct SystemClock
{
static constexpr uint32_t Hse = 8_MHz;
static constexpr uint32_t Lse = 32.768_kHz;

static constexpr Rcc::PllConfig pll1
{
.range = Rcc::PllInputRange::MHz2_4,
.M = 4, // 8 MHz / 4 = 2 MHz
.N = 250, // 2 MHz * 120 = 500 MHz
.P = 2, // 500 MHz / 2 = 250 MHz = F_cpu
};
static constexpr uint32_t Pll1P = Hse / pll1.M * pll1.N / pll1.P;
static_assert(Pll1P == Rcc::MaxFrequency);

static constexpr Rcc::PllConfig pll3
{
.range = Rcc::PllInputRange::MHz8_16,
.M = 1, // 8 MHz / 1 = 8 MHz
.N = 18, // 8 MHz * 18 = 144 MHz
.Q = 3, // 144 MHz / 3 = 48 MHz = F_usb
};
static constexpr uint32_t Pll3Q = Hse / pll3.M * pll3.N / pll3.Q;

static constexpr uint32_t SysClk = Pll1P;
static constexpr uint32_t Frequency = SysClk;

// AHB Bus - Max 250MHz
static constexpr uint32_t Hclk = SysClk / 1;
static constexpr uint32_t Ahb = Hclk;

// APB Buses - Max 250MHz
static constexpr uint32_t Apb1 = Hclk / 1;
static constexpr uint32_t Apb2 = Hclk / 1;
static constexpr uint32_t Apb3 = Hclk / 1;

// Peripherals on AHB2
static constexpr uint32_t Adc1 = Hclk;
static constexpr uint32_t Dac1 = Hclk;

// Peripherals on APB2
static constexpr uint32_t Spi1 = Apb2;
static constexpr uint32_t Usart1 = Apb2;

// Peripherals on APB1
static constexpr uint32_t Spi2 = Apb1;
static constexpr uint32_t Spi3 = Apb1;
static constexpr uint32_t Usart2 = Apb1;
static constexpr uint32_t Usart3 = Apb1;
static constexpr uint32_t Fdcan1 = Apb1;

// Peripherals on APB3
static constexpr uint32_t LpUart1 = Apb3;

// Timer Clocks
static constexpr uint32_t Apb1Timer = Apb1 * 1;
static constexpr uint32_t Apb2Timer = Apb2 * 1;

static constexpr uint32_t Timer1 = Apb2Timer;
static constexpr uint32_t Timer2 = Apb1Timer;
static constexpr uint32_t Timer3 = Apb1Timer;
static constexpr uint32_t Timer6 = Apb1Timer;
static constexpr uint32_t Timer7 = Apb1Timer;

static constexpr uint32_t Rtc = Lse;
static constexpr uint32_t Usb = Pll3Q;
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;

static bool inline
enable()
{
Rcc::enableLseCrystal();
Rcc::enableHseCrystal();

Rcc::setVoltageScaling(Rcc::VoltageScaling::Scale0);
Rcc::setFlashLatency<Frequency>();

Rcc::enablePll1(Rcc::PllSource::Hse, pll1);
Rcc::enablePll3(Rcc::PllSource::Hse, pll3);

Rcc::setAhbPrescaler(Rcc::AhbPrescaler::Div1);
Rcc::setApb1Prescaler(Rcc::ApbPrescaler::Div1);
Rcc::setApb2Prescaler(Rcc::ApbPrescaler::Div1);
Rcc::setApb3Prescaler(Rcc::ApbPrescaler::Div1);

Rcc::updateCoreFrequency<Frequency>();

Rcc::enableSystemClock(Rcc::SystemClockSource::Pll1P);
Rcc::setUsbClockSource(Rcc::UsbClockSource::Pll3Q);
Rcc::setRealTimeClockSource(Rcc::RealTimeClockSource::Lse);

return true;
}
};

using Button = GpioInverted<GpioInputA0>;

using Led = GpioInverted<GpioOutputC13>;
using Leds = SoftwareGpioPort< Led >;
/// @}

namespace usb
{
/// @ingroup modm_board_weact_h523ce
/// @{
using Dm = GpioA11;
using Dp = GpioA12;

using Device = UsbFs;
/// @}
}

/// @ingroup modm_board_weact_h523ce
/// @{
%% if with_logger
using LoggerDevice = modm::IODeviceWrapper< Rtt<0>, modm::IOBuffer::DiscardIfFull >;
%#
%% endif
inline void
initialize()
{
SystemClock::enable();
SysTickTimer::initialize<SystemClock>();

Led::setOutput(modm::Gpio::Low);
Button::setInput(Gpio::InputType::PullUp);
}

inline void
initializeUsb(uint8_t priority=3)
{
usb::Device::initialize<SystemClock>(priority);
usb::Device::connect<usb::Dm::Dm, usb::Dp::Dp>();
}
/// @}

}

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

<options>
<option name="modm:target">stm32h523cet6</option>
</options>
<modules>
<module>modm:board:weact-h523ce</module>
</modules>
</library>
82 changes: 82 additions & 0 deletions src/modm/board/weact_h523c/module.lb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2026, 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.name = ":board:weact-h523ce"
module.description = """
# WeAct Studio STM32H523Cx Core Board

[Documentation](https://github.com/WeActStudio/WeActStudio.STM32H523CoreBoard)

Cheap and bread-board-friendly board for the STM32H523 series.


## Programming

Since the board has no St-Link programmer on the board,
you must use DFU (Device Firmware Update (via USB)) to program the board.
A DFU command is integrated into the `modm:build:scons` tool:

```
scons program-dfu
```

Note that you need to manually reset the board due to a bug in the DFU
implementation.


## Logging

To log via RTT attach a debugger to the SWD port and select the RTT option:

```xml
<option name="modm:board:weact-h523ce:with_rtt">yes</option>
```

Then log using:

```sh
scons log-rtt
```
"""

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

module.depends(
":debug",
":architecture:clock",
":platform:core",
":platform:gpio",
":platform:clock",
":platform:usb")

module.add_option(
BooleanOption(name="with_rtt", description="Log using RTT", default=False,
dependencies=lambda v: ":platform:rtt" if v else None))

return True

def build(env):
env.outbasepath = "modm/src/modm/board"
env.substitutions = {
"with_logger": env["with_rtt"],
"with_assert": env.has_module(":architecture:assert"),
}
env.template("../board.cpp.in", "board.cpp")
env.template("board.hpp.in")

env.outbasepath = "modm/openocd/modm/board/"
env.template(repopath("tools/openocd/modm/stm32_swd.cfg.in"), "board.cfg",
substitutions={"target": "stm32h5x"})
env.collect(":build:openocd.source", "modm/board/board.cfg")
Loading