diff --git a/sw/airborne/mcu_periph/i2c.c b/sw/airborne/mcu_periph/i2c.c index d01c143638..897278d41c 100644 --- a/sw/airborne/mcu_periph/i2c.c +++ b/sw/airborne/mcu_periph/i2c.c @@ -69,32 +69,32 @@ void i2c_init(struct i2c_periph* p) { } -void i2c_transmit(struct i2c_periph* p, struct i2c_transaction* t, +bool_t i2c_transmit(struct i2c_periph* p, struct i2c_transaction* t, uint8_t s_addr, uint8_t len) { t->type = I2CTransTx; t->slave_addr = s_addr; t->len_w = len; t->len_r = 0; - i2c_submit(p, t); + return i2c_submit(p, t); } -void i2c_receive(struct i2c_periph* p, struct i2c_transaction* t, +bool_t i2c_receive(struct i2c_periph* p, struct i2c_transaction* t, uint8_t s_addr, uint16_t len) { t->type = I2CTransRx; t->slave_addr = s_addr; t->len_w = 0; t->len_r = len; - i2c_submit(p, t); + return i2c_submit(p, t); } -void i2c_transceive(struct i2c_periph* p, struct i2c_transaction* t, +bool_t i2c_transceive(struct i2c_periph* p, struct i2c_transaction* t, uint8_t s_addr, uint8_t len_w, uint16_t len_r) { t->type = I2CTransTxRx; t->slave_addr = s_addr; t->len_w = len_w; t->len_r = len_r; - i2c_submit(p, t); + return i2c_submit(p, t); } diff --git a/sw/airborne/mcu_periph/i2c.h b/sw/airborne/mcu_periph/i2c.h index 71ce56d095..6b22b0e9a9 100644 --- a/sw/airborne/mcu_periph/i2c.h +++ b/sw/airborne/mcu_periph/i2c.h @@ -176,15 +176,17 @@ extern void i2c_event(void); * Convenience functions. * Usually these are preferred over i2c_submit, * as they explicitly set the transaction type again. + * + * Return FALSE if submitting the transaction failed. */ -extern void i2c_transmit(struct i2c_periph* p, struct i2c_transaction* t, - uint8_t s_addr, uint8_t len); +extern bool_t i2c_transmit(struct i2c_periph* p, struct i2c_transaction* t, + uint8_t s_addr, uint8_t len); -extern void i2c_receive(struct i2c_periph* p, struct i2c_transaction* t, - uint8_t s_addr, uint16_t len); +extern bool_t i2c_receive(struct i2c_periph* p, struct i2c_transaction* t, + uint8_t s_addr, uint16_t len); -extern void i2c_transceive(struct i2c_periph* p, struct i2c_transaction* t, - uint8_t s_addr, uint8_t len_w, uint16_t len_r); +extern bool_t i2c_transceive(struct i2c_periph* p, struct i2c_transaction* t, + uint8_t s_addr, uint8_t len_w, uint16_t len_r); /** @}*/ /** @}*/