From 3f913efda03fd840cd526ef72e6f397c7da61bd7 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Tue, 9 Aug 2022 22:23:08 +0200 Subject: code layout --- fw/fe310/eos/soc/i2c.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'fw/fe310/eos/soc/i2c.c') diff --git a/fw/fe310/eos/soc/i2c.c b/fw/fe310/eos/soc/i2c.c index a507af1..553a9bf 100644 --- a/fw/fe310/eos/soc/i2c.c +++ b/fw/fe310/eos/soc/i2c.c @@ -11,22 +11,28 @@ int eos_i2c_init(uint8_t wakeup_cause) { eos_i2c_speed(EOS_I2C_SPEED); - // eos_i2c_start(); + eos_i2c_enable(); return EOS_OK; } -void eos_i2c_start(void) { +void eos_i2c_enable(void) { I2C0_REGB(I2C_CONTROL) |= I2C_CONTROL_EN; + GPIO_REG(GPIO_IOF_SEL) &= ~IOF0_I2C0_MASK; GPIO_REG(GPIO_IOF_EN) |= IOF0_I2C0_MASK; } -void eos_i2c_stop(void) { +void eos_i2c_disable(void) { GPIO_REG(GPIO_IOF_EN) &= ~IOF0_I2C0_MASK; + I2C0_REGB(I2C_CONTROL) &= ~I2C_CONTROL_EN; } +int eos_i2c_enabled(void) { + return !!(GPIO_REG(GPIO_IOF_EN) & IOF0_I2C0_MASK); +} + void eos_i2c_speed(uint32_t baud_rate) { unsigned long clock_rate = PRCI_get_cpu_freq(); uint16_t prescaler = (clock_rate / (baud_rate * 5)) - 1; -- cgit v1.2.3