Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add STM32C0x #1188

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions .github/workflows/compile-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,32 @@ jobs:
name: samx7-compile-all
path: test/all/log

stm32c0-compile-all:
if: github.event.label.name == 'ci:hal'
runs-on: ubuntu-22.04
container:
image: ghcr.io/modm-ext/modm-build-cortex-m:2023-03-12
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Fix Git permission/ownership problem
run: |
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
- name: Compile HAL for all STM32C0
run: |
(cd test/all && python3 run_all.py stm32c0 --quick-remaining)
- name: Upload log artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: stm32c0-compile-all
path: test/all/log

stm32f0-compile-all:
if: github.event.label.name == 'ci:hal'
runs-on: ubuntu-22.04
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ jobs:
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
- name: Examples STM32C0 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_c031c6)
- name: Examples STM32F0 Series
if: always()
run: |
Expand Down
51 changes: 36 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ git clone --recurse-submodules --jobs 8 https://github.com/modm-io/modm.git

## Microcontrollers

modm can create a HAL for <!--allcount-->3779<!--/allcount--> devices of these vendors:
modm can create a HAL for <!--allcount-->3839<!--/allcount--> devices of these vendors:

- STMicroelectronics STM32: <!--stmcount-->2974<!--/stmcount--> devices.
- STMicroelectronics STM32: <!--stmcount-->3034<!--/stmcount--> devices.
- Microchip SAM: <!--samcount-->416<!--/samcount--> devices.
- Microchip AVR: <!--avrcount-->388<!--/avrcount--> devices.
- Raspberry Pi: <!--rpicount-->1<!--/rpicount--> device.
Expand All @@ -104,12 +104,13 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<table>
<tr>
<th align="center"></th>
<th align="center" colspan="14">STM32</th>
<th align="center" colspan="15">STM32</th>
<th align="center" colspan="4">SAM</th>
<th align="center" colspan="1">RP</th>
<th align="center" colspan="3">AT</th>
</tr><tr>
<th align="left">Peripheral</th>
<th align="center">C0</th>
<th align="center">F0</th>
<th align="center">F1</th>
<th align="center">F2</th>
Expand Down Expand Up @@ -143,6 +144,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">✅</td>
<td align="center">✅</td>
Expand All @@ -158,6 +160,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
</tr><tr>
<td align="left">CAN</td>
<td align="center">✕</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
Expand All @@ -182,6 +185,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✕</td>
</tr><tr>
<td align="left">Comparator</td>
<td align="center">✕</td>
<td align="center">○</td>
<td align="center">✕</td>
<td align="center">✕</td>
Expand All @@ -206,6 +210,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">○</td>
</tr><tr>
<td align="left">DAC</td>
<td align="center">✕</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
Expand Down Expand Up @@ -243,6 +248,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
Expand All @@ -255,6 +261,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
</tr><tr>
<td align="left">Ethernet</td>
<td align="center">✕</td>
<td align="center">✕</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">✕</td>
Expand Down Expand Up @@ -293,6 +300,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
Expand All @@ -303,6 +311,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
</tr><tr>
<td align="left">External Memory</td>
<td align="center">✕</td>
<td align="center">✕</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✕</td>
Expand All @@ -320,7 +329,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✕</td>
<td align="center">○</td>
<td align="center">✕</td>
<td align="center"></td>
<td align="center"></td>
<td align="center">✕</td>
<td align="center">✕</td>
<td align="center">✕</td>
Expand Down Expand Up @@ -348,6 +357,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
</tr><tr>
<td align="left">I<sup>2</sup>C</td>
<td align="center">✅</td>
Expand All @@ -364,6 +374,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">✅</td>
Expand All @@ -375,6 +386,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
</tr><tr>
<td align="left">Internal Flash</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">○</td>
Expand Down Expand Up @@ -412,6 +424,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✕</td>
<td align="center">✕</td>
<td align="center">✕</td>
Expand All @@ -424,6 +437,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="left">Random Generator</td>
<td align="center">✕</td>
<td align="center">✕</td>
<td align="center">✕</td>
<td align="center">✅</td>
<td align="center">✕</td>
<td align="center">✅</td>
Expand Down Expand Up @@ -459,6 +473,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">○</td>
Expand Down Expand Up @@ -489,6 +504,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✕</td>
<td align="center">✕</td>
<td align="center">✕</td>
Expand All @@ -508,6 +524,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">○</td>
<td align="center">○</td>
<td align="center">✅</td>
Expand Down Expand Up @@ -539,6 +556,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">○</td>
</tr><tr>
<td align="left">Unique ID</td>
Expand All @@ -556,6 +574,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✕</td>
<td align="center">✕</td>
<td align="center">✕</td>
Expand All @@ -572,6 +591,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✕</td>
<td align="center">✅</td>
<td align="center">✅</td>
Expand Down Expand Up @@ -638,59 +658,60 @@ We have out-of-box support for many development boards including documentation.
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-feather-rp2040">FEATHER-RP2040</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-mega-2560-pro">MEGA-2560-PRO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-c031c6">NUCLEO-C031C6</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f031k6">NUCLEO-F031K6</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f042k6">NUCLEO-F042K6</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f042k6">NUCLEO-F042K6</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f072rb">NUCLEO-F072RB</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f091rc">NUCLEO-F091RC</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f103rb">NUCLEO-F103RB</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f303k8">NUCLEO-F303K8</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f303k8">NUCLEO-F303K8</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f303re">NUCLEO-F303RE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f334r8">NUCLEO-F334R8</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f401re">NUCLEO-F401RE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f411re">NUCLEO-F411RE</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f411re">NUCLEO-F411RE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f429zi">NUCLEO-F429ZI</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f439zi">NUCLEO-F439ZI</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f446re">NUCLEO-F446RE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f446ze">NUCLEO-F446ZE</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f446ze">NUCLEO-F446ZE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f746zg">NUCLEO-F746ZG</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-f767zi">NUCLEO-F767ZI</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g070rb">NUCLEO-G070RB</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g071rb">NUCLEO-G071RB</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g071rb">NUCLEO-G071RB</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431kb">NUCLEO-G431KB</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g431rb">NUCLEO-G431RB</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-g474re">NUCLEO-G474RE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h723zg">NUCLEO-H723ZG</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h723zg">NUCLEO-H723ZG</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-h743zi">NUCLEO-H743ZI</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l031k6">NUCLEO-L031K6</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l053r8">NUCLEO-L053R8</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l152re">NUCLEO-L152RE</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l152re">NUCLEO-L152RE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l432kc">NUCLEO-L432KC</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l452re">NUCLEO-L452RE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l476rg">NUCLEO-L476RG</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l496zg-p">NUCLEO-L496ZG-P</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l496zg-p">NUCLEO-L496ZG-P</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-l552ze-q">NUCLEO-L552ZE-Q</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-nucleo-u575zi-q">NUCLEO-U575ZI-Q</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-olimexino-stm32">OLIMEXINO-STM32</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-rp-pico">Raspberry Pi Pico</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-rp-pico">Raspberry Pi Pico</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-mini">SAMD21-MINI</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-samd21-xplained-pro">SAMD21-XPLAINED-PRO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-same54-xplained-pro">SAME54-XPLAINED-PRO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-same70-xplained">SAME70-XPLAINED</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/config/modm-same70-xplained">SAME70-XPLAINED</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-samg55-xplained-pro">SAMG55-XPLAINED-PRO</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-samv71-xplained-ultra">SAMV71-XPLAINED-ULTRA</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-srxe">Smart Response XE</a></td>
<td align="center"><a href="https://modm.io/reference/config/modm-stm32_f4ve">STM32-F4VE</a></td>
</tr><tr>
<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>
</tr>
Expand Down
48 changes: 48 additions & 0 deletions examples/nucleo_c031c6/adc/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024, Jörg Ebeling
*
* 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>

using namespace Board;

/*
* This example demonstrates the usage of the ADC peripheral.
* Connect two potentiometers to A0 and A1 to get reasonable readings or just
* touch the two pins with your fingers to get ... interesting readings.
* Make sure you're not too charged up with static electricity!
*/

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

Adc1::connect<GpioA0::In0, GpioA1::In1>();
Adc1::initialize<Board::SystemClock, Adc1::ClockMode::Asynchronous,
24_MHz>(); // 24MHz/160.5 sample time=6.6us (fulfill Ts_temp of 5us)

Adc1::setResolution(Adc1::Resolution::Bits12);
Adc1::setSampleTime(Adc1::SampleTime::Cycles160_5);
Adc1::setRightAdjustResult();
Adc1::enableOversampling(Adc1::OversampleRatio::x16, Adc1::OversampleShift::Div16);

while (true)
{
Board::LedD13::toggle();
modm::delay(500ms);

const uint16_t vref = Adc1::readInternalVoltageReference();
MODM_LOG_INFO.printf("Vref=%4humV T=%2hu°C A0=%4humV A1=%4humV\n",
vref, Adc1::readTemperature(vref),
(vref * Adc1::readChannel(Adc1::Channel::In0) / 0xFFF),
(vref * Adc1::readChannel(Adc1::Channel::In1) / 0xFFF));
}
}
10 changes: 10 additions & 0 deletions examples/nucleo_c031c6/adc/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<library>
<extends>modm:nucleo-c031c6</extends>
<options>
<option name="modm:build:build.path">../../../build/nucleo_c031c6/adc</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:platform:adc</module>
</modules>
</library>
Loading
Loading