Option to not have a GPIO port typecasted to a pointer
Split from Inconsistent pin naming - this is a separate suggestion.
I would like the option to have the define of a particular GPIO port, or all defines, not typecasted to a pointer. So only the base address as an uint32_t (or uintptr_t). This would make using it in C++ in constexpr easier. Because reinterpret_cast and pointer comparison is not allowed in a constant expression. This should be an additional define for backwards compatibility.
#define CLK_A_GPIO_PIN GPIO_PIN_0
#define CLK_A_GPIO_PORT GPIOF
#define CLK_A_GPIO_PORT_BASE GPIOF_BASE // <- for use in constexpr
In C++ it would be much easier to do things at compile time using templates and constexpr this way. Example:
- you want to create a function at compile time that sets 2 defined pins high
- if they are the same port they can be combined in one call to GPIO_set()
- if they are not the same port they need to be separate calls
- no macros needed in user code, no runtime checks needed, no manual tweaks needed, just optimal code for a specific pinout
