fix(lp_i2s): added cbs iram check

This commit is contained in:
Armando 2024-11-08 12:24:52 +08:00
parent 30f0c6f5db
commit e83fc30b67
2 changed files with 10 additions and 2 deletions

View File

@ -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;

View File

@ -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;