Skip to content

Commit aaaef87

Browse files
committed
STM32: Enable I2CTarget for STM32L4.
STM32L4 uses the same I2C controller as STM32WB. Change `defined(STM32WB)` to `defined(STM32WB) || defined(STM32L4)` in: stm32/i2cslav stm32/i2cslave.h stm32/mpconfigboard_common.h Signed-off-by: Chris Mason <c.mason@inchipdesign.com.au>
1 parent 1588c45 commit aaaef87

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

ports/stm32/i2cslave.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void i2c_slave_irq_handler(i2c_slave_t *i2c) {
7676
}
7777
}
7878

79-
#elif defined(STM32F7) || defined(STM32H7) || defined(STM32WB)
79+
#elif defined(STM32F7) || defined(STM32H7) || defined(STM32WB) || defined(STM32L4)
8080

8181
void i2c_slave_init_helper(i2c_slave_t *i2c, int addr) {
8282
i2c->CR1 = I2C_CR1_STOPIE | I2C_CR1_ADDRIE | I2C_CR1_RXIE | I2C_CR1_TXIE;

ports/stm32/i2cslave.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include STM32_HAL_H
3030

31-
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32WB)
31+
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32WB) || defined(STM32L4)
3232

3333
#if !defined(I2C2_BASE)
3434
// This MCU doesn't have I2C2_BASE, define it so that the i2c_idx calculation works.
@@ -63,7 +63,7 @@ static inline void i2c_slave_init(i2c_slave_t *i2c, int irqn, int irq_pri, int a
6363
volatile uint32_t tmp = RCC->APB1ENR1; // Delay after enabling clock
6464
(void)tmp;
6565
}
66-
#elif defined(STM32WB)
66+
#elif defined(STM32WB) || defined(STM32L4)
6767
RCC->APB1ENR1 |= 1 << (RCC_APB1ENR1_I2C1EN_Pos + i2c_idx);
6868
volatile uint32_t tmp = RCC->APB1ENR1; // Delay after enabling clock
6969
(void)tmp;

ports/stm32/mpconfigboard_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@
640640
|| defined(MICROPY_HW_I2C3_SCL) || defined(MICROPY_HW_I2C4_SCL)
641641
#define MICROPY_HW_ENABLE_HW_I2C (1)
642642
#ifndef MICROPY_HW_ENABLE_HW_I2C_TARGET
643-
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32WB)
643+
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32WB) || defined(STM32L4)
644644
#define MICROPY_HW_ENABLE_HW_I2C_TARGET (1)
645645
#else
646646
#define MICROPY_HW_ENABLE_HW_I2C_TARGET (0)

0 commit comments

Comments
 (0)