Mastering STM32 by Carmine Noviello, Read 6.2 GPIOs Configuration section and the section 6.2.1 GPIO Mode.