aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2018-05-17 23:37:12 +1000
committerDamien George2018-05-17 23:37:12 +1000
commit58331e3c28e41ad7e3c3dd7dabf6d508a8bfe1cb (patch)
tree7212690ca0e56ac0ce3bd9522bd9b9d6364975f1
parent1e2a6a84a263e069d7be5f27d73e7fc124413fa5 (diff)
esp8266/modmachine: Allow I2C and SPI to be configured out of the build.
I2C costs about 3000 bytes of code, and SPI costs about 4400 bytes.
-rw-r--r--ports/esp8266/machine_hspi.c4
-rw-r--r--ports/esp8266/modmachine.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/ports/esp8266/machine_hspi.c b/ports/esp8266/machine_hspi.c
index ff7728291..07770c8c8 100644
--- a/ports/esp8266/machine_hspi.c
+++ b/ports/esp8266/machine_hspi.c
@@ -39,6 +39,8 @@
#include "modmachine.h"
#include "hspi.h"
+#if MICROPY_PY_MACHINE_SPI
+
typedef struct _machine_hspi_obj_t {
mp_obj_base_t base;
uint32_t baudrate;
@@ -180,3 +182,5 @@ const mp_obj_type_t machine_hspi_type = {
.protocol = &machine_hspi_p,
.locals_dict = (mp_obj_dict_t*)&mp_machine_spi_locals_dict,
};
+
+#endif // MICROPY_PY_MACHINE_SPI
diff --git a/ports/esp8266/modmachine.c b/ports/esp8266/modmachine.c
index 99286848e..7e5f6714b 100644
--- a/ports/esp8266/modmachine.c
+++ b/ports/esp8266/modmachine.c
@@ -255,8 +255,12 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_PWM), MP_ROM_PTR(&pyb_pwm_type) },
{ MP_ROM_QSTR(MP_QSTR_ADC), MP_ROM_PTR(&pyb_adc_type) },
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&pyb_uart_type) },
+ #if MICROPY_PY_MACHINE_I2C
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_i2c_type) },
+ #endif
+ #if MICROPY_PY_MACHINE_SPI
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_hspi_type) },
+ #endif
// wake abilities
{ MP_ROM_QSTR(MP_QSTR_DEEPSLEEP), MP_ROM_INT(MACHINE_WAKE_DEEPSLEEP) },