cembeddedinfineon

Is using the vendors libary with bitfields for mapping register a good idea?


For the TLE985x Infineon uses bitfields to map the registers in their library. Since I'm am kind of new to embedded programming, I read about bitfields. Many of the articles mentiond bad effects of bitfield. Now the question is, when bitfields are somehow bad, why is Infineon using it in their library?

Thank you for your help


Solution

  • Whether to use the default register maps from the vendor or roll out your own is pretty much project-specific. If you have high requirements of portability and general source code quality, you have to make your own register map.

    Some discussion on that topic can be found here: How to access a hardware register from firmware? As discussed in that post, the vendor has several reasons for rolling out their own custom, crappy register maps:

    What you could do however, in case of Infineon specifically, is to ask: "Hey guys, you seem to like automotive electronics a lot. The automotive industry has been using MISRA-C since 1998. How come you still don't provide MISRA-C compliant libraries in the year 2020? You don't want automotive customers to use your products?" Lots of amusing mumbling responses to be had.