From 8e89a136e1b47b1ff14fa44d9d40e6a9099813fc Mon Sep 17 00:00:00 2001 From: shinyquagsire23 Date: Tue, 4 Apr 2017 00:24:11 -0700 Subject: [PATCH 1/3] Fix impossible check in uart_set_line_inverse --- components/driver/uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/driver/uart.c b/components/driver/uart.c index 7c341b6b0..78add6d2d 100644 --- a/components/driver/uart.c +++ b/components/driver/uart.c @@ -191,7 +191,7 @@ esp_err_t uart_get_baudrate(uart_port_t uart_num, uint32_t* baudrate) esp_err_t uart_set_line_inverse(uart_port_t uart_num, uint32_t inverse_mask) { UART_CHECK((uart_num < UART_NUM_MAX), "uart_num error", ESP_FAIL); - UART_CHECK((((inverse_mask & UART_LINE_INV_MASK) == 0) && (inverse_mask != 0)), "inverse_mask error", ESP_FAIL); + UART_CHECK((((inverse_mask & ~UART_LINE_INV_MASK) == 0) && (inverse_mask != 0)), "inverse_mask error", ESP_FAIL); UART_ENTER_CRITICAL(&uart_spinlock[uart_num]); CLEAR_PERI_REG_MASK(UART_CONF0_REG(uart_num), UART_LINE_INV_MASK); SET_PERI_REG_MASK(UART_CONF0_REG(uart_num), inverse_mask); From cc164b0dc36535047d2d38b368c681a1a892d5d2 Mon Sep 17 00:00:00 2001 From: devsaurus Date: Tue, 4 Apr 2017 22:06:44 +0200 Subject: [PATCH 2/3] fix rmt_set_tx_thr_intr_en(): check evt_thresh only in enable path --- components/driver/rmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/driver/rmt.c b/components/driver/rmt.c index c216c7475..4b939f87b 100644 --- a/components/driver/rmt.c +++ b/components/driver/rmt.c @@ -344,8 +344,8 @@ esp_err_t rmt_set_tx_intr_en(rmt_channel_t channel, bool en) esp_err_t rmt_set_tx_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); - RMT_CHECK(evt_thresh < 256, "RMT EVT THRESH ERR", ESP_ERR_INVALID_ARG); if(en) { + RMT_CHECK(evt_thresh < 256, "RMT EVT THRESH ERR", ESP_ERR_INVALID_ARG); RMT.tx_lim_ch[channel].limit = evt_thresh; rmt_set_tx_wrap_en(channel, true); rmt_set_intr_enable_mask(BIT(channel + 24)); From ae94fe04ef4a3d095698ba8e285f945da91f6c10 Mon Sep 17 00:00:00 2001 From: devsaurus Date: Wed, 5 Apr 2017 23:08:55 +0200 Subject: [PATCH 3/3] components/driver/rmt: Add const qualifier for config and tx data. --- components/driver/include/driver/rmt.h | 6 +++--- components/driver/rmt.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/driver/include/driver/rmt.h b/components/driver/include/driver/rmt.h index f5e82b4a1..0a958688c 100644 --- a/components/driver/include/driver/rmt.h +++ b/components/driver/include/driver/rmt.h @@ -564,7 +564,7 @@ esp_err_t rmt_set_pin(rmt_channel_t channel, rmt_mode_t mode, gpio_num_t gpio_nu * - ESP_ERR_INVALID_ARG Parameter error * - ESP_OK Success */ -esp_err_t rmt_config(rmt_config_t* rmt_param); +esp_err_t rmt_config(const rmt_config_t* rmt_param); /** * @brief register RMT interrupt handler, the handler is an ISR. @@ -612,7 +612,7 @@ esp_err_t rmt_isr_deregister(rmt_isr_handle_t handle); * - ESP_ERR_INVALID_ARG Parameter error * - ESP_OK Success */ -esp_err_t rmt_fill_tx_items(rmt_channel_t channel, rmt_item32_t* item, uint16_t item_num, uint16_t mem_offset); +esp_err_t rmt_fill_tx_items(rmt_channel_t channel, const rmt_item32_t* item, uint16_t item_num, uint16_t mem_offset); /** * @brief Initialize RMT driver @@ -670,7 +670,7 @@ esp_err_t rmt_driver_uninstall(rmt_channel_t channel); * - ESP_ERR_INVALID_ARG Parameter error * - ESP_OK Success */ -esp_err_t rmt_write_items(rmt_channel_t channel, rmt_item32_t* rmt_item, int item_num, bool wait_tx_done); +esp_err_t rmt_write_items(rmt_channel_t channel, const rmt_item32_t* rmt_item, int item_num, bool wait_tx_done); /** * @brief Wait RMT TX finished. diff --git a/components/driver/rmt.c b/components/driver/rmt.c index 4b939f87b..5172621db 100644 --- a/components/driver/rmt.c +++ b/components/driver/rmt.c @@ -61,7 +61,7 @@ typedef struct { int tx_len_rem; int tx_sub_len; rmt_channel_t channel; - rmt_item32_t* tx_data; + const rmt_item32_t* tx_data; xSemaphoreHandle tx_sem; RingbufHandle_t tx_buf; RingbufHandle_t rx_buf; @@ -373,7 +373,7 @@ esp_err_t rmt_set_pin(rmt_channel_t channel, rmt_mode_t mode, gpio_num_t gpio_nu return ESP_OK; } -esp_err_t rmt_config(rmt_config_t* rmt_param) +esp_err_t rmt_config(const rmt_config_t* rmt_param) { uint8_t mode = rmt_param->rmt_mode; uint8_t channel = rmt_param->channel; @@ -464,7 +464,7 @@ esp_err_t rmt_config(rmt_config_t* rmt_param) return ESP_OK; } -static void IRAM_ATTR rmt_fill_memory(rmt_channel_t channel, rmt_item32_t* item, uint16_t item_num, uint16_t mem_offset) +static void IRAM_ATTR rmt_fill_memory(rmt_channel_t channel, const rmt_item32_t* item, uint16_t item_num, uint16_t mem_offset) { portENTER_CRITICAL(&rmt_spinlock); RMT.apb_conf.fifo_mask = RMT_DATA_MODE_MEM; @@ -475,7 +475,7 @@ static void IRAM_ATTR rmt_fill_memory(rmt_channel_t channel, rmt_item32_t* item, } } -esp_err_t rmt_fill_tx_items(rmt_channel_t channel, rmt_item32_t* item, uint16_t item_num, uint16_t mem_offset) +esp_err_t rmt_fill_tx_items(rmt_channel_t channel, const rmt_item32_t* item, uint16_t item_num, uint16_t mem_offset) { RMT_CHECK(channel < RMT_CHANNEL_MAX, RMT_CHANNEL_ERROR_STR, (0)); RMT_CHECK((item != NULL), RMT_ADDR_ERROR_STR, ESP_ERR_INVALID_ARG); @@ -589,7 +589,7 @@ static void IRAM_ATTR rmt_driver_isr_default(void* arg) if(p_rmt->tx_data == NULL) { //skip } else { - rmt_item32_t* pdata = p_rmt->tx_data; + const rmt_item32_t* pdata = p_rmt->tx_data; int len_rem = p_rmt->tx_len_rem; if(len_rem >= p_rmt->tx_sub_len) { rmt_fill_memory(channel, pdata, p_rmt->tx_sub_len, p_rmt->tx_offset); @@ -678,7 +678,7 @@ esp_err_t rmt_driver_install(rmt_channel_t channel, size_t rx_buf_size, int intr return ESP_OK; } -esp_err_t rmt_write_items(rmt_channel_t channel, rmt_item32_t* rmt_item, int item_num, bool wait_tx_done) +esp_err_t rmt_write_items(rmt_channel_t channel, const rmt_item32_t* rmt_item, int item_num, bool wait_tx_done) { RMT_CHECK(channel < RMT_CHANNEL_MAX, RMT_CHANNEL_ERROR_STR, ESP_ERR_INVALID_ARG); RMT_CHECK(p_rmt_obj[channel] != NULL, RMT_DRIVER_ERROR_STR, ESP_FAIL);