From cad47c34315f9b7c88751bf31749cb34281d8f51 Mon Sep 17 00:00:00 2001 From: Tester23 <85486843+openshwprojects@users.noreply.github.com> Date: Sun, 14 Sep 2025 15:56:03 +0200 Subject: [PATCH] hal --- src/driver/drv_dmx512.c | 4 ++-- src/driver/drv_uart.c | 2 +- src/hal/bk7231/hal_uart_bk7231.c | 2 +- src/hal/bl602/hal_uart_bl602.c | 2 +- src/hal/ecr6600/hal_uart_ecr6600.c | 2 +- src/hal/espidf/hal_uart_espidf.c | 10 ++++++---- src/hal/generic/hal_uart_generic.c | 2 +- src/hal/hal_uart.h | 2 +- src/hal/realtek/rtl8710a/hal_uart_rtl8710a.c | 2 +- src/hal/realtek/rtl8710b/hal_uart_rtl8710b.c | 2 +- src/hal/realtek/rtl8720d/hal_uart_rtl8720d.c | 2 +- src/hal/realtek/rtl8721da/hal_uart_rtl8721da.c | 2 +- src/hal/realtek/rtl87x0c/hal_uart_rtl87x0c.c | 2 +- src/hal/w800/hal_uart_w800.c | 2 +- src/hal/win32/hal_uart_win32.c | 2 +- src/hal/xradio/hal_uart_xradio.c | 2 +- src/selftest/selftest_ws2812b.c | 6 +++--- 17 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/driver/drv_dmx512.c b/src/driver/drv_dmx512.c index 588b1ee3a..99bf9e8bf 100644 --- a/src/driver/drv_dmx512.c +++ b/src/driver/drv_dmx512.c @@ -60,7 +60,7 @@ void DMX_Show() { HAL_Delay_us(120); // ≥88µs HAL_PIN_SetOutputValue(dmx_pin, 1); HAL_Delay_us(12); // MAB ≥8µs - HAL_UART_Init(250000, 2, false); + HAL_UART_Init(250000, 2, false, dmx_pin, -1); #else #define DMX_BREAK_DURATION_MICROS 88 uint32_t breakBaud = 1000000 * 8 / DMX_BREAK_DURATION_MICROS; @@ -107,7 +107,7 @@ void DMX_Init() { LEDS_InitShared(&ws_export); - HAL_UART_Init(250000, 2, false); + HAL_UART_Init(250000, 2, false, dmx_pin, -1); } void DMX_OnEverySecond() { } diff --git a/src/driver/drv_uart.c b/src/driver/drv_uart.c index 2bd0b61db..95d926999 100644 --- a/src/driver/drv_uart.c +++ b/src/driver/drv_uart.c @@ -254,7 +254,7 @@ int UART_InitUARTEx(int auartindex, int baud, int parity, bool hwflowc) #ifdef UART_2_UARTS_CONCURRENT HAL_UART_InitEx(auartindex, baud, parity, hwflowc); #else - HAL_UART_Init(baud, parity, hwflowc); + HAL_UART_Init(baud, parity, hwflowc, -1, -1); #endif return fuartbuf->g_uart_init_counter; } diff --git a/src/hal/bk7231/hal_uart_bk7231.c b/src/hal/bk7231/hal_uart_bk7231.c index d3cdc8bbc..be6067a13 100644 --- a/src/hal/bk7231/hal_uart_bk7231.c +++ b/src/hal/bk7231/hal_uart_bk7231.c @@ -28,7 +28,7 @@ void HAL_UART_SendByteEx(int auartindex, byte b) bk_send_byte(bk_port_from_portindex(auartindex), b); } -int HAL_UART_InitEx(int auartindex, int baud, int parity, bool hwflowc) +int HAL_UART_InitEx(int auartindex, int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { bk_uart_config_t config; diff --git a/src/hal/bl602/hal_uart_bl602.c b/src/hal/bl602/hal_uart_bl602.c index ce7e3299c..6e85846f8 100644 --- a/src/hal/bl602/hal_uart_bl602.c +++ b/src/hal/bl602/hal_uart_bl602.c @@ -66,7 +66,7 @@ void HAL_UART_SendByte(byte b) //bl_uart_data_send(g_id, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(fd_console < 0) { diff --git a/src/hal/ecr6600/hal_uart_ecr6600.c b/src/hal/ecr6600/hal_uart_ecr6600.c index 09294d253..077251ff2 100644 --- a/src/hal/ecr6600/hal_uart_ecr6600.c +++ b/src/hal/ecr6600/hal_uart_ecr6600.c @@ -25,7 +25,7 @@ void HAL_UART_SendByte(byte b) drv_uart_send_poll(uart, &b, 1); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { drv_uart_close(uart); T_DRV_UART_CONFIG config = diff --git a/src/hal/espidf/hal_uart_espidf.c b/src/hal/espidf/hal_uart_espidf.c index f4abc4aaa..3c4718e37 100644 --- a/src/hal/espidf/hal_uart_espidf.c +++ b/src/hal/espidf/hal_uart_espidf.c @@ -111,7 +111,7 @@ void HAL_SetBaud(uint32_t baud) uart_set_baudrate(uartnum, baud); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(CFG_HasFlag(OBK_FLAG_USE_SECONDARY_UART)) { @@ -145,9 +145,11 @@ int HAL_UART_Init(int baud, int parity, bool hwflowc) #if PLATFORM_ESPIDF - uart_set_pin(uartnum, - 22, 21, - UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); + if (txOverride != -1) { + uart_set_pin(uartnum, + txOverride, 21, + UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); + } #endif xTaskCreate(uart_event_task, "uart_event_task", 1024, NULL, 16, NULL); diff --git a/src/hal/generic/hal_uart_generic.c b/src/hal/generic/hal_uart_generic.c index 63b903f03..bfeee64a0 100644 --- a/src/hal/generic/hal_uart_generic.c +++ b/src/hal/generic/hal_uart_generic.c @@ -4,7 +4,7 @@ void __attribute__((weak)) HAL_UART_SendByte(byte b) { } -int __attribute__((weak)) HAL_UART_Init(int baud, int parity, bool hwflowc) +int __attribute__((weak)) HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { return 0; } diff --git a/src/hal/hal_uart.h b/src/hal/hal_uart.h index 8cf97e3fc..57cfd232f 100644 --- a/src/hal/hal_uart.h +++ b/src/hal/hal_uart.h @@ -12,5 +12,5 @@ int HAL_UART_InitEx(int auartindex, int baud, int parity, bool hwflowc); #else void HAL_UART_SendByte(byte b); -int HAL_UART_Init(int baud, int parity, bool hwflowc); +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride); #endif \ No newline at end of file diff --git a/src/hal/realtek/rtl8710a/hal_uart_rtl8710a.c b/src/hal/realtek/rtl8710a/hal_uart_rtl8710a.c index 41e601544..d85dc3137 100644 --- a/src/hal/realtek/rtl8710a/hal_uart_rtl8710a.c +++ b/src/hal/realtek/rtl8710a/hal_uart_rtl8710a.c @@ -28,7 +28,7 @@ void HAL_UART_SendByte(byte b) serial_putc(&sobj, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInitialized) { diff --git a/src/hal/realtek/rtl8710b/hal_uart_rtl8710b.c b/src/hal/realtek/rtl8710b/hal_uart_rtl8710b.c index 439aed817..0bd9285d8 100644 --- a/src/hal/realtek/rtl8710b/hal_uart_rtl8710b.c +++ b/src/hal/realtek/rtl8710b/hal_uart_rtl8710b.c @@ -31,7 +31,7 @@ void HAL_UART_SendByte(byte b) serial_putc(&sobj, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInitialized) { diff --git a/src/hal/realtek/rtl8720d/hal_uart_rtl8720d.c b/src/hal/realtek/rtl8720d/hal_uart_rtl8720d.c index df171b182..051c18e96 100644 --- a/src/hal/realtek/rtl8720d/hal_uart_rtl8720d.c +++ b/src/hal/realtek/rtl8720d/hal_uart_rtl8720d.c @@ -36,7 +36,7 @@ void HAL_UART_SendByte(byte b) serial_putc(&sobj, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInitialized) { diff --git a/src/hal/realtek/rtl8721da/hal_uart_rtl8721da.c b/src/hal/realtek/rtl8721da/hal_uart_rtl8721da.c index e4967565f..40ede9c3c 100644 --- a/src/hal/realtek/rtl8721da/hal_uart_rtl8721da.c +++ b/src/hal/realtek/rtl8721da/hal_uart_rtl8721da.c @@ -46,7 +46,7 @@ void HAL_UART_SendByte(byte b) serial_putc(&sobj, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInitialized) { diff --git a/src/hal/realtek/rtl87x0c/hal_uart_rtl87x0c.c b/src/hal/realtek/rtl87x0c/hal_uart_rtl87x0c.c index 1fdd6332d..3e82ea7a1 100644 --- a/src/hal/realtek/rtl87x0c/hal_uart_rtl87x0c.c +++ b/src/hal/realtek/rtl87x0c/hal_uart_rtl87x0c.c @@ -34,7 +34,7 @@ void HAL_UART_SendByte(byte b) hal_uart_putc(&sobj.uart_adp, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInitialized) { diff --git a/src/hal/w800/hal_uart_w800.c b/src/hal/w800/hal_uart_w800.c index 341ddfa75..a4e3582ad 100644 --- a/src/hal/w800/hal_uart_w800.c +++ b/src/hal/w800/hal_uart_w800.c @@ -45,7 +45,7 @@ void HAL_UART_SendByte(byte b) tls_uart_write(used_uart, (char*)&b, 1); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { struct tls_uart_options uart_opts; uart_opts.baudrate = baud; diff --git a/src/hal/win32/hal_uart_win32.c b/src/hal/win32/hal_uart_win32.c index 0138b50b5..8d4de82ce 100644 --- a/src/hal/win32/hal_uart_win32.c +++ b/src/hal/win32/hal_uart_win32.c @@ -13,7 +13,7 @@ void HAL_UART_SendByte(byte b) //addLogAdv(LOG_INFO, LOG_FEATURE_TUYAMCU,"%02X", b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { return 1; } diff --git a/src/hal/xradio/hal_uart_xradio.c b/src/hal/xradio/hal_uart_xradio.c index 8e0f853ed..2775514f6 100644 --- a/src/hal/xradio/hal_uart_xradio.c +++ b/src/hal/xradio/hal_uart_xradio.c @@ -29,7 +29,7 @@ void HAL_UART_SendByte(byte b) HAL_UART_Transmit_IT(uart, &b, 1); } -int OBK_HAL_UART_Init(int baud, int parity, bool hwflowc) +int OBK_HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInit) return 1; HAL_Status status = HAL_ERROR; diff --git a/src/selftest/selftest_ws2812b.c b/src/selftest/selftest_ws2812b.c index 80099847e..f126616a0 100644 --- a/src/selftest/selftest_ws2812b.c +++ b/src/selftest/selftest_ws2812b.c @@ -314,18 +314,18 @@ void Test_WS2812B() { } CMD_ExecuteCommand("startDriver DDP", 0); CMD_ExecuteCommand("startDriver DDPSend", 0); - CMD_ExecuteCommand("DDP_Send 127.0.0.1 4048 3 0 FF00AB", 0); + CMD_ExecuteCommand("DDP_Send 127.0.0.1 3 0 FF00AB", 0); SIM_WaitForDDPPacket(); // this requires udp to work so it can pass... if (1) { SELFTEST_ASSERT_PIXEL(0, 0xFF, 0x00, 0xAB); } - CMD_ExecuteCommand("DDP_Send 127.0.0.1 4048 3 0 ABCDEF", 0); + CMD_ExecuteCommand("DDP_Send 127.0.0.1 3 0 ABCDEF", 0); SIM_WaitForDDPPacket(); if (1) { SELFTEST_ASSERT_PIXEL(0, 0xAB, 0xCD, 0xEF); } - CMD_ExecuteCommand("DDP_Send 127.0.0.1 4048 3 0 ABCDEFAABBCC", 0); + CMD_ExecuteCommand("DDP_Send 127.0.0.1 3 0 ABCDEFAABBCC", 0); SIM_WaitForDDPPacket(); if (1) { SELFTEST_ASSERT_PIXEL(0, 0xAB, 0xCD, 0xEF);