Skip to content

Commit f2a7be3

Browse files
committed
chore(wb0): add I2C support
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 04d4468 commit f2a7be3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

libraries/Wire/src/utility/twi.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ static I2C_HandleTypeDef *i2c_handles[I2C_NUM];
193193
static uint32_t i2c_getClkFreq(I2C_TypeDef *i2c)
194194
{
195195
uint32_t clkSrcFreq = 0;
196+
#if defined(STM32WB0x)
197+
(void)i2c; // Avoid unused parameter warning
198+
clkSrcFreq = SystemCoreClock;
199+
#else
196200
#ifdef STM32H7xx
197201
PLL3_ClocksTypeDef PLL3_Clocks;
198202
#endif
@@ -511,6 +515,7 @@ static uint32_t i2c_getClkFreq(I2C_TypeDef *i2c)
511515
}
512516
}
513517
#endif // I2C6_BASE
518+
#endif /* STM32WB0x */
514519
return clkSrcFreq;
515520
}
516521

@@ -754,7 +759,7 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
754759

755760
obj->irq = I2C1_EV_IRQn;
756761
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32G0xx) && \
757-
!defined(STM32L0xx) && !defined(STM32U0xx)
762+
!defined(STM32L0xx) && !defined(STM32U0xx) && !defined(STM32WB0x)
758763
obj->irqER = I2C1_ER_IRQn;
759764
#endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
760765
i2c_handles[I2C1_INDEX] = handle;

libraries/Wire/src/utility/twi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ extern "C" {
6969

7070
/* Redefinition of IRQ for C0/F0/G0/L0/U0 families */
7171
#if defined(STM32C0xx) || defined(STM32F0xx) || defined(STM32G0xx) ||\
72-
defined(STM32L0xx) || defined(STM32U0xx)
72+
defined(STM32L0xx) || defined(STM32U0xx) || defined(STM32WB0x)
7373
#if defined(I2C1_BASE)
7474
#define I2C1_EV_IRQn I2C1_IRQn
7575
#define I2C1_EV_IRQHandler I2C1_IRQHandler

0 commit comments

Comments
 (0)