This commit is contained in:
2025-12-12 23:05:27 +06:00
parent 537e7bfe10
commit 64bb06f292
4 changed files with 23 additions and 26 deletions

View File

@@ -150,10 +150,11 @@ static inline void i2c_init(void) {
RCC->APB2PCENR |= RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO;
RCC->APB1PCENR |= RCC_APB1Periph_I2C1;
// PB6 (SCL) and PB7 (SDA)
GPIOB->CFGLR &= ~(0xFF << (4 * 6));
GPIOB->CFGLR |= ((GPIO_Speed_10MHz | GPIO_CNF_OUT_OD_AF) << (4 * 6)) |
((GPIO_Speed_10MHz | GPIO_CNF_OUT_OD_AF) << (4 * 7));
AFIO->PCFR1 |= AFIO_PCFR1_I2C1_REMAP; // I2C1_RM: 1
// PB8 (SCL) and PB9 (SDA)
funPinMode(PB8, GPIO_CFGLR_OUT_10Mhz_AF_OD);
funPinMode(PB9, GPIO_CFGLR_OUT_10Mhz_AF_OD);
// Reset I2C1 to init all regs
RCC->APB1PRSTR |= RCC_APB1Periph_I2C1;