drv_usart.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2020-2021, Bluetrum Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-11-20 greedyhao first version
  9. */
  10. #ifndef DRV_USART_H__
  11. #define DRV_USART_H__
  12. #include "drv_common.h"
  13. #ifdef RT_USING_SERIAL
  14. /* an32 config class */
  15. struct ab32_uart_config
  16. {
  17. const char *name;
  18. hal_sfr_t instance;
  19. uint8_t mode;
  20. uint16_t fifo_size;
  21. uint8_t reserve[1];
  22. // struct dma_config *dma_rx;
  23. // struct dma_config *dma_tx;
  24. };
  25. /* ab32 uart driver class */
  26. struct ab32_uart
  27. {
  28. struct uart_handle handle;
  29. struct ab32_uart_config *config;
  30. #ifdef RT_SERIAL_USING_DMA
  31. struct
  32. {
  33. DMA_HandleTypeDef handle;
  34. rt_size_t last_index;
  35. } dma_rx;
  36. struct
  37. {
  38. DMA_HandleTypeDef handle;
  39. } dma_tx;
  40. #endif
  41. rt_uint16_t uart_dma_flag;
  42. struct rt_serial_device serial;
  43. rt_uint8_t *rx_buf;
  44. rt_uint8_t rx_idx;
  45. rt_uint8_t rx_idx_prev;
  46. };
  47. #endif
  48. int rt_hw_usart_init(void);
  49. #endif