From 5c6a13b1fac113589abae26df641e8b0b814879a Mon Sep 17 00:00:00 2001 From: demik Date: Thu, 5 Aug 2021 18:41:04 +0200 Subject: [PATCH] increase RMT buffer and stability on data rx errors --- main/adb.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main/adb.c b/main/adb.c index f7f033f..463fff9 100644 --- a/main/adb.c +++ b/main/adb.c @@ -31,6 +31,9 @@ #include "esp_system.h" #include "esp_spi_flash.h" #include "driver/rmt.h" +#include "driver/periph_ctrl.h" +#include "soc/periph_defs.h" +#include "soc/rmt_reg.h" #include "adb.h" #include "led.h" @@ -46,6 +49,7 @@ extern TaskHandle_t t_click, t_qx, t_qy; /* static defines */ static void adb_handle_button(bool action); +static void adb_rmt_reset(void); static bool adb_rx_isone(rmt_item32_t cell); static bool adb_rx_isstop(rmt_item32_t cell); static bool adb_rx_iszero(rmt_item32_t cell); @@ -91,7 +95,7 @@ void adb_init(void) { esp_log_level_set("intr_alloc", ESP_LOG_INFO); /* init RMT RX driver with default values for ADB */ - adb_rmt_rx.mem_block_num = 2; + adb_rmt_rx.mem_block_num = 4; adb_rmt_rx.rx_config.filter_en = true; adb_rmt_rx.rx_config.filter_ticks_thresh = 10; adb_rmt_rx.rx_config.idle_threshold = 100; @@ -296,7 +300,9 @@ static uint16_t IRAM_ATTR adb_rx_mouse() { case 0: return 0; case 4: - /* single glitch, go timeout */ + /* single glitch or service request (keyboard), timeout/ignore */ + rmt_memory_rw_rst(RMT_RX_CHANNEL); + vRingbufferReturnItem(rb, (void*) items); return 0; case 72: xTaskNotify(t_yellow, LED_ONCE, eSetValueWithOverwrite);