drv_dma.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2006-2024, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-03-19 Evlers first implementation
  9. */
  10. #ifndef _DRV_DMA_H_
  11. #define _DRV_DMA_H_
  12. #if defined SOC_SERIES_GD32E23x
  13. #define DRV_DMA_CONFIG(chx) \
  14. (struct dma_config) { \
  15. .periph = DMA, \
  16. .rcu = RCU_DMA, \
  17. .channel = DMA_CH##chx, \
  18. .irq = ((chx) == 0 ? DMA_Channel0_IRQn : \
  19. (chx) == 1 ? DMA_Channel1_2_IRQn : \
  20. (chx) == 2 ? DMA_Channel1_2_IRQn : \
  21. (chx) == 3 ? DMA_Channel3_4_IRQn : \
  22. (chx) == 4 ? DMA_Channel3_4_IRQn : (IRQn_Type)0) \
  23. }
  24. struct dma_config
  25. {
  26. uint32_t periph;
  27. rcu_periph_enum rcu;
  28. dma_channel_enum channel;
  29. IRQn_Type irq;
  30. };
  31. #else
  32. #define DRV_DMA_CONFIG(dmax, chx, subx) { \
  33. .periph = DMA##dmax, \
  34. .channel = DMA_CH##chx, \
  35. .rcu = RCU_DMA##dmax, \
  36. .subperiph = DMA_SUBPERI##subx, \
  37. .irq = DMA##dmax##_Channel##chx##_IRQn, \
  38. }
  39. struct dma_config
  40. {
  41. uint32_t periph;
  42. rcu_periph_enum rcu;
  43. dma_channel_enum channel;
  44. dma_subperipheral_enum subperiph;
  45. IRQn_Type irq;
  46. };
  47. #endif
  48. #endif /* _DRV_DMA_H_ */