AnsweredAssumed Answered

GPIO Hal remap

Question asked by Denis Gottardello on Dec 22, 2016
Latest reply on Jan 3, 2017 by Khouloud G

Hi. I'm trying to remap a gpio pin from out to it but the following lines of code don't work.

Can someone help me?

I need to remap GPIOx, GPIO_Pin from out to in on the fly.

 

void DigitalInOut::SwitchToInput() {
    HAL_GPIO_DeInit(GPIOx, GPIO_Pin);
    GPIO_InitTypeDef GPIO_InitStruct;
    GPIO_InitStruct.Pin = GPIO_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOx, &GPIO_InitStruct);
}

 

void DigitalInOut::SwitchToOutput() {
    HAL_GPIO_DeInit(GPIOx, GPIO_Pin);
    GPIO_InitTypeDef GPIO_InitStruct;
    GPIO_InitStruct.Pin = GPIO_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    HAL_GPIO_Init(GPIOx, &GPIO_InitStruct);
}

Outcomes