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);