| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #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
- #if (CONFIG_MC105_HW_VERSION==2)
- #define SHARK_UART_TX_MEM_SIZE (256)
- #define SHARK_UART_RX_MEM_SIZE 256
- #else
- #define SHARK_UART_TX_MEM_SIZE (5 * 1024)
- #define SHARK_UART_RX_MEM_SIZE 512
- #endif
- #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);
|