diff options
-rw-r--r-- | os/hal/include/i2c.h | 5 | ||||
-rw-r--r-- | os/hal/src/i2c.c | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/os/hal/include/i2c.h b/os/hal/include/i2c.h index 8cfd97e75..5ee4887e9 100644 --- a/os/hal/include/i2c.h +++ b/os/hal/include/i2c.h @@ -181,15 +181,16 @@ extern "C" { void i2cObjectInit(I2CDriver *i2cp);
void i2cStart(I2CDriver *i2cp, const I2CConfig *config);
void i2cStop(I2CDriver *i2cp);
- void i2cMasterTransmit(I2CDriver *i2cp,
+ i2cflags_t i2cMasterTransmit(I2CDriver *i2cp,
uint8_t slave_addr,
uint8_t *txbuf, size_t txbytes,
uint8_t *rxbuf, size_t rxbytes);
- void i2cMasterReceive(I2CDriver *i2cp,
+ i2cflags_t i2cMasterReceive(I2CDriver *i2cp,
uint8_t slave_addr, uint8_t *rxbuf, size_t rxbytes);
void i2cMasterStart(I2CDriver *i2cp);
void i2cMasterStop(I2CDriver *i2cp);
void i2cAddFlagsI(I2CDriver *i2cp, i2cflags_t mask);
+ i2cflags_t i2cGetAndClearFlags(I2CDriver *i2cp);
#if I2C_USE_MUTUAL_EXCLUSION
void i2cAcquireBus(I2CDriver *i2cp);
diff --git a/os/hal/src/i2c.c b/os/hal/src/i2c.c index 996343104..f20932ef3 100644 --- a/os/hal/src/i2c.c +++ b/os/hal/src/i2c.c @@ -149,8 +149,10 @@ void i2cStop(I2CDriver *i2cp) { * @param[in] rxbuf pointer to receive buffer
* @param[in] rxbytes number of bytes to be received, set it to 0 if
* you want transmit only
+ *
+ * @return Zero if no errors, otherwise return error code.
*/
-void i2cMasterTransmit(I2CDriver *i2cp,
+i2cflags_t i2cMasterTransmit(I2CDriver *i2cp,
uint8_t slave_addr,
uint8_t *txbuf,
size_t txbytes,
@@ -173,6 +175,8 @@ void i2cMasterTransmit(I2CDriver *i2cp, i2cp->id_state = I2C_ACTIVE_TRANSMIT;
i2c_lld_master_transmit(i2cp, slave_addr, txbuf, txbytes, rxbuf, rxbytes);
_i2c_wait_s(i2cp);
+
+ return i2cGetAndClearFlags(i2cp);
}
/**
@@ -184,8 +188,10 @@ void i2cMasterTransmit(I2CDriver *i2cp, * @param[in] slave_addr slave device address (7 bits) without R/W bit
* @param[in] rxbytes number of bytes to be received
* @param[in] rxbuf pointer to receive buffer
+ *
+ * @return Zero if no errors, otherwise return error code.
*/
-void i2cMasterReceive(I2CDriver *i2cp,
+i2cflags_t i2cMasterReceive(I2CDriver *i2cp,
uint8_t slave_addr,
uint8_t *rxbuf,
size_t rxbytes){
@@ -205,6 +211,8 @@ void i2cMasterReceive(I2CDriver *i2cp, i2cp->id_state = I2C_ACTIVE_RECEIVE;
i2c_lld_master_receive(i2cp, slave_addr, rxbuf, rxbytes);
_i2c_wait_s(i2cp);
+
+ return i2cGetAndClearFlags(i2cp);
}
/**
|