stm32f1xx-hal icon indicating copy to clipboard operation
stm32f1xx-hal copied to clipboard

Use modify instead of write for clearing sr1

Open TheZoq2 opened this issue 4 years ago • 3 comments

As per the discussion in #282

This seems better, but it also leaves the possibility of some flags not being cleared if multiple flags are raised at the same time. Is that something that can even happen, and how should we deal with it then?

CC: @Disasm

TheZoq2 avatar Dec 23 '20 16:12 TheZoq2

I think that all errors should be additionally cleared before a transaction begins.

Disasm avatar Dec 23 '20 17:12 Disasm

I think this code is not optimal. You read sr1 twice. Before comparison and when do modify.

burrbull avatar Dec 26 '20 15:12 burrbull

Updated the PR with the suggested changes, status flags should now be cleared before starting a new transaction, and only the error we actually noted is cleared.

I hope the unsafe I had to add is correct, writing to read only registers should have no effect.

We also don't have a way to read more than one error flag, perhaps that's something we should add at some point

TheZoq2 avatar Jan 23 '21 09:01 TheZoq2