1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

46600 Commits

Author SHA1 Message Date
Gilles DOFFE
3347170db0 tests/conn_can: make test support CAN FD
Increase Shell buffer size for 64 bytes payload length of CAN FD frame.
This also implies to increase main thread stack size and especially for
native architectures.
Add two new sub-commands to test_can command:
* fdsend: to send a CAN FD frame
* fdsendrtr: to send a CAN FD RTR frame (payload length = 0).

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2024-11-03 23:14:30 +01:00
Gilles DOFFE
1d3197843b boards/nucleo-g431rb: enable periph_can
Enable periph_can to add CAN FD support to nucleo-g431rb.

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2024-11-03 23:14:30 +01:00
Gilles DOFFE
e826ec8e3b cpu/native: enable CAN FD support
As CAN FD is already supported by SocketCAN on Linux, just enable the
fdcan pseudomodule and allow CAN FD frames.

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2024-11-03 23:14:30 +01:00
Gilles DOFFE
42da782e88 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>
2024-11-03 23:14:30 +01:00
Gilles DOFFE
6c02337c33 can: introduce loop_delay
During the data phase of a FDCAN transmission only one node is
transmitting, all others are receivers. The length of the bus line has
no impact.
When transmitting via pin FDCAN_TX the protocol controller receives the
transmitted data from its local CAN transceiver via pin FDCAN_RX. The
received data is delayed by the CAN transceiver loop delay.
If this delay is greater than TSEG1 (time segment before sample point),
a bit error is detected. Without transceiver delay compensation, the bit
rate in the data phase of a FDCAN frame is limited by the transceiver's
loop delay.

Since this parameter is related to the transceiver used, there cannot be
a default value, and it must be explicitly defined with the
configuration variable CONFIG_FDCAN_DEVICE_TRANSCEIVER_LOOP_DELAY.

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2024-11-03 23:14:23 +01:00
Gilles DOFFE
f1163c317e can: add CAN FD configuration
Add CAN FD specifities to CAN system library in RIOT:
* 64 bytes payload
* Bit rate switching
* Error State Indicator

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2024-11-03 22:16:41 +01:00
Gilles DOFFE
0b03226f58 makefiles: introduce fdcan pseudomodule
This pseudomodule is used to enable code depending on CAN FD support.

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2024-11-03 22:16:41 +01:00
Gilles DOFFE
99d7cb34d8 can: introduce typedef can_frame_t
Whole CAN code in RIOT is using 'struct can_frame' to represent a CAN
frame.
However incoming CAN FD support will bring 'struct canfd_frame' to
represent CAN FD frames.
Even if the 'struct canfd_frame' has additional flags and a bigger
payload, it is aligned on 'struct can_frame' and thus they can be
referenced by the same pointers in the code.

As it is impossible to predict which one will be used in RIOT, just
define a new type 'can_frame_t' which will map to the right struct
according to the MCU CAN supported format.

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2024-11-03 22:16:41 +01:00
Gilles DOFFE
80aee7b5e7 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>
2024-11-03 22:16:41 +01:00
Marian Buschsieweke
5ae4c96cba
Merge pull request #20946 from maribu/sys/nanocoap/fix-header-size-computation
sys/net/nanocoap: fix coap_get_total_hdr_len()
2024-11-01 15:39:35 +00:00
Marian Buschsieweke
2b3da3911c
tests/unittests: increase coverage for coap_get_total_hdr_len()
Previously the corner case when RFC 8974 extended TKL fields are used
the result of coap_get_totel_hdr_len() was not tested, resulting in a
bug slipping through the test. This increase the test coverage.
2024-11-01 13:59:20 +01:00
Marian Buschsieweke
469edf4827
sys/net/nanocoap: fix coap_get_total_hdr_len()
Before `coap_get_total_hdr_len()` did not take the extended TKL field
(RFC 8974) into account. This fixes the issue.
2024-11-01 13:58:34 +01:00
mguetschow
00e25adfe3
Merge pull request #20720 from netd-tud/chacha20-glue-code-implementation
sys/psa_crypto: one-shot Chacha20 support
2024-10-29 16:52:30 +00:00
benpicco
1fc9d1bb82
Merge pull request #20934 from LasseRosenow/pthread-attr-setstack
sys/posix/pthread: Add pthread_attr_getstack and pthread_attr_setstack
2024-10-29 16:17:51 +00:00
Lasse Rosenow
459b8dc6aa
sys/posix/pthread: Add pthread_attr_getstack and pthread_attr_setstack 2024-10-29 13:29:54 +00:00
Marian Buschsieweke
02e059546f
Merge pull request #20944 from maribu/sys/usbus/stable-ids
sys/usb: Use luid_base for stable USB serials
2024-10-29 09:10:31 +00:00
mguetschow
94bb7b2915
Merge pull request #20943 from maribu/sys/luid/get/fixed_width
sys/luid: luid_custom() use fixed width int
2024-10-29 08:46:27 +00:00
Marian Buschsieweke
6b80a1a61e
sys/usb: Use luid_base for stable USB serials
This is useful when having multiple instances of the same board
connected via USB CDC ACM and telling the TTYs apart.
2024-10-29 09:40:22 +01:00
Marian Buschsieweke
49c151e432
sys/luid: luid_custom() use fixed width int
This changes the type of the last parameter of `luid_custom()` to a
fixed width integer for consistent behavior among different
architectures.
2024-10-28 14:51:44 +01:00
Teufelchen
b376bec667
Merge pull request #20847 from benpicco/event_assert
sys/event: add assertion that event has a handler
2024-10-25 08:11:51 +00:00
Marian Buschsieweke
ba83fefe3b
Merge pull request #20936 from maribu/drivers/periph_gpio/gpio_read/bool
drivers/periph_gpio: let gpio_read() return bool
2024-10-24 20:43:55 +00:00
benpicco
ae36fa4b37
Merge pull request #20921 from Vjorald/cord-doc
sys/net/app/cord: update doc
2024-10-24 16:59:01 +00:00
mguetschow
fbde0209d1
Merge pull request #20933 from benpicco/sys/net/application_layer/gcoap-ipv4
gcoap: fix build with IPv4
2024-10-24 09:28:23 +00:00
Marian Buschsieweke
7d1313b3bf
treewide: update rust-riot-wrappers 2024-10-24 09:57:36 +02:00
benpicco
87c825dd82
Merge pull request #20915 from fabian18/pr/gcoap_forward_proxy_timeout
gcoap/forward_proxy: handle timeout case
2024-10-23 21:58:57 +00:00
Marian Buschsieweke
ceeb787a6f
drivers: no need to convert gpio_read() to bool
We just changed the API so that it returns bool anyway.
2024-10-23 13:24:10 +02: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
benpicco
faa10032ca
Merge pull request #20935 from benpicco/gpio_write-bool
drivers/periph/gpio: make `gpio_write()` take a bool
2024-10-22 14:59:41 +00:00
Benjamin Valentin
4627f66caa drivers/periph/gpio: make gpio_write() take a bool 2024-10-22 16:39:48 +02:00
Marian Buschsieweke
75a5f0f12f
Merge pull request #20912 from maribu/boards/adafruit-metro-m4-express
boards/adafruit-metro-m4-express: initial port
2024-10-22 13:58:18 +00:00
Marian Buschsieweke
d9863c6b3c
boards/adafruit-metro-m4-express: initial port
This adds the board specification of the Adafruit Metro M4 Express [1].
The significance of this board is that it is compatible with both
classical SPI Arduino Shields using the ISP header for SPI
(such as `shield_w5100`) and more recent shields using D11/D12/D13 as
SPI (such as `shield_llcc68`).

[1]: https://learn.adafruit.com/adafruit-metro-m4-express-featuring-atsamd51/overview
2024-10-22 15:54:45 +02:00
benpicco
9187145df3
Merge pull request #20932 from benpicco/boards/samd5x-adc_freq
boards/samd5x: GCLK source for ADC must not exceed 100 MHz
2024-10-22 13:01:11 +00:00
Benjamin Valentin
419fc6e7f6 boards/samd5x: GCLK source for ADC must not exceed 100 MHz 2024-10-22 14:54:17 +02:00
Benjamin Valentin
ce6d753aa1 gcoap: fix build with IPv4 2024-10-22 14:04:20 +02:00
benpicco
33b1cac251
Merge pull request #20931 from krzysztof-cabaj/nucleo-64-pinout-source
boards/nucleo64: add pinout source
2024-10-22 09:03:31 +00:00
mguetschow
e5c185b9eb
Merge pull request #20927 from Firobe/dht-fix
drivers/dht: fix null deref with saul
2024-10-21 13:54:50 +00:00
Virgile Robles
7c68f00cd1 drivers/dht: test and doc 2024-10-21 15:13:23 +02:00
benpicco
c48247f984
Merge pull request #20916 from derMihai/mir/event_sync_mainline
sys/event: add event_sync()
2024-10-21 09:55:56 +00:00
Virgile Robles
a2db594eb5 drivers/dht: fix null deref with saul 2024-10-20 07:53:52 +02:00
krzysztof-cabaj
53b2f78ce7 boards/nucleo-l4: add pinout source 2024-10-19 18:10:06 +02:00
krzysztof-cabaj
c9e4ae173b boards/nucleo64-l0: add pinout source 2024-10-19 18:09:57 +02:00
Vjorald
d2600f8eff cord/doc: Remove the label (Not Yet Implemented) and the group part
Co-authored-by: chrysn <chrysn@fsfe.org>
2024-10-18 23:55:07 +02:00
Vjorald
d4fb64cfbc cord/doc: Update references to RFC 9176 2024-10-18 23:52:35 +02:00
Marian Buschsieweke
616e6a526a
Merge pull request #20924 from Enoch247/fix-ztimer-timer-reschedule
sys/ztimer: fix re-scheduling of timers
2024-10-18 21:25:33 +00:00
Joshua DeWeese
45942f6821 sys/ztimer: fix re-scheduling of timers
If the timer at the head of a ztimer clock's timer list is re-scheduled
(ztimer_set() called on an already set timer) and the timer is no longer
at the head after being re-scheduled, clock-ops->set() is never called
from inside ztimer_set(), and the underlying timer is left with an ISR
scheduled to expire at the timer's old time. The intended behavior is
that the clock's lower level timer should always be set to expire at the
time of the clocks head timer.

This patch changes ztimer_set() to call _ztimer_update(), which sets the
lower level timer according to the current list of timers, rather than
setting the timer directly inside of ztimer_set().
2024-10-18 14:52:11 -04:00
krzysztof-cabaj
f96151ea2d boards/nucleo64-l1: add pinout source 2024-10-18 18:02:00 +02:00
krzysztof-cabaj
cdf84b5ca8 boards/nucleo64-f4: add pinout source 2024-10-18 18:02:00 +02:00
krzysztof-cabaj
f45ccded23 boards/nucleo64-f3: add pinout source 2024-10-18 18:02:00 +02:00
krzysztof-cabaj
8e46b11f08 boards/nucleo64-f1: add pinout source 2024-10-18 18:02:00 +02:00
krzysztof-cabaj
bc7511e03b boards/nucleo64-f0: add pinout source 2024-10-18 18:02:00 +02:00