feat(hal): graudate the RMT hal driver into a new component

This commit is contained in:
Chen Jichang
2025-11-13 17:54:54 +08:00
parent cb5f2ff4c2
commit 2cb84ecf95
65 changed files with 625 additions and 919 deletions

View File

@@ -0,0 +1,62 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*******************************************************************************
* NOTICE
* The hal is not public api, don't use in application code.
* See readme.md in hal/include/hal/readme.md
******************************************************************************/
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct rmt_dev_t *rmt_soc_handle_t; // RMT SOC layer handle
/**
* @brief HAL context type of RMT driver
*/
typedef struct {
rmt_soc_handle_t regs; /*!< RMT Register base address */
} rmt_hal_context_t;
/**
* @brief Initialize the RMT HAL driver
*
* @param hal: RMT HAL context
*/
void rmt_hal_init(rmt_hal_context_t *hal);
/**
* @brief Deinitialize the RMT HAL driver
*
* @param hal: RMT HAL context
*/
void rmt_hal_deinit(rmt_hal_context_t *hal);
/**
* @brief Reset RMT TX Channel
*
* @param hal: RMT HAL context
* @param channel: RMT channel number
*/
void rmt_hal_tx_channel_reset(rmt_hal_context_t *hal, uint32_t channel);
/**
* @brief Reset RMT TX Channel
*
* @param hal: RMT HAL context
* @param channel: RMT channel number
*/
void rmt_hal_rx_channel_reset(rmt_hal_context_t *hal, uint32_t channel);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,55 @@
/*
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "soc/soc_caps.h"
#include "soc/periph_defs.h"
#include "soc/regdma.h"
#if SOC_HAS(RMT)
#include "hal/rmt_ll.h"
#endif
#if SOC_RMT_SUPPORT_SLEEP_RETENTION
#include "soc/retention_periph_defs.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if SOC_HAS(RMT)
typedef struct {
const int irq;
struct {
struct {
const int tx_sig;
const int rx_sig;
};
} channels[RMT_LL_GET(CHANS_PER_INST)];
} soc_rmt_signal_desc_t;
extern const soc_rmt_signal_desc_t soc_rmt_signals[RMT_LL_GET(INST_NUM)];
#if SOC_RMT_SUPPORT_SLEEP_RETENTION
typedef struct {
periph_retention_module_t module;
const regdma_entries_config_t *regdma_entry_array;
uint32_t array_size;
} rmt_reg_retention_info_t;
// TODO: implement the retention link on the channel level, this can:
// - save memory when not all RMT channels are used
// - specify different retention dependency, e.g. only RMT channel x is capable to use DMA, we only want to add the DMA dependency for that channel
extern const rmt_reg_retention_info_t rmt_reg_retention_info[RMT_LL_GET(INST_NUM)];
#endif // SOC_RMT_SUPPORT_SLEEP_RETENTION
#endif // SOC_HAS(RMT)
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,42 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include "soc/clk_tree_defs.h"
#include "soc/soc_caps.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief RMT group clock source
* @note User should select the clock source based on the power and resolution requirement
*/
#if SOC_HAS(RMT)
typedef soc_periph_rmt_clk_src_t rmt_clock_source_t;
#else
typedef int rmt_clock_source_t;
#endif
/**
* @brief The layout of RMT symbol stored in memory, which is decided by the hardware design
*/
typedef union {
struct {
uint16_t duration0 : 15; /*!< Duration of level0 */
uint16_t level0 : 1; /*!< Level of the first part */
uint16_t duration1 : 15; /*!< Duration of level1 */
uint16_t level1 : 1; /*!< Level of the second part */
};
uint32_t val; /*!< Equivalent unsigned value for the RMT symbol */
} rmt_symbol_word_t;
#ifdef __cplusplus
}
#endif