From 3fb42ea36ee70c22f853b69090f4ad33c1b50489 Mon Sep 17 00:00:00 2001 From: Erik Olof Gunnar Andersson Date: Fri, 29 Nov 2024 09:38:25 +0100 Subject: [PATCH] Alternative fix serial for 204 and 205 boards --- components/asic/bm1368.c | 6 ++++++ components/asic/bm1370.c | 6 ++++++ components/asic/bm1397.c | 5 +++++ components/asic/serial.c | 3 --- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/components/asic/bm1368.c b/components/asic/bm1368.c index 802a70dfb..caf856a79 100644 --- a/components/asic/bm1368.c +++ b/components/asic/bm1368.c @@ -8,6 +8,8 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "driver/uart.h" + #include #include #include @@ -317,6 +319,10 @@ int BM1368_set_max_baud(void) unsigned char init8[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x28, 0x11, 0x30, 0x02, 0x00, 0x03}; _send_simple(init8, 11); + + // Make sure that we are done writing before setting a new baudrate on the ESP32 controller side. + uart_wait_tx_done(UART_NUM_1, 1000 / portTICK_PERIOD_MS); + return 1000000; } diff --git a/components/asic/bm1370.c b/components/asic/bm1370.c index 05bc06788..f30ac8388 100644 --- a/components/asic/bm1370.c +++ b/components/asic/bm1370.c @@ -9,6 +9,8 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "driver/uart.h" + #include #include #include @@ -381,6 +383,10 @@ int BM1370_set_max_baud(void) unsigned char init8[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x28, 0x11, 0x30, 0x02, 0x00, 0x03}; _send_simple(init8, 11); + + // Make sure that we are done writing before setting a new baudrate on the ESP32 controller side. + uart_wait_tx_done(UART_NUM_1, 1000 / portTICK_PERIOD_MS); + return 1000000; } diff --git a/components/asic/bm1397.c b/components/asic/bm1397.c index ae1001604..48605d105 100644 --- a/components/asic/bm1397.c +++ b/components/asic/bm1397.c @@ -6,6 +6,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "driver/uart.h" #include "esp_log.h" #include "serial.h" @@ -322,6 +323,10 @@ int BM1397_set_max_baud(void) unsigned char baudrate[9] = {0x00, MISC_CONTROL, 0x00, 0x00, 0b01100000, 0b00110001}; ; // baudrate - misc_control _send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), baudrate, 6, BM1937_SERIALTX_DEBUG); + + // Make sure that we are done writing before setting a new baudrate on the ESP32 controller side. + uart_wait_tx_done(UART_NUM_1, 1000 / portTICK_PERIOD_MS); + return 3125000; } diff --git a/components/asic/serial.c b/components/asic/serial.c index b18877fe4..4a04526f2 100644 --- a/components/asic/serial.c +++ b/components/asic/serial.c @@ -47,9 +47,6 @@ void SERIAL_set_baud(int baud) { ESP_LOGI(TAG, "Changing UART baud to %i", baud); - // Make sure that we are done writing before setting a new baudrate. - uart_wait_tx_done(UART_NUM_1, 1000 / portTICK_PERIOD_MS); - uart_set_baudrate(UART_NUM_1, baud); }