diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-04-01 16:16:18 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-04-01 16:16:18 +0000 |
commit | 356fb1a2a03fa00622580077007622d5c5e62555 (patch) | |
tree | 9044349351cd922c62f2343ce377b4e548086e55 /os | |
parent | 0ebb7959d58256bea8e65b2cbed282e840297880 (diff) | |
download | ChibiOS-356fb1a2a03fa00622580077007622d5c5e62555.tar.gz ChibiOS-356fb1a2a03fa00622580077007622d5c5e62555.tar.bz2 ChibiOS-356fb1a2a03fa00622580077007622d5c5e62555.zip |
I2Cv2 driver tested on STM32F37x.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5526 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r-- | os/hal/include/i2c.h | 8 | ||||
-rw-r--r-- | os/hal/platforms/STM32/I2Cv2/i2c_lld.c | 16 |
2 files changed, 15 insertions, 9 deletions
diff --git a/os/hal/include/i2c.h b/os/hal/include/i2c.h index c19ea64cb..b3a9ffdff 100644 --- a/os/hal/include/i2c.h +++ b/os/hal/include/i2c.h @@ -45,14 +45,10 @@ */
#define I2CD_NO_ERROR 0x00 /**< @brief No error. */
#define I2CD_BUS_ERROR 0x01 /**< @brief Bus Error. */
-#define I2CD_ARBITRATION_LOST 0x02 /**< @brief Arbitration Lost
- (master mode). */
+#define I2CD_ARBITRATION_LOST 0x02 /**< @brief Arbitration Lost. */
#define I2CD_ACK_FAILURE 0x04 /**< @brief Acknowledge Failure. */
#define I2CD_OVERRUN 0x08 /**< @brief Overrun/Underrun. */
-#define I2CD_PEC_ERROR 0x10 /**< @brief PEC Error in
- reception. */
-#define I2CD_TIMEOUT 0x20 /**< @brief Hardware timeout. */
-#define I2CD_SMB_ALERT 0x40 /**< @brief SMBus Alert. */
+#define I2CD_TIMEOUT 0x10 /**< @brief Hardware timeout. */
/** @} */
/*===========================================================================*/
diff --git a/os/hal/platforms/STM32/I2Cv2/i2c_lld.c b/os/hal/platforms/STM32/I2Cv2/i2c_lld.c index 6668c212f..3b7b52e3b 100644 --- a/os/hal/platforms/STM32/I2Cv2/i2c_lld.c +++ b/os/hal/platforms/STM32/I2Cv2/i2c_lld.c @@ -177,10 +177,20 @@ static void i2c_lld_serve_interrupt(I2CDriver *i2cp, uint32_t isr) { }
else {
dp->CR2 |= I2C_CR2_STOP;
- wakeup_isr(i2cp, RDY_OK);
}
}
+ else if (isr & I2C_ISR_STOPF) {
+ /* Stops the associated DMA streams.*/
+ dmaStreamDisable(i2cp->dmatx);
+ dmaStreamDisable(i2cp->dmarx);
+
+ wakeup_isr(i2cp, RDY_OK);
+ }
else if (isr & I2C_ISR_NACKF) {
+ /* Stops the associated DMA streams.*/
+ dmaStreamDisable(i2cp->dmatx);
+ dmaStreamDisable(i2cp->dmarx);
+
i2cp->errors |= I2CD_ACK_FAILURE;
wakeup_isr(i2cp, RDY_RESET);
}
@@ -503,8 +513,8 @@ void i2c_lld_start(I2CDriver *i2cp) { dmaStreamSetPeripheral(i2cp->dmatx, &dp->TXDR);
/* Reset i2c peripheral.*/
- dp->CR1 = i2cp->config->cr1 | I2C_CR1_ERRIE | I2C_CR1_NACKIE |
- I2C_CR1_TCIE | I2C_CR1_TXDMAEN | I2C_CR1_RXDMAEN;
+ dp->CR1 = i2cp->config->cr1 | I2C_CR1_ERRIE | I2C_CR1_STOPIE |
+ I2C_CR1_NACKIE | I2C_CR1_TCIE | I2C_CR1_TXDMAEN | I2C_CR1_RXDMAEN;
/* Set slave address field (master mode) */
dp->CR2 = (i2cp->config->cr2 & ~I2C_CR2_SADD);
|