From f3e571839bd7649073664d1c2c4ea3842695b6d5 Mon Sep 17 00:00:00 2001 From: barthess Date: Sat, 18 Jun 2011 13:35:26 +0000 Subject: I2C. Code cleanups. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3056 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/i2c.h | 17 ++++++----------- os/hal/platforms/STM32/i2c_lld.h | 8 ++------ os/hal/src/i2c.c | 2 +- 3 files changed, 9 insertions(+), 18 deletions(-) (limited to 'os') diff --git a/os/hal/include/i2c.h b/os/hal/include/i2c.h index 6b8661c7e..cc551887d 100644 --- a/os/hal/include/i2c.h +++ b/os/hal/include/i2c.h @@ -96,11 +96,7 @@ typedef enum { /** * @brief I2C notification callback type. * @details This callback invoked when byte transfer finish event occurs, - * No matter sending or reading. This function designed - * for sending (re)start or stop events to I2C bus from user level. - * - * If callback function is set to NULL - driver atomaticcaly - * generate stop condition after the transfer finish. + * No matter sending or reading. * * @param[in] i2cp pointer to the @p I2CDriver object triggering the * callback @@ -135,8 +131,7 @@ typedef uint8_t i2cblock_t; struct I2CSlaveConfig{ /** * @brief Callback pointer. - * @note Transfer finished callback. Invoke when all data transferred, or - * by DMA buffer events + * @note Transfer finished callback. Invoke when all data transferred. * If set to @p NULL then the callback is disabled. */ i2ccallback_t id_callback; @@ -154,8 +149,8 @@ struct I2CSlaveConfig{ i2cblock_t *txbuf; /*!< Pointer to transmit buffer.*/ uint16_t slave_addr; /*!< Slave device address.*/ uint8_t nbit_addr; /*!< Length of address (must be 7 or 10).*/ - i2cflags_t errors; - i2cflags_t flags; + i2cflags_t errors; /*!< Error flags.*/ + i2cflags_t flags; /*!< State flags.*/ /* Status Change @p EventSource.*/ EventSource sevent; }; @@ -212,7 +207,7 @@ struct I2CSlaveConfig{ * - Callback invocation. * - Waiting thread wakeup, if any. * - Driver state transitions. - * . + * * @note This macro is meant to be used in the low level drivers * implementation only. * @@ -236,7 +231,7 @@ extern "C" { #endif void i2cInit(void); void i2cObjectInit(I2CDriver *i2cp); - void i2cStart(I2CDriver *i2cp, I2CConfig *config); + void i2cStart(I2CDriver *i2cp, const I2CConfig *config); void i2cStop(I2CDriver *i2cp); void i2cMasterTransmit(I2CDriver *i2cp, I2CSlaveConfig *i2cscfg); void i2cMasterReceive(I2CDriver *i2cp, I2CSlaveConfig *i2cscfg); diff --git a/os/hal/platforms/STM32/i2c_lld.h b/os/hal/platforms/STM32/i2c_lld.h index a97e863f6..815e451f0 100644 --- a/os/hal/platforms/STM32/i2c_lld.h +++ b/os/hal/platforms/STM32/i2c_lld.h @@ -157,15 +157,11 @@ struct I2CDriver{ /** * @brief Current configuration data. */ - I2CConfig *id_config; + const I2CConfig *id_config; /** * @brief Current slave configuration data. */ I2CSlaveConfig *id_slave_config; - /** - * @brief RW-bit sent to slave. - */ - uint8_t rw_bit; uint8_t slave_addr1; // 7-bit address of the slave uint8_t slave_addr2; // used in 10-bit address mode @@ -194,7 +190,7 @@ struct I2CDriver{ */ #define i2c_lld_wait_bus_free(i2cp) { \ uint32_t tmo = 0xffff; \ - while((i2cp->id_i2c->SR2 & I2C_SR2_BUSY) && tmo--) \ + while((i2cp->id_i2c->SR2 & I2C_SR2_BUSY) && tmo--) \ ; \ } diff --git a/os/hal/src/i2c.c b/os/hal/src/i2c.c index b43be0261..cd1a238ba 100644 --- a/os/hal/src/i2c.c +++ b/os/hal/src/i2c.c @@ -96,7 +96,7 @@ void i2cObjectInit(I2CDriver *i2cp) { * * @api */ -void i2cStart(I2CDriver *i2cp, I2CConfig *config) { +void i2cStart(I2CDriver *i2cp, const I2CConfig *config) { chDbgCheck((i2cp != NULL) && (config != NULL), "i2cStart"); -- cgit v1.2.3