stm32cubeMX difference between Gpio_output and Gpio_input
Inputs and outputs always imply from the point of view of the MCU.

Set the pin to input if the signal is generated by the other component.

Set the pin to output if the signal is to be generated by the MCU.

Read carefully the General-purpose I/Os (GPIO) chapter in the reference manual, and also these posts before setting input/output modes if you don't want to damage components.

Push-pull/open drain; pull-up/pull-down

STM32 Understanding GPIO Settings