summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/soc/i2c.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-08-09 22:23:08 +0200
committerUros Majstorovic <majstor@majstor.org>2022-08-09 22:23:08 +0200
commit3f913efda03fd840cd526ef72e6f397c7da61bd7 (patch)
tree08f62c93e0e0660fdb7beba32276ff1ceb7a8a3c /fw/fe310/eos/soc/i2c.c
parent810dde21ee65653c15606917b19566cfbaaf165e (diff)
code layout
Diffstat (limited to 'fw/fe310/eos/soc/i2c.c')
-rw-r--r--fw/fe310/eos/soc/i2c.c12
1 files changed, 9 insertions, 3 deletions
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;