spi_config.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-11-06 SummerGift change to new framework
  9. */
  10. #ifndef __SPI_CONFIG_H__
  11. #define __SPI_CONFIG_H__
  12. #include <rtthread.h>
  13. #ifdef BSP_USING_SPI1
  14. #define SPI1_BUS_CONFIG \
  15. { \
  16. .Instance = SPI1, \
  17. .bus_name = "spi1", \
  18. .dma_rx.dma_rcc = RCC_AHB1ENR_DMA2EN, \
  19. .dma_tx.dma_rcc = RCC_AHB1ENR_DMA2EN, \
  20. .dma_rx.Instance = DMA2_Stream2, \
  21. .dma_rx.channel = DMA_CHANNEL_3, \
  22. .dma_rx.dma_irq = DMA2_Stream2_IRQn, \
  23. .dma_tx.Instance = DMA2_Stream3, \
  24. .dma_tx.channel = DMA_CHANNEL_3, \
  25. .dma_tx.dma_irq = DMA2_Stream3_IRQn, \
  26. }
  27. #define SPI1_DMA_RX_IRQHandler DMA2_Stream2_IRQHandler
  28. #define SPI1_DMA_TX_IRQHandler DMA2_Stream3_IRQHandler
  29. #endif
  30. #ifdef BSP_USING_SPI2
  31. #define SPI2_BUS_CONFIG \
  32. { \
  33. .Instance = SPI2, \
  34. .bus_name = "spi2", \
  35. .dma_rx.dma_rcc = RCC_AHB1ENR_DMA1EN, \
  36. .dma_tx.dma_rcc = RCC_AHB1ENR_DMA1EN, \
  37. .dma_rx.Instance = DMA1_Stream3, \
  38. .dma_rx.channel = DMA_CHANNEL_0, \
  39. .dma_rx.dma_irq = DMA1_Stream3_IRQn, \
  40. .dma_tx.Instance = DMA1_Stream4, \
  41. .dma_tx.channel = DMA_CHANNEL_0, \
  42. .dma_tx.dma_irq = DMA1_Stream4_IRQn, \
  43. }
  44. #define SPI2_DMA_RX_IRQHandler DMA1_Stream3_IRQHandler
  45. #define SPI2_DMA_TX_IRQHandler DMA1_Stream4_IRQHandler
  46. #endif
  47. #ifdef BSP_USING_SPI3
  48. #define SPI3_BUS_CONFIG \
  49. { \
  50. .Instance = SPI3, \
  51. .bus_name = "spi3", \
  52. .dma_rx.dma_rcc = RCC_AHB1ENR_DMA1EN, \
  53. .dma_tx.dma_rcc = RCC_AHB1ENR_DMA1EN, \
  54. .dma_rx.Instance = DMA1_Stream0, \
  55. .dma_rx.channel = DMA_CHANNEL_0, \
  56. .dma_rx.dma_irq = DMA1_Stream0_IRQn, \
  57. .dma_tx.Instance = DMA1_Stream7, \
  58. .dma_tx.channel = DMA_CHANNEL_0, \
  59. .dma_tx.dma_irq = DMA1_Stream7_IRQn, \
  60. }
  61. #define SPI3_DMA_RX_IRQHandler DMA1_Stream0_IRQHandler
  62. #define SPI3_DMA_TX_IRQHandler DMA1_Stream7_IRQHandler
  63. #endif
  64. #ifdef BSP_USING_SPI4
  65. #define SPI4_BUS_CONFIG \
  66. { \
  67. .Instance = SPI4, \
  68. .bus_name = "spi4", \
  69. .dma_rx.dma_rcc = RCC_AHB1ENR_DMA2EN, \
  70. .dma_tx.dma_rcc = RCC_AHB1ENR_DMA2EN, \
  71. .dma_rx.Instance = DMA2_Stream0, \
  72. .dma_rx.channel = DMA_CHANNEL_4, \
  73. .dma_rx.dma_irq = DMA2_Stream0_IRQn, \
  74. .dma_tx.Instance = DMA2_Stream1, \
  75. .dma_tx.channel = DMA_CHANNEL_4, \
  76. .dma_tx.dma_irq = DMA2_Stream1_IRQn, \
  77. }
  78. #define SPI4_DMA_RX_IRQHandler DMA2_Stream0_IRQHandler
  79. #define SPI4_DMA_TX_IRQHandler DMA2_Stream1_IRQHandler
  80. #endif
  81. #ifdef BSP_USING_SPI5
  82. #define SPI5_BUS_CONFIG \
  83. { \
  84. .Instance = SPI5, \
  85. .bus_name = "spi5", \
  86. .dma_rx.dma_rcc = RCC_AHB1ENR_DMA2EN, \
  87. .dma_tx.dma_rcc = RCC_AHB1ENR_DMA2EN, \
  88. .dma_rx.Instance = DMA2_Stream3, \
  89. .dma_rx.channel = DMA_CHANNEL_2, \
  90. .dma_rx.dma_irq = DMA2_Stream3_IRQn, \
  91. .dma_tx.Instance = DMA2_Stream4, \
  92. .dma_tx.channel = DMA_CHANNEL_2, \
  93. .dma_tx.dma_irq = DMA2_Stream4_IRQn, \
  94. }
  95. #define SPI5_DMA_RX_IRQHandler DMA2_Stream3_IRQHandler
  96. #define SPI5_DMA_TX_IRQHandler DMA2_Stream4_IRQHandler
  97. #endif
  98. #ifdef BSP_USING_SPI6
  99. #define SPI5_BUS_CONFIG \
  100. { \
  101. .Instance = SPI6, \
  102. .bus_name = "spi6", \
  103. .dma_rx.dma_rcc = RCC_AHB1ENR_DMA2EN, \
  104. .dma_tx.dma_rcc = RCC_AHB1ENR_DMA2EN, \
  105. .dma_rx.Instance = DMA2_Stream6, \
  106. .dma_rx.channel = DMA_CHANNEL_1, \
  107. .dma_rx.dma_irq = DMA2_Stream6_IRQn, \
  108. .dma_tx.Instance = DMA2_Stream5, \
  109. .dma_tx.channel = DMA_CHANNEL_1, \
  110. .dma_tx.dma_irq = DMA2_Stream5_IRQn, \
  111. }
  112. #define SPI6_DMA_RX_IRQHandler DMA2_Stream6_IRQHandler
  113. #define SPI6_DMA_TX_IRQHandler DMA2_Stream5_IRQHandler
  114. #endif
  115. #endif /*__SPI_CONFIG_H__ */