mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
Merge branch 'feature/support_i2s_and_etm_on_h4' into 'master'
feat(i2s & etm): support i2s and etm on esp32-h4 Closes IDF-12385, IDF-12355, and IDF-13396 See merge request espressif/esp-idf!39698
This commit is contained in:
@@ -29,6 +29,7 @@ typedef enum {
|
||||
ETM_TRIG_PERIPH_TSENS, /*!< ETM trigger source: Temperature Sensor */
|
||||
ETM_TRIG_PERIPH_I2S, /*!< ETM trigger source: I2S */
|
||||
ETM_TRIG_PERIPH_LP_CORE, /*!< ETM trigger source: Low-Power Core */
|
||||
ETM_TRIG_PERIPH_MODEM, /*!< ETM trigger source: Modem */
|
||||
} etm_trigger_peripheral_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Modem ETM event type
|
||||
*
|
||||
* @note The event type is used to identify the event type.
|
||||
*/
|
||||
typedef enum {
|
||||
MODEM_ETM_EVENT_G0 = 0, /*!< Modem ETM event group 0 */
|
||||
MODEM_ETM_EVENT_G1 = 1, /*!< Modem ETM event group 1 */
|
||||
MODEM_ETM_EVENT_G2 = 2, /*!< Modem ETM event group 2 */
|
||||
MODEM_ETM_EVENT_G3 = 3, /*!< Modem ETM event group 3 */
|
||||
MODEM_ETM_EVENT_MAX,
|
||||
} modem_etm_event_type_t;
|
||||
|
||||
/**
|
||||
* @brief Modem ETM task type
|
||||
*
|
||||
* @note The task type is used to identify the task type.
|
||||
*/
|
||||
typedef enum {
|
||||
MODEM_ETM_TASK_G0 = 0, /*!< Modem ETM task group 0 */
|
||||
MODEM_ETM_TASK_G1 = 1, /*!< Modem ETM task group 1 */
|
||||
MODEM_ETM_TASK_G2 = 2, /*!< Modem ETM task group 2 */
|
||||
MODEM_ETM_TASK_G3 = 3, /*!< Modem ETM task group 3 */
|
||||
MODEM_ETM_TASK_MAX,
|
||||
} modem_etm_task_type_t;
|
||||
|
||||
/**
|
||||
* @brief Modem ETM event configuration
|
||||
*
|
||||
* @note The event configuration is used to configure the event.
|
||||
*/
|
||||
typedef struct {
|
||||
modem_etm_event_type_t event_type; /*!< Modem ETM event type */
|
||||
} modem_etm_event_config_t;
|
||||
|
||||
/**
|
||||
* @brief Modem ETM task configuration
|
||||
*
|
||||
* @note The task configuration is used to configure the task.
|
||||
*/
|
||||
typedef struct {
|
||||
modem_etm_task_type_t task_type; /*!< Modem ETM task type */
|
||||
} modem_etm_task_config_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create a new modem ETM event
|
||||
*
|
||||
* @param config The modem ETM event configuration
|
||||
* @param out_event The output modem ETM event handle
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - ESP_ERR_INVALID_ARG: Invalid argument
|
||||
* - ESP_ERR_NO_MEM: No memory
|
||||
*/
|
||||
esp_err_t modem_new_etm_event(const modem_etm_event_config_t *config, esp_etm_event_handle_t *out_event);
|
||||
|
||||
/**
|
||||
* @brief Create a new modem ETM task
|
||||
*
|
||||
* @param config The modem ETM task configuration
|
||||
* @param out_task The output modem ETM task handle
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - ESP_ERR_INVALID_ARG: Invalid argument
|
||||
* - ESP_ERR_NO_MEM: No memory
|
||||
*/
|
||||
esp_err_t modem_new_etm_task(const modem_etm_task_config_t *config, esp_etm_task_handle_t *out_task);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_check.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "modem/modem_etm.h"
|
||||
#include "hal/modem_ll.h"
|
||||
#include "esp_private/etm_interface.h"
|
||||
|
||||
#define ETM_MEM_ALLOC_CAPS MALLOC_CAP_DEFAULT
|
||||
|
||||
static const char *TAG = "modem-etm";
|
||||
|
||||
static esp_err_t s_modem_del_etm_event(esp_etm_event_t *event)
|
||||
{
|
||||
free(event);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t s_modem_del_etm_task(esp_etm_task_t *task)
|
||||
{
|
||||
free(task);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t modem_new_etm_event(const modem_etm_event_config_t *config, esp_etm_event_handle_t *out_event)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(config && out_event, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
|
||||
ESP_RETURN_ON_FALSE(config->event_type < MODEM_ETM_EVENT_MAX, ESP_ERR_INVALID_ARG, TAG, "invalid event type");
|
||||
esp_etm_event_t *event = heap_caps_calloc(1, sizeof(esp_etm_event_t), ETM_MEM_ALLOC_CAPS);
|
||||
ESP_RETURN_ON_FALSE(event, ESP_ERR_NO_MEM, TAG, "no memory for ETM event");
|
||||
|
||||
// Get the event id from the modem ETM event table
|
||||
uint32_t event_id = MODEM_LL_ETM_EVENT_TABLE((uint32_t)config->event_type);
|
||||
|
||||
// fill the ETM event object
|
||||
event->event_id = event_id;
|
||||
event->trig_periph = ETM_TRIG_PERIPH_MODEM;
|
||||
event->del = s_modem_del_etm_event;
|
||||
*out_event = event;
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t modem_new_etm_task(const modem_etm_task_config_t *config, esp_etm_task_handle_t *out_task)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(config && out_task, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
|
||||
ESP_RETURN_ON_FALSE(config->task_type < MODEM_ETM_TASK_MAX, ESP_ERR_INVALID_ARG, TAG, "invalid task type");
|
||||
esp_etm_task_t *task = heap_caps_calloc(1, sizeof(esp_etm_task_t), ETM_MEM_ALLOC_CAPS);
|
||||
ESP_RETURN_ON_FALSE(task, ESP_ERR_NO_MEM, TAG, "no memory for ETM task");
|
||||
|
||||
// Get the task id from the modem ETM task table
|
||||
uint32_t task_id = MODEM_LL_ETM_TASK_TABLE((uint32_t)config->task_type);
|
||||
|
||||
// fill the ETM task object
|
||||
task->task_id = task_id;
|
||||
task->trig_periph = ETM_TRIG_PERIPH_MODEM;
|
||||
task->del = s_modem_del_etm_task;
|
||||
*out_task = task;
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
Reference in New Issue
Block a user