2014-07-10 05:39 AM
Hi All
I'm using an STM32L151 in my project.I have one GPIO configured as an input, and I need to change the direction dynamically. What is the most efficient way to do this ?Each time I want to change direction, should I:Call GPIO_Deinit()Re-populate the structure GPIO_InitStructure according to the new directionCall GPIO_Init()Is there a most efficient way to do ?ThanksJerome #gpio-port #stm32l #gpio #stm322014-07-10 06:56 AM
Don't use the ''library'' functions, write to GPIO registers (here: GPIOx_MODER, or the bit-band ''mirror'' of the respective bit(s)) directly.
JW2014-07-14 12:25 AM
My goal was to switch between driven high and high-Z, what worked for me was:
GPIOA->MODER |= (0x0001<<2);
// make OUTPUT
GPIOA->MODER &= ~(0x0003<<2);
// make INPUT