sys_dma.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /** @file dma.h
  2. * @brief DMA Driver Definition File
  3. * @date 29.May.2013
  4. * @version 03.05.02
  5. *
  6. */
  7. /* (c) Texas Instruments 2009-2013, All rights reserved. */
  8. #ifndef __DMA_H__
  9. #define __DMA_H__
  10. #include "reg_dma.h"
  11. /* dma configuration definitions */
  12. #define BLOCK_TRANSFER 1U
  13. #define FRAME_TRANSFER 0U
  14. #define AUTOINIT_ON 1U
  15. #define AUTOINIT_OFF 0U
  16. #define ADDR_FIXED 0U
  17. #define ADDR_INC1 1U
  18. #define ADDR_RESERVED 2U
  19. #define ADDR_OFFSET 3U
  20. #define INTERRUPT_ENABLE 1U
  21. #define INTERRUPT_DISABLE 0U
  22. /*Bit Masks*/
  23. #define DMA_GCTRL_BUSBUSY (1U << 14U)
  24. /** @enum dmaREQTYPE
  25. * @brief DMA TRANSFER Type definitions
  26. *
  27. * Used to define DMA transfer type
  28. */
  29. enum dmaREQTYPE
  30. {
  31. DMA_HW = 0x0U, /**< Hardware trigger */
  32. DMA_SW = 0x1U /**< Software trigger */
  33. };
  34. /** @enum dmaCHANNEL
  35. * @brief DMA CHANNEL definitions
  36. *
  37. * Used to define DMA Channel Number
  38. */
  39. enum dmaCHANNEL
  40. {
  41. DMA_CH0 = 0x00U,
  42. DMA_CH1 = 0x01U,
  43. DMA_CH2 = 0x02U,
  44. DMA_CH3 = 0x03U,
  45. DMA_CH4 = 0x04U,
  46. DMA_CH5 = 0x05U,
  47. DMA_CH6 = 0x06U,
  48. DMA_CH7 = 0x07U,
  49. DMA_CH8 = 0x08U,
  50. DMA_CH9 = 0x09U,
  51. DMA_CH10 = 0x0AU,
  52. DMA_CH11 = 0x0BU,
  53. DMA_CH12 = 0x0CU,
  54. DMA_CH13 = 0x0DU,
  55. DMA_CH14 = 0x0EU,
  56. DMA_CH15 = 0x0FU,
  57. DMA_CH16 = 0x10U,
  58. DMA_CH17 = 0x11U,
  59. DMA_CH18 = 0x12U,
  60. DMA_CH19 = 0x13U,
  61. DMA_CH20 = 0x14U,
  62. DMA_CH21 = 0x15U,
  63. DMA_CH22 = 0x16U,
  64. DMA_CH23 = 0x17U,
  65. DMA_CH24 = 0x18U,
  66. DMA_CH25 = 0x19U,
  67. DMA_CH26 = 0x1AU,
  68. DMA_CH27 = 0x1BU,
  69. DMA_CH28 = 0x1CU,
  70. DMA_CH29 = 0x1DU,
  71. DMA_CH30 = 0x1EU,
  72. DMA_CH31 = 0x1FU,
  73. DMA_CH32 = 0x20U
  74. };
  75. /** @enum dmaACCESS
  76. * @brief DMA ACESS WIDTH definitions
  77. *
  78. * Used to define DMA access width
  79. */
  80. typedef enum dmaACCESS
  81. {
  82. ACCESS_8_BIT = 0U,
  83. ACCESS_16_BIT = 1U,
  84. ACCESS_32_BIT = 2U,
  85. ACCESS_64_BIT = 3U
  86. }dmaACCESS_t;
  87. /** @enum dmaPRIORITY
  88. * @brief DMA Channel Priority
  89. *
  90. * Used to define to which priority queue a DMA channel is assigned to
  91. */
  92. typedef enum dmaPRIORITY
  93. {
  94. LOWPRIORITY = 0U,
  95. HIGHPRIORITY = 1U
  96. }dmaPRIORITY_t;
  97. /** @enum dmaREGION
  98. * @brief DMA Memory Protection Region
  99. *
  100. * Used to define DMA Memory Protection Region
  101. */
  102. typedef enum dmaREGION
  103. {
  104. DMA_REGION0 = 0U,
  105. DMA_REGION1 = 1U,
  106. DMA_REGION2 = 2U,
  107. DMA_REGION3 = 3U
  108. }dmaREGION_t;
  109. /** @enum dmaRegionAccess
  110. * @brief DMA Memory Protection Region Access
  111. *
  112. * Used to define access permission of DMA memory protection regions
  113. */
  114. typedef enum dmaRegionAccess
  115. {
  116. FULLACCESS = 0U,
  117. READONLY = 1U,
  118. WRITEONLY = 2U,
  119. NOACCESS = 3U
  120. }dmaRegionAccess_t;
  121. /** @enum dmaInterrupt
  122. * @brief DMA Interrupt
  123. *
  124. * Used to define DMA interrupts
  125. */
  126. typedef enum dmaInterrupt
  127. {
  128. FTC = 1U, /**< Frame transfer complete Interrupt */
  129. LFS = 2U, /**< Last frame transfer started Interrupt */
  130. HBC = 3U, /**< First half of block complete Interrupt */
  131. BTC = 4U /**< Block transfer complete Interrupt */
  132. }dmaInterrupt_t;
  133. /** @struct g_dmaCTRL
  134. * @brief Interrupt mode globals
  135. *
  136. */
  137. typedef struct dmaCTRLPKT
  138. {
  139. uint32 SADD; /* initial source address */
  140. uint32 DADD; /* initial destination address */
  141. uint32 CHCTRL; /* channel count */
  142. uint32 FRCNT; /* frame count */
  143. uint32 ELCNT; /* element count */
  144. uint32 ELDOFFSET; /* element destination offset */
  145. uint32 ELSOFFSET; /* element source offset */
  146. uint32 FRDOFFSET; /* frame detination offset */
  147. uint32 FRSOFFSET; /* frame source offset */
  148. uint32 PORTASGN; /* dma port */
  149. uint32 RDSIZE; /* read element size */
  150. uint32 WRSIZE; /* write element size */
  151. uint32 TTYPE; /* trigger type - frame/block */
  152. uint32 ADDMODERD; /* addresssing mode for source */
  153. uint32 ADDMODEWR; /* addresssing mode for destination */
  154. uint32 AUTOINIT; /* auto-init mode */
  155. uint32 COMBO; /* next ctrl packet trigger */
  156. } g_dmaCTRL;
  157. typedef volatile struct
  158. {
  159. struct /* 0x000-0x400 */
  160. {
  161. uint32 ISADDR;
  162. uint32 IDADDR;
  163. uint32 ITCOUNT;
  164. uint32 rsvd1;
  165. uint32 CHCTRL;
  166. uint32 EIOFF;
  167. uint32 FIOFF;
  168. uint32 rsvd2;
  169. }PCP[32U];
  170. struct /* 0x400-0x800 */
  171. {
  172. uint32 res[256U];
  173. } RESERVED;
  174. struct /* 0x800-0xA00 */
  175. {
  176. uint32 CSADDR;
  177. uint32 CDADDR;
  178. uint32 CTCOUNT;
  179. uint32 rsvd3;
  180. }WCP[32U];
  181. } dmaRAMBASE_t;
  182. #define dmaRAMREG ((dmaRAMBASE_t *)0xFFF80000U)
  183. /**
  184. * @defgroup DMA DMA
  185. * @brief Direct Memory Access Controller
  186. *
  187. * The DMA controller is used to transfer data between two locations in the memory map in the background
  188. * of CPU operations. Typically, the DMA is used to:
  189. * - Transfer blocks of data between external and internal data memories
  190. * - Restructure portions of internal data memory
  191. * - Continually service a peripheral
  192. * - Page program sections to internal program memory
  193. *
  194. * Related files:
  195. * - reg_dma.h
  196. * - sys_dma.h
  197. * - sys_dma.c
  198. *
  199. * @addtogroup DMA
  200. * @{
  201. */
  202. /* DMA Interface Functions */
  203. void dmaEnable(void);
  204. void dmaDisable(void);
  205. void dmaSetCtrlPacket(uint32 channel, g_dmaCTRL g_dmaCTRLPKT);
  206. void dmaSetChEnable(uint32 channel,uint32 type);
  207. void dmaReqAssign(uint32 channel,uint32 reqline);
  208. uint32 dmaGetReq(uint32 channel);
  209. void dmaSetPriority(uint32 channel, dmaPRIORITY_t priority);
  210. void dmaEnableInterrupt(uint32 channel, dmaInterrupt_t inttype);
  211. void dmaDisableInterrupt(uint32 channel, dmaInterrupt_t inttype);
  212. void dmaDefineRegion(dmaREGION_t region, uint32 start_add, uint32 end_add);
  213. void dmaEnableRegion(dmaREGION_t region, dmaRegionAccess_t access, boolean intenable);
  214. void dmaDisableRegion(dmaREGION_t region);
  215. void dmaEnableParityCheck(void);
  216. void dmaDisableParityCheck(void);
  217. /** @fn void dmaGroupANotification(dmaInterrupt_t inttype, sint32 channel)
  218. * @brief Interrupt callback
  219. * @param[in] inttype Interrupt type
  220. * - FTC
  221. * - LFS
  222. * - HBC
  223. * - BTC
  224. * @param[in] channel channel number 0..15
  225. * This is a callback that is provided by the application and is called apon
  226. * an interrupt. The parameter passed to the callback is a copy of the
  227. * interrupt flag register.
  228. */
  229. void dmaGroupANotification(dmaInterrupt_t inttype, sint32 channel);
  230. /**@}*/
  231. #endif