1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/stm32/periph
bors[bot] 6f0ac0c092
Merge #19460
19460: cpu/stm32/usbdev_fs: fix ep registration and EP_REG assignments r=gschorcht a=dylad

### Contribution description
This PR provides two fixes for the `usbdev_fs` driver:

- Fix endpoints registration
- Fix assignment of toggleable bits in EP_REG(x) registers

These bugs were encountered with the USBUS MSC implementation.

Regarding the endpoints registration:

For the `usbdev_fs` peripheral, IN and OUT endpoints of the same index must have the same type.
For instance, if EP1 OUT is a bulk endpoint, EP1 IN must either be unused or used as bulk too but it cannot be used as interrupt or isochronous.
With the previous check, the following registration pattern (EP OUT Bulk -> EP IN Interrupt -> EP IN Bulk) would assign both EP OUT Bulk and EP IN Interrupt to same endpoint index. So the configuration would be broken.
Applying the same registration pattern with this patch would now produce EP OUT Bulk -> 1 / EP IN Interrupt -> 2 / EP IN Bulk 1. Which is a working configuration for this IP.

and for the second fix:

EP_REG(x) registers have a total of 6 toggleable bits. Those bits can only be toggled if we write a one to it, otherwise writing a zero has no effect
This commit fixes all the access to these registers to prevent from modifying these bits when not needed.
Without this patch, the endpoint status (VALID / NACK / STALL) can be erroneously modify because bits are not cleared when assigning the new content to the register and thus make the bits toggle and change values.

### Testing procedure
This can be tested with tests/usbus_msc on any board using this `usbdev_fs` driver.
It is easier to test this PR with #19443 alongside. Then the following would be enough:
`CFLAGS='-DSECTOR_COUNT=64' USEMODULE='mtd_emulated' make -j8 BOARD=p-nucleo-wb55 -C tests/usbus_msc flash`

Otherwise this can also be tested by attaching a SPI<->SDCARD adapter.

### Issues/PRs references
None.

Co-authored-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-04-09 16:03:55 +00:00
..
adc_f0_g0.c cpu/stm32: add VBAT for stm32 2022-02-21 10:49:43 +01:00
adc_f1.c cpu/stm32/periph/adc_f1: removes ADC configuration loading 2020-08-27 03:56:26 +02:00
adc_f2.c cpu/stm32: add VBAT for stm32 2022-02-21 10:49:43 +01:00
adc_f3.c cpu/stm32: add VBAT for stm32 2022-02-21 10:49:43 +01:00
adc_f4_f7.c cpu/stm32: add sampling time to F4/F7 ADC driver 2022-02-21 10:49:43 +01:00
adc_l0.c cpu/stm32/periph/adc_l0: removes ADC configuration loading 2020-08-27 03:58:33 +02:00
adc_l1.c cpu/stm32/periph/adc_l1: removes ADC configuration loading 2020-08-27 03:56:26 +02:00
adc_l4.c cpu/stm32/l4: add ADC support for l496zg 2022-11-21 05:52:02 -05:00
adc_wl.c cpu/stm32: add VBAT for stm32 2022-02-21 10:49:43 +01:00
can.c cpu/stm32/periph_can: use container_of() 2021-12-03 10:12:35 +01:00
dac.c cpu/stm32: adapt Doxygen documentation 2020-05-20 13:39:11 +02:00
dma.c cpu/stm32/periph/dma: make dma_prepare() generic 2022-10-26 09:36:45 -04:00
doc.txt cpu/stm32: Add stm32_eth_auto for auto-negotiation 2020-10-22 12:37:23 +02:00
eeprom.c cpu/*: realign ENABLE_DEBUG 2020-10-23 00:46:26 +02:00
eth_common.c cpu/stm32/periph_eth: add stm32_eth_tracing 2022-09-14 14:00:27 +02:00
eth.c core/lib: Add macros/utils.h header 2023-01-07 09:47:44 +01:00
flash_common.c cpu/stm32: add initial support for stm32u5 family 2021-12-23 11:04:41 +01:00
flashpage.c cpu/stm32: add initial support for stm32u5 family 2021-12-23 11:04:41 +01:00
gpio_all.c cpu/stm32: add initial support for stm32u5 family 2021-12-23 11:04:41 +01:00
gpio_f1.c treewide: fix typos 2022-09-15 12:12:23 +02:00
gpio_ll_irq.c cpu/stm32/periph_gpio_ll: Fix misleading comments 2023-04-06 08:31:48 +02:00
gpio_ll.c cpu/stm32/periph_gpio_ll: Fix misleading comments 2023-04-06 08:31:48 +02:00
hwrng.c cpu/stm32: add initial support for stm32u5 family 2021-12-23 11:04:41 +01:00
i2c_1.c cpu/stm32/periph/i2c_1: export PERIPH_I2C_MAX_BYTES_PER_FRAME 2023-02-14 17:39:42 +01:00
i2c_2.c cpu/stm32: i2c include panic.h 2022-02-12 18:30:58 +01:00
Kconfig cpu/stm32: improvement of USB driver selection 2022-11-03 13:52:01 +01:00
Kconfig.eth cpu/{sam0_common, stm32}: select netdev_legacy_api in KConfig 2022-08-17 23:37:05 +02:00
ltdc.c cpu/stm32: adapt ltdc periph disp_dev interface 2022-04-13 12:49:58 +02:00
Makefile cpu/stm32: fix periph_usb modeling for STM32F1 2022-10-14 16:20:04 +02:00
pm.c cpu/{cortexm_common, stm32}: add support for backup RAM 2022-01-21 15:53:18 +01:00
ptp.c stm32/ptp: avoid creating a new rounding rule 2021-03-29 16:27:27 +02:00
pwm.c cpu/stm32/periph_pwm: support pin remap for F1 2022-10-27 14:28:06 +02:00
qdec.c cpu/stm32/periph_qdec: support pin remap for F1 2022-10-27 14:28:06 +02:00
rtc_all.c cpu/stm32: add rtc_mem 2021-09-07 10:06:31 +02:00
rtc_f1.c cpu/*: realign ENABLE_DEBUG 2020-10-23 00:46:26 +02:00
rtc_mem.c cpu/stm32: add rtc_mem 2021-09-07 10:06:31 +02:00
rtt_all.c boards/stm32g031-disco,examples,tests: Added STM32G031-DISCO board 2021-10-13 12:14:45 -04:00
rtt_f1.c cpu/*: realign ENABLE_DEBUG 2020-10-23 00:46:26 +02:00
spi.c cpu/stm32: Fix periph_spi operation in non-DMA mode 2023-03-30 10:36:20 +02:00
timer.c cpu/stm32/periph/timer: fix clobered IRQ flag 2023-03-13 14:01:48 -04:00
uart.c treewide/stm32: Make CLOCK_HS* configurable 2022-11-03 11:37:28 +01:00
usbdev_fs.c cpu/stm32/usbdev_fs: fix EP_REG(x) assignment for toggleable bits 2023-04-07 22:35:45 +02:00
vbat.c cpu/stm32: add VBAT for stm32 2022-02-21 10:49:43 +01:00
wdt.c cpu/*: remove unneeded ENABLE_DEBUG 2020-10-23 11:29:57 +02:00