chrysn / efm32gg-hal

Implementation of the `embedded-hal` traits for EFM32GG microcontrollers
9 stars 9 forks source link

Abundant critical sections for lack of bit-band access #1

Open chrysn opened 5 years ago

chrysn commented 5 years ago

There are currently several read-modify-write operations that are unprotected against race conditions.

These occur when a peripheral has been split into parts, and a part logically owns a few bits inside a register. That part could safely read-modify-write on that part of a single 32bit peripheral register, but a different part could simultaneously do the same with different bits of the same register.

Currently, those sections only have big FIXME comments (to be pointed towards this issue).

Paths forward on this issue would be packing them into critical sections, or (at least for setBit/clearBit use) bitband access (cf. https://github.com/rust-embedded/svd2rust/issues/226).

chrysn commented 5 years ago

The race-condition part has been replaced with critical sections -- would be nicer to just set the bits, but at last now that's a matter of style and efficiency rather than soundness.