1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

735 Commits

Author SHA1 Message Date
crasbe
b1256ffb1b
Merge pull request #21837 from crasbe/pr/nucleo-wl55jc-rtc-support_new
boards/nucleo-wl55jc, cpu/stm32: enable RTC support, increase RTC accuracy
2025-11-07 08:16:46 +00:00
crasbe
71c2d4ab6a cpu/stm32: disable RTC MEM feature for F302 2025-11-06 19:38:51 +01:00
Guillaume Meunier
315e3dab39 cpu/stm32/periph/rtc: don't stop RTC for every lock 2025-11-06 19:38:51 +01:00
Kasper Hjort Berthelsen
07cca537ff boards/nucleo-wl55jc: enable RTC peripheral 2025-11-06 19:38:51 +01:00
crasbe
2844950a39 cpu/stm32: style improvements of rtc_all.c 2025-11-06 19:38:42 +01:00
crasbe
e2a61226c3 cpu/stm32: fix _ccmram_length name, make names consistent 2025-10-15 14:11:22 +02:00
crasbe
e0f9f11044 cpu/stm32: update STM32C0 CMSIS version 2025-10-10 12:43:17 +02:00
Jason Parker
7badfe61b7 cpu/stm32: add new STM32C0 lines 2025-10-09 13:40:49 +02:00
krzysztof-cabaj
2cce71925f cpu/stm32/gen_kconfig: move script license to SPDX format 2025-10-08 10:41:13 +02:00
krzysztof-cabaj
26928f994c cpu/stm32/gen_kconfig: templates - move licenses to SPDX format 2025-10-08 10:41:13 +02:00
Marian Buschsieweke
9cbd344fdc
Merge pull request #21718 from maribu/cpu/stm32/usbdev_fs/inverted-disconnect-pin
cpu/stm32/usbdev_fs: allow inverted disconnect GPIO
2025-10-07 18:44:07 +00:00
Marian Buschsieweke
26d8fe4383
cpu/stm32/usbdev_fs: allow inverted disconnect GPIO
The STM32F3 requires a dedicated digital signal to emulate a disconnect
event by pulling D+ down via a 1.5 kOhm resistor. Some boards, such as
the OLIMEXINO-STM32F3, do not directly connect a GPIO but place a
transistor in between. Depending on the exact implementation, the logic
level may end up being inverted compared to directly connecting a
GPIO.

This adds a flag member to the `stm32_usbdev_fs_config_t` and a new flag
to indicate inverted logic. In addition the members in the struct are
sorted by alignment, as this is a foolproof algorithm to prevent wasting
memory on unneeded padding.

Finally, the USB driver is adapted to honor the flag.

Co-authored-by: crasbe <crasbe@gmail.com>
2025-10-07 17:42:28 +02:00
krzysztof-cabaj
c6113d2630 cpu/stm32: move licenses to SPDX format 2025-10-02 10:24:48 +02:00
krzysztof-cabaj
d0decbd065 cpu: rename doc.txt -> doc.md for remaining CPUs 2025-09-05 13:14:22 +02:00
krzysztof-cabaj
7816da2d75 boards/nucleo-l412kb: add VBAT monitoring feature 2025-06-28 21:14:51 +02:00
krzysztof-cabaj
3fe4db6724 cpu/stm32/l4: add ADC support for l412kb 2025-06-27 22:04:59 +02:00
krzysztof-cabaj
6619a5acf4 boards/nucleo-l4: fix VBAT capable boards list 2025-06-10 17:14:26 +02:00
Marian Buschsieweke
cac44edec7
tree-wide: replace multiple empty lines with one
For each C source/header `$file`: `sed -e '/^$/N;/^\n$/D' -i $file`.
2025-05-21 22:51:04 +02:00
KSKNico
fe821eaa1d cpu: replace header guards with #pragma once 2025-05-21 17:13:37 +02:00
Marian Buschsieweke
4ce7ab2133
tree-wide: fix documentation issues
This should fix compilation with -Wdocumentation on LLVM.
2025-04-10 13:37:13 +02:00
crasbe
8a76cee6c5
Merge pull request #20971 from crasbe/pr/stm32_adc
cpu/stm32: Make ADC Resolution Definition uniform
2025-04-02 22:30:52 +00:00
crasbe
1d3939d882 cpu/stm32: make ADC resolution uniform 2025-04-02 22:45:35 +02:00
crasbe
596670bdde cpu/stm32f2: fix sampling time for VBat 2025-04-02 21:38:29 +02:00
Marian Buschsieweke
4f676cd318
Merge pull request #21238 from crasbe/pr/fix_stm32wl_adc
cpu/stm32{f3,l4,wb,wl}: Replace ztimer with busy_wait, fix VBat sampling time and {wl only} fix initialization sequence
2025-04-02 16:42:13 +00:00
crasbe
112e542923 cpu/stm32{f3,l4,wb,wl}: increase sampling time for VBat line 2025-04-02 16:53:33 +02:00
crasbe
f1a102bb87 cpu/stm32wl: fix ADC initialization sequence 2025-04-02 16:53:33 +02:00
crasbe
05eda72e96 cpu/stm32{f0,g0,c0}: fix ADC initialization sequence 2025-03-12 13:49:45 +01:00
crasbe
768989ca6f cpu/stm32{f3,l4,wb,wl}: replace ztimer w/ busy_wait for uncrit. delay 2025-03-12 13:20:33 +01:00
Gilles DOFFE
5d48376a21 cpu/stm32: add FDCAN support to STM32G4 family
Until now, STM32 MCUs classic CAN support is coded in can.c file.
However CAN FD in STM32G4 family is designed in a very different way:
* CAN FD channels are independant
* CAN FD channel configuration is done in a dedicated RAM block called
  message RAM, with one message RAM per channel
* Each message RAM is divided this way:
  - 11-bit filter (28 elements / 28 words)
  - 29-bit filter (8 elements / 16 words)
  - Rx FIFO 0 (3 elements / 54 words)
  - Rx FIFO 1 (3 elements / 54 words)
  - Tx event FIFO (3 elements / 6 words)
  - Tx buffers (3 elements / 54 words)

Due to these design differences with other STM32 MCUs, the choice is
made to split the driver in two files:
* classiccan.c for STM32 MCUs that support classical CAN. This file
  has just been renamed (previously can.c) to avoid build conflicts
  but does not introduce changes
* fdcan.c for STM32 MCUs that support CAN FD

Message RAM definitions is not provided in CMSIS headers of the STM32G4
family, they are defined in fdcandev_stm32.h. Those definitions could be
extracted to a new file for each STM32 families as some differences
exist with other STM32 families that support CAN FD (for instance
STM32H7). This could be done in a futher commit, according to new
families requirements.

CAN hardware parameters stay similar and are kept in can_params.h.

There are 36 filters per channel:
* 28 first filters are standard ID (11 bit) filters
* 8 last filters are extended ID (29 bit) filters

On each Tx frame sent, the STM32G4 can store Tx events in a dedicated
FIFO. This feature is not yet implemented and Tx event FIFO is disabled
by default.
Automatic retransmission on arbitration loss is enabled by default by
the STM32G4.

About Rx, if no filter is configured, all frames are accepted by
default.

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2025-01-29 20:51:23 +01:00
Gilles DOFFE
ae51a22fbb can: use frame len instead of can_dlc
RIOT implementation of CAN bus relies on SocketCAN model.
Since commit c398e56 (can: add optional DLC element to Classical CAN
frame structure), '__u8 can_dlc' attribute of struct can_frame is
considered as deprecated in SocketCAN and kept for legacy support.
Attribute '__u8 len' should be used instead.

	union {
		/* CAN frame payload length in byte (0 .. CAN_MAX_DLEN)
		 * was previously named can_dlc so we need to carry that
		 * name for legacy support
		 */
		__u8 len;
		__u8 can_dlc; /* deprecated */
	};

Moreover, CAN FD frame structure does not support legacy attribute
'can_dlc', making 'len' mandatory for incoming CAN FD support in RIOT.

	struct canfd_frame {
		canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
		__u8    len;     /* frame payload length in byte */
		__u8    flags;   /* additional flags for CAN FD */
		__u8    __res0;  /* reserved / padding */
		__u8    __res1;  /* reserved / padding */
		__u8    data[CANFD_MAX_DLEN]
__attribute__((aligned(8)));
	};

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2025-01-29 20:51:22 +01:00
Marian Buschsieweke
f4fcac25f6
Merge pull request #21011 from crasbe/pr/stm32l0_adc_fix
cpu/stm32l0,l1: Fix ADC initialization order
2025-01-15 20:56:07 +00:00
crasbe
17ee40dafa cpu/stm32l1: fix ADC initialization & resolution setting
Co-authored-by: benpicco <benpicco@googlemail.com>
2024-12-13 21:38:21 +01:00
krzysztof-cabaj
bb982ad3b2 cpu/stm32/eth: improve defines concerning checksum 2024-12-10 17:49:03 +01:00
krzysztof-cabaj
428a424581 cpu/stm32/eth: fix RX_DESC_STAT_ES define 2024-12-03 17:11:11 +01:00
Marian Buschsieweke
0dfd83938f
{cpu,drivers}/periph_gpio_ll: add missing include
For `gpio_ll_print_conf()` we need to include `<stdio.h>`, when not
using `fmt.h`.
2024-11-27 09:06:56 +01:00
benpicco
1938002526
Merge pull request #20926 from Enoch247/fix-stm32-periph-timer-spurious-irq
cpu/stm32/periph/timer: prevent spurious IRQs
2024-11-20 16:24:49 +00:00
Joshua DeWeese
f24fc69118 cpu/stm32/periph/timer: fix whitespace style 2024-11-19 21:50:23 -05:00
crasbe
2f8b23a596 cpu/stm32l0: fix ADC initialization order 2024-11-18 20:54:53 +01:00
Marian Buschsieweke
2b6f65a08a
build_system/xfa: change API to fix alignment
This changes the API of xfa from

    XFA(array_name, prio) type element_name = INITIALIZER;

to

    XFA(type, array_name, prio) element_name = INITIALIZER;

this allows forcing natural alignment of the type, fixing failing tests
on `native64`.
2024-11-07 16:30:01 +01:00
Marian Buschsieweke
c2c2cc8592
drivers/periph_gpio: let gpio_read() return bool
Since https://github.com/RIOT-OS/RIOT/pull/20935 gpio_write()
uses a `bool` instead of an `int`. This does the same treatment for
`gpio_read()`.

This does indeed add an instruction to `gpio_read()` implementations.
However, users caring about an instruction more are better served with
`gpio_ll_read()` anyway. And `gpio_read() == 1` is often seen in
newcomer's code, which would now work as expected.
2024-10-23 13:24:09 +02:00
Benjamin Valentin
4627f66caa drivers/periph/gpio: make gpio_write() take a bool 2024-10-22 16:39:48 +02:00
Joshua DeWeese
4e357d410c cpu/stm32/periph/timer: prevnt spurious IRQs
This patch hardens the STM32 timer driver against some possible causes
of spurious IRQs.
2024-10-18 15:51:42 -04:00
Didier DONSEZ
84ec09f3cf boards/nucleo-l432kc: add configuration CAN peripheral
Signed-off-by: Didier DONSEZ <didier.donsez@gmail.com>
2024-10-07 17:35:10 +02:00
krzysztof-cabaj
2d52ebd136 cpu/stm32/f4: add ADC support for f439zi 2024-08-16 10:03:33 +02:00
Marian Buschsieweke
8839ccbe50
cpu/stm32: implement periph_gpio_ll_switch_dir
This implements periph_gpio_ll_switch_dir for STM32 except for STM32F1,
which has a different register layout.
2024-08-08 22:17:35 +02:00
Marian Buschsieweke
422042bd00
drivers/periph_gpio_ll_irq: make support for both edges optional
The assumption that every MCU has this feature turned out wrong. Hence,
add a feature to allow testing for support of edge triggered IRQs on
both flanks.
2024-08-02 13:41:36 +02:00
Marian Buschsieweke
4a092862f8
cpu/stm32/periph_eth: adapt to GPIO LL API change 2024-08-02 09:55:25 +02:00
Marian Buschsieweke
36e8526046
drivers/periph_gpio_ll: change API to access GPIO ports
The API was based on the assumption that GPIO ports are mapped in memory
sanely, so that a `GPIO_PORT(num)` macro would work allow for constant
folding when `num` is known and still be efficient when it is not.

Some MCUs, however, will need a look up tables to efficiently translate
GPIO port numbers to the port's base address. This will prevent the use
of such a `GPIO_PORT(num)` macro in constant initializers.

As a result, we rather provide `GPIO_PORT_0`, `GPIO_PORT_1`, etc. macros
for each GPIO port present (regardless of MCU naming scheme), as well as
`GPIO_PORT_A`, `GPIO_PORT_B`, etc. macros if (and only if) the MCU port
naming scheme uses letters rather than numbers.

These can be defined as macros to the peripheral base address even when
those are randomly mapped into the address space. In addition, a C
function `gpio_port()` replaces the role of the `GPIO_PORT()` and
`gpio_port_num()` the `GPIO_PORT_NUM()` macro. Those functions will
still be implemented as efficient as possible and will allow constant
folding where it was formerly possible. Hence, there is no downside for
MCUs with sane peripheral memory mapping, but it is highly beneficial
for the crazy ones.

There are also two benefits for the non-crazy MCUs:
1. We can now test for valid port numbers with `#ifdef GPIO_PORT_<NUM>`
    - This directly benefits the test in `tests/periph/gpio_ll`, which
      can now provide a valid GPIO port for each and every board
    - Writing to invalid memory mapped I/O addresses was treated as
      triggering undefined behavior by the compiler and used as a
      optimization opportunity
2. We can now detect at compile time if the naming scheme of the MCU
   uses letters or numbers, and produce more user friendly output.
    - This is directly applied in the test app
2024-08-02 09:55:24 +02:00
krzysztof-cabaj
99b5bc1f4f cpu/stm32/l4: enable missing star-up time 2024-07-24 12:09:42 +02:00
crasbe
f93aa40186 cpu/stm32: add ADC support for WB55 2024-07-08 11:18:57 +02:00