diff --git a/components/esp_driver_i2s/lp_i2s.c b/components/esp_driver_i2s/lp_i2s.c index 0d5e43dd8d..5b5f8b7393 100644 --- a/components/esp_driver_i2s/lp_i2s.c +++ b/components/esp_driver_i2s/lp_i2s.c @@ -18,6 +18,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "esp_clk_tree.h" +#include "esp_memory_utils.h" #include "hal/hal_utils.h" #include "hal/lp_i2s_hal.h" #include "hal/lp_i2s_ll.h" @@ -250,6 +251,13 @@ esp_err_t lp_i2s_register_event_callbacks(lp_i2s_chan_handle_t handle, const lp_ ESP_RETURN_ON_FALSE(handle && cbs, ESP_ERR_INVALID_ARG, TAG, "invalid argument"); ESP_RETURN_ON_FALSE(handle->state < I2S_CHAN_STATE_RUNNING, ESP_ERR_INVALID_STATE, TAG, "the channel is in enabled state already"); + if (cbs->on_thresh_met) { + ESP_RETURN_ON_FALSE(esp_ptr_in_iram(cbs->on_thresh_met), ESP_ERR_INVALID_ARG, TAG, "on_thresh_met callback not in IRAM"); + } + if (cbs->on_request_new_trans) { + ESP_RETURN_ON_FALSE(esp_ptr_in_iram(cbs->on_request_new_trans), ESP_ERR_INVALID_ARG, TAG, "on_request_new_trans callback not in IRAM"); + } + handle->cbs.on_thresh_met = cbs->on_thresh_met; handle->cbs.on_request_new_trans = cbs->on_request_new_trans; handle->user_data = user_data; diff --git a/components/esp_driver_i2s/test_apps/lp_i2s/main/test_lp_i2s.c b/components/esp_driver_i2s/test_apps/lp_i2s/main/test_lp_i2s.c index 8d87f12f78..4e399a9efd 100644 --- a/components/esp_driver_i2s/test_apps/lp_i2s/main/test_lp_i2s.c +++ b/components/esp_driver_i2s/test_apps/lp_i2s/main/test_lp_i2s.c @@ -222,7 +222,7 @@ TEST_CASE("test LP I2S read for STD", "[lp_i2s]") } } -static bool s_lp_i2s_on_thresh_met(lp_i2s_chan_handle_t handle, lp_i2s_evt_data_t *edata, void *user_data) +static bool IRAM_ATTR s_lp_i2s_on_thresh_met(lp_i2s_chan_handle_t handle, lp_i2s_evt_data_t *edata, void *user_data) { ESP_DRAM_LOGD(TAG, "edata->trans.received_size: %d", edata->trans.received_size); s_data_check(edata->trans.buffer, edata->trans.received_size); @@ -230,7 +230,7 @@ static bool s_lp_i2s_on_thresh_met(lp_i2s_chan_handle_t handle, lp_i2s_evt_data_ return false; } -static bool s_lp_i2s_on_request_new_trans(lp_i2s_chan_handle_t handle, lp_i2s_evt_data_t *edata, void *user_data) +static bool IRAM_ATTR s_lp_i2s_on_request_new_trans(lp_i2s_chan_handle_t handle, lp_i2s_evt_data_t *edata, void *user_data) { lp_i2s_trans_t trans = *(lp_i2s_trans_t *)user_data; edata->trans.buffer = trans.buffer;