drv_usart.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef __DRV_USART_H__
  2. #define __DRV_USART_H__
  3. #include "rkfifo.h"
  4. #include "hpm_uart_drv.h"
  5. #include "hpm_dmamux_drv.h"
  6. #include "hpm_dma_drv.h"
  7. #include "stdint.h"
  8. /* ========== 结构体定义 ========== */
  9. struct _uart_config {
  10. UART_Type *uart_base; /* UART基地址 */
  11. uart_intr_enable_t uart_irq_mask; /* UART中断掩码 */
  12. uint8_t uart_irq_num; /* 中断号 */
  13. /* DMA配置 */
  14. DMA_Type *dma_base; /* DMA控制器基地址 */
  15. DMAMUX_Type *dma_mux_base; /* DMA MUX */
  16. uint8_t dma_enable; /* DMA 使能 */
  17. uint8_t dma_channel; /* DMA通道 */
  18. uint8_t dma_irq_num; /* DMA中断号 */
  19. uint8_t dma_request; /* DMA请求源 */
  20. /* 缓冲区 */
  21. uint8_t *tx_fifo_buff; /* TX FIFO缓冲区 */
  22. uint32_t tx_fifo_buff_size; /* TX FIFO大小 */
  23. uint8_t *rx_fifo_buff; /* RX FIFO缓冲区 */
  24. uint32_t rx_fifo_buff_size; /* RX FIFO大小 */
  25. /* DMA缓冲区 */
  26. uint8_t *dma_tx_buff; /* DMA发送缓冲区 */
  27. uint32_t dma_tx_buff_size; /* DMA发送缓冲区大小 */
  28. /* 内部使用 */
  29. rkfifo_t tx_fifo; /* TX FIFO */
  30. rkfifo_t rx_fifo; /* RX FIFO */
  31. };
  32. struct _uart_ops {
  33. int (*init)(uint32_t baudrate);
  34. uint32_t (*read)(void *data, uint32_t len);
  35. uint32_t (*write)(const void *data, uint32_t len);
  36. };
  37. struct _uart_device {
  38. struct _uart_config *config;
  39. struct _uart_ops *ops;
  40. };
  41. struct _uart_device *uart_find(const char *name);
  42. extern int uart_test_main(int test_mode);
  43. #endif