diff options
author | Timofey Titovets <nefelim4ag@gmail.com> | 2024-10-21 14:19:56 +0200 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2024-10-26 22:06:30 -0400 |
commit | a4aa2a900267c83d20247f93e6ddb06f63324135 (patch) | |
tree | 7c0d71f171ebc997e9205f8ed0489017a70878bc /src/stm32/stm32f0_i2c.c | |
parent | 08a85ba869c3232ca7063c737c238ca41e20885e (diff) | |
download | kutter-a4aa2a900267c83d20247f93e6ddb06f63324135.tar.gz kutter-a4aa2a900267c83d20247f93e6ddb06f63324135.tar.xz kutter-a4aa2a900267c83d20247f93e6ddb06f63324135.zip |
i2c: handle errors at i2ccmds
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Diffstat (limited to 'src/stm32/stm32f0_i2c.c')
-rw-r--r-- | src/stm32/stm32f0_i2c.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/stm32/stm32f0_i2c.c b/src/stm32/stm32f0_i2c.c index b83ceb0f..1baa28a9 100644 --- a/src/stm32/stm32f0_i2c.c +++ b/src/stm32/stm32f0_i2c.c @@ -9,6 +9,7 @@ #include "gpio.h" // i2c_setup #include "internal.h" // GPIO #include "sched.h" // sched_shutdown +#include "i2ccmds.h" // I2C_BUS_SUCCESS struct i2c_info { I2C_TypeDef *i2c; @@ -188,7 +189,7 @@ i2c_wait(I2C_TypeDef *i2c, uint32_t set, uint32_t timeout) } } -void +int i2c_write(struct i2c_config config, uint8_t write_len, uint8_t *write) { I2C_TypeDef *i2c = config.i2c; @@ -202,9 +203,11 @@ i2c_write(struct i2c_config config, uint8_t write_len, uint8_t *write) i2c->TXDR = *write++; } i2c_wait(i2c, I2C_ISR_TXE, timeout); + + return I2C_BUS_SUCCESS; } -void +int i2c_read(struct i2c_config config, uint8_t reg_len, uint8_t *reg , uint8_t read_len, uint8_t *read) { @@ -228,4 +231,6 @@ i2c_read(struct i2c_config config, uint8_t reg_len, uint8_t *reg *read++ = i2c->RXDR; } i2c_wait(i2c, I2C_ISR_STOPF, timeout); + + return I2C_BUS_SUCCESS; } |