@@ -675,9 +675,10 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
675
675
__HAL_RCC_I2C1_RELEASE_RESET ();
676
676
677
677
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 )
679
680
obj -> irqER = I2C1_ER_IRQn ;
680
- #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
681
+ #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
681
682
i2c_handles [I2C1_INDEX ] = handle ;
682
683
}
683
684
#endif // I2C1_BASE
@@ -688,9 +689,10 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
688
689
__HAL_RCC_I2C2_FORCE_RESET ();
689
690
__HAL_RCC_I2C2_RELEASE_RESET ();
690
691
obj -> irq = I2C2_EV_IRQn ;
691
- #if !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx )
692
+ #if !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx ) && \
693
+ !defined(STM32U0xx )
692
694
obj -> irqER = I2C2_ER_IRQn ;
693
- #endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
695
+ #endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
694
696
i2c_handles [I2C2_INDEX ] = handle ;
695
697
}
696
698
#endif // I2C2_BASE
@@ -701,9 +703,9 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
701
703
__HAL_RCC_I2C3_FORCE_RESET ();
702
704
__HAL_RCC_I2C3_RELEASE_RESET ();
703
705
obj -> irq = I2C3_EV_IRQn ;
704
- #if !defined(STM32G0xx ) && !defined(STM32L0xx )
706
+ #if !defined(STM32G0xx ) && !defined(STM32L0xx ) && !defined( STM32U0xx )
705
707
obj -> irqER = I2C3_ER_IRQn ;
706
- #endif /* !STM32G0xx && !STM32L0xx */
708
+ #endif /* !STM32G0xx && !STM32L0xx && !STM32U0xx */
707
709
i2c_handles [I2C3_INDEX ] = handle ;
708
710
}
709
711
#endif // I2C3_BASE
@@ -714,7 +716,9 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
714
716
__HAL_RCC_I2C4_FORCE_RESET ();
715
717
__HAL_RCC_I2C4_RELEASE_RESET ();
716
718
obj -> irq = I2C4_EV_IRQn ;
719
+ #if !defined(STM32U0xx )
717
720
obj -> irqER = I2C4_ER_IRQn ;
721
+ #endif /* !STM32U0xx */
718
722
i2c_handles [I2C4_INDEX ] = handle ;
719
723
}
720
724
#endif // I2C4_BASE
@@ -769,10 +773,11 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
769
773
770
774
HAL_NVIC_SetPriority (obj -> irq , I2C_IRQ_PRIO , I2C_IRQ_SUBPRIO );
771
775
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 )
773
778
HAL_NVIC_SetPriority (obj -> irqER , I2C_IRQ_PRIO , I2C_IRQ_SUBPRIO );
774
779
HAL_NVIC_EnableIRQ (obj -> irqER );
775
- #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
780
+ #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
776
781
777
782
/* Init the I2C */
778
783
if (HAL_I2C_Init (handle ) != HAL_OK ) {
@@ -796,9 +801,10 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
796
801
void i2c_deinit (i2c_t * obj )
797
802
{
798
803
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 )
800
806
HAL_NVIC_DisableIRQ (obj -> irqER );
801
- #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
807
+ #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
802
808
HAL_I2C_DeInit (& (obj -> handle ));
803
809
/* Reset I2C GPIO pins as INPUT_ANALOG */
804
810
pin_function (obj -> scl , STM_PIN_DATA (STM_MODE_ANALOG , GPIO_NOPULL , 0 ));
@@ -1221,12 +1227,14 @@ void I2C1_EV_IRQHandler(void)
1221
1227
{
1222
1228
I2C_HandleTypeDef * handle = i2c_handles [I2C1_INDEX ];
1223
1229
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 )
1225
1232
HAL_I2C_ER_IRQHandler (handle );
1226
- #endif /* STM32C0xx || STM32F0xx || STM32G0xx || STM32L0xx */
1233
+ #endif /* STM32C0xx || STM32F0xx || STM32G0xx || STM32L0xx || STM32U0xx */
1227
1234
}
1228
1235
1229
- #if !defined(STM32C0xx ) && !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx )
1236
+ #if !defined(STM32C0xx ) && !defined(STM32F0xx ) && !defined(STM32G0xx ) && \
1237
+ !defined(STM32L0xx ) && !defined(STM32U0xx )
1230
1238
/**
1231
1239
* @brief This function handles I2C1 interrupt.
1232
1240
* @param None
@@ -1237,7 +1245,7 @@ void I2C1_ER_IRQHandler(void)
1237
1245
I2C_HandleTypeDef * handle = i2c_handles [I2C1_INDEX ];
1238
1246
HAL_I2C_ER_IRQHandler (handle );
1239
1247
}
1240
- #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx */
1248
+ #endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
1241
1249
#endif // I2C1_BASE
1242
1250
1243
1251
#if defined(I2C2_BASE )
@@ -1248,7 +1256,7 @@ void I2C1_ER_IRQHandler(void)
1248
1256
*/
1249
1257
void I2C2_EV_IRQHandler (void )
1250
1258
{
1251
- #if defined(I2C3_BASE ) && defined(STM32G0xx )
1259
+ #if defined(I2C3_BASE ) && ( defined(STM32G0xx ) || defined( STM32U0xx ) )
1252
1260
/* I2C2_3_IRQHandler */
1253
1261
I2C_HandleTypeDef * handle2 = i2c_handles [I2C2_INDEX ];
1254
1262
I2C_HandleTypeDef * handle3 = i2c_handles [I2C3_INDEX ];
@@ -1260,16 +1268,26 @@ void I2C2_EV_IRQHandler(void)
1260
1268
HAL_I2C_EV_IRQHandler (handle3 );
1261
1269
HAL_I2C_ER_IRQHandler (handle3 );
1262
1270
}
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 */
1263
1279
#else
1264
1280
I2C_HandleTypeDef * handle = i2c_handles [I2C2_INDEX ];
1265
1281
HAL_I2C_EV_IRQHandler (handle );
1266
- #if defined(STM32F0xx ) || defined(STM32G0xx ) || defined(STM32L0xx )
1282
+ #if defined(STM32F0xx ) || defined(STM32G0xx ) || defined(STM32L0xx ) || \
1283
+ defined(STM32U0xx )
1267
1284
HAL_I2C_ER_IRQHandler (handle );
1268
- #endif /* STM32F0xx || STM32G0xx || STM32L0xx */
1285
+ #endif /* STM32F0xx || STM32G0xx || STM32L0xx || STM32U0xx */
1269
1286
#endif
1270
1287
}
1271
1288
1272
- #if !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx )
1289
+ #if !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx ) && \
1290
+ !defined(STM32U0xx )
1273
1291
/**
1274
1292
* @brief This function handles I2C2 interrupt.
1275
1293
* @param None
@@ -1280,10 +1298,10 @@ void I2C2_ER_IRQHandler(void)
1280
1298
I2C_HandleTypeDef * handle = i2c_handles [I2C2_INDEX ];
1281
1299
HAL_I2C_ER_IRQHandler (handle );
1282
1300
}
1283
- #endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
1301
+ #endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
1284
1302
#endif // I2C2_BASE
1285
1303
1286
- #if defined(I2C3_BASE ) && !defined(STM32G0xx )
1304
+ #if defined(I2C3_BASE ) && !defined(STM32G0xx ) && !defined( STM32U0xx )
1287
1305
/**
1288
1306
* @brief This function handles I2C3 interrupt.
1289
1307
* @param None
@@ -1310,9 +1328,9 @@ void I2C3_ER_IRQHandler(void)
1310
1328
HAL_I2C_ER_IRQHandler (handle );
1311
1329
}
1312
1330
#endif /* !STM32L0xx */
1313
- #endif /* I2C3_BASE && ! STM32G0xx */
1331
+ #endif /* I2C3_BASE && ! STM32G0xx && !STM32U0xx */
1314
1332
1315
- #if defined(I2C4_BASE )
1333
+ #if defined(I2C4_BASE ) && !defined( STM32U0xx )
1316
1334
/**
1317
1335
* @brief This function handles I2C4 interrupt.
1318
1336
* @param None
@@ -1335,7 +1353,7 @@ void I2C4_ER_IRQHandler(void)
1335
1353
I2C_HandleTypeDef * handle = i2c_handles [I2C4_INDEX ];
1336
1354
HAL_I2C_ER_IRQHandler (handle );
1337
1355
}
1338
- #endif // I2C4_BASE
1356
+ #endif // I2C4_BASE && !STM32U0xx
1339
1357
1340
1358
#if defined(I2C5_BASE )
1341
1359
/**
0 commit comments