stm32f1_dma.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. #ifndef _STM32F1_DMA_H_
  2. #define _STM32F1_DMA_H_
  3. /*
  4. * Copyright (C) 2010 by Ulrich Prinz (uprinz2@netscape.net)
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. */
  35. /*!
  36. * \verbatim
  37. * $Id: ih_stm32_usart1.c 3131 2010-09-22 21:47:23Z Astralix $
  38. * \endverbatim
  39. */
  40. /*!
  41. * \brief DMA Channel Naming
  42. *
  43. * These defines keep Nut/OS internal channel numbering
  44. * aligned with the STM32 documentation RM0008.
  45. */
  46. #include <cfg/devices.h>
  47. #define DMA1_CH1 0
  48. #define DMA1_CH2 1
  49. #define DMA1_CH3 2
  50. #define DMA1_CH4 3
  51. #define DMA1_CH5 4
  52. #define DMA1_CH6 5
  53. #define DMA1_CH7 6
  54. #define STM_HAS_DMA1 7
  55. #define DMA2_CH1 7
  56. #define DMA2_CH2 8
  57. #define DMA2_CH3 9
  58. #define DMA2_CH4 10
  59. /* FIXME: Some F1 devices have C4 and C5 coupled*/
  60. #define DMA2_CH5 11
  61. #if defined(HW_DMA2_STM32F1)
  62. #define STM_HAS_DMA2 5
  63. #endif
  64. #define ADC1_DMA_DMA DMA1_CH1
  65. #define ADC1_DMA_DMA_SIG sig_DMA1_CH1
  66. #define TIM2_CH3_DMA DMA1_CH1
  67. #define TIM2_CH3_DMA_IRQ sig_DMA1_CH1
  68. #define TIM4_CH1_DMA DMA1_CH1
  69. #define TIM4_CH1_DMA_IRQ sig_DMA1_CH1
  70. #define TIM17_CH1_UP_DMA DMA1_CH1
  71. #define TIM17_CH1_UP_DMA_IRQ sig_DMA1_CH1
  72. #define TIM19_CH3_CH4_DMA DMA1_CH1
  73. #define TIM19_CH3_CH4_DMA_IRQ sig_DMA1_CH1
  74. #define SPI1_RX_DMA DMA1_CH2
  75. #define SPI1_RX_DMA_IRQ sig_DMA1_CH2
  76. #define USART3_TX_DMA DMA1_CH2
  77. #define USART3_TX_DMA_IRQ sig_DMA1_CH2
  78. #define TIM2_UP_DMA DMA1_CH2
  79. #define TIM2_UP_DMA_IRQ sig_DMA1_CH2
  80. #define TIM3_CH3_DMA DMA1_CH2
  81. #define TIM3_CH3_DMA_IRQ sig_DMA1_CH2
  82. #define TIM19_CH1_DMA DMA1_CH2
  83. #define TIM19_CH1_DMA_IRQ sig_DMA1_CH2
  84. #define SPI1_TX_DMA DMA1_CH3
  85. #define SPI1_TX_DMA_IRQ sig_DMA1_CH3
  86. #define USART3_RX_DMA DMA1_CH3
  87. #define USART3_RX_DMA_IRQ sig_DMA1_CH3
  88. #define TIM3_CH4_UP_DMA DMA1_CH3
  89. #define TIM3_CH4_UP_DMA_IRQ sig_DMA1_CH3
  90. #define TIM6_UP_DAC1_CH1_DMA DMA1_CH3
  91. #define TIM6_UP_DAC1_CH1_DMA_IRQ sig_DMA1_CH3
  92. #define TIM15_CH1_UP_DMA DMA1_CH3
  93. #define TIM15_CH1_UP_DMA_IRQ sig_DMA1_CH3
  94. #define TIM19_CH2_DMA DMA1_CH3
  95. #define TIM19_CH2_DMA_IRQ sig_DMA1_CH3
  96. #define SPI2_RX_DMA DMA1_CH4
  97. #define SPI2_RX_DMA_IRQ sig_DMA1_CH4
  98. #define USART1_TX_DMA DMA1_CH4
  99. #define USART1_TX_DMA_IRQ sig_DMA1_CH4
  100. #define TIM4_CH2_DMA DMA1_CH4
  101. #define TIM4_CH2_DMA_IRQ sig_DMA1_CH4
  102. #define TIM7_UP_DAC1_CH2_DMA DMA1_CH4
  103. #define TIM7_UP_DAC1_CH2_DMA_IRQ sig_DMA1_CH4
  104. #define TIM19_UP_DMA DMA1_CH4
  105. #define TIM19_UP_DMA_IRQ sig_DMA1_CH4
  106. #define SPI2_TX_DMA DMA1_CH5
  107. #define SPI2_TX_DMA_IRQ sig_DMA1_CH5
  108. #define USART1_RX_DMA DMA1_CH5
  109. #define USART1_RX_DMA_IRQ sig_DMA1_CH5
  110. #define TIM1_CH1_DMA DMA1_CH5
  111. #define TIM1_CH1_DMA_IRQ sig_DMA1_CH5
  112. #define TIM4_CH3_DMA DMA1_CH5
  113. #define TIM4_CH3_DMA_IRQ sig_DMA1_CH5
  114. #define TIM18_UP_DAC2_CH1_DMA DMA1_CH5
  115. #define TIM18_UP_DAC2_CH1_DMA_IRQ sig_DMA1_CH5
  116. #define TIM15_CH1_UP_TRIG_COM_DMA DMA1_CH5
  117. #define TIM15_CH1_UP_TRIG_COM_DMA_IRQ sig_DMA1_CH5
  118. #define USART2_RX_DMA DMA1_CH6
  119. #define USART2_RX_DMA_IRQ sig_DMA1_CH6
  120. #define I2C1_TX_DMA DMA1_CH6
  121. #define I2C1_TX_DMA_IRQ sig_DMA1_CH6
  122. #define TIM3_CH1_TRIG_DMA DMA1_CH6
  123. #define TIM3_CH1_TRIG_DMA_IRQ sig_DMA1_CH6
  124. #define TIM16_CH1_UP_DMA DMA1_CH6
  125. #define TIM16_CH1_UP_DMA_IRQ sig_DMA1_CH6
  126. #define USART2_TX_DMA DMA1_CH7
  127. #define USART2_TX_DMA_IRQ sig_DMA1_CH7
  128. #define I2C1_RX_DMA DMA1_CH7
  129. #define I2C1_RX_DMA_IRQ sig_DMA1_CH7
  130. #define TIM2_CH2_CH4_DMA DMA1_CH7
  131. #define TIM2_CH2_CH4_DMA_IRQ sig_DMA1_CH7
  132. #define TIM4_UP_DMA DMA1_CH7
  133. #define TIM4_UP_DMA_IRQ sig_DMA1_CH7
  134. #define TIM17_CH1_UP_ALT_DMA DMA1_CH7
  135. #define TIM17_CH1_UP_ALT_DMA_IRQ sig_DMA1_CH7
  136. #define SPI3_RX_DMA DMA2_CH1
  137. #define SPI3_RX_DMA_IRQ sig_DMA2_CH1
  138. #define TIM5_CH4_TRIG_DMA DMA2_CH1
  139. #define TIM5_CH4_TRIG_DMA_IRQ sig_DMA2_CH1
  140. #define SPI3_TX_DMA DMA2_CH2
  141. #define SPI3_TX_DMA_IRQ sig_DMA2_CH2
  142. #define TIM5_CH3_UP_DMA DMA2_CH2
  143. #define TIM5_CH3_UP_DMA_IRQ sig_DMA2_CH2
  144. #define SDADC1_DMA DMA2_CH3
  145. #define SDADC1_DMA_IRQ sig_DMA2_CH3
  146. #define TIM6_UP_DAC1_CH1_ALT_DMA DMA2_CH3
  147. #define TIM6_UP_DAC1_CH1_ALT_DMA_IRQ sig_DMA2_CH3
  148. #define SDADC2_DMA DMA2_CH4
  149. #define SDADC2_DMA_IRQ sig_DMA2_CH4
  150. #define TIM5_CH2_DMA DMA2_CH4
  151. #define TIM5_CH2_DMA_IRQ sig_DMA2_CH4
  152. #define TIM7_UP_DAC1_CH2_ALT_DMA DMA2_CH4
  153. #define TIM7_UP_DAC1_CH2_ALT_DMA_IRQ sig_DMA2_CH4
  154. #define SDADC3_DMA DMA2_CH5
  155. #define SDADC3_DMA_IRQ sig_DMA2_CH5
  156. #define TIM5_CH1 DMA2_CH5
  157. #define TIM5_CH1_IRQ sig_DMA2_CH5
  158. #define TIM18_UP_DAC2_CH1_ALT_DMA DMA2_CH5
  159. #define TIM18_UP_DAC2_CH1_ALT_DMA_IRQ sig_DMA2_CH5
  160. /* RM0008 defines the bits for CCR1, CCR2 etc. only.
  161. * Equalize the names by using the general names from STM32F3*/
  162. #if !defined(DMA_CCR_EN) && defined(DMA_CCR1_EN)
  163. #define DMA_CCR_EN DMA_CCR1_EN
  164. #endif
  165. #if !defined(DMA_CCR_TCIE) && defined(DMA_CCR1_TCIE)
  166. #define DMA_CCR_TCIE DMA_CCR1_TCIE
  167. #endif
  168. #if !defined(DMA_CCR_HTIE) && defined(DMA_CCR1_HTIE)
  169. #define DMA_CCR_HTIE DMA_CCR1_HTIE
  170. #endif
  171. #if !defined(DMA_CCR_TEIE) && defined(DMA_CCR1_TEIE)
  172. #define DMA_CCR_TEIE DMA_CCR1_TEIE
  173. #endif
  174. #if !defined(DMA_CCR_DIR) && defined(DMA_CCR1_DIR)
  175. #define DMA_CCR_DIR DMA_CCR1_DIR
  176. #endif
  177. #if !defined(DMA_CCR_CIRC) && defined(DMA_CCR1_CIRC)
  178. #define DMA_CCR_CIRC DMA_CCR1_CIRC
  179. #endif
  180. #if !defined(DMA_CCR_PINC) && defined(DMA_CCR1_PINC)
  181. #define DMA_CCR_PINC DMA_CCR1_PINC
  182. #endif
  183. #if !defined(DMA_CCR_MINC) && defined(DMA_CCR1_MINC)
  184. #define DMA_CCR_MINC DMA_CCR1_MINC
  185. #endif
  186. #if !defined(DMA_CCR_PSIZE) && defined(DMA_CCR1_PSIZE)
  187. #define DMA_CCR_PSIZE DMA_CCR1_PSIZE
  188. #endif
  189. #if !defined(DMA_CCR_PSIZE_0) && defined(DMA_CCR1_PSIZE_0)
  190. #define DMA_CCR_PSIZE_0 DMA_CCR1_PSIZE_0
  191. #endif
  192. #if !defined(DMA_CCR_PSIZE_1) && defined(DMA_CCR1_PSIZE_1)
  193. #define DMA_CCR_PSIZE_1 DMA_CCR1_PSIZE_1
  194. #endif
  195. #if !defined(DMA_CCR_MSIZE) && defined(DMA_CCR1_MSIZE)
  196. #define DMA_CCR_MSIZE DMA_CCR1_MSIZE
  197. #endif
  198. #if !defined(DMA_CCR_MSIZE_0) && defined(DMA_CCR1_MSIZE_0)
  199. #define DMA_CCR_MSIZE_0 DMA_CCR1_MSIZE_0
  200. #endif
  201. #if !defined(DMA_CCR_MSIZE_1) && defined(DMA_CCR1_MSIZE_1)
  202. #define DMA_CCR_MSIZE_1 DMA_CCR1_MSIZE_1
  203. #endif
  204. #if !defined(DMA_CCR_PL) && defined(DMA_CCR1_PL)
  205. #define DMA_CCR_PL DMA_CCR1_PL
  206. #endif
  207. #if !defined(DMA_CCR_PL_0) && defined(DMA_CCR1_PL_0)
  208. #define DMA_CCR_PL_0 DMA_CCR1_PL_0
  209. #endif
  210. #if !defined(DMA_CCR_PL_1) && defined(DMA_CCR1_PL_1)
  211. #define DMA_CCR_PL_1 DMA_CCR1_PL_1
  212. #endif
  213. #if !defined(DMA_CCR_MEM2MEM) && defined(DMA_CCR1_MEM2MEM)
  214. #define DMA_CCR_MEM2MEM DMA_CCR1_MEM2MEM
  215. #endif
  216. #define DMA_MINC DMA_CCR_MINC
  217. #define DMA_CIRC DMA_CCR_CIRC
  218. /* Internally used struct and table to align
  219. * DMA channels and interrupts. */
  220. typedef struct {
  221. uint32_t dma; /*< DMA Controller Register Base Address */
  222. uint32_t fofs; /*< DMA Channel Flags Offset */
  223. DMA_Channel_TypeDef* dma_ch; /*< DMA Channel Register Base Address */
  224. } DMATAB;
  225. extern const DMATAB DmaTab[];
  226. #endif /* _STM32F1_DMA_H_ */