Skip to content

Commit 302e110

Browse files
committed
[board] Add WeAct C011 board
1 parent da93da5 commit 302e110

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ We have out-of-box support for many development boards including documentation.
738738
<td align="center"><a href="https://modm.io/reference/config/modm-stm32_f4ve">STM32-F4VE</a></td>
739739
<td align="center"><a href="https://modm.io/reference/config/modm-stm32f030_demo">STM32F030-DEMO</a></td>
740740
<td align="center"><a href="https://modm.io/reference/config/modm-thingplus-rp2040">THINGPLUS-RP2040</a></td>
741+
<td align="center"><a href="https://modm.io/reference/config/modm-weact-c011f6">WEACT-C011F6</a></td>
742+
</tr><tr>
741743
</tr>
742744
</table>
743745
<!--/bsptable-->

src/modm/board/weact_c011f6/board.hpp

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright (c) 2016-2018, 2024, 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+
#pragma once
14+
15+
#include <modm/architecture.hpp>
16+
#include <modm/platform.hpp>
17+
18+
using namespace modm::platform;
19+
20+
namespace Board
21+
{
22+
/// @ingroup modm_board_nucleo_c011f6
23+
/// @{
24+
using namespace modm::literals;
25+
26+
/// STM32C011F6 running at 48MHz generated from the internal clock
27+
struct SystemClock
28+
{
29+
static constexpr uint32_t Frequency = Rcc::HsiFrequency;
30+
static constexpr uint32_t Ahb = Frequency;
31+
static constexpr uint32_t Apb = Frequency;
32+
33+
static constexpr uint32_t Adc1 = Apb;
34+
35+
static constexpr uint32_t Spi1 = Apb;
36+
37+
static constexpr uint32_t Usart1 = Apb;
38+
static constexpr uint32_t Usart2 = Apb;
39+
40+
static constexpr uint32_t I2c1 = Apb;
41+
42+
static constexpr uint32_t Timer1 = Apb;
43+
static constexpr uint32_t Timer2 = Apb;
44+
static constexpr uint32_t Timer3 = Apb;
45+
static constexpr uint32_t Timer14 = Apb;
46+
static constexpr uint32_t Timer16 = Apb;
47+
static constexpr uint32_t Timer17 = Apb;
48+
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
49+
static constexpr uint32_t Rtc = 32.768_kHz;
50+
51+
static bool inline
52+
enable()
53+
{
54+
Rcc::enableLowSpeedExternalCrystal();
55+
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::LowSpeedExternalCrystal);
56+
57+
// 48MHz generated from internal RC
58+
Rcc::enableInternalClock();
59+
Rcc::setHsiSysDivider(Rcc::HsiSysDivider::Div1);
60+
// set flash latency for 48MHz
61+
Rcc::setFlashLatency<Frequency>();
62+
// switch system clock to PLL output
63+
Rcc::setAhbPrescaler(Rcc::AhbPrescaler::Div1);
64+
Rcc::setApbPrescaler(Rcc::ApbPrescaler::Div1);
65+
// update frequencies for busy-wait delay functions
66+
Rcc::updateCoreFrequency<Frequency>();
67+
68+
return true;
69+
}
70+
};
71+
72+
using Button = GpioInputA14; // SWDCLK!
73+
using LedA4 = GpioInverted<GpioOutputA4>;
74+
75+
using Leds = SoftwareGpioPort< LedA4 >;
76+
/// @}
77+
78+
/// @ingroup modm_board_nucleo_c011f6
79+
/// @{
80+
81+
inline void
82+
initialize()
83+
{
84+
SystemClock::enable();
85+
SysTickTimer::initialize<SystemClock>();
86+
}
87+
/// @}
88+
89+
}

src/modm/board/weact_c011f6/board.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<library>
2+
<repositories>
3+
<repository>
4+
<path>../../../../repo.lb</path>
5+
</repository>
6+
</repositories>
7+
8+
<options>
9+
<option name="modm:target">stm32c011f6p6</option>
10+
<option name="modm:platform:cortex-m:main_stack_size">1Ki</option>
11+
</options>
12+
<modules>
13+
<module>modm:board:weact-c011f6</module>
14+
</modules>
15+
</library>

src/modm/board/weact_c011f6/module.lb

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:weact-c011f6"
16+
module.description = """\
17+
# WeAct Studio STM32C011F6 Core Board
18+
19+
[Documentation](https://github.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard)
20+
"""
21+
22+
def prepare(module, options):
23+
if not options[":target"].partname.startswith("stm32c011f6p"):
24+
return False
25+
26+
module.depends(":platform:core", ":platform:gpio", ":platform:clock",
27+
":architecture:clock", ":architecture:clock")
28+
return True
29+
30+
def build(env):
31+
env.outbasepath = "modm/src/modm/board"
32+
env.substitutions = {
33+
"with_logger": False,
34+
"with_assert": env.has_module(":architecture:assert")
35+
}
36+
env.template("../board.cpp.in", "board.cpp")
37+
env.copy('.')
38+
39+
env.outbasepath = "modm/openocd/modm/board/"
40+
env.template(repopath("tools/openocd/modm/stm32_swd.cfg.in"), "board.cfg",
41+
substitutions={"target": "stm32c0x"})
42+
env.collect(":build:openocd.source", "modm/board/board.cfg")

0 commit comments

Comments
 (0)