Hllo
Not exactly، i'm going to show you how to set each pin to I2C1 as alternate functions:
For PB6, write 0 to the bit 12 of the GPIOB_MODER register and 1 to the bit 13 of the GPIOB_MODER register. After that, write 0 to the bits 24, 25 and 27 of the GPIOB_AFRL register and 1 to the bit 26 of the GPIOB_AFRL register.
For PB7, write 0 to the bit 14 of the GPIOB_MODER register and 1 to the bit 15 of the GPIOB_MODER register. After that, write 0 to the bits 28, 29 and 31 of the GPIOB_AFRL register and 1 to the bit 30 of the GPIOB_AFRL register.
For PB8, write 0 to the bit 16 of the GPIOB_MODER register and 1 to the bit 17 of the GPIOB_MODER register. After that, write 0 to the bits 0, 1 and 3 of the GPIOB_AFRH register and 1 to the bit 2 of the GPIOB_AFRH register.
For PB9, write 0 to the bit 18 of the GPIOB_MODER register and 1 to the bit 19 of the GPIOB_MODER register. After that, write 0 to the bits 4, 5 and 7 of the GPIOB_AFRH register and 1 to the bit 6 of the GPIOB_AFRH register.
GPIOB_MODER used to select the mode of the gpio (digital input, digital output, alternate function or analog).
GPIOB_AFRL used to select the alternate function of each of the pins PB0->PB7
GPIOB_AFRH used to select the alternate function of each of the pins PB8->PB15.
Please take a look at the GPIO chapter of the RM0385 For more details.
Best Regards.
STTwo-32
