Check how something like [this](https://github.com/STMicroelectronics/cmsis-device-f4/blob/1777d8832e57ec2974afaa9f24dc3ac56bb4cffb/Include/stm32f4xx.h#L227-L280) would be feasible and useful, using `std::atomic` primitives.