drv_uart.h 979 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2020-2022, CQ 100ask Development Team
  3. *
  4. * Change Logs:
  5. * Date Author Notes
  6. * 2022-05-29 Alen first version
  7. */
  8. #ifndef __DRV_USART_H__
  9. #define __DRV_USART_H__
  10. #include <rtthread.h>
  11. #include "rtdevice.h"
  12. #include <rthw.h>
  13. #include <drv_common.h>
  14. int rt_hw_uart_init(void);
  15. #define DMA_INSTANCE_TYPE MA_Channel_TypeDef
  16. #define UART_INSTANCE_CLEAR_FUNCTION __HAL_UART_CLEAR_FLAG
  17. /* mm32 config class */
  18. struct mm32_uart_config
  19. {
  20. const char *name;
  21. UART_Type *Instance;
  22. IRQn_Type irq_type;
  23. struct dma_config *dma_rx;
  24. struct dma_config *dma_tx;
  25. };
  26. /* mm32 uart dirver class */
  27. struct mm32_uart
  28. {
  29. UART_Init_Type handle;
  30. struct mm32_uart_config *config;
  31. #ifdef RT_SERIAL_USING_DMA
  32. struct
  33. {
  34. DMA_Type handle;
  35. rt_size_t last_index;
  36. } dma_rx;
  37. #endif
  38. rt_uint16_t uart_dma_flag;
  39. struct rt_serial_device serial;
  40. };
  41. #endif /* __DRV_USART_H__ */