hw_dma_uart.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef __HW_UART_H__
  2. #define __HW_UART_H__
  3. #define HW_DMA_UART_NUMBER 2
  4. typedef struct
  5. {
  6. int speed; //速度
  7. int databits; //数据位
  8. int stopbits; //停止位
  9. int parity; //奇偶校验位,0表示无,1表示奇,2表示偶
  10. } hw_uart_config;
  11. #define UART_CTRL_RECONFIG 0x0A //设置串口速度
  12. #define UART_CTRL_SET_SPEED 0x01 //设置串口速度
  13. #define UART_CTRL_SET_RDFIN_TIME 0x02 //设置串口接收完成判断时间
  14. #define UART_CTRL_SET_WRFIN_TIME 0x03 //设置串口发送完成判断时间
  15. #define UART_CTRL_GET_SPEED 0x81 //获取当前速度
  16. #define UART_CTRL_GET_RDFIN_TIME 0x82 //获取当前串口接收完成时间
  17. #define UART_CTRL_GET_WRFIN_TIME 0x83 //获取当前串口写入完成时间
  18. #define UART_CTRL_GET_RDFIN 0x84 //串口接收是否完成,如果完成会返回接收长度
  19. #define UART_CTRL_GET_WRFIN 0x85 //串口发送是否完成
  20. #define hw_dma_uart_read(a,b,c) hw_dma_uart_begin_read(a,b,c)
  21. #define hw_dma_uart_write(a,b,c) hw_dma_uart_begin_write(a,b,c)
  22. void hw_dma_uart_init(int clk);
  23. int hw_dma_uart_control(unsigned char uart_index, char cmd, void *value);
  24. int hw_dma_uart_begin_write(unsigned char uart_index, const char *buffer, int size);
  25. int hw_dma_uart_write_finish(unsigned char uart_index);
  26. int hw_dma_uart_begin_read(unsigned char uart_index,unsigned char *buffer, int size);
  27. int hw_dma_uart_read_finish(unsigned char uart_index);
  28. #endif