Skip to content

Commit

Permalink
Alternative fix serial for 204 and 205 boards
Browse files Browse the repository at this point in the history
  • Loading branch information
eandersson committed Nov 29, 2024
1 parent e9b30ba commit 3fb42ea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions components/asic/bm1368.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

#include "driver/uart.h"

#include <math.h>
#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions components/asic/bm1370.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

#include "driver/uart.h"

#include <math.h>
#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions components/asic/bm1397.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/uart.h"
#include "esp_log.h"

#include "serial.h"
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 0 additions & 3 deletions components/asic/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 3fb42ea

Please sign in to comment.