stm32f1xx-hal
stm32f1xx-hal copied to clipboard
serial::{Tx, Rx}::{listen, unlisten} are unsafe
And also Rx::{listen_idle, unlisten_idle} are unsafe.
They all use unsafe { (*USART::ptr()).cr1.modify(|_, w| w. ...) };.
It is non-atomic read-modify-write.
Tx and Rx can be used simultaneously from different execution threads. At the same time, they do not provide thread-safe access.
technically we could rewrite those with bit-banding (bb::set)
I think this will be the most optimal solution.