How does a stm32f chip set its GPIO speed? (hardware, not register setting)
Generally this is done by having multiple different drivers for the line, of different sizes and therefore with varying output impedance. Recall the basic CMOS driver:







simulate this circuit &ndash; Schematic created using CircuitLab

Making the transistors larger increases their drive strength and lowers their on-resistance, but requires more charge to be moved on and off the gate when changing state. That results in increased power consumption.