Skip to content

Commit 23911d6

Browse files
committed
chore(wl3): add I2C support
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 4b76c98 commit 23911d6

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

libraries/Wire/src/utility/twi.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ 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)
196+
#if defined(STM32WB0x) || defined(STM32WL3x)
197197
(void)i2c; // Avoid unused parameter warning
198-
clkSrcFreq = SystemCoreClock;
198+
clkSrcFreq = SystemCoreClock / 4;
199199
#else
200200
#ifdef STM32H7xx
201201
PLL3_ClocksTypeDef PLL3_Clocks;
@@ -515,7 +515,7 @@ static uint32_t i2c_getClkFreq(I2C_TypeDef *i2c)
515515
}
516516
}
517517
#endif // I2C6_BASE
518-
#endif /* STM32WB0x */
518+
#endif /* STM32WB0x || STM32WL3x */
519519
return clkSrcFreq;
520520
}
521521

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

760760
obj->irq = I2C1_EV_IRQn;
761761
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32G0xx) && \
762-
!defined(STM32L0xx) && !defined(STM32U0xx) && !defined(STM32WB0x)
762+
!defined(STM32L0xx) && !defined(STM32U0xx) && !defined(STM32WB0x) && \
763+
!defined(STM32WL3x)
763764
obj->irqER = I2C1_ER_IRQn;
764765
#endif /* !STM32C0xx && !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
765766
i2c_handles[I2C1_INDEX] = handle;
@@ -773,7 +774,8 @@ void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
773774
__HAL_RCC_I2C2_RELEASE_RESET();
774775
obj->irq = I2C2_EV_IRQn;
775776
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32G0xx) && \
776-
!defined(STM32L0xx) && !defined(STM32U0xx)
777+
!defined(STM32L0xx) && !defined(STM32U0xx) && !defined(STM32WB0x) && \
778+
!defined(STM32WL3x)
777779
obj->irqER = I2C2_ER_IRQn;
778780
#endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx && !STM32U0xx */
779781
i2c_handles[I2C2_INDEX] = handle;

libraries/Wire/src/utility/twi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ 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) || defined(STM32WB0x)
72+
defined(STM32L0xx) || defined(STM32U0xx) || defined(STM32WB0x) || \
73+
defined(STM32WL3x)
7374
#if defined(I2C1_BASE)
7475
#define I2C1_EV_IRQn I2C1_IRQn
7576
#define I2C1_EV_IRQHandler I2C1_IRQHandler

0 commit comments

Comments
 (0)