diff --git a/ports/esp32/machine_i2s.c b/ports/esp32/machine_i2s.c index b0d02e74f6..099796cf43 100644 --- a/ports/esp32/machine_i2s.c +++ b/ports/esp32/machine_i2s.c @@ -38,6 +38,8 @@ #include "modmachine.h" #include "mphalport.h" +#if MICROPY_PY_MACHINE_I2S + #include "driver/i2s.h" #include "soc/i2s_reg.h" #include "freertos/FreeRTOS.h" @@ -807,3 +809,5 @@ const mp_obj_type_t machine_i2s_type = { .make_new = machine_i2s_make_new, .locals_dict = (mp_obj_dict_t *)&machine_i2s_locals_dict, }; + +#endif // MICROPY_PY_MACHINE_I2S diff --git a/ports/esp32/main.c b/ports/esp32/main.c index c1b8e8a31d..66068ccffa 100644 --- a/ports/esp32/main.c +++ b/ports/esp32/main.c @@ -138,7 +138,9 @@ soft_reset: // initialise peripherals machine_pins_init(); + #if MICROPY_PY_MACHINE_I2S machine_i2s_init0(); + #endif // run boot-up scripts pyexec_frozen_module("_boot.py"); diff --git a/ports/esp32/modmachine.c b/ports/esp32/modmachine.c index 5a7658dbbb..aa009944bd 100644 --- a/ports/esp32/modmachine.c +++ b/ports/esp32/modmachine.c @@ -282,7 +282,9 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { #endif { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_hw_i2c_type) }, { MP_ROM_QSTR(MP_QSTR_SoftI2C), MP_ROM_PTR(&mp_machine_soft_i2c_type) }, + #if MICROPY_PY_MACHINE_I2S { MP_ROM_QSTR(MP_QSTR_I2S), MP_ROM_PTR(&machine_i2s_type) }, + #endif { MP_ROM_QSTR(MP_QSTR_PWM), MP_ROM_PTR(&machine_pwm_type) }, { MP_ROM_QSTR(MP_QSTR_RTC), MP_ROM_PTR(&machine_rtc_type) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_hw_spi_type) }, diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h index aadf4620de..e4375bd0be 100644 --- a/ports/esp32/mpconfigport.h +++ b/ports/esp32/mpconfigport.h @@ -156,6 +156,9 @@ #ifndef MICROPY_PY_MACHINE_DAC #define MICROPY_PY_MACHINE_DAC (1) #endif +#ifndef MICROPY_PY_MACHINE_I2S +#define MICROPY_PY_MACHINE_I2S (1) +#endif #ifndef MICROPY_HW_ENABLE_SDCARD #define MICROPY_HW_ENABLE_SDCARD (1) #endif