mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 12:44:33 +02:00
fix(rmt): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled
This commit is contained in:
@@ -143,7 +143,7 @@ void rmt_release_group_handle(rmt_group_t *group)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if !SOC_RMT_CHANNEL_CLK_INDEPENDENT
|
#if !SOC_RMT_CHANNEL_CLK_INDEPENDENT
|
||||||
static esp_err_t s_rmt_set_group_prescale(rmt_channel_t *chan, uint32_t expect_resolution_hz, uint32_t *ret_channel_prescale)
|
static esp_err_t rmt_set_group_prescale(rmt_channel_t *chan, uint32_t expect_resolution_hz, uint32_t *ret_channel_prescale)
|
||||||
{
|
{
|
||||||
uint32_t periph_src_clk_hz = 0;
|
uint32_t periph_src_clk_hz = 0;
|
||||||
rmt_group_t *group = chan->group;
|
rmt_group_t *group = chan->group;
|
||||||
@@ -256,7 +256,7 @@ esp_err_t rmt_select_periph_clock(rmt_channel_handle_t chan, rmt_clock_source_t
|
|||||||
real_div = (group->resolution_hz + expect_channel_resolution / 2) / expect_channel_resolution;
|
real_div = (group->resolution_hz + expect_channel_resolution / 2) / expect_channel_resolution;
|
||||||
#else
|
#else
|
||||||
// set division for group clock source, to achieve highest resolution while guaranteeing the channel resolution.
|
// set division for group clock source, to achieve highest resolution while guaranteeing the channel resolution.
|
||||||
ESP_RETURN_ON_ERROR(s_rmt_set_group_prescale(chan, expect_channel_resolution, &real_div), TAG, "set rmt group prescale failed");
|
ESP_RETURN_ON_ERROR(rmt_set_group_prescale(chan, expect_channel_resolution, &real_div), TAG, "set rmt group prescale failed");
|
||||||
#endif // SOC_RMT_CHANNEL_CLK_INDEPENDENT
|
#endif // SOC_RMT_CHANNEL_CLK_INDEPENDENT
|
||||||
|
|
||||||
if (chan->direction == RMT_CHANNEL_DIRECTION_TX) {
|
if (chan->direction == RMT_CHANNEL_DIRECTION_TX) {
|
||||||
|
@@ -159,8 +159,8 @@ struct rmt_channel_t {
|
|||||||
rmt_channel_direction_t direction; // channel direction
|
rmt_channel_direction_t direction; // channel direction
|
||||||
rmt_symbol_word_t *hw_mem_base; // base address of RMT channel hardware memory
|
rmt_symbol_word_t *hw_mem_base; // base address of RMT channel hardware memory
|
||||||
gdma_channel_handle_t dma_chan; // DMA channel
|
gdma_channel_handle_t dma_chan; // DMA channel
|
||||||
esp_pm_lock_handle_t pm_lock; // power management lock
|
|
||||||
#if CONFIG_PM_ENABLE
|
#if CONFIG_PM_ENABLE
|
||||||
|
esp_pm_lock_handle_t pm_lock; // power management lock
|
||||||
char pm_lock_name[RMT_PM_LOCK_NAME_LEN_MAX]; // pm lock name
|
char pm_lock_name[RMT_PM_LOCK_NAME_LEN_MAX]; // pm lock name
|
||||||
#endif
|
#endif
|
||||||
// RMT channel common interface
|
// RMT channel common interface
|
||||||
|
@@ -148,9 +148,11 @@ static esp_err_t rmt_rx_destroy(rmt_rx_channel_t *rx_channel)
|
|||||||
if (rx_channel->base.intr) {
|
if (rx_channel->base.intr) {
|
||||||
ESP_RETURN_ON_ERROR(esp_intr_free(rx_channel->base.intr), TAG, "delete interrupt service failed");
|
ESP_RETURN_ON_ERROR(esp_intr_free(rx_channel->base.intr), TAG, "delete interrupt service failed");
|
||||||
}
|
}
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
if (rx_channel->base.pm_lock) {
|
if (rx_channel->base.pm_lock) {
|
||||||
ESP_RETURN_ON_ERROR(esp_pm_lock_delete(rx_channel->base.pm_lock), TAG, "delete pm_lock failed");
|
ESP_RETURN_ON_ERROR(esp_pm_lock_delete(rx_channel->base.pm_lock), TAG, "delete pm_lock failed");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#if SOC_RMT_SUPPORT_DMA
|
#if SOC_RMT_SUPPORT_DMA
|
||||||
if (rx_channel->base.dma_chan) {
|
if (rx_channel->base.dma_chan) {
|
||||||
ESP_RETURN_ON_ERROR(gdma_del_channel(rx_channel->base.dma_chan), TAG, "delete dma channel failed");
|
ESP_RETURN_ON_ERROR(gdma_del_channel(rx_channel->base.dma_chan), TAG, "delete dma channel failed");
|
||||||
@@ -499,10 +501,13 @@ static esp_err_t rmt_rx_enable(rmt_channel_handle_t channel)
|
|||||||
rmt_hal_context_t *hal = &group->hal;
|
rmt_hal_context_t *hal = &group->hal;
|
||||||
int channel_id = channel->channel_id;
|
int channel_id = channel->channel_id;
|
||||||
|
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
// acquire power manager lock
|
// acquire power manager lock
|
||||||
if (channel->pm_lock) {
|
if (channel->pm_lock) {
|
||||||
esp_pm_lock_acquire(channel->pm_lock);
|
esp_pm_lock_acquire(channel->pm_lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (channel->dma_chan) {
|
if (channel->dma_chan) {
|
||||||
#if SOC_RMT_SUPPORT_DMA
|
#if SOC_RMT_SUPPORT_DMA
|
||||||
// enable the DMA access mode
|
// enable the DMA access mode
|
||||||
@@ -560,10 +565,12 @@ static esp_err_t rmt_rx_disable(rmt_channel_handle_t channel)
|
|||||||
portEXIT_CRITICAL(&group->spinlock);
|
portEXIT_CRITICAL(&group->spinlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
// release power manager lock
|
// release power manager lock
|
||||||
if (channel->pm_lock) {
|
if (channel->pm_lock) {
|
||||||
esp_pm_lock_release(channel->pm_lock);
|
esp_pm_lock_release(channel->pm_lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// now we can switch the state to init
|
// now we can switch the state to init
|
||||||
atomic_store(&channel->fsm, RMT_FSM_INIT);
|
atomic_store(&channel->fsm, RMT_FSM_INIT);
|
||||||
|
@@ -203,9 +203,11 @@ static esp_err_t rmt_tx_destroy(rmt_tx_channel_t *tx_channel)
|
|||||||
if (tx_channel->base.intr) {
|
if (tx_channel->base.intr) {
|
||||||
ESP_RETURN_ON_ERROR(esp_intr_free(tx_channel->base.intr), TAG, "delete interrupt service failed");
|
ESP_RETURN_ON_ERROR(esp_intr_free(tx_channel->base.intr), TAG, "delete interrupt service failed");
|
||||||
}
|
}
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
if (tx_channel->base.pm_lock) {
|
if (tx_channel->base.pm_lock) {
|
||||||
ESP_RETURN_ON_ERROR(esp_pm_lock_delete(tx_channel->base.pm_lock), TAG, "delete pm_lock failed");
|
ESP_RETURN_ON_ERROR(esp_pm_lock_delete(tx_channel->base.pm_lock), TAG, "delete pm_lock failed");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#if SOC_RMT_SUPPORT_DMA
|
#if SOC_RMT_SUPPORT_DMA
|
||||||
if (tx_channel->base.dma_chan) {
|
if (tx_channel->base.dma_chan) {
|
||||||
ESP_RETURN_ON_ERROR(gdma_del_channel(tx_channel->base.dma_chan), TAG, "delete dma channel failed");
|
ESP_RETURN_ON_ERROR(gdma_del_channel(tx_channel->base.dma_chan), TAG, "delete dma channel failed");
|
||||||
@@ -766,10 +768,12 @@ static esp_err_t rmt_tx_enable(rmt_channel_handle_t channel)
|
|||||||
ESP_ERR_INVALID_STATE, TAG, "channel not in init state");
|
ESP_ERR_INVALID_STATE, TAG, "channel not in init state");
|
||||||
rmt_tx_channel_t *tx_chan = __containerof(channel, rmt_tx_channel_t, base);
|
rmt_tx_channel_t *tx_chan = __containerof(channel, rmt_tx_channel_t, base);
|
||||||
|
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
// acquire power manager lock
|
// acquire power manager lock
|
||||||
if (channel->pm_lock) {
|
if (channel->pm_lock) {
|
||||||
esp_pm_lock_acquire(channel->pm_lock);
|
esp_pm_lock_acquire(channel->pm_lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if SOC_RMT_SUPPORT_DMA
|
#if SOC_RMT_SUPPORT_DMA
|
||||||
rmt_group_t *group = channel->group;
|
rmt_group_t *group = channel->group;
|
||||||
@@ -860,10 +864,12 @@ static esp_err_t rmt_tx_disable(rmt_channel_handle_t channel)
|
|||||||
}
|
}
|
||||||
tx_chan->cur_trans = NULL;
|
tx_chan->cur_trans = NULL;
|
||||||
|
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
// release power manager lock
|
// release power manager lock
|
||||||
if (channel->pm_lock) {
|
if (channel->pm_lock) {
|
||||||
ESP_RETURN_ON_ERROR(esp_pm_lock_release(channel->pm_lock), TAG, "release pm_lock failed");
|
ESP_RETURN_ON_ERROR(esp_pm_lock_release(channel->pm_lock), TAG, "release pm_lock failed");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// finally we switch to the INIT state
|
// finally we switch to the INIT state
|
||||||
atomic_store(&channel->fsm, RMT_FSM_INIT);
|
atomic_store(&channel->fsm, RMT_FSM_INIT);
|
||||||
|
Reference in New Issue
Block a user