...
Notice that there is only 1 NMOS transistor that controls Vout. A Pull-up/Pull-down GPIO has two transistors. The drain is connected to the signal, and the source is tied to ground. This means the STM32 can only pull the line LOW. It needs a pull-up resistor to go back HIGH, as the pin is left floating. This plays a crucial role in preventing contention (Covered in arbitration and clock stretching) and leaving the output in something called “High-Z”. If you’re still confused by the purpose of Pull Up/Pull Down Resistors, see this document.
Pull-up Resistors:
The value of your pull-up resistor plays a crucial role in efficient communication. The following relations are important in choosing your pull-up resistance:
...