japaric / stm32f103xx-hal

HAL for the STM32F103xx family of microcontrollers
Apache License 2.0
116 stars 40 forks source link

Make serial error flags reset after read #53

Closed TheZoq2 closed 5 years ago

TheZoq2 commented 6 years ago

If any error occurs during serial read, a flag is set in the USARTx_SR register. However, this flag is not currently reset after being read which means that any errors are permanent.

The flags are reset by a read from the sr register followed by a read from dr which is what this PR does.

This seems to work in my limted testing, but I am not sure why the sr.<bit>().bit_is_set() doesn't count as a read for this purpose.

Frans-Willem commented 6 years ago

I too would like to see this merged. :+1:

TheZoq2 commented 6 years ago

There has been some discussion about this in the HAL crate https://github.com/japaric/embedded-hal/issues/85. Some people are advocating different methods for resetting error flags. I would say that this is still the best method, at least until the HAL has a specified way of doing things

eeeeeta commented 5 years ago

I also ran into this issue today, and would love to see it get merged!

TheZoq2 commented 5 years ago

Unless you find any other problems after my fix, this should be mergeable, right? @TeXitoi

TeXitoi commented 5 years ago

@TheZoq2 sorry, I forgot this PR.

eeeeeta commented 5 years ago

Thanks for merging, @therealprof - tested these changes out and they work perfectly!

eeeeeta commented 5 years ago

Thanks for merging, @therealprof - tested these changes out and they work perfectly!