2022-04-21 05:42 AM
2022-04-21 11:09 AM
SYSCFG->PMCR
*SYSCFG_PMCR
Such redefining has no advantage at all, but has a disadvantage - one can forget the * (pointer dereferencing) somewhere.
uint32_t ISR = *ADC_ISR;
Typically constants are named all upper-case, not variables. At least call the variable, for example, rISR, so that the first lower-case letter tells it's a variable and "r" semantically tells that it holds register data.
Defining globally names like CCR, RES, CONT, CFGR etc. will have many conflicts with other peripherals.
Seriously, why not use CMSIS defined peripheral structures and bit field macros?
2022-04-21 11:31 AM
Note that I am not saying the following is a valid reason,
I started programming the STM32H7 as a part of the PortentaH7 on Arduino IDE and I found no libraries which were not, at some point, conflicting with Arduino. So since I am lazy I found a random way to define what I needed and I kept it since then.
Still, I take your comment into account and will change my code accordingly (all I need to know about CMSIS is in the programming manual right?)
2022-04-22 01:12 PM
Read my comment about the same thing in this topic:
Here is a link for H7:
But Arduino does not redefine registers. They use the same ST's files:
You just had to not invent anything and just use the already provided definitions... ;)
2022-04-22 01:52 PM
I am grateful for the tips about CMSIS (as a matter of fact I made the beginner mistake described in your post...), I'll take my time reading about it and using it in my code (it might solve some issues linked to my register definitions).
Thanks a lot for your help and time