2022-01-05 03:11:19 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2019-11-19 03:10:02 -05:00
|
|
|
#include "hal/rmt_hal.h"
|
|
|
|
#include "hal/rmt_ll.h"
|
2021-01-06 21:13:17 -05:00
|
|
|
#include "soc/soc_caps.h"
|
2019-11-19 03:10:02 -05:00
|
|
|
|
|
|
|
void rmt_hal_init(rmt_hal_context_t *hal)
|
|
|
|
{
|
|
|
|
hal->regs = &RMT;
|
2024-06-20 11:46:21 -04:00
|
|
|
rmt_ll_mem_power_by_pmu(hal->regs);
|
2022-04-06 23:59:46 -04:00
|
|
|
rmt_ll_enable_mem_access_nonfifo(hal->regs, true); // APB access the RMTMEM in nonfifo mode
|
2024-06-20 11:46:21 -04:00
|
|
|
rmt_ll_enable_interrupt(hal->regs, UINT32_MAX, false); // disable all interrupt events
|
2022-04-06 23:59:46 -04:00
|
|
|
rmt_ll_clear_interrupt_status(hal->regs, UINT32_MAX); // clear all pending events
|
|
|
|
#if SOC_RMT_SUPPORT_TX_SYNCHRO
|
|
|
|
rmt_ll_tx_clear_sync_group(hal->regs);
|
|
|
|
#endif // SOC_RMT_SUPPORT_TX_SYNCHRO
|
|
|
|
}
|
|
|
|
|
|
|
|
void rmt_hal_deinit(rmt_hal_context_t *hal)
|
|
|
|
{
|
2024-06-20 11:46:21 -04:00
|
|
|
rmt_ll_enable_interrupt(hal->regs, UINT32_MAX, false); // disable all interrupt events
|
2022-04-06 23:59:46 -04:00
|
|
|
rmt_ll_clear_interrupt_status(hal->regs, UINT32_MAX); // clear all pending events
|
2024-06-20 11:46:21 -04:00
|
|
|
rmt_ll_mem_force_power_off(hal->regs); // power off RMTMEM power domain forcefully
|
2022-04-06 23:59:46 -04:00
|
|
|
hal->regs = NULL;
|
2019-11-19 03:10:02 -05:00
|
|
|
}
|
|
|
|
|
2020-10-09 04:41:41 -04:00
|
|
|
void rmt_hal_tx_channel_reset(rmt_hal_context_t *hal, uint32_t channel)
|
2019-11-19 03:10:02 -05:00
|
|
|
{
|
2022-03-01 02:06:29 -05:00
|
|
|
rmt_ll_tx_reset_channels_clock_div(hal->regs, 1 << channel);
|
2020-10-09 04:41:41 -04:00
|
|
|
rmt_ll_tx_reset_pointer(hal->regs, channel);
|
2022-03-01 02:06:29 -05:00
|
|
|
#if SOC_RMT_SUPPORT_TX_LOOP_COUNT
|
|
|
|
rmt_ll_tx_reset_loop_count(hal->regs, channel);
|
|
|
|
#endif // SOC_RMT_SUPPORT_TX_LOOP_COUNT
|
|
|
|
rmt_ll_enable_interrupt(hal->regs, RMT_LL_EVENT_TX_MASK(channel), false);
|
|
|
|
rmt_ll_clear_interrupt_status(hal->regs, RMT_LL_EVENT_TX_MASK(channel));
|
2019-11-19 03:10:02 -05:00
|
|
|
}
|
|
|
|
|
2020-10-09 04:41:41 -04:00
|
|
|
void rmt_hal_rx_channel_reset(rmt_hal_context_t *hal, uint32_t channel)
|
2019-11-19 03:10:02 -05:00
|
|
|
{
|
2022-03-01 02:06:29 -05:00
|
|
|
rmt_ll_rx_reset_channels_clock_div(hal->regs, 1 << channel);
|
2020-10-09 04:41:41 -04:00
|
|
|
rmt_ll_rx_reset_pointer(hal->regs, channel);
|
2022-03-01 02:06:29 -05:00
|
|
|
rmt_ll_enable_interrupt(hal->regs, RMT_LL_EVENT_RX_MASK(channel), false);
|
|
|
|
rmt_ll_clear_interrupt_status(hal->regs, RMT_LL_EVENT_RX_MASK(channel));
|
2019-11-19 03:10:02 -05:00
|
|
|
}
|