3 ms·
> Who still writes code like this!? Believe or not, a majority number of ARM MCU vendors does that with CMSIS headers in my experience (ST, TI, NXP, Nordic, EF
by kbumsik 8y ago
> Who still writes code like this!?
Believe or not, a majority number of ARM MCU vendors does that with CMSIS headers in my experience (ST, TI, NXP, Nordic, EFM32...). To be more precise, the registers are accessed using mask and shift macros. I've work on many ARMs too but only Atmel's header files use struct bitfield you mentioned.
But yeah, I've also seen that most of non-ARM vendors use struct bitfield.
- AceJohnny2 8y agoHm, is armcc still a thing? I don't remember what it guaranteed (or not) for bitfields. If it doesn't work consistently, that would explain that they're using masks and shifts. That, and because the C standard leaves it implementation-defined.
- monocasa 8y agoThe ARM ABI defines a lot of useful semantics for bitfields (particularly when combined with volatile), but GCC perennially regresses and breaks them so next to no one uses them.