I am using an STM32F4 discovery board and I have the following array v
typedef struct pin_map_dummy {
GPIO_TypeDef* GPIO_Port;
uint16_t GPIO_Pin;
} pin_map_t;
...
vector_pin_t v={{GPIOD,GPIO_Pin_0},{GPIOD,GPIO_Pin_1},{GPIOD,GPIO_Pin_2},
{GPIOD,GPIO_Pin_3} , {GPIOD,GPIO_Pin_4}, {GPIOD,GPIO_Pin_5}, {GPIOD,GPIO_Pin_6}, {GPIOD,GPIO_Pin_7}};
I'm passing the array to the initialization function but I'm trying to figure out if it's possible to set each Pin to a different GPIO port, in the array v all pins are located in PORTD but what if one pin happens to be in PORTA
This is the GPIO init function:
void init_library(vector_pin_t pines)
{
GPIO_InitTypeDef puerto;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
puerto.GPIO_Pin = pines[0].GPIO_Pin | pines[1].GPIO_Pin | pines[2].GPIO_Pin | pines[3].GPIO_Pin
| pines[4].GPIO_Pin | pines[5].GPIO_Pin | pines[6].GPIO_Pin | pines[7].GPIO_Pin ; //All pins
puerto.GPIO_Mode = GPIO_Mode_OUT;
puerto.GPIO_OType = GPIO_OType_PP;
puerto.GPIO_Speed = GPIO_Speed_100MHz;
puerto.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(pines[0].GPIO_Port, &puerto);
}