AnsweredAssumed Answered

How to index diferent GPIO ports and pins

Question asked by anton.bogdan on Jun 6, 2018
Latest reply on Jun 6, 2018 by Tilen MAJERLE


i have a aplication where a SPI master from the stm32 chip is connected to 30 pieces of mux chips.

Each of the 30 spi channels has a enable signal connected to diferent gpio ports on the mcu side.


The enable signals are named EN1....EN30,   but for example en1 is on GPIOA PA3,    EN11 is on GPIOB PB7, en30 is on GPIOD PD9.


Is it posible to store these gpio ports and gpio pins like a array structure? 


Something like:


port_array[30] = { GPIOA.......GPIOD }

port_pins[30] = { GPIO_Pin_3....GPIO_Pin_9 }


for( i=0; i<30; i++) {


port_array[i] -> BSRRH = port_pins[i]; // set port Lo  

between here i send the data over master spi

port_array[i] -> BSRRL = port_pins[i]; // set port Hi