From 4a9fc1026a0e1f400fe9ebdbb68caa4a6bece586 Mon Sep 17 00:00:00 2001 From: xiongyu Date: Fri, 27 Dec 2019 20:27:01 +0800 Subject: [PATCH] bugfix(driver): fix i2s and timergroup some issues * fix i2s and timergroup dev array used by isr crash issue * Closes IDFGH-2432 * Closes https://github.com/espressif/esp-idf/issues/4545 * fix i2s adc data inv issue * Closes IDFGH-2444 * Closes https://github.com/espressif/esp-idf/issues/4557 --- components/driver/i2s.c | 3 ++- components/driver/rtc_module.c | 2 ++ components/driver/timer.c | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/driver/i2s.c b/components/driver/i2s.c index c4dce4b175..9c6cf17dfe 100644 --- a/components/driver/i2s.c +++ b/components/driver/i2s.c @@ -90,7 +90,8 @@ typedef struct { } i2s_obj_t; static i2s_obj_t *p_i2s_obj[I2S_NUM_MAX] = {0}; -static i2s_dev_t* I2S[I2S_NUM_MAX] = {&I2S0, &I2S1}; +/* DRAM_ATTR is required to avoid I2S array placed in flash, due to accessed from ISR */ +static DRAM_ATTR i2s_dev_t* I2S[I2S_NUM_MAX] = {&I2S0, &I2S1}; static portMUX_TYPE i2s_spinlock[I2S_NUM_MAX] = {portMUX_INITIALIZER_UNLOCKED, portMUX_INITIALIZER_UNLOCKED}; static int _i2s_adc_unit = -1; static int _i2s_adc_channel = -1; diff --git a/components/driver/rtc_module.c b/components/driver/rtc_module.c index a7124a1bfe..3bf63d131a 100644 --- a/components/driver/rtc_module.c +++ b/components/driver/rtc_module.c @@ -1183,10 +1183,12 @@ esp_err_t adc_set_data_inv(adc_unit_t adc_unit, bool inv_en) if (adc_unit & ADC_UNIT_1) { // Enable ADC data invert SENS.sar_read_ctrl.sar1_data_inv = inv_en; + SYSCON.saradc_ctrl2.sar1_inv = inv_en; } if (adc_unit & ADC_UNIT_2) { // Enable ADC data invert SENS.sar_read_ctrl2.sar2_data_inv = inv_en; + SYSCON.saradc_ctrl2.sar2_inv = inv_en; } portEXIT_CRITICAL(&rtc_spinlock); return ESP_OK; diff --git a/components/driver/timer.c b/components/driver/timer.c index 8f881fc5a8..106c412bdf 100644 --- a/components/driver/timer.c +++ b/components/driver/timer.c @@ -36,7 +36,8 @@ static const char* TIMER_TAG = "timer_group"; #define TIMER_SCALE_ERROR "HW TIMER SCALE ERROR" #define TIMER_ALARM_ERROR "HW TIMER ALARM ERROR" #define DIVIDER_RANGE_ERROR "HW TIMER divider outside of [2, 65536] range error" -static timg_dev_t *TG[2] = {&TIMERG0, &TIMERG1}; +/* DRAM_ATTR is required to avoid TG array placed in flash, due to accessed from ISR */ +static DRAM_ATTR timg_dev_t *TG[2] = {&TIMERG0, &TIMERG1}; static portMUX_TYPE timer_spinlock[TIMER_GROUP_MAX] = {portMUX_INITIALIZER_UNLOCKED, portMUX_INITIALIZER_UNLOCKED}; #define TIMER_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux);