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/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/i2c.c')
-rw-r--r-- | src/stm32/i2c.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/stm32/i2c.c b/src/stm32/i2c.c index 4bb8b105..441f611a 100644 --- a/src/stm32/i2c.c +++ b/src/stm32/i2c.c @@ -11,6 +11,7 @@ #include "internal.h" // GPIO #include "sched.h" // sched_shutdown #include "board/irq.h" //irq_disable +#include "i2ccmds.h" // I2C_BUS_SUCCESS struct i2c_info { I2C_TypeDef *i2c; @@ -149,7 +150,7 @@ i2c_stop(I2C_TypeDef *i2c, uint32_t timeout) i2c_wait(i2c, 0, I2C_SR1_TXE, timeout); } -void +int i2c_write(struct i2c_config config, uint8_t write_len, uint8_t *write) { I2C_TypeDef *i2c = config.i2c; @@ -159,9 +160,11 @@ i2c_write(struct i2c_config config, uint8_t write_len, uint8_t *write) while (write_len--) i2c_send_byte(i2c, *write++, timeout); i2c_stop(i2c, 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) { @@ -182,4 +185,6 @@ i2c_read(struct i2c_config config, uint8_t reg_len, uint8_t *reg read++; } i2c_wait(i2c, 0, I2C_SR1_RXNE, timeout); + + return I2C_BUS_SUCCESS; } |