@@ -274,6 +274,7 @@ static uint32_t i2c_getClkFreq(I2C_TypeDef *i2c)
274
274
#endif // I2C2_BASE
275
275
#if defined I2C3_BASE
276
276
if (i2c == I2C3 ) {
277
+ #if defined(__HAL_RCC_GET_I2C3_SOURCE )
277
278
switch (__HAL_RCC_GET_I2C3_SOURCE ()) {
278
279
case RCC_I2C3CLKSOURCE_HSI :
279
280
clkSrcFreq = HSI_VALUE ;
@@ -307,6 +308,10 @@ static uint32_t i2c_getClkFreq(I2C_TypeDef *i2c)
307
308
default :
308
309
Error_Handler ();
309
310
}
311
+ #else
312
+ /* STM32 G0 I2C3 has no independent clock */
313
+ clkSrcFreq = HAL_RCC_GetPCLK1Freq ();
314
+ #endif
310
315
}
311
316
#endif // I2C3_BASE
312
317
#if defined I2C4_BASE
@@ -648,7 +653,7 @@ void i2c_custom_init(i2c_t *obj, uint32_t timing, uint32_t addressingMode, uint3
648
653
__HAL_RCC_I2C3_FORCE_RESET ();
649
654
__HAL_RCC_I2C3_RELEASE_RESET ();
650
655
obj -> irq = I2C3_EV_IRQn ;
651
- #if !defined(STM32L0xx )
656
+ #if !defined(STM32G0xx ) && !defined( STM32L0xx )
652
657
obj -> irqER = I2C3_ER_IRQn ;
653
658
#endif /* !STM32L0xx */
654
659
i2c_handles [I2C3_INDEX ] = handle ;
@@ -1138,11 +1143,25 @@ void I2C1_ER_IRQHandler(void)
1138
1143
*/
1139
1144
void I2C2_EV_IRQHandler (void )
1140
1145
{
1146
+ #if defined(I2C3_BASE ) && defined(STM32G0xx )
1147
+ /* I2C2_3_IRQHandler */
1148
+ I2C_HandleTypeDef * handle2 = i2c_handles [I2C2_INDEX ];
1149
+ I2C_HandleTypeDef * handle3 = i2c_handles [I2C3_INDEX ];
1150
+ if (handle2 ) {
1151
+ HAL_I2C_EV_IRQHandler (handle2 );
1152
+ HAL_I2C_ER_IRQHandler (handle2 );
1153
+ }
1154
+ if (handle3 ) {
1155
+ HAL_I2C_EV_IRQHandler (handle3 );
1156
+ HAL_I2C_ER_IRQHandler (handle3 );
1157
+ }
1158
+ #else
1141
1159
I2C_HandleTypeDef * handle = i2c_handles [I2C2_INDEX ];
1142
1160
HAL_I2C_EV_IRQHandler (handle );
1143
1161
#if defined(STM32F0xx ) || defined(STM32G0xx ) || defined(STM32L0xx )
1144
1162
HAL_I2C_ER_IRQHandler (handle );
1145
1163
#endif /* STM32F0xx || STM32G0xx || STM32L0xx */
1164
+ #endif
1146
1165
}
1147
1166
1148
1167
#if !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx )
@@ -1159,7 +1178,7 @@ void I2C2_ER_IRQHandler(void)
1159
1178
#endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
1160
1179
#endif // I2C2_BASE
1161
1180
1162
- #if defined(I2C3_BASE )
1181
+ #if defined(I2C3_BASE ) && !defined( STM32G0xx )
1163
1182
/**
1164
1183
* @brief This function handles I2C3 interrupt.
1165
1184
* @param None
@@ -1186,7 +1205,7 @@ void I2C3_ER_IRQHandler(void)
1186
1205
HAL_I2C_ER_IRQHandler (handle );
1187
1206
}
1188
1207
#endif /* !STM32L0xx */
1189
- #endif // I2C3_BASE
1208
+ #endif /* I2C3_BASE && ! STM32G0xx */
1190
1209
1191
1210
#if defined(I2C4_BASE )
1192
1211
/**
0 commit comments