From da0a5a6ac0c5c8ce75e1292570a142af99ac5aad Mon Sep 17 00:00:00 2001 From: Niel Nielsen Date: Mon, 31 Aug 2026 08:41:40 +0200 Subject: [PATCH] Define target baud rate for UART negotiation Added target baud rate for UART negotiation and updated comments. Signed-off-by: Niel Nielsen --- armsrc/bwm_uart_at32.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/armsrc/bwm_uart_at32.h b/armsrc/bwm_uart_at32.h index 707a2f102..b5ead636d 100644 --- a/armsrc/bwm_uart_at32.h +++ b/armsrc/bwm_uart_at32.h @@ -14,11 +14,27 @@ #include "common.h" -#define BWM_UART_BAUD 460800 +// Boot/default baud. Must match UART_BAUD_RATE_DEFAULT in the ESP firmware +// (Proxmark5_BWM_esp32). The link comes up here, then the ARM negotiates up to +// BWM_UART_BAUD_TARGET at runtime via app_com cmd 1011 - the ESP is designed to +// be told, not reflashed (the SET command is explicitly non-persistent). +#define BWM_UART_BAUD 460800 + +// Target baud to negotiate after link-up. 0 disables negotiation (stay at +// BWM_UART_BAUD). Bounded by the ESP's CONFIG_SOC_UART_BITRATE_MAX and PA0/PA1 +// signal integrity; validate on hardware before raising further. +#ifndef BWM_UART_BAUD_TARGET +#define BWM_UART_BAUD_TARGET 921600 +#endif void bwm_uart_init(void); -void UART4_IRQHandler(void); +// Re-init UART4 + RX DMA at a new baud (used by the runtime baud negotiation). +// Discards any bytes already in the RX ring. +void bwm_uart_set_baud(uint32_t baud); + +// Baud the link is currently running at (updated by bwm_uart_set_baud). +uint32_t bwm_uart_get_baud(void); int bwm_uart_write(const uint8_t *data, size_t len);