Skip to content

Commit 22f1414

Browse files
committed
stm32/i2c: Fully support peripheral I2C4.
1 parent 69bf23c commit 22f1414

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

ports/stm32/i2c.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,10 @@ STATIC mp_obj_t pyb_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_
650650
} else if (strcmp(port, MICROPY_HW_I2C3_NAME) == 0) {
651651
i2c_id = 3;
652652
#endif
653+
#ifdef MICROPY_HW_I2C4_NAME
654+
} else if (strcmp(port, MICROPY_HW_I2C4_NAME) == 0) {
655+
i2c_id = 4;
656+
#endif
653657
} else {
654658
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
655659
"I2C(%s) doesn't exist", port));

ports/stm32/i2c.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ typedef struct _pyb_i2c_obj_t {
4242
extern I2C_HandleTypeDef I2CHandle1;
4343
extern I2C_HandleTypeDef I2CHandle2;
4444
extern I2C_HandleTypeDef I2CHandle3;
45+
extern I2C_HandleTypeDef I2CHandle4;
4546
extern const mp_obj_type_t pyb_i2c_type;
4647
extern const pyb_i2c_obj_t pyb_i2c_obj[4];
4748

0 commit comments

Comments
 (0)