| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #pragma once
- #include "libs/shark_libs.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
- typedef enum {
- SHARK_UART0,
- 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[256];
- uint16_t rx_length;
- bool escape;
- }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);
|