drv_usart.h 1016 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-08-27 liYony the 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. /* Do not use GPIO_Remap*/
  16. #define GPIO_Remap_NONE 0
  17. /* ch32 hardware config class */
  18. struct ch32_uart_hw_config
  19. {
  20. rt_uint32_t uart_periph_clock;
  21. rt_uint32_t gpio_periph_clock;
  22. GPIO_TypeDef *tx_gpio_port;
  23. rt_uint16_t tx_gpio_pin;
  24. GPIO_TypeDef *rx_gpio_port;
  25. rt_uint16_t rx_gpio_pin;
  26. rt_uint32_t remap;
  27. };
  28. /* ch32 config class */
  29. struct ch32_uart_config
  30. {
  31. const char *name;
  32. USART_TypeDef *Instance;
  33. IRQn_Type irq_type;
  34. };
  35. /* ch32 uart dirver class */
  36. struct ch32_uart
  37. {
  38. struct ch32_uart_hw_config *hw_config;
  39. struct ch32_uart_config *config;
  40. USART_InitTypeDef Init;
  41. struct rt_serial_device serial;
  42. };
  43. int rt_hw_usart_init(void);
  44. #endif