cancel
Showing results for 
Search instead for 
Did you mean: 

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

 

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
1 ACCEPTED SOLUTION

Accepted Solutions
Ghofrane GSOURI
ST Employee

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.

View solution in original post

1 REPLY 1
Ghofrane GSOURI
ST Employee

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.