-
-
Notifications
You must be signed in to change notification settings - Fork 39.6k
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
[Core] Allow ChibiOS SIO
driver for UART
driver
#22839
Conversation
5fb34c8
to
540ddb6
Compare
builddefs/common_features.mk
Outdated
@@ -951,6 +951,11 @@ ifeq ($(strip $(SPI_DRIVER_REQUIRED)), yes) | |||
endif | |||
|
|||
ifeq ($(strip $(UART_DRIVER_REQUIRED)), yes) | |||
OPT_DEFS += -DHAL_USE_SERIAL=TRUE | |||
ifneq ($(filter $(MCU_SERIES),RP2040),) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like this solution, is it the best we can do?
IMHO the whole driver infrastructure scream for a makeover - but this is outside the scope of this PR. |
540ddb6
to
28454f5
Compare
28454f5
to
cc3192d
Compare
Tested on both RP2040 and STM32F411. |
platforms/chibios/drivers/uart_sio.c
Outdated
}; | ||
// clang-format on | ||
#else | ||
static SIOConfig sioConfig = {SIO_DEFAULT_BITRATE, UART_CR1, UART_CR2, UART_CR3}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This initializer is not correct even for STM32 USARTv2 and USARTv3 (USARTv1 does not have a SIO driver implementation) — there is an extra presc
field there (and no differences between USARTv2 and USARTv3):
/**
* @brief Low level fields of the SIO configuration structure.
*/
#define sio_lld_config_fields \
/* Desired baud rate.*/ \
uint32_t baud; \
/* USART PRESC register initialization data.*/ \
uint32_t presc; \
/* USART CR1 register initialization data.*/ \
uint32_t cr1; \
/* USART CR2 register initialization data.*/ \
uint32_t cr2; \
/* USART CR3 register initialization data.*/ \
uint32_t cr3
Maybe you can fix and test this code even on STM32 if you have suitable chips:
- USARTv1: F1xx, F4xx, L1xx — no SIO support there ❌
- USARTv2: F0xx, F3xx, F37x, F7x, L0xx, L4xx, WBxx, WLxx — SIO supported, but the USART hardware does not have FIFOs
- USARTv3: G0xx, G4xx, H7xx, L4xx+, L5xx — SIO supported; G4xx, L4xx**+**, L5xx chips apparently have RX/TX FIFOs with 8 entries; G0B1/G0C1 chips have 8-entry FIFOs for USART1/2/3 and LPUART1/2, but not others
Although some of those devices may have noticeable problems, because the USART peripheral on many of those chips does not have any FIFO, and the SIO driver does not perform any buffering (and even if the hardware has FIFOs, 8 entries might be not enough).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed comment. Just a quick reply - I've ordered some WeAct G431 dev boards as I don't have any USARTv3 boards with FIFOs. The F303 devboard I have has problems both with the sio and serial driver - I'm investigating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sigprof The G431 boards arrived and the UART driver works just fine with the SERIAL
and SIO
implementation on this board. The F303 had problems due to the pin mapping, but works just fine with SERIAL
. For now I opted to just enable the SIO
driver for RP2040 though to keep the configuration simple.
platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/config.h
Outdated
Show resolved
Hide resolved
598749f
to
a780bf8
Compare
7d27d56
to
b1324f3
Compare
b1324f3
to
72d051f
Compare
Signed-off-by: Stefan Kerkmann <[email protected]>
Signed-off-by: Stefan Kerkmann <[email protected]>
Signed-off-by: Stefan Kerkmann <[email protected]> Co-authored-by: Sergey Vlasov <[email protected]>
72d051f
to
095a015
Compare
Co-authored-by: Joel Challis <[email protected]>
* onekey: stm32f3_disco: add usart pins and activate peripheral Signed-off-by: Stefan Kerkmann <[email protected]> * chibios: uart: change SD1 prefix to UART Signed-off-by: Stefan Kerkmann <[email protected]> * chibios: uart: add SIO driver and RP2040 compatibility Signed-off-by: Stefan Kerkmann <[email protected]> Co-authored-by: Sergey Vlasov <[email protected]> * Update platforms/chibios/drivers/uart.h Co-authored-by: Joel Challis <[email protected]> --------- Signed-off-by: Stefan Kerkmann <[email protected]> Co-authored-by: Sergey Vlasov <[email protected]> Co-authored-by: Joel Challis <[email protected]>
* onekey: stm32f3_disco: add usart pins and activate peripheral Signed-off-by: Stefan Kerkmann <[email protected]> * chibios: uart: change SD1 prefix to UART Signed-off-by: Stefan Kerkmann <[email protected]> * chibios: uart: add SIO driver and RP2040 compatibility Signed-off-by: Stefan Kerkmann <[email protected]> Co-authored-by: Sergey Vlasov <[email protected]> * Update platforms/chibios/drivers/uart.h Co-authored-by: Joel Challis <[email protected]> --------- Signed-off-by: Stefan Kerkmann <[email protected]> Co-authored-by: Sergey Vlasov <[email protected]> Co-authored-by: Joel Challis <[email protected]>
Description
SD1
UART prefix toUART
SIO
driver forUART
SIO
forUART
by default for RP2040Types of Changes
Issues Fixed or Closed by This PR
Checklist