Skip to content

Commit 37d5c36

Browse files
Apehaengersalkinium
authored andcommitted
[stm32] Enable and port HAL for STM32C0 family
1 parent 3614dc0 commit 37d5c36

File tree

21 files changed

+163
-56
lines changed

21 files changed

+163
-56
lines changed

.github/workflows/compile-all.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,32 @@ jobs:
109109
name: samx7-compile-all
110110
path: test/all/log
111111

112+
stm32c0-compile-all:
113+
if: github.event.label.name == 'ci:hal'
114+
runs-on: ubuntu-22.04
115+
container:
116+
image: ghcr.io/modm-ext/modm-build-cortex-m:2023-03-12
117+
steps:
118+
- name: Check out repository
119+
uses: actions/checkout@v4
120+
with:
121+
submodules: 'recursive'
122+
- name: Fix Git permission/ownership problem
123+
run: |
124+
git config --global --add safe.directory /__w/modm/modm
125+
- name: Update lbuild
126+
run: |
127+
pip3 install --upgrade --upgrade-strategy=eager modm
128+
- name: Compile HAL for all STM32C0
129+
run: |
130+
(cd test/all && python3 run_all.py stm32c0 --quick-remaining)
131+
- name: Upload log artifacts
132+
if: always()
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: stm32c0-compile-all
136+
path: test/all/log
137+
112138
stm32f0-compile-all:
113139
if: github.event.label.name == 'ci:hal'
114140
runs-on: ubuntu-22.04

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ git clone --recurse-submodules --jobs 8 https://github.com/modm-io/modm.git
8282

8383
## Microcontrollers
8484

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

87-
- STMicroelectronics STM32: <!--stmcount-->2974<!--/stmcount--> devices.
87+
- STMicroelectronics STM32: <!--stmcount-->3034<!--/stmcount--> devices.
8888
- Microchip SAM: <!--samcount-->416<!--/samcount--> devices.
8989
- Microchip AVR: <!--avrcount-->388<!--/avrcount--> devices.
9090
- Raspberry Pi: <!--rpicount-->1<!--/rpicount--> device.
@@ -104,12 +104,13 @@ Please [discover modm's peripheral drivers for your specific device][discover].
104104
<table>
105105
<tr>
106106
<th align="center"></th>
107-
<th align="center" colspan="14">STM32</th>
107+
<th align="center" colspan="15">STM32</th>
108108
<th align="center" colspan="4">SAM</th>
109109
<th align="center" colspan="1">RP</th>
110110
<th align="center" colspan="3">AT</th>
111111
</tr><tr>
112112
<th align="left">Peripheral</th>
113+
<th align="center">C0</th>
113114
<th align="center">F0</th>
114115
<th align="center">F1</th>
115116
<th align="center">F2</th>
@@ -143,6 +144,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
143144
<td align="center">✅</td>
144145
<td align="center">✅</td>
145146
<td align="center">✅</td>
147+
<td align="center">✅</td>
146148
<td align="center">○</td>
147149
<td align="center">✅</td>
148150
<td align="center">✅</td>
@@ -158,6 +160,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
158160
<td align="center">✅</td>
159161
</tr><tr>
160162
<td align="left">CAN</td>
163+
<td align="center">✕</td>
161164
<td align="center">✅</td>
162165
<td align="center">✅</td>
163166
<td align="center">✅</td>
@@ -182,6 +185,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
182185
<td align="center">✕</td>
183186
</tr><tr>
184187
<td align="left">Comparator</td>
188+
<td align="center">✕</td>
185189
<td align="center">○</td>
186190
<td align="center">✕</td>
187191
<td align="center">✕</td>
@@ -206,6 +210,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
206210
<td align="center">○</td>
207211
</tr><tr>
208212
<td align="left">DAC</td>
213+
<td align="center">✕</td>
209214
<td align="center">✅</td>
210215
<td align="center">✅</td>
211216
<td align="center">✅</td>
@@ -243,6 +248,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
243248
<td align="center">✅</td>
244249
<td align="center">✅</td>
245250
<td align="center">✅</td>
251+
<td align="center">✅</td>
246252
<td align="center">○</td>
247253
<td align="center">○</td>
248254
<td align="center">○</td>
@@ -255,6 +261,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
255261
</tr><tr>
256262
<td align="left">Ethernet</td>
257263
<td align="center">✕</td>
264+
<td align="center">✕</td>
258265
<td align="center">○</td>
259266
<td align="center">○</td>
260267
<td align="center">✕</td>
@@ -293,6 +300,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
293300
<td align="center">✅</td>
294301
<td align="center">✅</td>
295302
<td align="center">✅</td>
303+
<td align="center">✅</td>
296304
<td align="center">○</td>
297305
<td align="center">○</td>
298306
<td align="center">○</td>
@@ -303,6 +311,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
303311
</tr><tr>
304312
<td align="left">External Memory</td>
305313
<td align="center">✕</td>
314+
<td align="center">✕</td>
306315
<td align="center">✅</td>
307316
<td align="center">✅</td>
308317
<td align="center">✕</td>
@@ -320,7 +329,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
320329
<td align="center">✕</td>
321330
<td align="center">○</td>
322331
<td align="center">✕</td>
323-
<td align="center"></td>
332+
<td align="center"></td>
324333
<td align="center">✕</td>
325334
<td align="center">✕</td>
326335
<td align="center">✕</td>
@@ -348,6 +357,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
348357
<td align="center">✅</td>
349358
<td align="center">✅</td>
350359
<td align="center">✅</td>
360+
<td align="center">✅</td>
351361
</tr><tr>
352362
<td align="left">I<sup>2</sup>C</td>
353363
<td align="center">✅</td>
@@ -364,6 +374,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
364374
<td align="center">✅</td>
365375
<td align="center">✅</td>
366376
<td align="center">✅</td>
377+
<td align="center">✅</td>
367378
<td align="center">○</td>
368379
<td align="center">○</td>
369380
<td align="center">✅</td>
@@ -375,6 +386,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
375386
</tr><tr>
376387
<td align="left">Internal Flash</td>
377388
<td align="center">○</td>
389+
<td align="center">○</td>
378390
<td align="center">✅</td>
379391
<td align="center">○</td>
380392
<td align="center">○</td>
@@ -412,6 +424,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
412424
<td align="center">✅</td>
413425
<td align="center">✅</td>
414426
<td align="center">✅</td>
427+
<td align="center">✅</td>
415428
<td align="center">✕</td>
416429
<td align="center">✕</td>
417430
<td align="center">✕</td>
@@ -424,6 +437,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
424437
<td align="left">Random Generator</td>
425438
<td align="center">✕</td>
426439
<td align="center">✕</td>
440+
<td align="center">✕</td>
427441
<td align="center">✅</td>
428442
<td align="center">✕</td>
429443
<td align="center">✅</td>
@@ -459,6 +473,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
459473
<td align="center">✅</td>
460474
<td align="center">✅</td>
461475
<td align="center">✅</td>
476+
<td align="center">✅</td>
462477
<td align="center">○</td>
463478
<td align="center">○</td>
464479
<td align="center">○</td>
@@ -489,6 +504,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
489504
<td align="center">✅</td>
490505
<td align="center">✅</td>
491506
<td align="center">✅</td>
507+
<td align="center">✅</td>
492508
<td align="center">✕</td>
493509
<td align="center">✕</td>
494510
<td align="center">✕</td>
@@ -508,6 +524,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
508524
<td align="center">✅</td>
509525
<td align="center">✅</td>
510526
<td align="center">✅</td>
527+
<td align="center">✅</td>
511528
<td align="center">○</td>
512529
<td align="center">○</td>
513530
<td align="center">✅</td>
@@ -539,6 +556,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
539556
<td align="center">✅</td>
540557
<td align="center">✅</td>
541558
<td align="center">✅</td>
559+
<td align="center">✅</td>
542560
<td align="center">○</td>
543561
</tr><tr>
544562
<td align="left">Unique ID</td>
@@ -556,6 +574,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
556574
<td align="center">✅</td>
557575
<td align="center">✅</td>
558576
<td align="center">✅</td>
577+
<td align="center">✅</td>
559578
<td align="center">✕</td>
560579
<td align="center">✕</td>
561580
<td align="center">✕</td>
@@ -572,6 +591,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
572591
<td align="center">✅</td>
573592
<td align="center">✅</td>
574593
<td align="center">✅</td>
594+
<td align="center">✅</td>
575595
<td align="center">✕</td>
576596
<td align="center">✅</td>
577597
<td align="center">✅</td>

ext/modm-devices

Submodule modm-devices updated 43 files

ext/st/module.lb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def common_header_file(env):
127127
define = None
128128

129129
content = Path(localpath(folder, family_header)).read_text(encoding="utf-8", errors="replace")
130-
match = re.findall(r"if defined\((?P<define>STM32[FGHLU][\w\d]+)\)", content)
130+
match = re.findall(r"if defined\((?P<define>STM32[CFGHLU][\w\d]+)\)", content)
131131
define = getDefineForDevice(device.identifier, match)
132132
if define is None or match is None:
133133
raise ValidateException("No device define found for '{}'!".format(device.partname))

repo.lb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ class DevicesCache(dict):
8383
device_file_names += glob.glob(repopath("tools/devices/**/*.xml"))
8484

8585
# roughly filter to supported devices
86-
supported = ["stm32f0", "stm32f1", "stm32f2", "stm32f3", "stm32f4", "stm32f7",
86+
supported = ["stm32c0",
87+
"stm32f0", "stm32f1", "stm32f2", "stm32f3", "stm32f4", "stm32f7",
8788
"stm32g0", "stm32g4",
8889
"stm32h7",
8990
"stm32l0", "stm32l1", "stm32l4", "stm32l5",

src/modm/platform/adc/stm32f0/adc.hpp.in

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public:
8989
%% endif
9090
};
9191

92-
%% if target.family in ["g0"]
92+
%% if target.family in ["c0", "g0"]
9393
enum class SampleTimeGroup
9494
{
9595
Group1,
@@ -229,7 +229,7 @@ public:
229229
static inline void
230230
setWaitMode(bool enable);
231231

232-
%% if target.family in ["g0"]
232+
%% if target.family in ["c0", "g0"]
233233
static inline void
234234
enableOversampling(OversampleRatio ratio, OversampleShift shift = OversampleShift::Div1);
235235

@@ -299,7 +299,7 @@ public:
299299
* initialize()
300300
*/
301301
static inline bool
302-
%% if target.family in ["g0"]
302+
%% if target.family in ["c0", "g0"]
303303
setChannel(Channel channel, SampleTimeGroup group = SampleTimeGroup::Group1);
304304
%% else
305305
setChannel(Channel channel);
@@ -318,7 +318,7 @@ public:
318318
static consteval ChannelMask_t
319319
channelMaskFromPins();
320320

321-
%% if target.family in ["g0"]
321+
%% if target.family in ["c0", "g0"]
322322
/**
323323
* Set channel scan sequence to convert up to 8 channels in arbitrary order.
324324
*
@@ -342,7 +342,7 @@ public:
342342
/// Setting the channel for a Pin
343343
template< class Gpio >
344344
static inline bool
345-
%% if target.family in ["g0"]
345+
%% if target.family in ["c0", "g0"]
346346
setPinChannel(SampleTimeGroup group = SampleTimeGroup::Group1)
347347
{
348348
return setChannel(getPinChannel<Gpio>(), group);
@@ -369,7 +369,7 @@ public:
369369
return readChannel(getPinChannel<Gpio>());
370370
}
371371

372-
%% if target.family in ["g0"]
372+
%% if target.family in ["c0", "g0"]
373373
static inline void
374374
setSampleTime(SampleTime sampleTime, SampleTimeGroup group = SampleTimeGroup::Group1);
375375

@@ -429,7 +429,7 @@ public:
429429
enableInternalChannel(Channel channel);
430430

431431
private:
432-
%% if target.family in ["g0"]
432+
%% if target.family in ["c0", "g0"]
433433
static inline void
434434
waitChannelConfigReady();
435435

@@ -445,7 +445,12 @@ private:
445445

446446
public:
447447
static constexpr uint8_t TS_CAL1_TEMP{30};
448-
%% if target.family in ["f0"]
448+
%% if target.family in ["c0"]
449+
static constexpr uint16_t VDDA_CAL{3000};
450+
static inline volatile uint16_t *const VREFINT_CAL{(volatile uint16_t *)0x1FFF756A};
451+
static inline volatile uint16_t *const TS_CAL1{(volatile uint16_t *)0x1FFF7568};
452+
static constexpr uint16_t TS_AVG_SLOPE{3454}; // Typ. 2.53mV/°C => 2530uV * 4096 / 3000
453+
%% elif target.family in ["f0"]
449454
static constexpr uint16_t VDDA_CAL{3300};
450455
static inline volatile uint16_t *const VREFINT_CAL{(volatile uint16_t *)0x1FFF'F7BA};
451456
static inline volatile uint16_t *const TS_CAL1{(volatile uint16_t *)0x1FFF'F7B8};

0 commit comments

Comments
 (0)