@@ -274,6 +274,7 @@ static uint32_t i2c_getClkFreq(I2C_TypeDef *i2c)
274274#endif // I2C2_BASE
275275#if defined I2C3_BASE
276276 if (i2c == I2C3 ) {
277+ #if defined(__HAL_RCC_GET_I2C3_SOURCE )
277278 switch (__HAL_RCC_GET_I2C3_SOURCE ()) {
278279 case RCC_I2C3CLKSOURCE_HSI :
279280 clkSrcFreq = HSI_VALUE ;
@@ -307,6 +308,10 @@ static uint32_t i2c_getClkFreq(I2C_TypeDef *i2c)
307308 default :
308309 Error_Handler ();
309310 }
311+ #else
312+ /* STM32 G0 I2C3 has no independent clock */
313+ clkSrcFreq = HAL_RCC_GetPCLK1Freq ();
314+ #endif
310315 }
311316#endif // I2C3_BASE
312317#if defined I2C4_BASE
@@ -648,7 +653,7 @@ void i2c_custom_init(i2c_t *obj, uint32_t timing, uint32_t addressingMode, uint3
648653 __HAL_RCC_I2C3_FORCE_RESET ();
649654 __HAL_RCC_I2C3_RELEASE_RESET ();
650655 obj -> irq = I2C3_EV_IRQn ;
651- #if !defined(STM32L0xx )
656+ #if !defined(STM32G0xx ) && !defined( STM32L0xx )
652657 obj -> irqER = I2C3_ER_IRQn ;
653658#endif /* !STM32L0xx */
654659 i2c_handles [I2C3_INDEX ] = handle ;
@@ -1138,11 +1143,25 @@ void I2C1_ER_IRQHandler(void)
11381143*/
11391144void I2C2_EV_IRQHandler (void )
11401145{
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
11411159 I2C_HandleTypeDef * handle = i2c_handles [I2C2_INDEX ];
11421160 HAL_I2C_EV_IRQHandler (handle );
11431161#if defined(STM32F0xx ) || defined(STM32G0xx ) || defined(STM32L0xx )
11441162 HAL_I2C_ER_IRQHandler (handle );
11451163#endif /* STM32F0xx || STM32G0xx || STM32L0xx */
1164+ #endif
11461165}
11471166
11481167#if !defined(STM32F0xx ) && !defined(STM32G0xx ) && !defined(STM32L0xx )
@@ -1159,7 +1178,7 @@ void I2C2_ER_IRQHandler(void)
11591178#endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
11601179#endif // I2C2_BASE
11611180
1162- #if defined(I2C3_BASE )
1181+ #if defined(I2C3_BASE ) && !defined( STM32G0xx )
11631182/**
11641183* @brief This function handles I2C3 interrupt.
11651184* @param None
@@ -1186,7 +1205,7 @@ void I2C3_ER_IRQHandler(void)
11861205 HAL_I2C_ER_IRQHandler (handle );
11871206}
11881207#endif /* !STM32L0xx */
1189- #endif // I2C3_BASE
1208+ #endif /* I2C3_BASE && ! STM32G0xx */
11901209
11911210#if defined(I2C4_BASE )
11921211/**
0 commit comments