|
|
@@ -4,87 +4,150 @@
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
*/
|
|
|
|
|
|
+/**
|
|
|
+ * @note TX and RX channels are index from 0 in the LL driver, i.e. tx_channel = [0,3], rx_channel = [0,3]
|
|
|
+ */
|
|
|
+
|
|
|
#pragma once
|
|
|
|
|
|
-#include <stddef.h>
|
|
|
+#include <stdint.h>
|
|
|
#include <stdbool.h>
|
|
|
+#include <stddef.h>
|
|
|
#include "hal/misc.h"
|
|
|
+#include "hal/assert.h"
|
|
|
#include "soc/rmt_struct.h"
|
|
|
+#include "hal/rmt_types.h"
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
extern "C" {
|
|
|
#endif
|
|
|
|
|
|
-typedef struct rmt_mem_t {
|
|
|
- struct {
|
|
|
- uint32_t data32[48];
|
|
|
- } chan[8];
|
|
|
-} rmt_mem_t;
|
|
|
-extern rmt_mem_t RMTMEM;
|
|
|
-
|
|
|
-#define RMT_LL_MAX_LOOP_COUNT (1023)/*!< Max loop count that hardware is supported */
|
|
|
-#define RMT_LL_HW_BASE (&RMT)
|
|
|
-#define RMT_LL_MEM_BASE (&RMTMEM)
|
|
|
-
|
|
|
-// Note: TX and RX channel number are all index from zero in the LL driver
|
|
|
-// i.e. tx_channel belongs to [0,3], and rx_channel belongs to [0,3]
|
|
|
-
|
|
|
-static inline void rmt_ll_enable_drive_clock(rmt_dev_t *dev, bool enable)
|
|
|
+#define RMT_LL_EVENT_TX_DONE(channel) (1 << (channel))
|
|
|
+#define RMT_LL_EVENT_TX_THRES(channel) (1 << ((channel) + 8))
|
|
|
+#define RMT_LL_EVENT_TX_LOOP_END(channel) (1 << ((channel) + 12))
|
|
|
+#define RMT_LL_EVENT_TX_ERROR(channel) (1 << ((channel) + 4))
|
|
|
+#define RMT_LL_EVENT_RX_DONE(channel) (1 << ((channel) + 16))
|
|
|
+#define RMT_LL_EVENT_RX_THRES(channel) (1 << ((channel) + 24))
|
|
|
+#define RMT_LL_EVENT_RX_ERROR(channel) (1 << ((channel) + 20))
|
|
|
+#define RMT_LL_EVENT_TX_MASK(channel) (RMT_LL_EVENT_TX_DONE(channel) | RMT_LL_EVENT_TX_THRES(channel) | RMT_LL_EVENT_TX_LOOP_END(channel))
|
|
|
+#define RMT_LL_EVENT_RX_MASK(channel) (RMT_LL_EVENT_RX_DONE(channel) | RMT_LL_EVENT_RX_THRES(channel))
|
|
|
+
|
|
|
+#define RMT_LL_MAX_LOOP_COUNT_PER_BATCH 1023
|
|
|
+
|
|
|
+typedef enum {
|
|
|
+ RMT_LL_MEM_OWNER_SW = 0,
|
|
|
+ RMT_LL_MEM_OWNER_HW = 1,
|
|
|
+} rmt_ll_mem_owner_t;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Enable clock gate for register and memory
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_enable_periph_clock(rmt_dev_t *dev, bool enable)
|
|
|
{
|
|
|
dev->sys_conf.clk_en = enable; // register clock gating
|
|
|
dev->sys_conf.mem_clk_force_on = enable; // memory clock gating
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Power down memory
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param enable True to power down, False to power up
|
|
|
+ */
|
|
|
static inline void rmt_ll_power_down_mem(rmt_dev_t *dev, bool enable)
|
|
|
{
|
|
|
dev->sys_conf.mem_force_pu = !enable;
|
|
|
dev->sys_conf.mem_force_pd = enable;
|
|
|
}
|
|
|
|
|
|
-static inline bool rmt_ll_is_mem_power_down(rmt_dev_t *dev)
|
|
|
-{
|
|
|
- // the RTC domain can also power down RMT memory
|
|
|
- // so it's probably not enough to detect whether it's powered down or not
|
|
|
- // mem_force_pd has higher priority than mem_force_pu
|
|
|
- return (dev->sys_conf.mem_force_pd) || !(dev->sys_conf.mem_force_pu);
|
|
|
-}
|
|
|
-
|
|
|
-static inline void rmt_ll_enable_mem_access(rmt_dev_t *dev, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Enable APB accessing RMT memory in nonfifo mode
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_enable_mem_access_nonfifo(rmt_dev_t *dev, bool enable)
|
|
|
{
|
|
|
dev->sys_conf.apb_fifo_mask = enable;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_set_group_clock_src(rmt_dev_t *dev, uint32_t channel, uint8_t src, uint8_t div_num, uint8_t div_a, uint8_t div_b)
|
|
|
+/**
|
|
|
+ * @brief Set clock source and divider for RMT channel group
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel not used as clock source is set for all channels
|
|
|
+ * @param src Clock source
|
|
|
+ * @param divider_integral Integral part of the divider
|
|
|
+ * @param divider_denominator Denominator part of the divider
|
|
|
+ * @param divider_numerator Numerator part of the divider
|
|
|
+ */
|
|
|
+static inline void rmt_ll_set_group_clock_src(rmt_dev_t *dev, uint32_t channel, rmt_clock_source_t src,
|
|
|
+ uint32_t divider_integral, uint32_t divider_denominator, uint32_t divider_numerator)
|
|
|
{
|
|
|
// Formula: rmt_sclk = module_clock_src / (1 + div_num + div_a / div_b)
|
|
|
+ (void)channel; // the source clock is set for all channels
|
|
|
+ HAL_ASSERT(divider_integral >= 1);
|
|
|
dev->sys_conf.sclk_active = 0;
|
|
|
- dev->sys_conf.sclk_sel = src;
|
|
|
- HAL_FORCE_MODIFY_U32_REG_FIELD(dev->sys_conf, sclk_div_num, div_num);
|
|
|
- dev->sys_conf.sclk_div_a = div_a;
|
|
|
- dev->sys_conf.sclk_div_b = div_b;
|
|
|
+ HAL_FORCE_MODIFY_U32_REG_FIELD(dev->sys_conf, sclk_div_num, divider_integral - 1);
|
|
|
+ dev->sys_conf.sclk_div_a = divider_numerator;
|
|
|
+ dev->sys_conf.sclk_div_b = divider_denominator;
|
|
|
+ switch (src) {
|
|
|
+ case RMT_CLK_SRC_APB:
|
|
|
+ dev->sys_conf.sclk_sel = 1;
|
|
|
+ break;
|
|
|
+ case RMT_CLK_SRC_FAST_RC:
|
|
|
+ dev->sys_conf.sclk_sel = 2;
|
|
|
+ break;
|
|
|
+ case RMT_CLK_SRC_XTAL:
|
|
|
+ dev->sys_conf.sclk_sel = 3;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ HAL_ASSERT(false && "unsupported RMT clock source");
|
|
|
+ break;
|
|
|
+ }
|
|
|
dev->sys_conf.sclk_active = 1;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint32_t channel)
|
|
|
-{
|
|
|
- return dev->sys_conf.sclk_sel;
|
|
|
-}
|
|
|
-
|
|
|
-static inline void rmt_ll_tx_reset_channel_clock_div(rmt_dev_t *dev, uint32_t channel)
|
|
|
-{
|
|
|
- dev->ref_cnt_rst.val |= (1 << channel);
|
|
|
-}
|
|
|
+////////////////////////////////////////TX Channel Specific/////////////////////////////////////////////////////////////
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Reset clock divider for TX channels by mask
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel_mask Mask of TX channels
|
|
|
+ */
|
|
|
static inline void rmt_ll_tx_reset_channels_clock_div(rmt_dev_t *dev, uint32_t channel_mask)
|
|
|
{
|
|
|
- dev->ref_cnt_rst.val |= channel_mask;
|
|
|
+ // write 1 to reset
|
|
|
+ dev->ref_cnt_rst.val |= channel_mask & 0x0F;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_reset_channel_clock_div(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Set TX channel clock divider
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param div Division value
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div)
|
|
|
{
|
|
|
- dev->ref_cnt_rst.val |= (1 << (channel + 4));
|
|
|
+ HAL_ASSERT(div >= 1 && div <= 256 && "divider out of range");
|
|
|
+ // limit the maximum divider to 256
|
|
|
+ if (div >= 256) {
|
|
|
+ div = 0; // 0 means 256 division
|
|
|
+ }
|
|
|
+ HAL_FORCE_MODIFY_U32_REG_FIELD(dev->chnconf0[channel], div_cnt_n, div);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Reset RMT reading pointer for TX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ */
|
|
|
static inline void rmt_ll_tx_reset_pointer(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
dev->chnconf0[channel].mem_rd_rst_n = 1;
|
|
|
@@ -93,411 +156,664 @@ static inline void rmt_ll_tx_reset_pointer(rmt_dev_t *dev, uint32_t channel)
|
|
|
dev->chnconf0[channel].apb_mem_rst_n = 0;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_reset_pointer(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Enable DMA access for TX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_enable_dma(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- dev->chmconf[channel].conf1.mem_wr_rst_m = 1;
|
|
|
- dev->chmconf[channel].conf1.mem_wr_rst_m = 0;
|
|
|
- dev->chmconf[channel].conf1.apb_mem_rst_m = 1;
|
|
|
- dev->chmconf[channel].conf1.apb_mem_rst_m = 0;
|
|
|
+ HAL_ASSERT(channel == 3 && "only TX channel 3 has DMA ability");
|
|
|
+ dev->chnconf0[channel].dma_access_en_n = enable;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Start transmitting for TX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ */
|
|
|
static inline void rmt_ll_tx_start(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
+ // update other configuration registers before start transmitting
|
|
|
dev->chnconf0[channel].conf_update_n = 1;
|
|
|
dev->chnconf0[channel].tx_start_n = 1;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Stop transmitting for TX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ */
|
|
|
static inline void rmt_ll_tx_stop(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
dev->chnconf0[channel].tx_stop_n = 1;
|
|
|
+ // stop won't take place until configurations updated
|
|
|
dev->chnconf0[channel].conf_update_n = 1;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_enable(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
-{
|
|
|
- dev->chmconf[channel].conf1.rx_en_m = enable;
|
|
|
- dev->chmconf[channel].conf1.conf_update_m = 1;
|
|
|
-}
|
|
|
-
|
|
|
+/**
|
|
|
+ * @brief Set memory block number for TX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param block_num memory block number
|
|
|
+ */
|
|
|
static inline void rmt_ll_tx_set_mem_blocks(rmt_dev_t *dev, uint32_t channel, uint8_t block_num)
|
|
|
{
|
|
|
dev->chnconf0[channel].mem_size_n = block_num;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_set_mem_blocks(rmt_dev_t *dev, uint32_t channel, uint8_t block_num)
|
|
|
-{
|
|
|
- dev->chmconf[channel].conf0.mem_size_m = block_num;
|
|
|
-}
|
|
|
-
|
|
|
-static inline uint32_t rmt_ll_tx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel)
|
|
|
-{
|
|
|
- return dev->chnconf0[channel].mem_size_n;
|
|
|
-}
|
|
|
-
|
|
|
-static inline uint32_t rmt_ll_rx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Enable TX wrap
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_enable_wrap(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- return dev->chmconf[channel].conf0.mem_size_m;
|
|
|
+ dev->chnconf0[channel].mem_tx_wrap_en_n = enable;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div)
|
|
|
+/**
|
|
|
+ * @brief Enable transmitting in a loop
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_enable_loop(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- HAL_FORCE_MODIFY_U32_REG_FIELD(dev->chnconf0[channel], div_cnt_n, div);
|
|
|
+ dev->chnconf0[channel].tx_conti_mode_n = enable;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div)
|
|
|
+/**
|
|
|
+ * @brief Set loop count for TX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param count TX loop count
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_set_loop_count(rmt_dev_t *dev, uint32_t channel, uint32_t count)
|
|
|
{
|
|
|
- HAL_FORCE_MODIFY_U32_REG_FIELD(dev->chmconf[channel].conf0, div_cnt_m, div);
|
|
|
+ HAL_ASSERT(count <= RMT_LL_MAX_LOOP_COUNT_PER_BATCH && "loop count out of range");
|
|
|
+ dev->chn_tx_lim[channel].tx_loop_num_chn = count;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_tx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Reset loop count for TX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_reset_loop_count(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- return HAL_FORCE_READ_U32_REG_FIELD(dev->chnconf0[channel], div_cnt_n);
|
|
|
+ dev->chn_tx_lim[channel].loop_count_reset_chn = 1;
|
|
|
+ dev->chn_tx_lim[channel].loop_count_reset_chn = 0;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_rx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Enable loop count for TX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_enable_loop_count(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- return HAL_FORCE_READ_U32_REG_FIELD(dev->chmconf[channel].conf0, div_cnt_m);
|
|
|
+ dev->chn_tx_lim[channel].tx_loop_cnt_en_chn = enable;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_enable_pingpong(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Enable loop stop at count value automatically
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_enable_loop_autostop(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- dev->chnconf0[channel].mem_tx_wrap_en_n = enable;
|
|
|
+ dev->chn_tx_lim[channel].loop_stop_en_chn = enable;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_set_idle_thres(rmt_dev_t *dev, uint32_t channel, uint32_t thres)
|
|
|
+/**
|
|
|
+ * @brief Enable transmit multiple channels synchronously
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_enable_sync(rmt_dev_t *dev, bool enable)
|
|
|
{
|
|
|
- dev->chmconf[channel].conf0.idle_thres_m = thres;
|
|
|
+ dev->tx_sim.tx_sim_en = enable;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_rx_get_idle_thres(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Clear the TX channels synchronous group
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_clear_sync_group(rmt_dev_t *dev)
|
|
|
{
|
|
|
- return dev->chmconf[channel].conf0.idle_thres_m;
|
|
|
+ dev->tx_sim.val &= ~(0x0F);
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_set_mem_owner(rmt_dev_t *dev, uint32_t channel, uint8_t owner)
|
|
|
+/**
|
|
|
+ * @brief Add TX channels to the synchronous group
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel_mask Mask of TX channels to be added to the synchronous group
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_sync_group_add_channels(rmt_dev_t *dev, uint32_t channel_mask)
|
|
|
{
|
|
|
- dev->chmconf[channel].conf1.mem_owner_m = owner;
|
|
|
+ dev->tx_sim.val |= (channel_mask & 0x0F);
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_rx_get_mem_owner(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Remove TX channels from the synchronous group
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel_mask Mask of TX channels to be removed from the synchronous group
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_sync_group_remove_channels(rmt_dev_t *dev, uint32_t channel_mask)
|
|
|
{
|
|
|
- return dev->chmconf[channel].conf1.mem_owner_m;
|
|
|
+ dev->tx_sim.val &= ~channel_mask;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_enable_loop(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Fix the output level when TX channel is in IDLE state
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param level IDLE level (1 => high, 0 => low)
|
|
|
+ * @param enable True to fix the IDLE level, otherwise the IDLE level is determined by EOF encoder
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_fix_idle_level(rmt_dev_t *dev, uint32_t channel, uint8_t level, bool enable)
|
|
|
{
|
|
|
- dev->chnconf0[channel].tx_conti_mode_n = enable;
|
|
|
+ dev->chnconf0[channel].idle_out_en_n = enable;
|
|
|
+ dev->chnconf0[channel].idle_out_lv_n = level;
|
|
|
}
|
|
|
|
|
|
-static inline bool rmt_ll_is_tx_loop_enabled(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Set the amount of RMT symbols that can trigger the limitation interrupt
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param limit Specify the number of symbols
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_set_limit(rmt_dev_t *dev, uint32_t channel, uint32_t limit)
|
|
|
{
|
|
|
- return dev->chnconf0[channel].tx_conti_mode_n;
|
|
|
+ dev->chn_tx_lim[channel].tx_lim_chn = limit;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_enable_loop_autostop(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Set high and low duration of carrier signal
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param high_ticks Duration of high level
|
|
|
+ * @param low_ticks Duration of low level
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_set_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t high_ticks, uint32_t low_ticks)
|
|
|
{
|
|
|
- dev->chn_tx_lim[channel].loop_stop_en_chn = enable;
|
|
|
+ HAL_ASSERT(high_ticks >= 1 && high_ticks <= 65536 && low_ticks >= 1 && low_ticks <= 65536 && "out of range high/low ticks");
|
|
|
+ // ticks=0 means 65536 in hardware
|
|
|
+ if (high_ticks >= 65536) {
|
|
|
+ high_ticks = 0;
|
|
|
+ }
|
|
|
+ if (low_ticks >= 65536) {
|
|
|
+ low_ticks = 0;
|
|
|
+ }
|
|
|
+ HAL_FORCE_MODIFY_U32_REG_FIELD(dev->chncarrier_duty[channel], carrier_high_chn, high_ticks);
|
|
|
+ HAL_FORCE_MODIFY_U32_REG_FIELD(dev->chncarrier_duty[channel], carrier_low_chn, low_ticks);
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_set_loop_count(rmt_dev_t *dev, uint32_t channel, uint32_t count)
|
|
|
+/**
|
|
|
+ * @brief Enable modulating carrier signal to TX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_enable_carrier_modulation(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- dev->chn_tx_lim[channel].tx_loop_num_chn = count;
|
|
|
+ dev->chnconf0[channel].carrier_en_n = enable;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_reset_loop(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Set on high or low to modulate the carrier signal
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param level Which level to modulate on (0=>low level, 1=>high level)
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_set_carrier_level(rmt_dev_t *dev, uint32_t channel, uint8_t level)
|
|
|
{
|
|
|
- dev->chn_tx_lim[channel].loop_count_reset_chn = 1;
|
|
|
- dev->chn_tx_lim[channel].loop_count_reset_chn = 0;
|
|
|
+ dev->chnconf0[channel].carrier_out_lv_n = level;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_enable_loop_count(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Enable to always output carrier signal, regardless of a valid data transmission
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param enable True to output carrier signal in all RMT state, False to only ouput carrier signal for effective data
|
|
|
+ */
|
|
|
+static inline void rmt_ll_tx_enable_carrier_always_on(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- dev->chn_tx_lim[channel].tx_loop_cnt_en_chn = enable;
|
|
|
+ dev->chnconf0[channel].carrier_eff_en_n = !enable;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_enable_sync(rmt_dev_t *dev, bool enable)
|
|
|
-{
|
|
|
- dev->tx_sim.tx_sim_en = enable;
|
|
|
-}
|
|
|
+////////////////////////////////////////RX Channel Specific/////////////////////////////////////////////////////////////
|
|
|
|
|
|
-static inline void rmt_ll_tx_add_to_sync_group(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Reset clock divider for RX channels by mask
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel_mask Mask of RX channels
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_reset_channels_clock_div(rmt_dev_t *dev, uint32_t channel_mask)
|
|
|
{
|
|
|
- dev->tx_sim.val |= 1 << channel;
|
|
|
+ dev->ref_cnt_rst.val |= ((channel_mask & 0x0F) << 4);
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_remove_from_sync_group(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Set RX channel clock divider
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @param div Division value
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div)
|
|
|
{
|
|
|
- dev->tx_sim.val &= ~(1 << channel);
|
|
|
+ HAL_ASSERT(div >= 1 && div <= 256 && "divider out of range");
|
|
|
+ // limit the maximum divider to 256
|
|
|
+ if (div >= 256) {
|
|
|
+ div = 0; // 0 means 256 division
|
|
|
+ }
|
|
|
+ HAL_FORCE_MODIFY_U32_REG_FIELD(dev->chmconf[channel].conf0, div_cnt_m, div);
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_enable_filter(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Reset RMT writing pointer for RX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_reset_pointer(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- dev->chmconf[channel].conf1.rx_filter_en_m = enable;
|
|
|
+ dev->chmconf[channel].conf1.mem_wr_rst_m = 1;
|
|
|
+ dev->chmconf[channel].conf1.mem_wr_rst_m = 0;
|
|
|
+ dev->chmconf[channel].conf1.apb_mem_rst_m = 1;
|
|
|
+ dev->chmconf[channel].conf1.apb_mem_rst_m = 0;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_set_filter_thres(rmt_dev_t *dev, uint32_t channel, uint32_t thres)
|
|
|
+/**
|
|
|
+ * @brief Enable DMA access for RX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_enable_dma(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- HAL_FORCE_MODIFY_U32_REG_FIELD(dev->chmconf[channel].conf1, rx_filter_thres_m, thres);
|
|
|
+ HAL_ASSERT(channel == 3 && "only RX channel 3 has DMA ability");
|
|
|
+ dev->chmconf[channel].conf0.dma_access_en_m = enable;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_enable_idle(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Enable receiving for RX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_enable(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- dev->chnconf0[channel].idle_out_en_n = enable;
|
|
|
+ dev->chmconf[channel].conf1.rx_en_m = enable;
|
|
|
+ // rx won't be enabled until configurations updated
|
|
|
+ dev->chmconf[channel].conf1.conf_update_m = 1;
|
|
|
}
|
|
|
|
|
|
-static inline bool rmt_ll_is_tx_idle_enabled(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Set memory block number for RX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @param block_num memory block number
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_set_mem_blocks(rmt_dev_t *dev, uint32_t channel, uint8_t block_num)
|
|
|
{
|
|
|
- return dev->chnconf0[channel].idle_out_en_n;
|
|
|
+ dev->chmconf[channel].conf0.mem_size_m = block_num;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_set_idle_level(rmt_dev_t *dev, uint32_t channel, uint8_t level)
|
|
|
+/**
|
|
|
+ * @brief Set the time length for RX channel before going into IDLE state
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @param thres Time length threshold
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_set_idle_thres(rmt_dev_t *dev, uint32_t channel, uint32_t thres)
|
|
|
{
|
|
|
- dev->chnconf0[channel].idle_out_lv_n = level;
|
|
|
+ dev->chmconf[channel].conf0.idle_thres_m = thres;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_tx_get_idle_level(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Set RMT memory owner for RX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @param owner Memory owner
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_set_mem_owner(rmt_dev_t *dev, uint32_t channel, rmt_ll_mem_owner_t owner)
|
|
|
{
|
|
|
- return dev->chnconf0[channel].idle_out_lv_n;
|
|
|
+ dev->chmconf[channel].conf1.mem_owner_m = owner;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_rx_get_channel_status(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Enable filter for RX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX chanenl number
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_enable_filter(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- return dev->chmstatus[channel].val;
|
|
|
+ dev->chmconf[channel].conf1.rx_filter_en_m = enable;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_tx_get_channel_status(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Set RX channel filter threshold (i.e. the maximum width of one pulse signal that would be treated as a noise)
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @param thres Filter threshold
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_set_filter_thres(rmt_dev_t *dev, uint32_t channel, uint32_t thres)
|
|
|
{
|
|
|
- return dev->chnstatus[channel].val;
|
|
|
+ HAL_FORCE_MODIFY_U32_REG_FIELD(dev->chmconf[channel].conf1, rx_filter_thres_m, thres);
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_set_limit(rmt_dev_t *dev, uint32_t channel, uint32_t limit)
|
|
|
+/**
|
|
|
+ * @brief Get RMT memory write cursor offset
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @return writer offset
|
|
|
+ */
|
|
|
+static inline uint32_t rmt_ll_rx_get_memory_writer_offset(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- dev->chn_tx_lim[channel].tx_lim_chn = limit;
|
|
|
+ return dev->chmstatus[channel].mem_waddr_ex_m - (channel + 4) * 48;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Set the amount of RMT symbols that can trigger the limitation interrupt
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @param limit Specify the number of symbols
|
|
|
+ */
|
|
|
static inline void rmt_ll_rx_set_limit(rmt_dev_t *dev, uint32_t channel, uint32_t limit)
|
|
|
{
|
|
|
dev->chm_rx_lim[channel].chm_rx_lim_reg = limit;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_rx_get_limit(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Set high and low duration of carrier signal
|
|
|
+ *
|
|
|
+ * @param dev dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @param high_ticks Duration of high level
|
|
|
+ * @param low_ticks Duration of low level
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_set_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t high_ticks, uint32_t low_ticks)
|
|
|
{
|
|
|
- return dev->chm_rx_lim[channel].chm_rx_lim_reg;
|
|
|
+ HAL_ASSERT(high_ticks >= 1 && high_ticks <= 65536 && low_ticks >= 1 && low_ticks <= 65536 && "out of range high/low ticks");
|
|
|
+ HAL_FORCE_MODIFY_U32_REG_FIELD(dev->chm_rx_carrier_rm[channel], carrier_high_thres_chm, high_ticks - 1);
|
|
|
+ HAL_FORCE_MODIFY_U32_REG_FIELD(dev->chm_rx_carrier_rm[channel], carrier_low_thres_chm, low_ticks - 1);
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_enable_interrupt(rmt_dev_t *dev, uint32_t mask, bool enable)
|
|
|
-{
|
|
|
- if (enable) {
|
|
|
- dev->int_ena.val |= mask;
|
|
|
- } else {
|
|
|
- dev->int_ena.val &= ~mask;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static inline void rmt_ll_enable_tx_end_interrupt(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Enable demodulating the carrier on RX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_enable_carrier_demodulation(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- if (enable) {
|
|
|
- dev->int_ena.val |= (1 << channel);
|
|
|
- } else {
|
|
|
- dev->int_ena.val &= ~(1 << channel);
|
|
|
- }
|
|
|
+ dev->chmconf[channel].conf0.carrier_en_m = enable;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_enable_tx_err_interrupt(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Set on high or low to demodulate the carrier signal
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @param level Which level to demodulate (0=>low level, 1=>high level)
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_set_carrier_level(rmt_dev_t *dev, uint32_t channel, uint8_t level)
|
|
|
{
|
|
|
- if (enable) {
|
|
|
- dev->int_ena.val |= (1 << (channel + 4));
|
|
|
- } else {
|
|
|
- dev->int_ena.val &= ~(1 << (channel + 4));
|
|
|
- }
|
|
|
+ dev->chmconf[channel].conf0.carrier_out_lv_m = level;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_enable_rx_end_interrupt(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Enable RX wrap
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_rx_enable_wrap(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
{
|
|
|
- if (enable) {
|
|
|
- dev->int_ena.val |= (1 << (channel + 16));
|
|
|
- } else {
|
|
|
- dev->int_ena.val &= ~(1 << (channel + 16));
|
|
|
- }
|
|
|
+ dev->chmconf[channel].conf1.mem_rx_wrap_en_m = enable;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_enable_rx_err_interrupt(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
-{
|
|
|
- if (enable) {
|
|
|
- dev->int_ena.val |= (1 << (channel + 20));
|
|
|
- } else {
|
|
|
- dev->int_ena.val &= ~(1 << (channel + 20));
|
|
|
- }
|
|
|
-}
|
|
|
+//////////////////////////////////////////Interrupt Specific////////////////////////////////////////////////////////////
|
|
|
|
|
|
-static inline void rmt_ll_enable_tx_thres_interrupt(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Enable RMT interrupt for specific event mask
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param mask Event mask
|
|
|
+ * @param enable True to enable, False to disable
|
|
|
+ */
|
|
|
+static inline void rmt_ll_enable_interrupt(rmt_dev_t *dev, uint32_t mask, bool enable)
|
|
|
{
|
|
|
if (enable) {
|
|
|
- dev->int_ena.val |= (1 << (channel + 8));
|
|
|
+ dev->int_ena.val |= mask;
|
|
|
} else {
|
|
|
- dev->int_ena.val &= ~(1 << (channel + 8));
|
|
|
+ dev->int_ena.val &= ~mask;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_enable_tx_loop_interrupt(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Clear RMT interrupt status by mask
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param mask Interupt status mask
|
|
|
+ */
|
|
|
+static inline void rmt_ll_clear_interrupt_status(rmt_dev_t *dev, uint32_t mask)
|
|
|
{
|
|
|
- if (enable) {
|
|
|
- dev->int_ena.val |= (1 << (channel + 12));
|
|
|
- } else {
|
|
|
- dev->int_ena.val &= ~(1 << (channel + 12));
|
|
|
- }
|
|
|
+ dev->int_clr.val = mask;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_enable_rx_thres_interrupt(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+/**
|
|
|
+ * @brief Get interrupt status register address
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @return Register address
|
|
|
+ */
|
|
|
+static inline volatile void *rmt_ll_get_interrupt_status_reg(rmt_dev_t *dev)
|
|
|
{
|
|
|
- if (enable) {
|
|
|
- dev->int_ena.val |= (1 << (channel + 24));
|
|
|
- } else {
|
|
|
- dev->int_ena.val &= ~(1 << (channel + 24));
|
|
|
- }
|
|
|
+ return &dev->int_st;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_clear_tx_end_interrupt(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Get interrupt status for TX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @return Interrupt status
|
|
|
+ */
|
|
|
+static inline uint32_t rmt_ll_tx_get_interrupt_status(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- dev->int_clr.val = (1 << (channel));
|
|
|
+ return dev->int_st.val & RMT_LL_EVENT_TX_MASK(channel);
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_clear_rx_end_interrupt(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Get interrupt raw status for TX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT TX channel number
|
|
|
+ * @return Interrupt raw status
|
|
|
+ */
|
|
|
+static inline uint32_t rmt_ll_tx_get_interrupt_status_raw(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- dev->int_clr.val = (1 << (channel + 16));
|
|
|
+ return dev->int_raw.val & RMT_LL_EVENT_TX_MASK(channel);
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_clear_tx_err_interrupt(rmt_dev_t *dev, uint32_t channel)
|
|
|
+/**
|
|
|
+ * @brief Get interrupt status for RX channel
|
|
|
+ *
|
|
|
+ * @param dev Peripheral instance address
|
|
|
+ * @param channel RMT RX channel number
|
|
|
+ * @return Interrupt status
|
|
|
+ */
|
|
|
+static inline uint32_t rmt_ll_rx_get_interrupt_status(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- dev->int_clr.val = (1 << (channel + 4));
|
|
|
+ return dev->int_st.val & RMT_LL_EVENT_RX_MASK(channel);
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_clear_rx_err_interrupt(rmt_dev_t *dev, uint32_t channel)
|
|
|
-{
|
|
|
- dev->int_clr.val = (1 << (channel + 20));
|
|
|
-}
|
|
|
+//////////////////////////////////////////Deprecated Functions//////////////////////////////////////////////////////////
|
|
|
+/////////////////////////////The following functions are only used by the legacy driver/////////////////////////////////
|
|
|
+/////////////////////////////They might be removed in the next major release (ESP-IDF 6.0)//////////////////////////////
|
|
|
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
-static inline void rmt_ll_clear_tx_thres_interrupt(rmt_dev_t *dev, uint32_t channel)
|
|
|
+static inline uint32_t rmt_ll_tx_get_status_word(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- dev->int_clr.val = (1 << (channel + 8));
|
|
|
+ return dev->chnstatus[channel].val;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_clear_tx_loop_interrupt(rmt_dev_t *dev, uint32_t channel)
|
|
|
+static inline uint32_t rmt_ll_rx_get_status_word(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- dev->int_clr.val = (1 << (channel + 12));
|
|
|
+ return dev->chmstatus[channel].val;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_clear_rx_thres_interrupt(rmt_dev_t *dev, uint32_t channel)
|
|
|
+static inline uint32_t rmt_ll_tx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- dev->int_clr.val = (1 << (channel + 24));
|
|
|
+ uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->chnconf0[channel], div_cnt_n);
|
|
|
+ return div == 0 ? 256 : div;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_get_tx_end_interrupt_status(rmt_dev_t *dev)
|
|
|
+static inline uint32_t rmt_ll_rx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- return dev->int_st.val & 0x0F;
|
|
|
+ uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->chmconf[channel].conf0, div_cnt_m);
|
|
|
+ return div == 0 ? 256 : div;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_get_rx_end_interrupt_status(rmt_dev_t *dev)
|
|
|
+static inline uint32_t rmt_ll_rx_get_idle_thres(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- return (dev->int_st.val >> 16) & 0x0F;
|
|
|
+ return dev->chmconf[channel].conf0.idle_thres_m;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_get_tx_err_interrupt_status(rmt_dev_t *dev)
|
|
|
+static inline uint32_t rmt_ll_tx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- return (dev->int_st.val >> 4) & 0x0F;
|
|
|
+ return dev->chnconf0[channel].mem_size_n;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_get_rx_err_interrupt_status(rmt_dev_t *dev)
|
|
|
+static inline uint32_t rmt_ll_rx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- return (dev->int_st.val >> 20) & 0x0F;
|
|
|
+ return dev->chmconf[channel].conf0.mem_size_m;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_get_tx_thres_interrupt_status(rmt_dev_t *dev)
|
|
|
+static inline bool rmt_ll_tx_is_loop_enabled(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- return (dev->int_st.val >> 8) & 0x0F;
|
|
|
+ return dev->chnconf0[channel].tx_conti_mode_n;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_get_rx_thres_interrupt_status(rmt_dev_t *dev)
|
|
|
+static inline rmt_clock_source_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- return (dev->int_st.val >> 24) & 0x0F;
|
|
|
+ rmt_clock_source_t clk_src = RMT_CLK_SRC_APB;
|
|
|
+ switch (dev->sys_conf.sclk_sel) {
|
|
|
+ case 1:
|
|
|
+ clk_src = RMT_CLK_SRC_APB;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ clk_src = RMT_CLK_SRC_FAST_RC;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ clk_src = RMT_CLK_SRC_XTAL;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return clk_src;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t rmt_ll_get_tx_loop_interrupt_status(rmt_dev_t *dev)
|
|
|
+static inline bool rmt_ll_tx_is_idle_enabled(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- return (dev->int_st.val >> 12) & 0x0F;
|
|
|
+ return dev->chnconf0[channel].idle_out_en_n;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_set_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t high_ticks, uint32_t low_ticks)
|
|
|
+static inline uint32_t rmt_ll_tx_get_idle_level(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- // In case the compiler optimise a 32bit instruction (e.g. s32i) into two 16bit instruction (e.g. s16i, which is not allowed to access a register)
|
|
|
- // We take care of the "read-modify-write" procedure by ourselves.
|
|
|
- rmt_chncarrier_duty_reg_t reg;
|
|
|
- reg.carrier_high_chn = high_ticks;
|
|
|
- reg.carrier_low_chn = low_ticks;
|
|
|
- dev->chncarrier_duty[channel].val = reg.val;
|
|
|
+ return dev->chnconf0[channel].idle_out_lv_n;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_set_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t high_ticks, uint32_t low_ticks)
|
|
|
+static inline bool rmt_ll_is_mem_powered_down(rmt_dev_t *dev)
|
|
|
{
|
|
|
- rmt_chm_rx_carrier_rm_reg_t reg;
|
|
|
- reg.carrier_high_thres_chm = high_ticks;
|
|
|
- reg.carrier_low_thres_chm = low_ticks;
|
|
|
- dev->chm_rx_carrier_rm[channel].val = reg.val;
|
|
|
+ // the RTC domain can also power down RMT memory
|
|
|
+ // so it's probably not enough to detect whether it's powered down or not
|
|
|
+ // mem_force_pd has higher priority than mem_force_pu
|
|
|
+ return (dev->sys_conf.mem_force_pd) || !(dev->sys_conf.mem_force_pu);
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_get_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t *high_ticks, uint32_t *low_ticks )
|
|
|
+static inline uint32_t rmt_ll_rx_get_mem_owner(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- *high_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->chncarrier_duty[channel], carrier_high_chn);
|
|
|
- *low_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->chncarrier_duty[channel], carrier_low_chn);
|
|
|
+ return dev->chmconf[channel].conf1.mem_owner_m;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_get_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t *high_ticks, uint32_t *low_ticks)
|
|
|
+static inline uint32_t rmt_ll_rx_get_limit(rmt_dev_t *dev, uint32_t channel)
|
|
|
{
|
|
|
- *high_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->chm_rx_carrier_rm[channel], carrier_high_thres_chm);
|
|
|
- *low_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->chm_rx_carrier_rm[channel], carrier_low_thres_chm);
|
|
|
+ return dev->chm_rx_lim[channel].chm_rx_lim_reg;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_enable_carrier_modulation(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+static inline uint32_t rmt_ll_get_tx_end_interrupt_status(rmt_dev_t *dev)
|
|
|
{
|
|
|
- dev->chnconf0[channel].carrier_en_n = enable;
|
|
|
+ return dev->int_st.val & 0x0F;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_enable_carrier_demodulation(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+static inline uint32_t rmt_ll_get_rx_end_interrupt_status(rmt_dev_t *dev)
|
|
|
{
|
|
|
- dev->chmconf[channel].conf0.carrier_en_m = enable;
|
|
|
+ return (dev->int_st.val >> 16) & 0x0F;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_tx_set_carrier_level(rmt_dev_t *dev, uint32_t channel, uint8_t level)
|
|
|
+static inline uint32_t rmt_ll_get_tx_err_interrupt_status(rmt_dev_t *dev)
|
|
|
{
|
|
|
- dev->chnconf0[channel].carrier_out_lv_n = level;
|
|
|
+ return (dev->int_st.val >> 4) & 0x0F;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_set_carrier_level(rmt_dev_t *dev, uint32_t channel, uint8_t level)
|
|
|
+static inline uint32_t rmt_ll_get_rx_err_interrupt_status(rmt_dev_t *dev)
|
|
|
{
|
|
|
- dev->chmconf[channel].conf0.carrier_out_lv_m = level;
|
|
|
+ return (dev->int_st.val >> 20) & 0x0F;
|
|
|
}
|
|
|
|
|
|
-// set true, enable carrier in all RMT state (idle, reading, sending)
|
|
|
-// set false, enable carrier only in sending state (i.e. there're effective data in RAM to be sent)
|
|
|
-static inline void rmt_ll_tx_set_carrier_always_on(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+static inline uint32_t rmt_ll_get_tx_thres_interrupt_status(rmt_dev_t *dev)
|
|
|
{
|
|
|
- dev->chnconf0[channel].carrier_eff_en_n = !enable;
|
|
|
+ return (dev->int_st.val >> 8) & 0x0F;
|
|
|
}
|
|
|
|
|
|
-//Writes items to the specified TX channel memory with the given offset and length.
|
|
|
-//the caller should ensure that (length + off) <= (memory block * SOC_RMT_MEM_WORDS_PER_CHANNEL)
|
|
|
-static inline void rmt_ll_write_memory(rmt_mem_t *mem, uint32_t channel, const void *data, size_t length_in_words, size_t off)
|
|
|
+static inline uint32_t rmt_ll_get_rx_thres_interrupt_status(rmt_dev_t *dev)
|
|
|
{
|
|
|
- volatile uint32_t *to = (volatile uint32_t *)&mem->chan[channel].data32[off];
|
|
|
- uint32_t *from = (uint32_t *)data;
|
|
|
- while (length_in_words--) {
|
|
|
- *to++ = *from++;
|
|
|
- }
|
|
|
+ return (dev->int_st.val >> 24) & 0x0F;
|
|
|
}
|
|
|
|
|
|
-static inline void rmt_ll_rx_enable_pingpong(rmt_dev_t *dev, uint32_t channel, bool enable)
|
|
|
+static inline uint32_t rmt_ll_get_tx_loop_interrupt_status(rmt_dev_t *dev)
|
|
|
{
|
|
|
- dev->chmconf[channel].conf1.mem_rx_wrap_en_m = enable;
|
|
|
+ return (dev->int_st.val >> 12) & 0x0F;
|
|
|
}
|
|
|
|
|
|
#ifdef __cplusplus
|