From 6a31936e80ae2743376dcbf9d39cd92461c4deca Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Thu, 25 Nov 2021 01:59:07 +0100 Subject: i2s init/start/running fixed; i2c start returns error if i2s is running --- fw/fe310/eos/i2c.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'fw/fe310/eos/i2c.c') diff --git a/fw/fe310/eos/i2c.c b/fw/fe310/eos/i2c.c index 122a1b2..f296bc7 100644 --- a/fw/fe310/eos/i2c.c +++ b/fw/fe310/eos/i2c.c @@ -6,15 +6,24 @@ #include "prci_driver.h" #include "eos.h" +#include "i2s.h" #include "i2c.h" -void eos_i2c_start(uint32_t baud_rate) { - eos_i2c_set_baud_rate(baud_rate); +void eos_i2c_init(uint8_t wakeup_cause) { GPIO_REG(GPIO_IOF_SEL) &= ~IOF0_I2C0_MASK; +} + +int eos_i2c_start(uint32_t baud_rate) { + if (eos_i2s_running()) return EOS_ERR_BUSY; + + eos_i2c_set_baud_rate(baud_rate); GPIO_REG(GPIO_IOF_EN) |= IOF0_I2C0_MASK; + + return EOS_OK; } void eos_i2c_stop(void) { + if (eos_i2s_running()) return; GPIO_REG(GPIO_IOF_EN) &= ~IOF0_I2C0_MASK; } -- cgit v1.2.3