circuitpython/ports
Damien George 83827e8e63 stm32/uart: Fix race conditions and clearing status in IRQ handler.
Prior to this commit IRQs on STM32F4 could be lost because SR is cleared by
reading SR then reading DR.  For example, if both RXNE and IDLE IRQs were
active upon entry to the IRQ handler, then IDLE is lost because the code
that handles RXNE comes first and accidentally clears SR (by reading SR
then DR to get the incoming character).

This commit fixes this problem by making the IRQ handler more atomic in the
following operations:
- get current IRQ status flags
- deal with RX character
- clear remaining status flags
- call user handler

On the STM32F4 it's very hard to get this right because the only way to
clear IRQ status flags is to read SR then DR, but the read of DR may read
some data which should remain in the register until the user wants to read
it.  And it won't work to cache the read because RTS/CTS flow control will
then not work.  So instead the new code disables interrupts if the DR is
full and waits for the user to read it before reenabling the interrupts.

Fixes issue mentioned in #4599 and #6082.

Signed-off-by: Damien George <damien@micropython.org>
2021-10-28 13:14:21 +11:00
..
bare-arm all: Update to point to files in new shared/ directory. 2021-07-12 17:08:10 +10:00
cc3200 ports: Add board.json for all boards. 2021-10-27 14:04:53 +11:00
esp32 esp32/boards/ESP32_S2_WROVER: Link to specific deploy_s2 instructions. 2021-10-28 12:58:58 +11:00
esp8266 ports: Add board.json for all boards. 2021-10-27 14:04:53 +11:00
javascript javascript/Makefile: Change variable to EXPORTED_RUNTIME_METHODS. 2021-09-01 00:42:40 +10:00
mimxrt ports: Add board.json for all boards. 2021-10-27 14:04:53 +11:00
minimal minimal/mpconfigport.h: Use MICROPY_CONFIG_ROM_LEVEL_MINIMUM. 2021-09-16 13:24:33 +10:00
nrf ports: Add board.json for all boards. 2021-10-27 14:04:53 +11:00
pic16bit all: Update to point to files in new shared/ directory. 2021-07-12 17:08:10 +10:00
powerpc all: Update to point to files in new shared/ directory. 2021-07-12 17:08:10 +10:00
qemu-arm all: Update to point to files in new shared/ directory. 2021-07-12 17:08:10 +10:00
rp2 ports: Add board.json for all boards. 2021-10-27 14:04:53 +11:00
samd ports: Add board.json for all boards. 2021-10-27 14:04:53 +11:00
stm32 stm32/uart: Fix race conditions and clearing status in IRQ handler. 2021-10-28 13:14:21 +11:00
teensy all: Update to point to files in new shared/ directory. 2021-07-12 17:08:10 +10:00
unix unix/modusocket: Support MP_STREAM_POLL in unix socket_ioctl. 2021-10-19 22:48:10 +11:00
windows all: Remove MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE. 2021-09-16 16:04:03 +10:00
zephyr extmod/modbluetooth: Add connection interval to gap_connect. 2021-10-26 00:16:53 +11:00