drv_usart.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. * 2021-08-20 BruceOu first implementation
  9. */
  10. #ifndef __DRV_USART_H__
  11. #define __DRV_USART_H__
  12. #include <rthw.h>
  13. #include <rtthread.h>
  14. #include <board.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #define UART_ENABLE_IRQ(n) NVIC_EnableIRQ((n))
  19. #define UART_DISABLE_IRQ(n) NVIC_DisableIRQ((n))
  20. /* GD32 uart driver */
  21. // Todo: compress uart info
  22. struct gd32_uart
  23. {
  24. uint32_t uart_periph; //Todo: 3bits
  25. IRQn_Type irqn; //Todo: 7bits
  26. rcu_periph_enum per_clk; //Todo: 5bits
  27. rcu_periph_enum tx_gpio_clk; //Todo: 5bits
  28. rcu_periph_enum rx_gpio_clk; //Todo: 5bits
  29. uint32_t tx_port; //Todo: 4bits
  30. #if defined SOC_SERIES_GD32F4xx
  31. uint16_t tx_af; //Todo: 4bits
  32. #endif
  33. uint16_t tx_pin; //Todo: 4bits
  34. uint32_t rx_port; //Todo: 4bits
  35. #if defined SOC_SERIES_GD32F4xx
  36. uint16_t rx_af; //Todo: 4bits
  37. #endif
  38. uint16_t rx_pin; //Todo: 4bits
  39. struct rt_serial_device * serial;
  40. char *device_name;
  41. };
  42. #ifdef __cplusplus
  43. }
  44. #endif
  45. #endif /* __DRV_USART_H__ */