diff options
| author | Damien George | 2016-11-21 16:12:09 +1100 |
|---|---|---|
| committer | Damien George | 2016-11-21 16:12:09 +1100 |
| commit | 21d82421cd7b3a3f74850cffaf84646ff49a04f2 (patch) | |
| tree | c3e2c897069d8d211ffb02a67ba4f02bf37f5f3a | |
| parent | e30ca0e10287ac0ff6f66574611ca9cfaad11181 (diff) | |
stmhal/i2c: Use the HAL's I2C IRQ handler for F7 and L4 MCUs.
The custom IRQ handler only works for F4 MCUs, which have the SR1
register.
| -rw-r--r-- | stmhal/i2c.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/stmhal/i2c.c b/stmhal/i2c.c index 17557a46e..6146419a9 100644 --- a/stmhal/i2c.c +++ b/stmhal/i2c.c @@ -340,6 +340,8 @@ void i2c_ev_irq_handler(mp_uint_t i2c_id) { return; } + #if defined(MCU_SERIES_F4) + if (hi2c->Instance->SR1 & I2C_FLAG_BTF && hi2c->State == HAL_I2C_STATE_BUSY_TX) { if (hi2c->XferCount != 0U) { hi2c->Instance->DR = *hi2c->pBuffPtr++; @@ -353,6 +355,13 @@ void i2c_ev_irq_handler(mp_uint_t i2c_id) { hi2c->State = HAL_I2C_STATE_READY; } } + + #else + + // if not an F4 MCU, use the HAL's IRQ handler + HAL_I2C_EV_IRQHandler(hi2c); + + #endif } void i2c_er_irq_handler(mp_uint_t i2c_id) { @@ -378,6 +387,8 @@ void i2c_er_irq_handler(mp_uint_t i2c_id) { return; } + #if defined(MCU_SERIES_F4) + uint32_t sr1 = hi2c->Instance->SR1; // I2C Bus error @@ -404,6 +415,13 @@ void i2c_er_irq_handler(mp_uint_t i2c_id) { hi2c->ErrorCode |= HAL_I2C_ERROR_OVR; __HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_OVR); } + + #else + + // if not an F4 MCU, use the HAL's IRQ handler + HAL_I2C_ER_IRQHandler(hi2c); + + #endif } STATIC HAL_StatusTypeDef i2c_wait_dma_finished(I2C_HandleTypeDef *i2c, uint32_t timeout) { |
