diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-12-07 19:23:09 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-12-07 19:23:09 +0000 |
commit | 3799bf56f52f7a5be9eeda6757c6642105c4ed66 (patch) | |
tree | 561082b62d25f9f4ec0f26c2cb5657b1e27c8aae /os/hal/src/i2c.c | |
parent | b9df6d7c801d711fda3d83cd9a2eb7b456f60276 (diff) | |
download | ChibiOS-3799bf56f52f7a5be9eeda6757c6642105c4ed66.tar.gz ChibiOS-3799bf56f52f7a5be9eeda6757c6642105c4ed66.tar.bz2 ChibiOS-3799bf56f52f7a5be9eeda6757c6642105c4ed66.zip |
I2C. Error handling from userland code added.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3572 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src/i2c.c')
-rw-r--r-- | os/hal/src/i2c.c | 12 |
1 files changed, 10 insertions, 2 deletions
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);
}
/**
|