esp32/machine_i2s: Add MICROPY_PY_MACHINE_I2S option, enable by default.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2021-07-18 12:11:15 +10:00
parent 1f9243f8d4
commit 0fc0ccabec
4 changed files with 11 additions and 0 deletions

View File

@ -38,6 +38,8 @@
#include "modmachine.h" #include "modmachine.h"
#include "mphalport.h" #include "mphalport.h"
#if MICROPY_PY_MACHINE_I2S
#include "driver/i2s.h" #include "driver/i2s.h"
#include "soc/i2s_reg.h" #include "soc/i2s_reg.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
@ -807,3 +809,5 @@ const mp_obj_type_t machine_i2s_type = {
.make_new = machine_i2s_make_new, .make_new = machine_i2s_make_new,
.locals_dict = (mp_obj_dict_t *)&machine_i2s_locals_dict, .locals_dict = (mp_obj_dict_t *)&machine_i2s_locals_dict,
}; };
#endif // MICROPY_PY_MACHINE_I2S

View File

@ -138,7 +138,9 @@ soft_reset:
// initialise peripherals // initialise peripherals
machine_pins_init(); machine_pins_init();
#if MICROPY_PY_MACHINE_I2S
machine_i2s_init0(); machine_i2s_init0();
#endif
// run boot-up scripts // run boot-up scripts
pyexec_frozen_module("_boot.py"); pyexec_frozen_module("_boot.py");

View File

@ -282,7 +282,9 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
#endif #endif
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_hw_i2c_type) }, { 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) }, { 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) }, { 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_PWM), MP_ROM_PTR(&machine_pwm_type) },
{ MP_ROM_QSTR(MP_QSTR_RTC), MP_ROM_PTR(&machine_rtc_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) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_hw_spi_type) },

View File

@ -156,6 +156,9 @@
#ifndef MICROPY_PY_MACHINE_DAC #ifndef MICROPY_PY_MACHINE_DAC
#define MICROPY_PY_MACHINE_DAC (1) #define MICROPY_PY_MACHINE_DAC (1)
#endif #endif
#ifndef MICROPY_PY_MACHINE_I2S
#define MICROPY_PY_MACHINE_I2S (1)
#endif
#ifndef MICROPY_HW_ENABLE_SDCARD #ifndef MICROPY_HW_ENABLE_SDCARD
#define MICROPY_HW_ENABLE_SDCARD (1) #define MICROPY_HW_ENABLE_SDCARD (1)
#endif #endif