From edfa9d2fae1d667b3f71a8e61aa954ac2233e493 Mon Sep 17 00:00:00 2001 From: barthess Date: Thu, 8 Dec 2011 19:24:21 +0000 Subject: I2C. Added timeout in functions. Code clean ups. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3583 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/i2c.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'os/hal/include') diff --git a/os/hal/include/i2c.h b/os/hal/include/i2c.h index f412e8a97..31dcb53d5 100644 --- a/os/hal/include/i2c.h +++ b/os/hal/include/i2c.h @@ -108,12 +108,12 @@ typedef enum { * * @notapi */ -#define _i2c_wait_s(i2cp) { \ +#define _i2c_wait_s(i2cp, timeout, rdymsg) { \ chDbgAssert((i2cp)->id_thread == NULL, \ "_i2c_wait(), #1", "already waiting"); \ chSysLock(); \ (i2cp)->id_thread = chThdSelf(); \ - chSchGoSleepS(THD_STATE_SUSPENDED); \ + rdymsg = chSchGoSleepTimeoutS(THD_STATE_SUSPENDED, timeout); \ chSysUnlock(); \ } @@ -181,14 +181,15 @@ extern "C" { void i2cObjectInit(I2CDriver *i2cp); void i2cStart(I2CDriver *i2cp, const I2CConfig *config); void i2cStop(I2CDriver *i2cp); - i2cflags_t i2cMasterTransmit(I2CDriver *i2cp, + msg_t i2cMasterTransmit(I2CDriver *i2cp, uint8_t slave_addr, uint8_t *txbuf, size_t txbytes, - uint8_t *rxbuf, size_t rxbytes); - i2cflags_t i2cMasterReceive(I2CDriver *i2cp, - uint8_t slave_addr, uint8_t *rxbuf, size_t rxbytes); - void i2cAddFlagsI(I2CDriver *i2cp, i2cflags_t mask); - i2cflags_t i2cGetAndClearFlags(I2CDriver *i2cp); + uint8_t *rxbuf, size_t rxbytes, + i2cflags_t *errors, systime_t timeout); + msg_t i2cMasterReceive(I2CDriver *i2cp, + uint8_t slave_addr, + uint8_t *rxbuf, size_t rxbytes, + i2cflags_t *errors, systime_t timeout); #if I2C_USE_MUTUAL_EXCLUSION void i2cAcquireBus(I2CDriver *i2cp); -- cgit v1.2.3