diff options
| author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-06-30 13:43:42 +0000 |
|---|---|---|
| committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-06-30 13:43:42 +0000 |
| commit | f73960c8dcbcc2f4f4b4aba8599a45485038ec82 (patch) | |
| tree | a0eb72d7c2cd323b10b90e9ef3b7d4d763652bae /os/hal/platforms | |
| parent | 73ce7b4fe096f227fbabbe471a283f1b916383fb (diff) | |
| download | ChibiOS-f73960c8dcbcc2f4f4b4aba8599a45485038ec82.tar.gz ChibiOS-f73960c8dcbcc2f4f4b4aba8599a45485038ec82.tar.bz2 ChibiOS-f73960c8dcbcc2f4f4b4aba8599a45485038ec82.zip | |
I2C. API changed. Transmit and receive buffers removed from I2CSlaveConfig. Now pointers to that buffers pass in functions arguments.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3099 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms')
| -rw-r--r-- | os/hal/platforms/STM32/i2c_lld.c | 17 | ||||
| -rw-r--r-- | os/hal/platforms/STM32/i2c_lld.h | 6 |
2 files changed, 16 insertions, 7 deletions
diff --git a/os/hal/platforms/STM32/i2c_lld.c b/os/hal/platforms/STM32/i2c_lld.c index 0bc113313..d9ca29a9e 100644 --- a/os/hal/platforms/STM32/i2c_lld.c +++ b/os/hal/platforms/STM32/i2c_lld.c @@ -70,7 +70,7 @@ static void i2c_serve_event_interrupt(I2CDriver *i2cp) { break; } /* Initialize the transmit buffer pointer */ - txBuffp = (uint8_t*)i2cp->id_slave_config->txbuf; + txBuffp = (uint8_t*)i2cp->txbuf; i2cp->txbytes--; /* If no further data to be sent, disable the I2C ITBUF in order * to not have a TxE interrupt */ @@ -107,7 +107,7 @@ static void i2c_serve_event_interrupt(I2CDriver *i2cp) { /* Disable ITEVT In order to not have again a BTF IT */ dp->CR2 &= (uint16_t)~I2C_CR2_ITEVTEN; /* send restart and begin reading operations */ - i2c_lld_master_receive(i2cp, i2cp->slave_addr, i2cp->rxbytes); + i2c_lld_master_receive(i2cp, i2cp->slave_addr, i2cp->rxbuf, i2cp->rxbytes); } break; @@ -133,7 +133,7 @@ static void i2c_serve_event_interrupt(I2CDriver *i2cp) { } chSysUnlockFromIsr(); /* Initialize receive buffer pointer */ - rxBuffp = i2cp->id_slave_config->rxbuf; + rxBuffp = i2cp->rxbuf; break; case I2C_EV7_MASTER_REC_BYTE_RECEIVED: if(i2cp->rxbytes != 3) { @@ -530,10 +530,14 @@ void i2c_lld_stop(I2CDriver *i2cp) { * @param[in] rxbytes number of bytes to be received * */ -void i2c_lld_master_transmit(I2CDriver *i2cp, uint16_t slave_addr, size_t txbytes, size_t rxbytes) { +void i2c_lld_master_transmit(I2CDriver *i2cp, uint16_t slave_addr, + uint8_t *txbuf, size_t txbytes, uint8_t *rxbuf, size_t rxbytes) { + i2cp->slave_addr = slave_addr; i2cp->txbytes = txbytes; i2cp->rxbytes = rxbytes; + i2cp->txbuf = txbuf; + i2cp->rxbuf = rxbuf; /* enable ERR, EVT & BUF ITs */ i2cp->id_i2c->CR2 |= (I2C_CR2_ITERREN|I2C_CR2_ITEVTEN|I2C_CR2_ITBUFEN); @@ -579,9 +583,12 @@ void i2c_lld_master_transmit(I2CDriver *i2cp, uint16_t slave_addr, size_t txbyte * @param[in] rxbytes number of bytes to be received * */ -void i2c_lld_master_receive(I2CDriver *i2cp, uint16_t slave_addr, size_t rxbytes){ +void i2c_lld_master_receive(I2CDriver *i2cp, uint16_t slave_addr, + uint8_t *rxbuf, size_t rxbytes){ + i2cp->slave_addr = slave_addr; i2cp->rxbytes = rxbytes; + i2cp->rxbuf = rxbuf; /* enable ERR, EVT & BUF ITs */ i2cp->id_i2c->CR2 |= (I2C_CR2_ITERREN|I2C_CR2_ITEVTEN|I2C_CR2_ITBUFEN); diff --git a/os/hal/platforms/STM32/i2c_lld.h b/os/hal/platforms/STM32/i2c_lld.h index d9cd40915..f1f065359 100644 --- a/os/hal/platforms/STM32/i2c_lld.h +++ b/os/hal/platforms/STM32/i2c_lld.h @@ -165,6 +165,8 @@ struct I2CDriver{ size_t txbytes; /*!< Number of bytes to be transmitted. */ size_t rxbytes; /*!< Number of bytes to be received. */ + uint8_t *rxbuf; /*!< Pointer to receive buffer. */ + uint8_t *txbuf; /*!< Pointer to transmit 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. */ @@ -228,9 +230,9 @@ 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); + uint8_t *txbuf, size_t txbytes, uint8_t *rxbuf, size_t rxbytes); void i2c_lld_master_receive(I2CDriver *i2cp, uint16_t slave_addr, - size_t rxbytes); + uint8_t *rxbuf, size_t rxbytes); #ifdef __cplusplus } |
