summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2017-11-15 10:39:18 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2019-03-07 18:44:46 +0000
commit7751b34ffedf218dd790284b719c5c4c86f3da18 (patch)
tree805dba423e2788973043d6159b8f2221d99cd65d
parent90db4881201299a5faa39770a6918468ac1bb3e8 (diff)
downloadchrome-ec-7751b34ffedf218dd790284b719c5c4c86f3da18.tar.gz
stm32f0: i2c: Fix dropped Rx byte in TCPCI slave mode
If the i2c master sends a stop condition before we've buffered the last Rx byte (eg. due to higher than normal i2c interrupt latency) then we don't want to drop the last byte on the floor, it's still meaningful. BUG=b:65711378 BRANCH=glados TEST=Spam TCPC_REG_ROLE_CTRL commands from caroline to caroline_pd, verify no errors are observed on either side for 12,000,000 transactions. Change-Id: I0c4a81d97315cff553a5448c0940746e1ef0ed2c Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/772698 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 20baa933615fa6942005953e1e0ea3a3b16bbd5f) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1506412 Reviewed-by: Scott Collyer <scollyer@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Trybot-Ready: Scott Collyer <scollyer@chromium.org>
-rw-r--r--chip/stm32/i2c-stm32f0.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/chip/stm32/i2c-stm32f0.c b/chip/stm32/i2c-stm32f0.c
index 70b075298c..f7a8aff286 100644
--- a/chip/stm32/i2c-stm32f0.c
+++ b/chip/stm32/i2c-stm32f0.c
@@ -317,10 +317,14 @@ static void i2c_event_handler(int port)
/* Clear ADDR bit by writing to ADDRCF bit */
STM32_I2C_ICR(port) |= STM32_I2C_ICR_ADDRCF;
- /* Inhibit stop mode when addressed until STOPF flag is set */
+ /* Inhibit sleep mode when addressed until STOPF flag is set */
disable_sleep(SLEEP_MASK_I2C_SLAVE);
}
+ /* Receiver full event */
+ if (i2c_isr & STM32_I2C_ISR_RXNE)
+ host_buffer[buf_idx++] = STM32_I2C_RXDR(port);
+
/* Stop condition on bus */
if (i2c_isr & STM32_I2C_ISR_STOP) {
#ifdef TCPCI_I2C_SLAVE
@@ -346,10 +350,6 @@ static void i2c_event_handler(int port)
enable_sleep(SLEEP_MASK_I2C_SLAVE);
}
- /* Receiver full event */
- if (i2c_isr & STM32_I2C_ISR_RXNE)
- host_buffer[buf_idx++] = STM32_I2C_RXDR(port);
-
/* Master requested STOP or RESTART */
if (i2c_isr & STM32_I2C_ISR_NACK) {
/* Make sure TXIS interrupt is disabled */