I2C4 interrupt vectors on L4+ Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
FXCoder
Posts: 239
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 91 times
Been thanked: 71 times

I2C4 interrupt vectors on L4+

Postby FXCoder » Sun Mar 29, 2020 7:06 am

Hi,
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.
 

User avatar
FXCoder
Posts: 239
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 91 times
Been thanked: 71 times

Re: I2C4 interrupt vectors on L4+  Topic is solved

Postby FXCoder » Thu Apr 02, 2020 10:42 am

Fixed as bug #1080


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 12 guests