From e5595bc757f2dab3c9c582e8de6358613fa9af25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Tue, 3 Oct 2017 23:59:27 +0200 Subject: [PATCH] Extract I2C recovery code to recoverI2c() --- right/src/init_peripherals.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/right/src/init_peripherals.c b/right/src/init_peripherals.c index 1687acf..c487ae9 100644 --- a/right/src/init_peripherals.c +++ b/right/src/init_peripherals.c @@ -26,11 +26,8 @@ void delay(void) for (volatile uint32_t i=0; i<62; i++); } -void InitI2cMainBus(void) +void recoverI2c(void) { - CLOCK_EnableClock(I2C_MAIN_BUS_SDA_CLOCK); - CLOCK_EnableClock(I2C_MAIN_BUS_SCL_CLOCK); - PORT_SetPinMux(I2C_MAIN_BUS_SDA_PORT, I2C_MAIN_BUS_SCL_PIN, kPORT_MuxAsGpio); GPIO_PinInit(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SCL_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1}); PORT_SetPinMux(I2C_MAIN_BUS_SCL_PORT, I2C_MAIN_BUS_SDA_PIN, kPORT_MuxAsGpio); @@ -49,6 +46,14 @@ void InitI2cMainBus(void) delay(); GPIO_WritePinOutput(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SDA_PIN, 1); delay(); +} + +void InitI2cMainBus(void) +{ + CLOCK_EnableClock(I2C_MAIN_BUS_SDA_CLOCK); + CLOCK_EnableClock(I2C_MAIN_BUS_SCL_CLOCK); + + recoverI2c(); port_pin_config_t pinConfig = { .pullSelect = kPORT_PullUp,