Skip to content

Commit 3bc10aa

Browse files
committed
feat(rmt): add API to return the real clock resolution of a channel
Closes #15074
1 parent c042aad commit 3bc10aa

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

components/esp_driver_rmt/include/esp_private/rmt.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -28,6 +28,18 @@ extern "C" {
2828
*/
2929
esp_err_t rmt_get_channel_id(rmt_channel_handle_t channel, int *ret_id);
3030

31+
/**
32+
* @brief Get the RMT channel's real clock resolution
33+
*
34+
* @param[in] channel RMT generic channel that created by `rmt_new_tx_channel()` or `rmt_new_rx_channel()`
35+
* @param[out] ret_resolution_hz The real clock resolution in Hz
36+
* @return
37+
* - ESP_OK: Get RMT channel resolution successfully
38+
* - ESP_ERR_INVALID_ARG: Get RMT channel resolution failed because of invalid argument
39+
* - ESP_FAIL: Get RMT channel resolution failed because of other reasons
40+
*/
41+
esp_err_t rmt_get_channel_resolution(rmt_channel_handle_t channel, uint32_t *ret_resolution_hz);
42+
3143
#ifdef __cplusplus
3244
}
3345
#endif

components/esp_driver_rmt/src/rmt_common.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ esp_err_t rmt_get_channel_id(rmt_channel_handle_t channel, int *ret_id)
194194
return ESP_OK;
195195
}
196196

197+
esp_err_t rmt_get_channel_resolution(rmt_channel_handle_t channel, uint32_t *ret_resolution_hz)
198+
{
199+
ESP_RETURN_ON_FALSE(channel && ret_resolution_hz, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
200+
*ret_resolution_hz = channel->resolution_hz;
201+
return ESP_OK;
202+
}
203+
197204
esp_err_t rmt_apply_carrier(rmt_channel_handle_t channel, const rmt_carrier_config_t *config)
198205
{
199206
// specially, we allow config to be NULL, means to disable the carrier submodule

0 commit comments

Comments
 (0)