...
Open-Drain:
The defining characteristic of I2C buses is that both SCL and SDA are open-drain pins. Put simply, the pins are driven by a single transistor(MOSFET), where the When Vin is HIGH, Vout = GND. However, when Vin is LOW, we notice that Vout is left floating. That's when the pull-up resistor pulls the line HIGH
...
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”
...
Notice that there is only 1 NMOS transistor that controls Vout. A
Pull-up /Pull-down GPIO has two transistors. When Vin is HIGH, Vout = GND. However, when Vin is LOW, we notice that Vout is left floating. That's when the pull-up resistor pulls the line HIGH.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:
Higher supply voltage → Higher pull-up resistor (V/I = R)
More resistance → Lower power and current consumption (V2/R = Power) (V/R = I)
Lower resistance → Higher bandwidth/frequencies; faster rise time
More capacitance → Lower pull-up resistor
Generally, you should check the GPIO pins source/sinking current to determine the sizing of the pull-up/down resistor. Common values are 1k, 4.7k, 10k, but that will always depend on the scenario)
...