diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-04-14 18:31:15 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-04-14 18:31:15 +0000 |
commit | 1dab4fb6ae274abbb13724e4d1e9fe094582b51b (patch) | |
tree | 5f40f47ef5399f0ff620829baaf138f9fcab814e | |
parent | 6c6132abbb84a667a048c4d10a3dc830e7446d6a (diff) | |
download | ChibiOS-1dab4fb6ae274abbb13724e4d1e9fe094582b51b.tar.gz ChibiOS-1dab4fb6ae274abbb13724e4d1e9fe094582b51b.tar.bz2 ChibiOS-1dab4fb6ae274abbb13724e4d1e9fe094582b51b.zip |
Fixed bug 581.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7893 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | os/hal/ports/STM32/LLD/I2Cv2/i2c_lld.c | 28 | ||||
-rw-r--r-- | readme.txt | 4 |
2 files changed, 20 insertions, 12 deletions
diff --git a/os/hal/ports/STM32/LLD/I2Cv2/i2c_lld.c b/os/hal/ports/STM32/LLD/I2Cv2/i2c_lld.c index fffeae050..f348121dd 100644 --- a/os/hal/ports/STM32/LLD/I2Cv2/i2c_lld.c +++ b/os/hal/ports/STM32/LLD/I2Cv2/i2c_lld.c @@ -141,16 +141,20 @@ static void i2c_lld_serve_interrupt(I2CDriver *i2cp, uint32_t isr) { /* Starts the read operation.*/
dp->CR2 |= I2C_CR2_RD_WRN;
dp->CR2 |= I2C_CR2_START;
+ return;
}
- else {
- /* Nothing to receive - send STOP immediately.*/
- dp->CR2 |= I2C_CR2_STOP;
- }
+ /* Nothing to receive - send STOP immediately.*/
+ dp->CR2 |= I2C_CR2_STOP;
}
if (isr & I2C_ISR_NACKF) {
/* Starts a STOP sequence immediately on error.*/
dp->CR2 |= I2C_CR2_STOP;
+ /* Stops the associated DMA streams.*/
+ dmaStreamDisable(i2cp->dmatx);
+ dmaStreamDisable(i2cp->dmarx);
+
+ /* Error flag.*/
i2cp->errors |= I2C_ACK_FAILURE;
}
if (isr & I2C_ISR_STOPF) {
@@ -158,12 +162,13 @@ static void i2c_lld_serve_interrupt(I2CDriver *i2cp, uint32_t isr) { dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
- /* The wake up message depends on the presence of errors.*/
- if (i2cp->errors)
+ /* Errors are propagated to the upper layer.*/
+ if (i2cp->errors) {
_i2c_wakeup_error_isr(i2cp);
- else
- _i2c_wakeup_isr(i2cp);
+ return;
+ }
}
+ _i2c_wakeup_isr(i2cp);
}
/**
@@ -188,7 +193,6 @@ static void i2c_lld_serve_rx_end_irq(I2CDriver *i2cp, uint32_t flags) { dmaStreamDisable(i2cp->dmarx);
dp->CR2 |= I2C_CR2_STOP;
- _i2c_wakeup_isr(i2cp);
}
/**
@@ -595,8 +599,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr, /* If the system time went outside the allowed window then a timeout
condition is returned.*/
- if (!osalOsIsTimeWithinX(osalOsGetSystemTimeX(), start, end))
+ if (!osalOsIsTimeWithinX(osalOsGetSystemTimeX(), start, end)) {
return MSG_TIMEOUT;
+ }
osalSysUnlock();
}
@@ -685,8 +690,9 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr, /* If the system time went outside the allowed window then a timeout
condition is returned.*/
- if (!osalOsIsTimeWithinX(osalOsGetSystemTimeX(), start, end))
+ if (!osalOsIsTimeWithinX(osalOsGetSystemTimeX(), start, end)) {
return MSG_TIMEOUT;
+ }
osalSysUnlock();
}
diff --git a/readme.txt b/readme.txt index 8aa5f9391..5792be2ad 100644 --- a/readme.txt +++ b/readme.txt @@ -73,8 +73,10 @@ *** Releases and Change Log ***
*****************************************************************************
+- HAL: Fixed STM32 I2Cv2 driver issue (bug 581).
+
*** 3.0.0p3 ***
-- RT: Fixed tickless mode instability in RT (bug 577).
+- RT: Fixed tickless mode instability in RT (bug 577).
*** 3.0.0p2 ***
- HAL: Fixed instances of RT API in HAL drivers (bug 574).
|