@@ -675,9 +675,10 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
675675 __HAL_RCC_I2C1_RELEASE_RESET ();
676676
677677 obj -> irq = I2C1_EV_IRQn ;
678- #if !defined(STM32C0xx ) && !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx )
678+ #if !defined(STM32C0xx ) && !defined(STM32F0xx ) && !defined(STM32G0xx ) && \
679+ !defined(STM32L0xx ) && !defined(STM32U0xx )
679680 obj -> irqER = I2C1_ER_IRQn ;
680- #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
681+ #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
681682 i2c_handles [I2C1_INDEX ] = handle ;
682683 }
683684#endif // I2C1_BASE
@@ -688,9 +689,10 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
688689 __HAL_RCC_I2C2_FORCE_RESET ();
689690 __HAL_RCC_I2C2_RELEASE_RESET ();
690691 obj -> irq = I2C2_EV_IRQn ;
691- #if !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx )
692+ #if !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx ) && \
693+ !defined(STM32U0xx )
692694 obj -> irqER = I2C2_ER_IRQn ;
693- #endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
695+ #endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
694696 i2c_handles [I2C2_INDEX ] = handle ;
695697 }
696698#endif // I2C2_BASE
@@ -701,9 +703,9 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
701703 __HAL_RCC_I2C3_FORCE_RESET ();
702704 __HAL_RCC_I2C3_RELEASE_RESET ();
703705 obj -> irq = I2C3_EV_IRQn ;
704- #if !defined(STM32G0xx ) && !defined(STM32L0xx )
706+ #if !defined(STM32G0xx ) && !defined(STM32L0xx ) && !defined( STM32U0xx )
705707 obj -> irqER = I2C3_ER_IRQn ;
706- #endif /* !STM32G0xx && !STM32L0xx */
708+ #endif /* !STM32G0xx && !STM32L0xx && !STM32U0xx */
707709 i2c_handles [I2C3_INDEX ] = handle ;
708710 }
709711#endif // I2C3_BASE
@@ -714,7 +716,9 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
714716 __HAL_RCC_I2C4_FORCE_RESET ();
715717 __HAL_RCC_I2C4_RELEASE_RESET ();
716718 obj -> irq = I2C4_EV_IRQn ;
719+ #if !defined(STM32U0xx )
717720 obj -> irqER = I2C4_ER_IRQn ;
721+ #endif /* !STM32U0xx */
718722 i2c_handles [I2C4_INDEX ] = handle ;
719723 }
720724#endif // I2C4_BASE
@@ -769,10 +773,11 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
769773
770774 HAL_NVIC_SetPriority (obj -> irq , I2C_IRQ_PRIO , I2C_IRQ_SUBPRIO );
771775 HAL_NVIC_EnableIRQ (obj -> irq );
772- #if !defined(STM32C0xx ) && !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx )
776+ #if !defined(STM32C0xx ) && !defined(STM32F0xx ) && !defined(STM32G0xx ) && \
777+ !defined(STM32L0xx ) && !defined(STM32U0xx )
773778 HAL_NVIC_SetPriority (obj -> irqER , I2C_IRQ_PRIO , I2C_IRQ_SUBPRIO );
774779 HAL_NVIC_EnableIRQ (obj -> irqER );
775- #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
780+ #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
776781
777782 /* Init the I2C */
778783 if (HAL_I2C_Init (handle ) != HAL_OK ) {
@@ -796,9 +801,10 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
796801void i2c_deinit (i2c_t * obj )
797802{
798803 HAL_NVIC_DisableIRQ (obj -> irq );
799- #if !defined(STM32C0xx ) && !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx )
804+ #if !defined(STM32C0xx ) && !defined(STM32F0xx ) && !defined(STM32G0xx ) && \
805+ !defined(STM32L0xx ) && !defined(STM32U0xx )
800806 HAL_NVIC_DisableIRQ (obj -> irqER );
801- #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
807+ #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
802808 HAL_I2C_DeInit (& (obj -> handle ));
803809 /* Reset I2C GPIO pins as INPUT_ANALOG */
804810 pin_function (obj -> scl , STM_PIN_DATA (STM_MODE_ANALOG , GPIO_NOPULL , 0 ));
@@ -1221,12 +1227,14 @@ void I2C1_EV_IRQHandler(void)
12211227{
12221228 I2C_HandleTypeDef * handle = i2c_handles [I2C1_INDEX ];
12231229 HAL_I2C_EV_IRQHandler (handle );
1224- #if defined(STM32C0xx ) || defined(STM32F0xx ) || defined(STM32G0xx ) || defined(STM32L0xx )
1230+ #if defined(STM32C0xx ) || defined(STM32F0xx ) || defined(STM32G0xx ) || \
1231+ defined(STM32L0xx ) || defined(STM32U0xx )
12251232 HAL_I2C_ER_IRQHandler (handle );
1226- #endif /* STM32C0xx || STM32F0xx || STM32G0xx || STM32L0xx */
1233+ #endif /* STM32C0xx || STM32F0xx || STM32G0xx || STM32L0xx || STM32U0xx */
12271234}
12281235
1229- #if !defined(STM32C0xx ) && !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx )
1236+ #if !defined(STM32C0xx ) && !defined(STM32F0xx ) && !defined(STM32G0xx ) && \
1237+ !defined(STM32L0xx ) && !defined(STM32U0xx )
12301238/**
12311239* @brief This function handles I2C1 interrupt.
12321240* @param None
@@ -1237,7 +1245,7 @@ void I2C1_ER_IRQHandler(void)
12371245 I2C_HandleTypeDef * handle = i2c_handles [I2C1_INDEX ];
12381246 HAL_I2C_ER_IRQHandler (handle );
12391247}
1240- #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
1248+ #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
12411249#endif // I2C1_BASE
12421250
12431251#if defined(I2C2_BASE )
@@ -1248,7 +1256,7 @@ void I2C1_ER_IRQHandler(void)
12481256*/
12491257void I2C2_EV_IRQHandler (void )
12501258{
1251- #if defined(I2C3_BASE ) && defined(STM32G0xx )
1259+ #if defined(I2C3_BASE ) && ( defined(STM32G0xx ) || defined( STM32U0xx ) )
12521260 /* I2C2_3_IRQHandler */
12531261 I2C_HandleTypeDef * handle2 = i2c_handles [I2C2_INDEX ];
12541262 I2C_HandleTypeDef * handle3 = i2c_handles [I2C3_INDEX ];
@@ -1260,16 +1268,26 @@ void I2C2_EV_IRQHandler(void)
12601268 HAL_I2C_EV_IRQHandler (handle3 );
12611269 HAL_I2C_ER_IRQHandler (handle3 );
12621270 }
1271+ #if defined(I2C4_BASE )
1272+ /* I2C2_3_4_IRQHandler */
1273+ I2C_HandleTypeDef * handle4 = i2c_handles [I2C4_INDEX ];
1274+ if (handle4 ) {
1275+ HAL_I2C_EV_IRQHandler (handle4 );
1276+ HAL_I2C_ER_IRQHandler (handle4 );
1277+ }
1278+ #endif /* I2C4_BASE */
12631279#else
12641280 I2C_HandleTypeDef * handle = i2c_handles [I2C2_INDEX ];
12651281 HAL_I2C_EV_IRQHandler (handle );
1266- #if defined(STM32F0xx ) || defined(STM32G0xx ) || defined(STM32L0xx )
1282+ #if defined(STM32F0xx ) || defined(STM32G0xx ) || defined(STM32L0xx ) || \
1283+ defined(STM32U0xx )
12671284 HAL_I2C_ER_IRQHandler (handle );
1268- #endif /* STM32F0xx || STM32G0xx || STM32L0xx */
1285+ #endif /* STM32F0xx || STM32G0xx || STM32L0xx || STM32U0xx */
12691286#endif
12701287}
12711288
1272- #if !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx )
1289+ #if !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx ) && \
1290+ !defined(STM32U0xx )
12731291/**
12741292* @brief This function handles I2C2 interrupt.
12751293* @param None
@@ -1280,10 +1298,10 @@ void I2C2_ER_IRQHandler(void)
12801298 I2C_HandleTypeDef * handle = i2c_handles [I2C2_INDEX ];
12811299 HAL_I2C_ER_IRQHandler (handle );
12821300}
1283- #endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
1301+ #endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
12841302#endif // I2C2_BASE
12851303
1286- #if defined(I2C3_BASE ) && !defined(STM32G0xx )
1304+ #if defined(I2C3_BASE ) && !defined(STM32G0xx ) && !defined( STM32U0xx )
12871305/**
12881306* @brief This function handles I2C3 interrupt.
12891307* @param None
@@ -1310,9 +1328,9 @@ void I2C3_ER_IRQHandler(void)
13101328 HAL_I2C_ER_IRQHandler (handle );
13111329}
13121330#endif /* !STM32L0xx */
1313- #endif /* I2C3_BASE && ! STM32G0xx */
1331+ #endif /* I2C3_BASE && ! STM32G0xx && !STM32U0xx */
13141332
1315- #if defined(I2C4_BASE )
1333+ #if defined(I2C4_BASE ) && !defined( STM32U0xx )
13161334/**
13171335* @brief This function handles I2C4 interrupt.
13181336* @param None
@@ -1335,7 +1353,7 @@ void I2C4_ER_IRQHandler(void)
13351353 I2C_HandleTypeDef * handle = i2c_handles [I2C4_INDEX ];
13361354 HAL_I2C_ER_IRQHandler (handle );
13371355}
1338- #endif // I2C4_BASE
1356+ #endif // I2C4_BASE && !STM32U0xx
13391357
13401358#if defined(I2C5_BASE )
13411359/**
0 commit comments