| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #pragma once
- #include "bsp/bsp.h"
- #include "os/os_task.h"
- #include "libs/byte_queue.h"
- #include "libs/circle_buffer.h"
- #define CH_START 0xF5
- #define CH_END 0xF6
- #define CH_ESC 0xF7
- #define CH_ESC_START 0x05
- #define CH_ESC_END 0x06
- #define CH_ESC_ESC 0x07
- #define SHARK_UART_TX_MEM_SIZE 512
- #define SHARK_UART_RX_MEM_SIZE 512
- #define RX_FRAME_MAX_LEN 260
- #define RX_OLD_FRAME_MAX_LEN 256
- typedef enum {
- SHARK_UART0 = 0,
- SHARK_UART1,
- SHARK_UART2,
- SHARK_UART3,
- SHARK_UART4,
- SHARK_UART_COUNT
- } uart_enum_t;
- typedef struct {
- byte_queue_t tx_queue;
- c_buffer_t rx_queue;
- dma_channel_enum rx_dma_ch;
- dma_channel_enum tx_dma_ch;
- uint16_t tx_length;
- uint16_t tx_crc16;
- uint32_t uart_com;//uart device
- uint8_t rx_frame[RX_FRAME_MAX_LEN];
- uint16_t rx_length;
- bool escape;
- bool start;
- bool uart_no_data;
- }shark_uart_t;
- void shark_uart_init(uart_enum_t uart_no);
- void shark_uart_deinit(uart_enum_t uart_no);
- void shark_uart_write_frame(uart_enum_t uart_no, uint8_t *bytes, int len);
- void shark_uart_frame_start(uart_enum_t uart_no, uint8_t *bytes, int len);
- void shark_uart_frame_continue(uart_enum_t uart_no, uint8_t *bytes, int len);
- void shark_uart_frame_end(uart_enum_t uart_no);
- void shark_uart_write_bytes(uart_enum_t uart_no, u8 *buff, u16 size);
- void shark_uart_flush(void);
- bool shark_uart_timeout(void);
- void shark_uart_log(void);
|