Skip to content

Commit

Permalink
[board] Add WeAct C011 board
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Jan 1, 2025
1 parent bec7293 commit 7ba2fbb
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,8 @@ We have out-of-box support for many development boards including documentation.
<td align="center"><a href="https://modm.io/reference/config/modm-stm32_f4ve">STM32-F4VE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-stm32f030_demo">STM32F030-DEMO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-thingplus-rp2040">THINGPLUS-RP2040</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-weact-c011f6">WEACT-C011F6</a></td>
</tr><tr>
</tr>
</table>
<!--/bsptable-->
Expand Down
89 changes: 89 additions & 0 deletions src/modm/board/weact_c011f6/board.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2016-2018, 2024, Niklas Hauser
* Copyright (c) 2017, Nick Sarten
* 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/.
*/

#pragma once

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

using namespace modm::platform;

namespace Board
{
/// @ingroup modm_board_nucleo_c011f6
/// @{
using namespace modm::literals;

/// STM32C011F6 running at 48MHz generated from the internal clock
struct SystemClock
{
static constexpr uint32_t Frequency = Rcc::HsiFrequency;
static constexpr uint32_t Ahb = Frequency;
static constexpr uint32_t Apb = Frequency;

static constexpr uint32_t Adc1 = Apb;

static constexpr uint32_t Spi1 = Apb;

static constexpr uint32_t Usart1 = Apb;
static constexpr uint32_t Usart2 = Apb;

static constexpr uint32_t I2c1 = Apb;

static constexpr uint32_t Timer1 = Apb;
static constexpr uint32_t Timer2 = Apb;
static constexpr uint32_t Timer3 = Apb;
static constexpr uint32_t Timer14 = Apb;
static constexpr uint32_t Timer16 = Apb;
static constexpr uint32_t Timer17 = Apb;
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
static constexpr uint32_t Rtc = 32.768_kHz;

static bool inline
enable()
{
Rcc::enableLowSpeedExternalCrystal();
Rcc::enableRealTimeClock(Rcc::RealTimeClockSource::LowSpeedExternalCrystal);

// 48MHz generated from internal RC
Rcc::enableInternalClock();
Rcc::setHsiSysDivider(Rcc::HsiSysDivider::Div1);
// set flash latency for 48MHz
Rcc::setFlashLatency<Frequency>();
// switch system clock to PLL output
Rcc::setAhbPrescaler(Rcc::AhbPrescaler::Div1);
Rcc::setApbPrescaler(Rcc::ApbPrescaler::Div1);
// update frequencies for busy-wait delay functions
Rcc::updateCoreFrequency<Frequency>();

return true;
}
};

using Button = GpioInputA14; // SWDCLK!
using LedA4 = GpioInverted<GpioOutputA4>;

using Leds = SoftwareGpioPort< LedA4 >;
/// @}

/// @ingroup modm_board_nucleo_c011f6
/// @{

inline void
initialize()
{
SystemClock::enable();
SysTickTimer::initialize<SystemClock>();
}
/// @}

}
15 changes: 15 additions & 0 deletions src/modm/board/weact_c011f6/board.xml
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">stm32c011f6p6</option>
<option name="modm:platform:cortex-m:main_stack_size">1Ki</option>
</options>
<modules>
<module>modm:board:weact-c011f6</module>
</modules>
</library>
42 changes: 42 additions & 0 deletions src/modm/board/weact_c011f6/module.lb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016-2018, Niklas Hauser
# Copyright (c) 2017, Fabian Greif
#
# 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-c011f6"
module.description = """\
# WeAct Studio STM32C011F6 Core Board
[Documentation](https://github.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard)
"""

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

module.depends(":platform:core", ":platform:gpio", ":platform:clock",
":architecture:clock", ":architecture:clock")
return True

def build(env):
env.outbasepath = "modm/src/modm/board"
env.substitutions = {
"with_logger": False,
"with_assert": env.has_module(":architecture:assert")
}
env.template("../board.cpp.in", "board.cpp")
env.copy('.')

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

0 comments on commit 7ba2fbb

Please sign in to comment.