feat: save stable CH390 bridge baseline

This commit is contained in:
2026-04-04 02:48:21 +08:00
parent 6f4ba247a4
commit d5b2506269
18 changed files with 2146 additions and 1621 deletions
+22 -14
View File
@@ -1,6 +1,6 @@
/**
* @file uart_trans.h
* @brief Bare-metal UART DMA/IDLE transport layer.
* @brief Bare-metal UART DMA/IDLE transport and MUX framing helpers.
*/
#ifndef __UART_TRANS_H__
@@ -14,28 +14,28 @@ extern "C" {
#endif
typedef enum {
UART_CHANNEL_SERVER = 0,
UART_CHANNEL_CLIENT = 1,
UART_CHANNEL_U0 = 0,
UART_CHANNEL_U1 = 1,
UART_CHANNEL_MAX
} uart_channel_t;
typedef struct {
uint8_t src_id;
uint8_t dst_mask;
uint16_t payload_len;
uint8_t payload[256];
} uart_mux_frame_t;
#define UART_RX_DMA_BUFFER_SIZE 128u
#define UART_TX_DMA_BUFFER_SIZE 128u
#define UART_RX_RING_BUFFER_SIZE 512u
#define UART_TX_RING_BUFFER_SIZE 512u
#define UART_RX_RING_BUFFER_SIZE 256u
#define UART_TX_RING_BUFFER_SIZE 256u
#define UART_DEFAULT_BAUDRATE 115200u
typedef struct {
uint32_t baudrate;
uint8_t data_bits;
uint8_t stop_bits;
uint8_t parity;
} uart_config_t;
#define UART_DEFAULT_BAUDRATE 115200u
#define UART_DEFAULT_DATA_BITS 8u
#define UART_DEFAULT_STOP_BITS 1u
#define UART_DEFAULT_PARITY 0u
typedef struct {
uint32_t rx_bytes;
uint32_t tx_bytes;
@@ -61,9 +61,17 @@ void uart_trans_idle_handler(uart_channel_t channel);
void uart_trans_rx_half_cplt_handler(uart_channel_t channel);
void uart_trans_rx_cplt_handler(uart_channel_t channel);
void uart_trans_tx_cplt_handler(uart_channel_t channel);
bool uart_mux_try_extract_frame(uart_channel_t channel, uart_mux_frame_t *frame);
bool uart_mux_encode_frame(uint8_t src_id,
uint8_t dst_mask,
const uint8_t *payload,
uint16_t payload_len,
uint8_t *out,
uint16_t *out_len,
uint16_t out_capacity);
#ifdef __cplusplus
}
#endif
#endif
#endif /* __UART_TRANS_H__ */