drv_usart.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022.03.02 FMD-AE first version
  9. */
  10. #ifndef __DRV_USART_H__
  11. #define __DRV_USART_H__
  12. #include <rtthread.h>
  13. #include "rtdevice.h"
  14. #include <rthw.h>
  15. #include "drv_dma.h"
  16. int rt_hw_usart_init(void);
  17. #if defined(SOC_SERIES_FT32F0)
  18. #define DMA_INSTANCE_TYPE DMA_Channel_TypeDef
  19. #endif
  20. #if defined(SOC_SERIES_FT32F0)
  21. #define UART_INSTANCE_CLEAR_FUNCTION USART_ClearITPendingBit
  22. #endif
  23. #define USART_TX_Pin GPIO_PIN_2
  24. #define USART_TX_GPIO_Port GPIOA
  25. #define USART_RX_Pin GPIO_PIN_3
  26. #define USART_RX_GPIO_Port GPIOA
  27. /* ft32 config class */
  28. struct ft32_uart_config
  29. {
  30. const char *name;
  31. USART_TypeDef *Instance;
  32. IRQn_Type irq_type;
  33. struct dma_config *dma_rx;
  34. struct dma_config *dma_tx;
  35. };
  36. /* ft32 uart dirver class */
  37. struct ft32_uart
  38. {
  39. USART_InitTypeDef Init;
  40. struct ft32_uart_config *config;
  41. #ifdef RT_SERIAL_USING_DMA
  42. struct
  43. {
  44. DMA_InitTypeDef Init;
  45. DMA_Channel_TypeDef *Instance;
  46. rt_size_t last_index;
  47. } dma_rx;
  48. struct
  49. {
  50. DMA_InitTypeDef Init;
  51. DMA_Channel_TypeDef *Instance;
  52. } dma_tx;
  53. #endif
  54. rt_uint16_t uart_dma_flag;
  55. struct rt_serial_device serial;
  56. };
  57. #endif /* __DRV_USART_H__ */