Skip to content

Commit d5ecda0

Browse files
committed
ports: Allow MICROPY_PY_MACHINE_I2C_TARGET to be disabled by board cfg.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 255d74b commit d5ecda0

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

ports/alif/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,12 @@
132132
#define MICROPY_PY_MACHINE_PULSE (1)
133133
#define MICROPY_PY_MACHINE_I2C (MICROPY_HW_ENABLE_HW_I2C)
134134
#define MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 (1)
135+
#ifndef MICROPY_PY_MACHINE_I2C_TARGET
135136
#define MICROPY_PY_MACHINE_I2C_TARGET (MICROPY_HW_ENABLE_HW_I2C)
136137
#define MICROPY_PY_MACHINE_I2C_TARGET_INCLUDEFILE "ports/alif/machine_i2c_target.c"
137138
#define MICROPY_PY_MACHINE_I2C_TARGET_MAX (4)
138139
#define MICROPY_PY_MACHINE_I2C_TARGET_HARD_IRQ (1)
140+
#endif
139141
#define MICROPY_PY_MACHINE_SOFTI2C (1)
140142
#define MICROPY_PY_MACHINE_SPI (1)
141143
#define MICROPY_PY_MACHINE_SOFTSPI (1)

ports/esp32/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@
139139
#define MICROPY_PY_MACHINE_PWM_INCLUDEFILE "ports/esp32/machine_pwm.c"
140140
#define MICROPY_PY_MACHINE_I2C (1)
141141
#define MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 (1)
142+
#ifndef MICROPY_PY_MACHINE_I2C_TARGET
142143
// I2C target hardware is limited on ESP32 (eg read event comes after the read) so we only support newer SoCs.
143144
// ESP32C6 does not have enough flash space so also disable it on that SoC.
144145
#define MICROPY_PY_MACHINE_I2C_TARGET (SOC_I2C_SUPPORT_SLAVE && !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32C6)
145146
#define MICROPY_PY_MACHINE_I2C_TARGET_INCLUDEFILE "ports/esp32/machine_i2c_target.c"
146147
#define MICROPY_PY_MACHINE_I2C_TARGET_MAX (2)
148+
#endif
147149
#define MICROPY_PY_MACHINE_SOFTI2C (1)
148150
#define MICROPY_PY_MACHINE_SPI (1)
149151
#define MICROPY_PY_MACHINE_SOFTSPI (1)

ports/mimxrt/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ uint32_t trng_random_u32(void);
9292
#define MICROPY_PY_MACHINE_PWM (1)
9393
#define MICROPY_PY_MACHINE_PWM_INCLUDEFILE "ports/mimxrt/machine_pwm.c"
9494
#define MICROPY_PY_MACHINE_I2C (1)
95+
#ifndef MICROPY_PY_MACHINE_I2C_TARGET
9596
#define MICROPY_PY_MACHINE_I2C_TARGET (1)
9697
#define MICROPY_PY_MACHINE_I2C_TARGET_INCLUDEFILE "ports/mimxrt/machine_i2c_target.c"
9798
#define MICROPY_PY_MACHINE_I2C_TARGET_MAX (FSL_FEATURE_SOC_LPI2C_COUNT)
9899
#define MICROPY_PY_MACHINE_I2C_TARGET_HARD_IRQ (1)
99100
#define MICROPY_PY_MACHINE_I2C_TARGET_FINALISER (1)
101+
#endif
100102
#ifndef MICROPY_PY_MACHINE_I2S
101103
#define MICROPY_PY_MACHINE_I2S (0)
102104
#endif

ports/rp2/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,12 @@
171171
#define MICROPY_PY_MACHINE_PWM (1)
172172
#define MICROPY_PY_MACHINE_PWM_INCLUDEFILE "ports/rp2/machine_pwm.c"
173173
#define MICROPY_PY_MACHINE_I2C (1)
174+
#ifndef MICROPY_PY_MACHINE_I2C_TARGET
174175
#define MICROPY_PY_MACHINE_I2C_TARGET (1)
175176
#define MICROPY_PY_MACHINE_I2C_TARGET_INCLUDEFILE "ports/rp2/machine_i2c_target.c"
176177
#define MICROPY_PY_MACHINE_I2C_TARGET_MAX (2)
177178
#define MICROPY_PY_MACHINE_I2C_TARGET_HARD_IRQ (1)
179+
#endif
178180
#define MICROPY_PY_MACHINE_SOFTI2C (1)
179181
#define MICROPY_PY_MACHINE_I2S (1)
180182
#define MICROPY_PY_MACHINE_I2S_INCLUDEFILE "ports/rp2/machine_i2s.c"

ports/stm32/mpconfigboard_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,11 +639,13 @@
639639
#if defined(MICROPY_HW_I2C1_SCL) || defined(MICROPY_HW_I2C2_SCL) \
640640
|| defined(MICROPY_HW_I2C3_SCL) || defined(MICROPY_HW_I2C4_SCL)
641641
#define MICROPY_HW_ENABLE_HW_I2C (1)
642+
#ifndef MICROPY_HW_ENABLE_HW_I2C_TARGET
642643
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32WB)
643644
#define MICROPY_HW_ENABLE_HW_I2C_TARGET (1)
644645
#else
645646
#define MICROPY_HW_ENABLE_HW_I2C_TARGET (0)
646647
#endif
648+
#endif
647649
#else
648650
#define MICROPY_HW_ENABLE_HW_I2C (0)
649651
#define MICROPY_HW_ENABLE_HW_I2C_TARGET (0)

0 commit comments

Comments
 (0)