aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-04-02 18:08:00 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-04-02 18:08:00 +0000
commitd1e24e796efac7aeb29f5d7b7c679d9f23095b5b (patch)
tree67f2a8b0dc67b8823c082cf0e4d815ad9755fa73
parent96d50f2ac19ca5d285497b27a2500cc7859825bb (diff)
downloadChibiOS-d1e24e796efac7aeb29f5d7b7c679d9f23095b5b.tar.gz
ChibiOS-d1e24e796efac7aeb29f5d7b7c679d9f23095b5b.tar.bz2
ChibiOS-d1e24e796efac7aeb29f5d7b7c679d9f23095b5b.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5538 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/hal/platforms/STM32/I2Cv2/i2c_lld.c19
-rw-r--r--testhal/STM32F37x/I2C/main.c1
2 files changed, 12 insertions, 8 deletions
diff --git a/os/hal/platforms/STM32/I2Cv2/i2c_lld.c b/os/hal/platforms/STM32/I2Cv2/i2c_lld.c
index 3b7b52e3b..024bd13e9 100644
--- a/os/hal/platforms/STM32/I2Cv2/i2c_lld.c
+++ b/os/hal/platforms/STM32/I2Cv2/i2c_lld.c
@@ -179,20 +179,23 @@ static void i2c_lld_serve_interrupt(I2CDriver *i2cp, uint32_t isr) {
dp->CR2 |= I2C_CR2_STOP;
}
}
- else if (isr & I2C_ISR_STOPF) {
- /* Stops the associated DMA streams.*/
- dmaStreamDisable(i2cp->dmatx);
- dmaStreamDisable(i2cp->dmarx);
+ if (isr & I2C_ISR_NACKF) {
+ /* Starts a STOP sequence immediately.*/
+ dp->CR2 |= I2C_CR2_STOP;
- wakeup_isr(i2cp, RDY_OK);
+ i2cp->errors |= I2CD_ACK_FAILURE;
}
- else if (isr & I2C_ISR_NACKF) {
+ if (isr & I2C_ISR_STOPF) {
/* Stops the associated DMA streams.*/
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
- i2cp->errors |= I2CD_ACK_FAILURE;
- wakeup_isr(i2cp, RDY_RESET);
+ if (i2cp->errors) {
+ wakeup_isr(i2cp, RDY_RESET);
+ }
+ else {
+ wakeup_isr(i2cp, RDY_OK);
+ }
}
}
diff --git a/testhal/STM32F37x/I2C/main.c b/testhal/STM32F37x/I2C/main.c
index 194f61f89..113515d39 100644
--- a/testhal/STM32F37x/I2C/main.c
+++ b/testhal/STM32F37x/I2C/main.c
@@ -103,6 +103,7 @@ int main(void) {
chSysHalt();
}
chThdSleepMilliseconds(500);
+ palTogglePad(GPIOC, GPIOC_LED2);
}
return 0;
}