2023-01-31 04:23 AM
Code isn't complex, hence i don't understand what could be the problem.
char pin_status;
pin_status=HAL_GPIO_ReadPin(SENSOR_H1_GPIO_Port,SENSOR_H1_Pin);
2023-01-31 05:05 AM
If there is nothing connected, the pin is floating and the result undetermined, maybe 1 maybe 0.
hth
KnarfB
2023-01-31 05:05 AM
There is no problem. If nothing is connected and the pin is not pulled up or high internally, random level is read. Random may be 0 or 1, depending on humidity, air ionization, touching etc. Enable the pull-down to force it to 0 when left open.
2023-01-31 09:11 AM
First, read the GPIO HW registers in debug mode, not a variable .
Second, manually turn the GPIO MODER and OUT registers to turn the pin to output low.
Then check the IDR pin level.
If the registers are always zero, the GPIO clock enable is missing
If the input level does not change, the pin is forced by external HW to its level.