Skip to main content
Lead II
March 19, 2026
Solved

Option to not have a GPIO port typecasted to a pointer

  • March 19, 2026
  • 1 reply
  • 170 views

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

 

Best answer by Ghofrane GSOURI

Hello @unsigned_char_array 

A change request #0060932  has been raised to dev team for feasibility check.

I will keep you posted with updates.

THX

Ghofrane

1 reply

Ghofrane GSOURI
Ghofrane GSOURIBest answer
Technical Moderator
March 24, 2026

Hello @unsigned_char_array 

A change request #0060932  has been raised to dev team for feasibility check.

I will keep you posted with updates.

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.