-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); | ||
} | ||
/// @} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |