drv_usart.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #if defined(SOC_SERIES_FT32F4)
  24. #define UART_INSTANCE_CLEAR_FUNCTION USART_ClearFlag
  25. #endif
  26. #define USART_TX_Pin GPIO_PIN_2
  27. #define USART_TX_GPIO_Port GPIOA
  28. #define USART_RX_Pin GPIO_PIN_3
  29. #define USART_RX_GPIO_Port GPIOA
  30. /* ft32 config class */
  31. struct ft32_uart_config
  32. {
  33. const char *name;
  34. USART_TypeDef *Instance;
  35. IRQn_Type irq_type;
  36. struct dma_config *dma_rx;
  37. struct dma_config *dma_tx;
  38. };
  39. /* ft32 uart dirver class */
  40. struct ft32_uart
  41. {
  42. USART_InitTypeDef Init;
  43. struct ft32_uart_config *config;
  44. rt_uint16_t uart_dma_flag;
  45. struct rt_serial_device serial;
  46. };
  47. #endif /* __DRV_USART_H__ */