| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #ifndef __DRV_USART_H__
- #define __DRV_USART_H__
- #include "rkfifo.h"
- #include "hpm_uart_drv.h"
- #include "hpm_dmamux_drv.h"
- #include "hpm_dma_drv.h"
- #include "stdint.h"
- /* ========== 结构体定义 ========== */
- struct _uart_config {
- UART_Type *uart_base; /* UART基地址 */
- uart_intr_enable_t uart_irq_mask; /* UART中断掩码 */
- uint8_t uart_irq_num; /* 中断号 */
-
- /* DMA配置 */
- DMA_Type *dma_base; /* DMA控制器基地址 */
- DMAMUX_Type *dma_mux_base; /* DMA MUX */
- uint8_t dma_enable; /* DMA 使能 */
- uint8_t dma_channel; /* DMA通道 */
- uint8_t dma_irq_num; /* DMA中断号 */
- uint8_t dma_request; /* DMA请求源 */
-
- /* 缓冲区 */
- uint8_t *tx_fifo_buff; /* TX FIFO缓冲区 */
- uint32_t tx_fifo_buff_size; /* TX FIFO大小 */
- uint8_t *rx_fifo_buff; /* RX FIFO缓冲区 */
- uint32_t rx_fifo_buff_size; /* RX FIFO大小 */
-
- /* DMA缓冲区 */
- uint8_t *dma_tx_buff; /* DMA发送缓冲区 */
- uint32_t dma_tx_buff_size; /* DMA发送缓冲区大小 */
-
- /* 内部使用 */
- rkfifo_t tx_fifo; /* TX FIFO */
- rkfifo_t rx_fifo; /* RX FIFO */
- };
- struct _uart_ops {
- int (*init)(uint32_t baudrate);
- uint32_t (*read)(void *data, uint32_t len);
- uint32_t (*write)(const void *data, uint32_t len);
- };
- struct _uart_device {
- struct _uart_config *config;
- struct _uart_ops *ops;
- };
- struct _uart_device *uart_find(const char *name);
- extern int uart_test_main(int test_mode);
- #endif
|