On L4+ the IRQ vectors for I2C4 are reversed versus I2C1, 2 & 3.
Also the bdma flag as not set correctly in the I2Cv3 driver.
Patch below.
--
Bob
Code: Select all
Index: os/hal/ports/STM32/LLD/I2Cv3/hal_i2c_lld.c
===================================================================
--- os/hal/ports/STM32/LLD/I2Cv3/hal_i2c_lld.c (revision 13469)
+++ os/hal/ports/STM32/LLD/I2Cv3/hal_i2c_lld.c (working copy)
@@ -461,7 +461,7 @@
if (isr & I2C_ISR_TIMEOUT)
i2cp->errors |= I2C_TIMEOUT;
- /* If some error has been identified then sends wakes the waiting thread.*/
+ /* If some error has been identified then wake the waiting thread.*/
if (i2cp->errors != I2C_NO_ERROR)
_i2c_wakeup_error_isr(i2cp);
}
@@ -770,16 +770,17 @@
I2CD4.i2c = I2C4;
#if STM32_I2C_USE_DMA == TRUE
#if defined(STM32_I2C_DMA_REQUIRED) && defined(STM32_I2C_BDMA_REQUIRED)
- I2CD4.is_bdma = true;
-#endif
#if STM32_I2C4_USE_BDMA == TRUE
+ I2CD4.is_bdma = true;
I2CD4.rx.bdma = NULL;
I2CD4.tx.bdma = NULL;
#else
+ I2CD4.is_bdma = false;
I2CD4.rx.dma = NULL;
I2CD4.tx.dma = NULL;
-#endif
-#endif
+#endif /* STM32_I2C4_USE_BDMA == TRUE */
+#endif /* defined(STM32_I2C_DMA_REQUIRED) && defined(STM32_I2C_BDMA_REQUIRED) */
+#endif /* STM32_I2C_USE_DMA == TRUE */
#if defined(STM32_I2C4_GLOBAL_NUMBER) || defined(__DOXYGEN__)
nvicEnableVector(STM32_I2C4_GLOBAL_NUMBER, STM32_I2C_I2C4_IRQ_PRIORITY);
#elif defined(STM32_I2C4_EVENT_NUMBER) && defined(STM32_I2C4_ERROR_NUMBER)
Index: os/hal/ports/STM32/LLD/I2Cv3/hal_i2c_lld.h
===================================================================
--- os/hal/ports/STM32/LLD/I2Cv3/hal_i2c_lld.h (revision 13469)
+++ os/hal/ports/STM32/LLD/I2Cv3/hal_i2c_lld.h (working copy)
@@ -379,6 +379,11 @@
#endif
#endif
+#if STM32_I2C_USE_I2C4
+#if !defined(STM32_BDMA_REQUIRED)
+#define STM32_BDMA_REQUIRED
+#endif
+#endif
#else /* STM32_I2C4_USE_BDMA != TRUE */
#if STM32_I2C_USE_I2C1 || STM32_I2C_USE_I2C2 || STM32_I2C_USE_I2C3 || STM32_I2C_USE_I2C4
@@ -390,15 +395,6 @@
#endif /* STM32_I2C4_USE_BDMA != TRUE */
-#if STM32_I2C4_USE_BDMA == TRUE
-#if STM32_I2C_USE_I2C4
-#define STM32_I2C_BDMA_REQUIRED
-#if !defined(STM32_BDMA_REQUIRED)
-#define STM32_BDMA_REQUIRED
-#endif
-#endif
-#endif /* STM32_I2C4_USE_BDMA == TRUE */
-
#endif /* STM32_I2C_USE_DMA == TRUE */
/*===========================================================================*/
Index: os/hal/ports/STM32/STM32L4xx+/stm32_isr.h
===================================================================
--- os/hal/ports/STM32/STM32L4xx+/stm32_isr.h (revision 13469)
+++ os/hal/ports/STM32/STM32L4xx+/stm32_isr.h (working copy)
@@ -148,8 +148,8 @@
#define STM32_I2C2_ERROR_HANDLER VectorC8
#define STM32_I2C3_EVENT_HANDLER Vector160
#define STM32_I2C3_ERROR_HANDLER Vector164
-#define STM32_I2C4_EVENT_HANDLER Vector18C
-#define STM32_I2C4_ERROR_HANDLER Vector190
+#define STM32_I2C4_ERROR_HANDLER Vector18C
+#define STM32_I2C4_EVENT_HANDLER Vector190
#define STM32_I2C1_EVENT_NUMBER 31
#define STM32_I2C1_ERROR_NUMBER 32
@@ -157,8 +157,9 @@
#define STM32_I2C2_ERROR_NUMBER 34
#define STM32_I2C3_EVENT_NUMBER 72
#define STM32_I2C3_ERROR_NUMBER 73
-#define STM32_I2C4_EVENT_NUMBER 83
-#define STM32_I2C4_ERROR_NUMBER 84
+#define STM32_I2C4_ERROR_NUMBER 83
+#define STM32_I2C4_EVENT_NUMBER 84
+
/*
* OCTOSPI unit.