From b1d043cede9e37dccff9731978887f51a514c387 Mon Sep 17 00:00:00 2001 From: barthess Date: Thu, 23 Jun 2011 19:06:33 +0000 Subject: [PATCH] I2C. Some coding style improvements. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3074 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/i2c.h | 9 ++++++--- os/hal/platforms/STM32/i2c_lld.c | 4 ++-- os/hal/platforms/STM32/i2c_lld.h | 10 ++++++---- os/hal/src/i2c.c | 15 +++++++++++---- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/os/hal/include/i2c.h b/os/hal/include/i2c.h index c14bf2a74..a024ddd9e 100644 --- a/os/hal/include/i2c.h +++ b/os/hal/include/i2c.h @@ -115,7 +115,8 @@ typedef void (*i2ccallback_t)(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg); * @param[in] i2cscfg pointer to the @p I2CSlaveConfig object triggering the * callback */ -typedef void (*i2cerrorcallback_t)(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg); +typedef void (*i2cerrorcallback_t)(I2CDriver *i2cp, + const I2CSlaveConfig *i2cscfg); /** @@ -227,8 +228,10 @@ extern "C" { void i2cObjectInit(I2CDriver *i2cp); void i2cStart(I2CDriver *i2cp, const I2CConfig *config); void i2cStop(I2CDriver *i2cp); - void i2cMasterTransmit(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t slave_addr, size_t txbytes, size_t rxbytes); - void i2cMasterReceive(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t slave_addr, size_t rxbytes); + void i2cMasterTransmit(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, + uint16_t slave_addr, size_t txbytes, size_t rxbytes); + void i2cMasterReceive(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, + uint16_t slave_addr, size_t rxbytes); void i2cMasterStart(I2CDriver *i2cp); void i2cMasterStop(I2CDriver *i2cp); void i2cAddFlagsI(I2CDriver *i2cp, i2cflags_t mask); diff --git a/os/hal/platforms/STM32/i2c_lld.c b/os/hal/platforms/STM32/i2c_lld.c index 6f2f26714..1dc58e8e6 100644 --- a/os/hal/platforms/STM32/i2c_lld.c +++ b/os/hal/platforms/STM32/i2c_lld.c @@ -42,8 +42,8 @@ static uint32_t i2c_get_event(I2CDriver *i2cp){ } static void i2c_serve_event_interrupt(I2CDriver *i2cp) { -#define txBuffp (i2cp->txBuffp) -#define rxBuffp (i2cp->rxBuffp) +#define txBuffp (i2cp->txbuff_p) +#define rxBuffp (i2cp->rxbuff_p) I2C_TypeDef *dp = i2cp->id_i2c; diff --git a/os/hal/platforms/STM32/i2c_lld.h b/os/hal/platforms/STM32/i2c_lld.h index d0c1415c4..51c975c37 100644 --- a/os/hal/platforms/STM32/i2c_lld.h +++ b/os/hal/platforms/STM32/i2c_lld.h @@ -165,8 +165,8 @@ struct I2CDriver{ size_t txbytes; /*!< Number of bytes to be transmitted. */ size_t rxbytes; /*!< Number of bytes to be received. */ - uint8_t *rxBuffp; /*!< Pointer to the current byte in slave rx buffer. */ - uint8_t *txBuffp; /*!< Pointer to the current byte in slave tx buffer. */ + uint8_t *rxbuff_p; /*!< Pointer to the current byte in slave rx buffer. */ + uint8_t *txbuff_p; /*!< Pointer to the current byte in slave tx buffer. */ i2cflags_t errors; /*!< Error flags.*/ i2cflags_t flags; /*!< State flags.*/ @@ -227,8 +227,10 @@ void i2c_lld_set_opmode(I2CDriver *i2cp); void i2c_lld_set_own_address(I2CDriver *i2cp); void i2c_lld_start(I2CDriver *i2cp); void i2c_lld_stop(I2CDriver *i2cp); -void i2c_lld_master_transmit(I2CDriver *i2cp, uint16_t slave_addr, size_t txbytes, size_t rxbytes); -void i2c_lld_master_receive(I2CDriver *i2cp, uint16_t slave_addr, size_t rxbytes); +void i2c_lld_master_transmit(I2CDriver *i2cp, uint16_t slave_addr, + size_t txbytes, size_t rxbytes); +void i2c_lld_master_receive(I2CDriver *i2cp, uint16_t slave_addr, + size_t rxbytes); #ifdef __cplusplus } diff --git a/os/hal/src/i2c.c b/os/hal/src/i2c.c index 377b27ecf..490ecf656 100644 --- a/os/hal/src/i2c.c +++ b/os/hal/src/i2c.c @@ -69,8 +69,8 @@ void i2cObjectInit(I2CDriver *i2cp) { i2cp->id_state = I2C_STOP; i2cp->id_config = NULL; - i2cp->rxBuffp = NULL; - i2cp->txBuffp = NULL; + i2cp->rxbuff_p = NULL; + i2cp->txbuff_p = NULL; i2cp->id_slave_config = NULL; #if I2C_USE_WAIT @@ -144,7 +144,11 @@ void i2cStop(I2CDriver *i2cp) { * @param[in] txbytes number of bytes to be transmited * @param[in] rxbytes number of bytes to be received */ -void i2cMasterTransmit(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t slave_addr, size_t txbytes, size_t rxbytes) { +void i2cMasterTransmit(I2CDriver *i2cp, + const I2CSlaveConfig *i2cscfg, + uint16_t slave_addr, + size_t txbytes, + size_t rxbytes) { chDbgCheck((i2cp != NULL) && (i2cscfg != NULL) &&\ (slave_addr != 0) &&\ @@ -191,7 +195,10 @@ void i2cMasterTransmit(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t * Bits 10-14 unused. * @param[in] txbytes number of bytes to be transmited */ -void i2cMasterReceive(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t slave_addr, size_t rxbytes){ +void i2cMasterReceive(I2CDriver *i2cp, + const I2CSlaveConfig *i2cscfg, + uint16_t slave_addr, + size_t rxbytes){ chDbgCheck((i2cp != NULL) && (i2cscfg != NULL) &&\ (slave_addr != 0) &&\