rmt: prefix caps name with SOC_

This commit is contained in:
morris 2020-03-25 17:13:10 +08:00
parent 9f035edb64
commit 4fc16e2374
10 changed files with 51 additions and 51 deletions

View file

@ -34,7 +34,7 @@ extern "C" {
* @brief Define memory space of each RMT channel (in words = 4 bytes)
*
*/
#define RMT_MEM_ITEM_NUM RMT_CHANNEL_MEM_WORDS
#define RMT_MEM_ITEM_NUM SOC_RMT_CHANNEL_MEM_WORDS
/**
* @brief Data struct of RMT TX configure parameters
@ -44,7 +44,7 @@ typedef struct {
rmt_carrier_level_t carrier_level; /*!< Level of the RMT output, when the carrier is applied */
rmt_idle_level_t idle_level; /*!< RMT idle level */
uint8_t carrier_duty_percent; /*!< RMT carrier duty (%) */
#if RMT_SUPPORT_TX_LOOP_COUNT
#if SOC_RMT_SUPPORT_TX_LOOP_COUNT
uint32_t loop_count; /*!< Maximum loop count */
#endif
bool carrier_en; /*!< RMT carrier enable */
@ -59,7 +59,7 @@ typedef struct {
uint16_t idle_threshold; /*!< RMT RX idle threshold */
uint8_t filter_ticks_thresh; /*!< RMT filter tick number */
bool filter_en; /*!< RMT receiver filter enable */
#if RMT_SUPPORT_RX_DEMODULATION
#if SOC_RMT_SUPPORT_RX_DEMODULATION
bool rm_carrier; /*!< RMT receiver remove carrier enable */
uint32_t carrier_freq_hz; /*!< RMT carrier frequency */
uint8_t carrier_duty_percent; /*!< RMT carrier duty (%) */
@ -792,7 +792,7 @@ esp_err_t rmt_write_sample(rmt_channel_t channel, const uint8_t *src, size_t src
*/
rmt_tx_end_callback_t rmt_register_tx_end_callback(rmt_tx_end_fn_t function, void *arg);
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
/**
* @brief Set RMT RX threshold event interrupt enable
*
@ -809,7 +809,7 @@ rmt_tx_end_callback_t rmt_register_tx_end_callback(rmt_tx_end_fn_t function, voi
esp_err_t rmt_set_rx_thr_intr_en(rmt_channel_t channel, bool en, uint16_t evt_thresh);
#endif
#if RMT_SUPPORT_TX_GROUP
#if SOC_RMT_SUPPORT_TX_GROUP
/**
* @brief Add channel into a group (channels in the same group will transmit simultaneously)
*

View file

@ -79,7 +79,7 @@ typedef struct {
#endif
rmt_item32_t *tx_buf;
RingbufHandle_t rx_buf;
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
rmt_item32_t *rx_item_buf;
uint32_t rx_item_buf_size;
uint32_t rx_item_len;
@ -197,7 +197,7 @@ esp_err_t rmt_tx_start(rmt_channel_t channel, bool tx_idx_rst)
if (!rmt_ll_is_tx_loop_enabled(p_rmt_obj[channel]->hal.regs, channel)) {
rmt_ll_enable_tx_end_interrupt(p_rmt_obj[channel]->hal.regs, channel, true);
} else {
#if RMT_SUPPORT_TX_LOOP_COUNT
#if SOC_RMT_SUPPORT_TX_LOOP_COUNT
rmt_ll_reset_tx_loop(p_rmt_obj[channel]->hal.regs, channel);
rmt_ll_enable_tx_loop_count(p_rmt_obj[channel]->hal.regs, channel, true);
rmt_ll_clear_tx_loop_interrupt(p_rmt_obj[channel]->hal.regs, channel);
@ -230,7 +230,7 @@ esp_err_t rmt_rx_start(rmt_channel_t channel, bool rx_idx_rst)
rmt_ll_clear_rx_end_interrupt(p_rmt_obj[channel]->hal.regs, channel);
rmt_ll_enable_rx_end_interrupt(p_rmt_obj[channel]->hal.regs, channel, true);
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
const uint32_t item_block_len = rmt_ll_get_mem_blocks(p_rmt_obj[channel]->hal.regs, channel) * RMT_MEM_ITEM_NUM;
p_rmt_obj[channel]->rx_item_start_idx = 0;
p_rmt_obj[channel]->rx_item_len = 0;
@ -249,7 +249,7 @@ esp_err_t rmt_rx_stop(rmt_channel_t channel)
rmt_ll_enable_rx_end_interrupt(p_rmt_obj[channel]->hal.regs, channel, false);
rmt_ll_enable_rx(p_rmt_obj[channel]->hal.regs, channel, false);
rmt_ll_reset_rx_pointer(p_rmt_obj[channel]->hal.regs, channel);
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
rmt_ll_enable_rx_thres_interrupt(p_rmt_obj[channel]->hal.regs, channel, false);
#endif
RMT_EXIT_CRITICAL();
@ -386,7 +386,7 @@ esp_err_t rmt_set_rx_intr_en(rmt_channel_t channel, bool en)
return ESP_OK;
}
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
esp_err_t rmt_set_rx_thr_intr_en(rmt_channel_t channel, bool en, uint16_t evt_thresh)
{
RMT_CHECK(channel < RMT_CHANNEL_MAX, RMT_CHANNEL_ERROR_STR, ESP_ERR_INVALID_ARG);
@ -507,7 +507,7 @@ static esp_err_t rmt_internal_config(rmt_dev_t *dev, const rmt_config_t *rmt_par
RMT_ENTER_CRITICAL();
rmt_ll_enable_tx_loop(dev, channel, rmt_param->tx_config.loop_en);
#if RMT_SUPPORT_TX_LOOP_COUNT
#if SOC_RMT_SUPPORT_TX_LOOP_COUNT
if (rmt_param->tx_config.loop_en) {
rmt_ll_set_tx_loop_count(dev, channel, rmt_param->tx_config.loop_count);
}
@ -545,12 +545,12 @@ static esp_err_t rmt_internal_config(rmt_dev_t *dev, const rmt_config_t *rmt_par
rmt_ll_set_rx_filter_thres(dev, channel, filter_cnt);
rmt_ll_enable_rx_filter(dev, channel, rmt_param->rx_config.filter_en);
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
/* always enable rx ping-pong */
rmt_ll_enable_rx_pingpong(dev, channel, true);
#endif
#if RMT_SUPPORT_RX_DEMODULATION
#if SOC_RMT_SUPPORT_RX_DEMODULATION
rmt_ll_enable_carrier(dev, channel, rmt_param->rx_config.rm_carrier);
if (rmt_param->rx_config.rm_carrier) {
uint32_t duty_total = rmt_source_clk_hz / rmt_ll_get_counter_clock_div(dev, channel) / rmt_param->rx_config.carrier_freq_hz;
@ -730,7 +730,7 @@ static void IRAM_ATTR rmt_driver_isr_default(void *arg)
rmt_ll_set_mem_owner(p_rmt_obj[channel]->hal.regs, channel, RMT_MEM_OWNER_SW);
if (p_rmt->rx_buf) {
addr = RMTMEM.chan[channel].data32;
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
if (item_len > p_rmt->rx_item_start_idx) {
item_len = item_len - p_rmt->rx_item_start_idx;
}
@ -747,7 +747,7 @@ static void IRAM_ATTR rmt_driver_isr_default(void *arg)
ESP_EARLY_LOGE(RMT_TAG, "RMT RX BUFFER ERROR");
}
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
p_rmt->rx_item_start_idx = 0;
p_rmt->rx_item_len = 0;
memset((void *)p_rmt->rx_item_buf, 0, p_rmt->rx_item_buf_size);
@ -759,7 +759,7 @@ static void IRAM_ATTR rmt_driver_isr_default(void *arg)
rmt_ll_clear_rx_end_interrupt(hal->regs, channel);
}
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
// Rx thres interrupt
status = rmt_ll_get_rx_thres_interrupt_status(hal->regs);
while (status) {
@ -785,7 +785,7 @@ static void IRAM_ATTR rmt_driver_isr_default(void *arg)
}
#endif
#if RMT_SUPPORT_TX_LOOP_COUNT
#if SOC_RMT_SUPPORT_TX_LOOP_COUNT
// loop count interrupt
status = rmt_ll_get_tx_loop_interrupt_status(hal->regs);
while (status) {
@ -839,7 +839,7 @@ esp_err_t rmt_driver_uninstall(rmt_channel_t channel)
rmt_set_err_intr_en(channel, 0);
rmt_set_tx_intr_en(channel, 0);
rmt_set_tx_thr_intr_en(channel, false, 0xffff);
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
rmt_set_rx_thr_intr_en(channel, false, 0xffff);
#endif
@ -873,7 +873,7 @@ esp_err_t rmt_driver_uninstall(rmt_channel_t channel)
if (p_rmt_obj[channel]->sample_to_rmt) {
p_rmt_obj[channel]->sample_to_rmt = NULL;
}
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
if (p_rmt_obj[channel]->rx_item_buf) {
free(p_rmt_obj[channel]->rx_item_buf);
p_rmt_obj[channel]->rx_item_buf = NULL;
@ -942,7 +942,7 @@ esp_err_t rmt_driver_install(rmt_channel_t channel, size_t rx_buf_size, int intr
p_rmt_obj[channel]->rx_buf = xRingbufferCreate(rx_buf_size, RINGBUF_TYPE_NOSPLIT);
}
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
if (p_rmt_obj[channel]->rx_item_buf == NULL && rx_buf_size > 0) {
#if !CONFIG_SPIRAM_USE_MALLOC
p_rmt_obj[channel]->rx_item_buf = calloc(1, rx_buf_size);
@ -1017,7 +1017,7 @@ esp_err_t rmt_write_items(rmt_channel_t channel, const rmt_item32_t *rmt_item, i
if (wait_tx_done) {
// wait loop done
if (rmt_ll_is_tx_loop_enabled(p_rmt_obj[channel]->hal.regs, channel)) {
#if RMT_SUPPORT_TX_LOOP_COUNT
#if SOC_RMT_SUPPORT_TX_LOOP_COUNT
xSemaphoreTake(p_rmt->tx_sem, portMAX_DELAY);
xSemaphoreGive(p_rmt->tx_sem);
#endif
@ -1167,7 +1167,7 @@ esp_err_t rmt_get_counter_clock(rmt_channel_t channel, uint32_t *clock_hz)
return ESP_OK;
}
#if RMT_SUPPORT_TX_GROUP
#if SOC_RMT_SUPPORT_TX_GROUP
esp_err_t rmt_add_channel_to_group(rmt_channel_t channel)
{
RMT_CHECK(channel < RMT_CHANNEL_MAX, RMT_CHANNEL_ERROR_STR, ESP_ERR_INVALID_ARG);

View file

@ -1,5 +1,5 @@
// RMT driver unit test is based on extended NEC protocol
// Please don't use channel number: RMT_CHANNELS_NUM - 1
// Please don't use channel number: SOC_RMT_CHANNELS_NUM - 1
#include <stdio.h>
#include <string.h>
#include "sdkconfig.h"
@ -33,7 +33,7 @@ static void rmt_setup_testbench(int tx_channel, int rx_channel, uint32_t flags)
if (flags & RMT_TESTBENCH_FLAGS_CARRIER_ON) {
tx_config.tx_config.carrier_en = true;
}
#if RMT_SUPPORT_TX_LOOP_COUNT
#if SOC_RMT_SUPPORT_TX_LOOP_COUNT
if (flags & RMT_TESTBENCH_FLAGS_LOOP_ON) {
tx_config.tx_config.loop_en = true;
tx_config.tx_config.loop_count = 10;
@ -47,7 +47,7 @@ static void rmt_setup_testbench(int tx_channel, int rx_channel, uint32_t flags)
if (flags & RMT_TESTBENCH_FLAGS_ALWAYS_ON) {
rx_config.flags |= RMT_CHANNEL_FLAGS_ALWAYS_ON;
}
#if RMT_SUPPORT_RX_DEMODULATION
#if SOC_RMT_SUPPORT_RX_DEMODULATION
if (flags & RMT_TESTBENCH_FLAGS_CARRIER_ON) {
rx_config.rx_config.rm_carrier = true;
rx_config.rx_config.carrier_freq_hz = 38000;
@ -108,7 +108,7 @@ TEST_CASE("RMT wrong configuration", "[rmt][error]")
TEST_ASSERT(rmt_config(&wrong_config) == ESP_ERR_INVALID_ARG);
wrong_config = correct_config;
wrong_config.channel = RMT_CHANNELS_NUM;
wrong_config.channel = SOC_RMT_CHANNELS_NUM;
TEST_ASSERT(rmt_config(&wrong_config) == ESP_ERR_INVALID_ARG);
wrong_config = correct_config;
@ -120,7 +120,7 @@ TEST_CASE("RMT wrong configuration", "[rmt][error]")
TEST_CASE("RMT miscellaneous functions", "[rmt]")
{
rmt_channel_t channel = RMT_CHANNELS_NUM - 2;
rmt_channel_t channel = SOC_RMT_CHANNELS_NUM - 2;
uint8_t div_cnt;
rmt_source_clk_t src_clk;
uint8_t memNum;
@ -185,7 +185,7 @@ TEST_CASE("RMT multiple channels", "[rmt]")
TEST_CASE("RMT install/uninstall test", "[rmt][pressure]")
{
rmt_config_t rx_cfg = RMT_DEFAULT_CONFIG_TX(RMT_DATA_IO, RMT_CHANNELS_NUM - 2);
rmt_config_t rx_cfg = RMT_DEFAULT_CONFIG_TX(RMT_DATA_IO, SOC_RMT_CHANNELS_NUM - 2);
TEST_ESP_OK(rmt_config(&rx_cfg));
for (int i = 0; i < 100; i++) {
TEST_ESP_OK(rmt_driver_install(rx_cfg.channel, 1000, 0));
@ -263,7 +263,7 @@ TEST_CASE("RMT NEC TX and RX (REF_TICK)", "[rmt][timeout=240]")
do_nec_tx_rx(RMT_TESTBENCH_FLAGS_ALWAYS_ON);
}
#if RMT_SUPPORT_RX_DEMODULATION
#if SOC_RMT_SUPPORT_RX_DEMODULATION
// basic nec tx and rx test, using APB source clock, with modulation and demodulation on
TEST_CASE("RMT NEC TX and RX (Modulation/Demodulation)", "[rmt]")
{
@ -271,12 +271,12 @@ TEST_CASE("RMT NEC TX and RX (Modulation/Demodulation)", "[rmt]")
}
#endif
TEST_CASE("RMT TX (RMT_CHANNEL_MEM_WORDS-1) symbols", "[rmt][boundary]")
TEST_CASE("RMT TX (SOC_RMT_CHANNEL_MEM_WORDS-1) symbols", "[rmt][boundary]")
{
int tx_channel = 0;
rmt_setup_testbench(tx_channel, -1, 0);
rmt_item32_t *items = malloc(sizeof(rmt_item32_t) * (RMT_CHANNEL_MEM_WORDS - 1));
for (int i = 0; i < RMT_CHANNEL_MEM_WORDS - 1; i++) {
rmt_item32_t *items = malloc(sizeof(rmt_item32_t) * (SOC_RMT_CHANNEL_MEM_WORDS - 1));
for (int i = 0; i < SOC_RMT_CHANNEL_MEM_WORDS - 1; i++) {
items[i] = (rmt_item32_t) {
{{
200, 1, 200, 0
@ -284,7 +284,7 @@ TEST_CASE("RMT TX (RMT_CHANNEL_MEM_WORDS-1) symbols", "[rmt][boundary]")
}
};
}
TEST_ESP_OK(rmt_write_items(tx_channel, items, RMT_CHANNEL_MEM_WORDS - 1, 1));
TEST_ESP_OK(rmt_write_items(tx_channel, items, SOC_RMT_CHANNEL_MEM_WORDS - 1, 1));
free(items);
rmt_clean_testbench(tx_channel, -1);
}
@ -354,12 +354,12 @@ TEST_CASE("RMT TX stop", "[rmt]")
rmt_clean_testbench(tx_channel, rx_channel);
}
#if RMT_SUPPORT_RX_PINGPONG
#if SOC_RMT_SUPPORT_RX_PINGPONG
TEST_CASE("RMT Ping-Pong operation", "[rmt]")
{
int tx_channel = 0;
int rx_channel = 1;
rmt_item32_t frames[RMT_CHANNEL_MEM_WORDS * 2]; // send two block data using ping-pong
rmt_item32_t frames[SOC_RMT_CHANNEL_MEM_WORDS * 2]; // send two block data using ping-pong
RingbufHandle_t rb = NULL;
uint32_t size = sizeof(frames) / sizeof(frames[0]);
@ -400,7 +400,7 @@ TEST_CASE("RMT Ping-Pong operation", "[rmt]")
rmt_clean_testbench(tx_channel, rx_channel);
}
#endif
#if RMT_SUPPORT_TX_GROUP
#if SOC_RMT_SUPPORT_TX_GROUP
static uint32_t tx_end_time0, tx_end_time1;
static void rmt_tx_end_cb(rmt_channel_t channel, void *arg)
{
@ -412,7 +412,7 @@ static void rmt_tx_end_cb(rmt_channel_t channel, void *arg)
}
TEST_CASE("RMT TX simultaneously", "[rmt]")
{
rmt_item32_t frames[RMT_CHANNEL_MEM_WORDS];
rmt_item32_t frames[SOC_RMT_CHANNEL_MEM_WORDS];
uint32_t size = sizeof(frames) / sizeof(frames[0]);
int channel0 = 0;
int channel1 = 1;
@ -461,7 +461,7 @@ TEST_CASE("RMT TX simultaneously", "[rmt]")
}
#endif
#if RMT_SUPPORT_TX_LOOP_COUNT
#if SOC_RMT_SUPPORT_TX_LOOP_COUNT
static void rmt_tx_loop_end(rmt_channel_t channel, void *arg)
{
rmt_tx_stop(channel);

View file

@ -29,7 +29,7 @@ typedef enum {
RMT_CHANNEL_1, /*!< RMT channel number 1 */
RMT_CHANNEL_2, /*!< RMT channel number 2 */
RMT_CHANNEL_3, /*!< RMT channel number 3 */
#if RMT_CHANNELS_NUM > 4
#if SOC_RMT_CHANNELS_NUM > 4
RMT_CHANNEL_4, /*!< RMT channel number 4 */
RMT_CHANNEL_5, /*!< RMT channel number 5 */
RMT_CHANNEL_6, /*!< RMT channel number 6 */

View file

@ -18,8 +18,8 @@
extern "C" {
#endif
#define RMT_CHANNEL_MEM_WORDS (64) /*!< Each channel owns 64 words memory */
#define RMT_CHANNELS_NUM (8) /*!< Total 8 channels */
#define SOC_RMT_CHANNEL_MEM_WORDS (64) /*!< Each channel owns 64 words memory */
#define SOC_RMT_CHANNELS_NUM (8) /*!< Total 8 channels */
#ifdef __cplusplus
}

View file

@ -18,12 +18,12 @@
extern "C" {
#endif
#define RMT_CHANNEL_MEM_WORDS (64) /*!< Each channel owns 64 words memory (1 word = 4 Bytes) */
#define RMT_CHANNELS_NUM (4) /*!< Total 4 channels */
#define RMT_SUPPORT_RX_PINGPONG (1) /*!< Support Ping-Pong mode on RX path */
#define RMT_SUPPORT_RX_DEMODULATION (1) /*!< Support signal demodulation on RX path (i.e. remove carrier) */
#define RMT_SUPPORT_TX_LOOP_COUNT (1) /*!< Support transmit specified number of cycles in loop mode */
#define RMT_SUPPORT_TX_GROUP (1) /*!< Support a group of TX channels to transmit simultaneously */
#define SOC_RMT_CHANNEL_MEM_WORDS (64) /*!< Each channel owns 64 words memory (1 word = 4 Bytes) */
#define SOC_RMT_CHANNELS_NUM (4) /*!< Total 4 channels */
#define SOC_RMT_SUPPORT_RX_PINGPONG (1) /*!< Support Ping-Pong mode on RX path */
#define SOC_RMT_SUPPORT_RX_DEMODULATION (1) /*!< Support signal demodulation on RX path (i.e. remove carrier) */
#define SOC_RMT_SUPPORT_TX_LOOP_COUNT (1) /*!< Support transmit specified number of cycles in loop mode */
#define SOC_RMT_SUPPORT_TX_GROUP (1) /*!< Support a group of TX channels to transmit simultaneously */
#ifdef __cplusplus
}

View file

@ -278,7 +278,7 @@ static inline void rmt_ll_set_carrier_on_level(rmt_dev_t *dev, uint32_t channel,
static inline void rmt_ll_write_memory(rmt_mem_t *mem, uint32_t channel, const rmt_item32_t *data, uint32_t length, uint32_t off)
{
length = (off + length) > RMT_CHANNEL_MEM_WORDS ? (RMT_CHANNEL_MEM_WORDS - off) : length;
length = (off + length) > SOC_RMT_CHANNEL_MEM_WORDS ? (SOC_RMT_CHANNEL_MEM_WORDS - off) : length;
for (uint32_t i = 0; i < length; i++) {
mem->chan[channel].data32[i + off].val = data[i].val;
}

View file

@ -369,7 +369,7 @@ static inline void rmt_ll_tx_set_carrier_always_on(rmt_dev_t *dev, uint32_t chan
static inline void rmt_ll_write_memory(rmt_mem_t *mem, uint32_t channel, const rmt_item32_t *data, uint32_t length, uint32_t off)
{
length = (off + length) > RMT_CHANNEL_MEM_WORDS ? (RMT_CHANNEL_MEM_WORDS - off) : length;
length = (off + length) > SOC_RMT_CHANNEL_MEM_WORDS ? (SOC_RMT_CHANNEL_MEM_WORDS - off) : length;
for (uint32_t i = 0; i < length; i++) {
mem->chan[channel].data32[i + off].val = data[i].val;
}

View file

@ -84,7 +84,7 @@ uint32_t rmt_hal_receive(rmt_hal_context_t *hal, uint32_t channel, rmt_item32_t
{
uint32_t len = 0;
rmt_ll_set_mem_owner(hal->regs, channel, RMT_MEM_OWNER_SW);
for (len = 0; len < RMT_CHANNEL_MEM_WORDS; len++) {
for (len = 0; len < SOC_RMT_CHANNEL_MEM_WORDS; len++) {
buf[len].val = hal->mem->chan[channel].data32[len].val;
if (!(buf[len].val & 0x7FFF)) {
break;

View file

@ -49,7 +49,7 @@
#include "sdkconfig.h"
/* Select which RMT and PCNT channels, and GPIO to use */
#define REF_CLOCK_RMT_CHANNEL RMT_CHANNELS_NUM - 1
#define REF_CLOCK_RMT_CHANNEL SOC_RMT_CHANNELS_NUM - 1
#define REF_CLOCK_PCNT_UNIT 0
#define REF_CLOCK_GPIO 21