drv_usart.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef __DRV_USART_H__
  2. #define __DRV_USART_H__
  3. #include "rkfifo.h"
  4. #include "stdint.h"
  5. #if 0
  6. struct stm32_uart_config
  7. {
  8. USART_TypeDef *uartx;
  9. GPIO_TypeDef *_tx_port;
  10. GPIO_TypeDef *_rx_port;
  11. uint8_t _uart_irq_channel;
  12. uint16_t _tx_pin;
  13. uint16_t _rx_pin;
  14. uint8_t *_dma_tx_buff;
  15. uint32_t _dma_tx_buff_size;
  16. uint8_t *_dma_rx_buff;
  17. uint32_t _dma_rx_buff_size;
  18. DMA_Stream_TypeDef *_tx_dma;
  19. uint32_t _tx_dma_channel;
  20. uint32_t _tx_dma_tcif;
  21. uint32_t _tx_dma_teif;
  22. uint8_t _tx_dma_irq_channel;
  23. DMA_Stream_TypeDef *_rx_dma;
  24. uint32_t _rx_dma_channel;
  25. uint32_t _rx_dma_tcif;
  26. uint32_t _rx_dma_teif;
  27. uint8_t _rx_dma_irq_channel;
  28. rkfifo_t _rx_fifo;
  29. uint8_t *_rx_fifo_buff;
  30. uint32_t _rx_fifo_buff_size;
  31. rkfifo_t _tx_fifo;
  32. uint8_t *_tx_fifo_buff;
  33. uint32_t _tx_fifo_buff_size;
  34. };
  35. struct stm32_uart_ops
  36. {
  37. int (*init)(uint32_t bps);
  38. uint32_t (*write)(const void *pdata, uint32_t len);
  39. uint32_t (*read)(void *pdata, uint32_t len);
  40. };
  41. struct stm32_uart
  42. {
  43. struct stm32_uart_ops *ops;
  44. struct stm32_uart_config *_config;
  45. };
  46. struct stm32_uart *uart_find(const char *name);
  47. #endif
  48. #endif