summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-05-14 13:53:46 +1000
committerDamien George <damien.p.george@gmail.com>2018-05-14 13:53:46 +1000
commit88c26a48b4a3c8850ff2677b2f0ce8c90ba8e660 (patch)
tree4dda9a0959eb87bd5b8b6c1a60dc5b4437bfc50d
parent92c5e2708d48a114f209a2299babb2c6de78ce22 (diff)
stm32/pyb_i2c: Put pyb.I2C under MICROPY_PY_PYB_LEGACY setting.
When disabled, the pyb.I2C class saves around 8k of code space and 172 bytes of RAM. The same functionality is now available in machine.I2C (for F4 and F7 MCUs). It is still enabled by default.
-rw-r--r--ports/stm32/main.c2
-rw-r--r--ports/stm32/modpyb.c2
-rw-r--r--ports/stm32/pyb_i2c.c4
-rw-r--r--ports/stm32/stm32_it.c4
4 files changed, 8 insertions, 4 deletions
diff --git a/ports/stm32/main.c b/ports/stm32/main.c
index 4553a07e2..460a19ccb 100644
--- a/ports/stm32/main.c
+++ b/ports/stm32/main.c
@@ -505,7 +505,7 @@ void stm32_main(uint32_t reset_mode) {
rtc_init_start(false);
#endif
spi_init0();
- #if MICROPY_HW_ENABLE_HW_I2C
+ #if MICROPY_PY_PYB_LEGACY && MICROPY_HW_ENABLE_HW_I2C
i2c_init0();
#endif
#if MICROPY_HW_HAS_SDCARD
diff --git a/ports/stm32/modpyb.c b/ports/stm32/modpyb.c
index 3438b12e8..6357aca94 100644
--- a/ports/stm32/modpyb.c
+++ b/ports/stm32/modpyb.c
@@ -227,7 +227,7 @@ STATIC const mp_rom_map_elem_t pyb_module_globals_table[] = {
#if defined(MICROPY_HW_LED1)
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pyb_led_type) },
#endif
- #if MICROPY_HW_ENABLE_HW_I2C
+ #if MICROPY_PY_PYB_LEGACY && MICROPY_HW_ENABLE_HW_I2C
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&pyb_i2c_type) },
#endif
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&pyb_spi_type) },
diff --git a/ports/stm32/pyb_i2c.c b/ports/stm32/pyb_i2c.c
index db09f688b..33aaa48cb 100644
--- a/ports/stm32/pyb_i2c.c
+++ b/ports/stm32/pyb_i2c.c
@@ -35,7 +35,7 @@
#include "dma.h"
#include "i2c.h"
-#if MICROPY_HW_ENABLE_HW_I2C
+#if MICROPY_PY_PYB_LEGACY && MICROPY_HW_ENABLE_HW_I2C
/// \moduleref pyb
/// \class I2C - a two-wire serial protocol
@@ -1065,4 +1065,4 @@ const mp_obj_type_t pyb_i2c_type = {
.locals_dict = (mp_obj_dict_t*)&pyb_i2c_locals_dict,
};
-#endif // MICROPY_HW_ENABLE_HW_I2C
+#endif // MICROPY_PY_PYB_LEGACY && MICROPY_HW_ENABLE_HW_I2C
diff --git a/ports/stm32/stm32_it.c b/ports/stm32/stm32_it.c
index db812958f..a77802bfa 100644
--- a/ports/stm32/stm32_it.c
+++ b/ports/stm32/stm32_it.c
@@ -776,6 +776,8 @@ void CAN2_SCE_IRQHandler(void) {
}
#endif
+#if MICROPY_PY_PYB_LEGACY
+
#if defined(MICROPY_HW_I2C1_SCL)
void I2C1_EV_IRQHandler(void) {
IRQ_ENTER(I2C1_EV_IRQn);
@@ -831,3 +833,5 @@ void I2C4_ER_IRQHandler(void) {
IRQ_EXIT(I2C4_ER_IRQn);
}
#endif // defined(MICROPY_HW_I2C4_SCL)
+
+#endif // MICROPY_PY_PYB_LEGACY