2021-12-09 06:38 AM
Do this with Arduino"
#define OutputSDIO() pinMode(SDIO,OUTPUT)
#define InputSDIO() pinMode(SDIO,INPUT)" functions. What functions can I do this using stm32cubeide?
2021-12-09 06:54 AM
If you need to read state of an (open collector) pin set to output, just set the pin as output, its input level can be read regardless of that.
If you need to switch between input and output dynamically, change the given pin's setting in GPIO_MODER, read the GPIO chapter in RM.
I don't use Cube/HAL.
JW
2021-12-09 01:26 PM
HAL_GPIO_Init can be used to initialize pins in input or output mode. STM32CubeMX will generate example initialization code for you.
For example, this initializes PA0 in input mode:
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
2021-12-09 11:21 PM
Hi. first of all thank you very much. How can I fix this error?
2021-12-09 11:27 PM
Create the variable you are using. You could do so locally within the subroutine.