I would like to concatenate a string and an integer (enum) for addressing a port/pin in an embedded system project. Ports are namend:
M1_MS1_GPIO_Port
M2_MS1_GPIO_Port
M2_MS1_GPIO_Port
... and the pins are named accordingly
M1_MS1_GPIO_Pin
M2_MS1_GPIO_Pin
M2_MS1_GPIO_Pin
...
Now I would like to have a function that gets a number, and calles the GPIO_Write function. I tried something like
#define SETMS1(NUMBER) (HAL_GPIO_WritePin(M##NUMBER##_GPIO_Port ...)
void set_MS1( int M )
{
SETMS1( M );
}
But M is not resolved as a number. Is there any way to do this?