diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2017-11-15 10:39:18 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-11-15 20:21:06 -0800 |
commit | 204880575d9b4f8d630c5e3264d8f96fe7690031 (patch) | |
tree | caaa8034b5a0637f01aef14ff74c5b4bac0e0d43 | |
parent | c5c061f9b5707205bb32abdac15dc14a9af14800 (diff) | |
download | chrome-ec-204880575d9b4f8d630c5e3264d8f96fe7690031.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/771936
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | chip/stm32/i2c-stm32f0.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/chip/stm32/i2c-stm32f0.c b/chip/stm32/i2c-stm32f0.c index f328b98acc..ad4df85bdd 100644 --- a/chip/stm32/i2c-stm32f0.c +++ b/chip/stm32/i2c-stm32f0.c @@ -330,10 +330,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 @@ -359,10 +363,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 */ |