]> granicus.if.org Git - esp-idf/commitdiff
bugfix(rmt): fix event thresh check issue
authorWangjialin <wangjialin@espressif.com>
Wed, 18 Oct 2017 10:49:09 +0000 (18:49 +0800)
committerWangjialin <wangjialin@espressif.com>
Wed, 18 Oct 2017 10:49:09 +0000 (18:49 +0800)
reported from: https://github.com/espressif/esp-idf/issues/1011

1. Fix event thresh check issue
2. Change IO number in example in case it conflicts with GPIO16(psram cs pin).

components/driver/rmt.c
examples/peripherals/rmt_nec_tx_rx/main/infrared_nec_main.c

index 7386aa2e64b8dae96d0f5bfbcedbfa46c10829b1..499f565bdc7df9487b20cdbae38cc93867f4146a 100644 (file)
@@ -351,8 +351,10 @@ esp_err_t rmt_set_tx_thr_intr_en(rmt_channel_t channel, bool en, uint16_t evt_th
 {
     RMT_CHECK(channel < RMT_CHANNEL_MAX, RMT_CHANNEL_ERROR_STR, ESP_ERR_INVALID_ARG);
     if(en) {
-        RMT_CHECK(evt_thresh < 256, "RMT EVT THRESH ERR", ESP_ERR_INVALID_ARG);
+        RMT_CHECK(evt_thresh <= 256, "RMT EVT THRESH ERR", ESP_ERR_INVALID_ARG);
+        portENTER_CRITICAL(&rmt_spinlock);
         RMT.tx_lim_ch[channel].limit = evt_thresh;
+        portEXIT_CRITICAL(&rmt_spinlock);
         rmt_set_tx_wrap_en(channel, true);
         rmt_set_intr_enable_mask(BIT(channel + 24));
     } else {
@@ -424,8 +426,6 @@ esp_err_t rmt_config(const rmt_config_t* rmt_param)
         /*Set idle level */
         RMT.conf_ch[channel].conf1.idle_out_en = rmt_param->tx_config.idle_output_en;
         RMT.conf_ch[channel].conf1.idle_out_lv = idle_level;
-        portEXIT_CRITICAL(&rmt_spinlock);
-
         /*Set carrier*/
         RMT.conf_ch[channel].conf0.carrier_en = carrier_en;
         if (carrier_en) {
@@ -441,6 +441,8 @@ esp_err_t rmt_config(const rmt_config_t* rmt_param)
             RMT.carrier_duty_ch[channel].high = 0;
             RMT.carrier_duty_ch[channel].low = 0;
         }
+        portEXIT_CRITICAL(&rmt_spinlock);
+
         ESP_LOGD(RMT_TAG, "Rmt Tx Channel %u|Gpio %u|Sclk_Hz %u|Div %u|Carrier_Hz %u|Duty %u",
                  channel, gpio_num, rmt_source_clk_hz, clk_div, carrier_freq_hz, carrier_duty_percent);
 
index 3e357a726d291ae539f814d81324f766b5b4f88e..6f589668783604273cd704b4a38dad3879d1118a 100644 (file)
@@ -40,7 +40,7 @@ static const char* NEC_TAG = "NEC";
 #endif
 
 #define RMT_TX_CHANNEL    1     /*!< RMT channel for transmitter */
-#define RMT_TX_GPIO_NUM  16     /*!< GPIO number for transmitter signal */
+#define RMT_TX_GPIO_NUM  18     /*!< GPIO number for transmitter signal */
 #define RMT_RX_CHANNEL    0     /*!< RMT channel for receiver */
 #define RMT_RX_GPIO_NUM  19     /*!< GPIO number for receiver */
 #define RMT_CLK_DIV      100    /*!< RMT counter clock divider */