F2837xD_Dma.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  1. //###########################################################################
  2. //
  3. // FILE: F2837xD_DMA.c
  4. //
  5. // TITLE: F2837xD Device DMA Initialization & Support Functions.
  6. //
  7. //###########################################################################
  8. // $TI Release: F2837xD Support Library v3.05.00.00 $
  9. // $Release Date: Tue Jun 26 03:15:23 CDT 2018 $
  10. // $Copyright:
  11. // Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/
  12. //
  13. // Redistribution and use in source and binary forms, with or without
  14. // modification, are permitted provided that the following conditions
  15. // are met:
  16. //
  17. // Redistributions of source code must retain the above copyright
  18. // notice, this list of conditions and the following disclaimer.
  19. //
  20. // Redistributions in binary form must reproduce the above copyright
  21. // notice, this list of conditions and the following disclaimer in the
  22. // documentation and/or other materials provided with the
  23. // distribution.
  24. //
  25. // Neither the name of Texas Instruments Incorporated nor the names of
  26. // its contributors may be used to endorse or promote products derived
  27. // from this software without specific prior written permission.
  28. //
  29. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. // $
  41. //###########################################################################
  42. //
  43. // Included Files
  44. //
  45. #include "F2837xD_device.h"
  46. #include "F2837xD_Examples.h"
  47. //
  48. // DMAInitialize - This function initializes the DMA to a known state.
  49. //
  50. void DMAInitialize(void)
  51. {
  52. EALLOW;
  53. //
  54. // Perform a hard reset on DMA
  55. //
  56. DmaRegs.DMACTRL.bit.HARDRESET = 1;
  57. __asm (" nop"); // one NOP required after HARDRESET
  58. //
  59. // Allow DMA to run free on emulation suspend
  60. //
  61. DmaRegs.DEBUGCTRL.bit.FREE = 1;
  62. EDIS;
  63. }
  64. //
  65. // DMACH1AddrConfig - DMA Channel 1 Address Configuration
  66. //
  67. void DMACH1AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
  68. {
  69. EALLOW;
  70. //
  71. // Set up SOURCE address:
  72. //
  73. DmaRegs.CH1.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to
  74. // beginning of
  75. // source buffer
  76. DmaRegs.CH1.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  77. //
  78. // Set up DESTINATION address:
  79. //
  80. DmaRegs.CH1.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to
  81. // beginning of
  82. // destination buffer
  83. DmaRegs.CH1.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  84. EDIS;
  85. }
  86. //
  87. // DMACH1BurstConfig - DMA Channel 1 Burst size configuration
  88. //
  89. void DMACH1BurstConfig(Uint16 bsize, int16 srcbstep, int16 desbstep)
  90. {
  91. EALLOW;
  92. //
  93. // Set up BURST registers:
  94. //
  95. DmaRegs.CH1.BURST_SIZE.all = bsize; // Number of words(X-1)
  96. // x-ferred in a burst.
  97. DmaRegs.CH1.SRC_BURST_STEP = srcbstep; // Increment source addr between
  98. // each word x-ferred.
  99. DmaRegs.CH1.DST_BURST_STEP = desbstep; // Increment dest addr between
  100. // each word x-ferred.
  101. EDIS;
  102. }
  103. //
  104. // DMACH1TransferConfig - DMA Channel 1 Transfer size configuration
  105. //
  106. void DMACH1TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
  107. {
  108. EALLOW;
  109. //
  110. // Set up TRANSFER registers:
  111. //
  112. DmaRegs.CH1.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
  113. // DMA interrupt will occur after
  114. // completed transfer.
  115. DmaRegs.CH1.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored
  116. // when WRAP occurs.
  117. DmaRegs.CH1.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored
  118. // when WRAP occurs.
  119. EDIS;
  120. }
  121. //
  122. // DMACH1WrapConfig - DMA Channel 1 Wrap size configuration
  123. //
  124. void DMACH1WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
  125. int16 deswstep)
  126. {
  127. EALLOW;
  128. //
  129. // Set up WRAP registers:
  130. //
  131. DmaRegs.CH1.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
  132. DmaRegs.CH1.SRC_WRAP_STEP = srcwstep; // Step for source wrap
  133. DmaRegs.CH1.DST_WRAP_SIZE = deswsize; // Wrap destination address after
  134. // N bursts.
  135. DmaRegs.CH1.DST_WRAP_STEP = deswstep; // Step for destination wrap
  136. EDIS;
  137. }
  138. //
  139. // DMACH1ModeConfig - DMA Channel 1 Mode configuration
  140. //
  141. void DMACH1ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
  142. Uint16 cont, Uint16 synce, Uint16 syncsel,
  143. Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
  144. Uint16 chinte)
  145. {
  146. EALLOW;
  147. //
  148. // Set up MODE Register:
  149. // persel - Source select
  150. // PERINTSEL - Should be hard coded to channel, above now selects source
  151. // PERINTE - Peripheral interrupt enable
  152. // ONESHOT - Oneshot enable
  153. // CONTINUOUS - Continuous enable
  154. // OVRINTE - Enable/disable the overflow interrupt
  155. // DATASIZE - 16-bit/32-bit data size transfers
  156. // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
  157. // CHINTE - Channel Interrupt to CPU enable
  158. //
  159. DmaClaSrcSelRegs.DMACHSRCSEL1.bit.CH1 = persel;
  160. DmaRegs.CH1.MODE.bit.PERINTSEL = 1;
  161. DmaRegs.CH1.MODE.bit.PERINTE = perinte;
  162. DmaRegs.CH1.MODE.bit.ONESHOT = oneshot;
  163. DmaRegs.CH1.MODE.bit.CONTINUOUS = cont;
  164. DmaRegs.CH1.MODE.bit.OVRINTE = ovrinte;
  165. DmaRegs.CH1.MODE.bit.DATASIZE = datasize;
  166. DmaRegs.CH1.MODE.bit.CHINTMODE = chintmode;
  167. DmaRegs.CH1.MODE.bit.CHINTE = chinte;
  168. //
  169. // Clear any spurious flags: interrupt and sync error flags
  170. //
  171. DmaRegs.CH1.CONTROL.bit.PERINTCLR = 1;
  172. DmaRegs.CH1.CONTROL.bit.ERRCLR = 1;
  173. //
  174. // Initialize PIE vector for CPU interrupt:
  175. // Enable DMA CH1 interrupt in PIE
  176. //
  177. PieCtrlRegs.PIEIER7.bit.INTx1 = 1;
  178. EDIS;
  179. }
  180. //
  181. // StartDMACH1 - This function starts DMA Channel 1.
  182. //
  183. void StartDMACH1(void)
  184. {
  185. EALLOW;
  186. DmaRegs.CH1.CONTROL.bit.RUN = 1;
  187. EDIS;
  188. }
  189. //
  190. // DMACH2AddrConfig - DMA Channel 2 Address Configuration
  191. //
  192. void DMACH2AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
  193. {
  194. EALLOW;
  195. //
  196. // Set up SOURCE address:
  197. //
  198. DmaRegs.CH2.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to
  199. // beginning of
  200. // source buffer.
  201. DmaRegs.CH2.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  202. //
  203. // Set up DESTINATION address:
  204. //
  205. DmaRegs.CH2.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
  206. // of destination
  207. // buffer.
  208. DmaRegs.CH2.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  209. EDIS;
  210. }
  211. //
  212. // DMACH2BurstConfig - DMA Channel 2 Burst size configuration
  213. //
  214. void DMACH2BurstConfig(Uint16 bsize, int16 srcbstep, int16 desbstep)
  215. {
  216. EALLOW;
  217. //
  218. // Set up BURST registers:
  219. //
  220. DmaRegs.CH2.BURST_SIZE.all = bsize; // Number of words(X-1) x-ferred in
  221. // a burst.
  222. DmaRegs.CH2.SRC_BURST_STEP = srcbstep; // Increment source addr between
  223. // each word x-ferred.
  224. DmaRegs.CH2.DST_BURST_STEP = desbstep; // Increment dest addr between each
  225. // word x-ferred.
  226. EDIS;
  227. }
  228. //
  229. // DMACH2TransferConfig - DMA Channel 2 Transfer size Configuration
  230. //
  231. void DMACH2TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
  232. {
  233. EALLOW;
  234. //
  235. // Set up TRANSFER registers:
  236. //
  237. DmaRegs.CH2.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
  238. // DMA interrupt will occur after
  239. // completed transfer.
  240. DmaRegs.CH2.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored when
  241. // WRAP occurs.
  242. DmaRegs.CH2.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored when
  243. // WRAP occurs.
  244. EDIS;
  245. }
  246. //
  247. // DMACH2WrapConfig - DMA Channel 2 Wrap size configuration
  248. //
  249. void DMACH2WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
  250. int16 deswstep)
  251. {
  252. EALLOW;
  253. //
  254. // Set up WRAP registers:
  255. //
  256. DmaRegs.CH2.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
  257. DmaRegs.CH2.SRC_WRAP_STEP = srcwstep; // Step for source wrap
  258. DmaRegs.CH2.DST_WRAP_SIZE = deswsize; // Wrap destination address after
  259. // N bursts.
  260. DmaRegs.CH2.DST_WRAP_STEP = deswstep; // Step for destination wrap
  261. EDIS;
  262. }
  263. //
  264. // DMACH2ModeConfig - DMA Channel 2 Mode configuration
  265. //
  266. void DMACH2ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
  267. Uint16 cont, Uint16 synce, Uint16 syncsel,
  268. Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
  269. Uint16 chinte)
  270. {
  271. EALLOW;
  272. //
  273. // Set up MODE Register:
  274. // persel - Source select
  275. // PERINTSEL - Should be hard coded to channel, above now selects source
  276. // PERINTE - Peripheral interrupt enable
  277. // ONESHOT - Oneshot enable
  278. // CONTINUOUS - Continuous enable
  279. // OVRINTE - Enable/disable the overflow interrupt
  280. // DATASIZE - 16-bit/32-bit data size transfers
  281. // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
  282. // CHINTE - Channel Interrupt to CPU enable
  283. //
  284. DmaClaSrcSelRegs.DMACHSRCSEL1.bit.CH2 = persel;
  285. DmaRegs.CH2.MODE.bit.PERINTSEL = 2;
  286. DmaRegs.CH2.MODE.bit.PERINTE = perinte;
  287. DmaRegs.CH2.MODE.bit.ONESHOT = oneshot;
  288. DmaRegs.CH2.MODE.bit.CONTINUOUS = cont;
  289. DmaRegs.CH2.MODE.bit.OVRINTE = ovrinte;
  290. DmaRegs.CH2.MODE.bit.DATASIZE = datasize;
  291. DmaRegs.CH2.MODE.bit.CHINTMODE = chintmode;
  292. DmaRegs.CH2.MODE.bit.CHINTE = chinte;
  293. //
  294. // Clear any spurious flags: Interrupt flags and sync error flags
  295. //
  296. DmaRegs.CH2.CONTROL.bit.PERINTCLR = 1;
  297. DmaRegs.CH2.CONTROL.bit.ERRCLR = 1;
  298. //
  299. // Initialize PIE vector for CPU interrupt:
  300. // Enable DMA CH2 interrupt in PIE
  301. //
  302. PieCtrlRegs.PIEIER7.bit.INTx2 = 1;
  303. EDIS;
  304. }
  305. //
  306. // StartDMACH2 - This function starts DMA Channel 2.
  307. //
  308. void StartDMACH2(void)
  309. {
  310. EALLOW;
  311. DmaRegs.CH2.CONTROL.bit.RUN = 1;
  312. EDIS;
  313. }
  314. //
  315. // DMACH3AddrConfig - DMA Channel 3 Address configuration
  316. //
  317. void DMACH3AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
  318. {
  319. EALLOW;
  320. //
  321. // Set up SOURCE address:
  322. //
  323. DmaRegs.CH3.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
  324. // of source buffer.
  325. DmaRegs.CH3.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  326. //
  327. // Set up DESTINATION address:
  328. //
  329. DmaRegs.CH3.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
  330. // of destination
  331. // buffer.
  332. DmaRegs.CH3.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  333. EDIS;
  334. }
  335. //
  336. // DMACH3BurstConfig - DMA Channel 3 burst size configuration
  337. //
  338. void DMACH3BurstConfig(Uint16 bsize, int16 srcbstep, int16 desbstep)
  339. {
  340. EALLOW;
  341. //
  342. // Set up BURST registers:
  343. //
  344. DmaRegs.CH3.BURST_SIZE.all = bsize; // Number of words(X-1) x-ferred in
  345. // a burst.
  346. DmaRegs.CH3.SRC_BURST_STEP = srcbstep; // Increment source addr between
  347. // each word x-ferred.
  348. DmaRegs.CH3.DST_BURST_STEP = desbstep; // Increment dest addr between each
  349. // word x-ferred.
  350. EDIS;
  351. }
  352. //
  353. // DMACH3TransferConfig - DMA channel 3 transfer size configuration
  354. //
  355. void DMACH3TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
  356. {
  357. EALLOW;
  358. //
  359. // Set up TRANSFER registers:
  360. //
  361. DmaRegs.CH3.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
  362. // DMA interrupt will occur after
  363. // completed transfer.
  364. DmaRegs.CH3.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored when
  365. // WRAP occurs.
  366. DmaRegs.CH3.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored when
  367. // WRAP occurs.
  368. EDIS;
  369. }
  370. //
  371. // DMACH3WrapConfig - DMA Channel 3 wrap size configuration
  372. //
  373. void DMACH3WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
  374. int16 deswstep)
  375. {
  376. EALLOW;
  377. //
  378. // Set up WRAP registers:
  379. //
  380. DmaRegs.CH3.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
  381. DmaRegs.CH3.SRC_WRAP_STEP = srcwstep; // Step for source wrap
  382. DmaRegs.CH3.DST_WRAP_SIZE = deswsize; // Wrap destination address after N
  383. // bursts.
  384. DmaRegs.CH3.DST_WRAP_STEP = deswstep; // Step for destination wrap
  385. EDIS;
  386. }
  387. //
  388. // DMACH3ModeConfig - DMA Channel 3 mode configuration
  389. //
  390. void DMACH3ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
  391. Uint16 cont, Uint16 synce, Uint16 syncsel,
  392. Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
  393. Uint16 chinte)
  394. {
  395. EALLOW;
  396. //
  397. // Set up MODE Register:
  398. // persel - Source select
  399. // PERINTSEL - Should be hard coded to channel, above now selects source
  400. // PERINTE - Peripheral interrupt enable
  401. // ONESHOT - Oneshot enable
  402. // CONTINUOUS - Continuous enable
  403. // OVRINTE - Enable/disable the overflow interrupt
  404. // DATASIZE - 16-bit/32-bit data size transfers
  405. // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
  406. // CHINTE - Channel Interrupt to CPU enable
  407. //
  408. DmaClaSrcSelRegs.DMACHSRCSEL1.bit.CH3 = persel;
  409. DmaRegs.CH3.MODE.bit.PERINTSEL = 3;
  410. DmaRegs.CH3.MODE.bit.PERINTE = perinte;
  411. DmaRegs.CH3.MODE.bit.ONESHOT = oneshot;
  412. DmaRegs.CH3.MODE.bit.CONTINUOUS = cont;
  413. DmaRegs.CH3.MODE.bit.OVRINTE = ovrinte;
  414. DmaRegs.CH3.MODE.bit.DATASIZE = datasize;
  415. DmaRegs.CH3.MODE.bit.CHINTMODE = chintmode;
  416. DmaRegs.CH3.MODE.bit.CHINTE = chinte;
  417. //
  418. // Clear any spurious flags: interrupt flags and sync error flags
  419. //
  420. DmaRegs.CH3.CONTROL.bit.PERINTCLR = 1;
  421. DmaRegs.CH3.CONTROL.bit.ERRCLR = 1;
  422. //
  423. // Initialize PIE vector for CPU interrupt:
  424. // Enable DMA CH3 interrupt in PIE
  425. //
  426. PieCtrlRegs.PIEIER7.bit.INTx3 = 1;
  427. EDIS;
  428. }
  429. //
  430. // StartDMACH3 - This function starts DMA Channel 3.
  431. //
  432. void StartDMACH3(void)
  433. {
  434. EALLOW;
  435. DmaRegs.CH3.CONTROL.bit.RUN = 1;
  436. EDIS;
  437. }
  438. //
  439. // DMACH4AddrConfig - DMA Channel 4 address configuration
  440. //
  441. void DMACH4AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
  442. {
  443. EALLOW;
  444. //
  445. // Set up SOURCE address:
  446. //
  447. DmaRegs.CH4.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
  448. // of source buffer.
  449. DmaRegs.CH4.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  450. //
  451. // Set up DESTINATION address:
  452. //
  453. DmaRegs.CH4.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
  454. // of destination
  455. // buffer.
  456. DmaRegs.CH4.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  457. EDIS;
  458. }
  459. //
  460. // DMACH4BurstConfig - DMA Channel 4 burst size configuration
  461. //
  462. void DMACH4BurstConfig(Uint16 bsize, int16 srcbstep, int16 desbstep)
  463. {
  464. EALLOW;
  465. //
  466. // Set up BURST registers:
  467. //
  468. DmaRegs.CH4.BURST_SIZE.all = bsize; // Number of words(X-1) x-ferred in
  469. // a burst.
  470. DmaRegs.CH4.SRC_BURST_STEP = srcbstep; // Increment source addr between
  471. // each word x-ferred.
  472. DmaRegs.CH4.DST_BURST_STEP = desbstep; // Increment dest addr between each
  473. // word x-ferred.
  474. EDIS;
  475. }
  476. //
  477. // DMACH4TransferConfig - DMA channel 4 transfer size configuration
  478. //
  479. void DMACH4TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
  480. {
  481. EALLOW;
  482. //
  483. // Set up TRANSFER registers:
  484. //
  485. DmaRegs.CH4.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
  486. // DMA interrupt will occur after
  487. // completed transfer.
  488. DmaRegs.CH4.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored when
  489. // WRAP occurs.
  490. DmaRegs.CH4.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored when
  491. // WRAP occurs.
  492. EDIS;
  493. }
  494. //
  495. // DMACH4WrapConfig - DMA channel 4 wrap size configuration
  496. //
  497. void DMACH4WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
  498. int16 deswstep)
  499. {
  500. EALLOW;
  501. //
  502. // Set up WRAP registers:
  503. //
  504. DmaRegs.CH4.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
  505. DmaRegs.CH4.SRC_WRAP_STEP = srcwstep; // Step for source wrap
  506. DmaRegs.CH4.DST_WRAP_SIZE = deswsize; // Wrap destination address after
  507. // N bursts.
  508. DmaRegs.CH4.DST_WRAP_STEP = deswstep; // Step for destination wrap
  509. EDIS;
  510. }
  511. //
  512. // DMACH4ModeConfig - DMA Channel 4 mode configuration
  513. //
  514. void DMACH4ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
  515. Uint16 cont, Uint16 synce, Uint16 syncsel,
  516. Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
  517. Uint16 chinte)
  518. {
  519. EALLOW;
  520. //
  521. // Set up MODE Register:
  522. // persel - Source select
  523. // PERINTSEL - Should be hard coded to channel, above now selects source
  524. // PERINTE - Peripheral interrupt enable
  525. // ONESHOT - Oneshot enable
  526. // CONTINUOUS - Continuous enable
  527. // OVRINTE - Enable/disable the overflow interrupt
  528. // DATASIZE - 16-bit/32-bit data size transfers
  529. // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
  530. // CHINTE - Channel Interrupt to CPU enable
  531. //
  532. DmaClaSrcSelRegs.DMACHSRCSEL1.bit.CH4 = persel;
  533. DmaRegs.CH4.MODE.bit.PERINTSEL = 4;
  534. DmaRegs.CH4.MODE.bit.PERINTE = perinte;
  535. DmaRegs.CH4.MODE.bit.ONESHOT = oneshot;
  536. DmaRegs.CH4.MODE.bit.CONTINUOUS = cont;
  537. DmaRegs.CH4.MODE.bit.OVRINTE = ovrinte;
  538. DmaRegs.CH4.MODE.bit.DATASIZE = datasize;
  539. DmaRegs.CH4.MODE.bit.CHINTMODE = chintmode;
  540. DmaRegs.CH4.MODE.bit.CHINTE = chinte;
  541. //
  542. // Clear any spurious flags: Interrupt flags and sync error flags
  543. //
  544. DmaRegs.CH4.CONTROL.bit.PERINTCLR = 1;
  545. DmaRegs.CH4.CONTROL.bit.ERRCLR = 1;
  546. //
  547. // Initialize PIE vector for CPU interrupt:
  548. // Enable DMA CH4 interrupt in PIE
  549. //
  550. PieCtrlRegs.PIEIER7.bit.INTx4 = 1;
  551. EDIS;
  552. }
  553. //
  554. // StartDMACH4 - This function starts DMA Channel 4.
  555. //
  556. void StartDMACH4(void)
  557. {
  558. EALLOW;
  559. DmaRegs.CH4.CONTROL.bit.RUN = 1;
  560. EDIS;
  561. }
  562. //
  563. // DMACH5AddrConfig - DMA channel 5 address configuration
  564. //
  565. void DMACH5AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
  566. {
  567. EALLOW;
  568. //
  569. // Set up SOURCE address:
  570. //
  571. DmaRegs.CH5.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
  572. // of source buffer
  573. DmaRegs.CH5.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  574. //
  575. // Set up DESTINATION address:
  576. //
  577. DmaRegs.CH5.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
  578. // of destination
  579. // buffer.
  580. DmaRegs.CH5.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  581. EDIS;
  582. }
  583. //
  584. // DMACH5BurstConfig - DMA Channel 5 burst size configuration
  585. //
  586. void DMACH5BurstConfig(Uint16 bsize, int16 srcbstep, int16 desbstep)
  587. {
  588. EALLOW;
  589. //
  590. // Set up BURST registers:
  591. //
  592. DmaRegs.CH5.BURST_SIZE.all = bsize; // Number of words(X-1) x-ferred in
  593. // a burst.
  594. DmaRegs.CH5.SRC_BURST_STEP = srcbstep; // Increment source addr between
  595. // each word x-ferred.
  596. DmaRegs.CH5.DST_BURST_STEP = desbstep; // Increment dest addr between each
  597. // word x-ferred.
  598. EDIS;
  599. }
  600. //
  601. // DMACH5TransferConfig - DMA channel 5 transfer size configuration
  602. //
  603. void DMACH5TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
  604. {
  605. EALLOW;
  606. //
  607. // Set up TRANSFER registers:
  608. //
  609. DmaRegs.CH5.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
  610. // DMA interrupt will occur after
  611. // completed transfer.
  612. DmaRegs.CH5.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored when
  613. // WRAP occurs.
  614. DmaRegs.CH5.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored when
  615. // WRAP occurs.
  616. EDIS;
  617. }
  618. //
  619. // DMACH5WrapConfig - DMA Channel 5 wrap size configuration
  620. //
  621. void DMACH5WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
  622. int16 deswstep)
  623. {
  624. EALLOW;
  625. //
  626. // Set up WRAP registers:
  627. //
  628. DmaRegs.CH5.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
  629. DmaRegs.CH5.SRC_WRAP_STEP = srcwstep; // Step for source wrap
  630. DmaRegs.CH5.DST_WRAP_SIZE = deswsize; // Wrap destination address after
  631. // N bursts.
  632. DmaRegs.CH5.DST_WRAP_STEP = deswstep; // Step for destination wrap
  633. EDIS;
  634. }
  635. //
  636. // DMACH5ModeConfig - DMA Channel 5 mode configuration
  637. //
  638. void DMACH5ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
  639. Uint16 cont, Uint16 synce, Uint16 syncsel,
  640. Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
  641. Uint16 chinte)
  642. {
  643. EALLOW;
  644. //
  645. // Set up MODE Register:
  646. // persel - Source select
  647. // PERINTSEL - Should be hard coded to channel, above now selects source
  648. // PERINTE - Peripheral interrupt enable
  649. // ONESHOT - Oneshot enable
  650. // CONTINUOUS - Continuous enable
  651. // OVRINTE - Enable/disable the overflow interrupt
  652. // DATASIZE - 16-bit/32-bit data size transfers
  653. // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
  654. // CHINTE - Channel Interrupt to CPU enable
  655. //
  656. DmaClaSrcSelRegs.DMACHSRCSEL2.bit.CH5 = persel;
  657. DmaRegs.CH5.MODE.bit.PERINTSEL = 5;
  658. DmaRegs.CH5.MODE.bit.PERINTE = perinte;
  659. DmaRegs.CH5.MODE.bit.ONESHOT = oneshot;
  660. DmaRegs.CH5.MODE.bit.CONTINUOUS = cont;
  661. DmaRegs.CH5.MODE.bit.OVRINTE = ovrinte;
  662. DmaRegs.CH5.MODE.bit.DATASIZE = datasize;
  663. DmaRegs.CH5.MODE.bit.CHINTMODE = chintmode;
  664. DmaRegs.CH5.MODE.bit.CHINTE = chinte;
  665. //
  666. // Clear any spurious flags: Interrupt flags and sync error flags
  667. //
  668. DmaRegs.CH5.CONTROL.bit.PERINTCLR = 1;
  669. DmaRegs.CH5.CONTROL.bit.ERRCLR = 1;
  670. //
  671. // Initialize PIE vector for CPU interrupt:
  672. // Enable DMA CH5 interrupt in PIE
  673. //
  674. PieCtrlRegs.PIEIER7.bit.INTx5 = 1;
  675. EDIS;
  676. }
  677. //
  678. // StartDMACH5 - This function starts DMA Channel 5.
  679. //
  680. void StartDMACH5(void)
  681. {
  682. EALLOW;
  683. DmaRegs.CH5.CONTROL.bit.RUN = 1;
  684. EDIS;
  685. }
  686. //
  687. // DMACH6AddrConfig - DMA Channel 6 address configuration
  688. //
  689. void DMACH6AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
  690. {
  691. EALLOW;
  692. //
  693. // Set up SOURCE address:
  694. //
  695. DmaRegs.CH6.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
  696. // of source buffer.
  697. DmaRegs.CH6.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  698. //
  699. // Set up DESTINATION address:
  700. //
  701. DmaRegs.CH6.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
  702. // of destination
  703. // buffer.
  704. DmaRegs.CH6.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  705. EDIS;
  706. }
  707. //
  708. // DMACH6BurstConfig - DMA Channel 6 burst size configuration
  709. //
  710. void DMACH6BurstConfig(Uint16 bsize,Uint16 srcbstep, int16 desbstep)
  711. {
  712. EALLOW;
  713. //
  714. // Set up BURST registers:
  715. //
  716. DmaRegs.CH6.BURST_SIZE.all = bsize; // Number of words(X-1) x-ferred in
  717. // a burst.
  718. DmaRegs.CH6.SRC_BURST_STEP = srcbstep; // Increment source addr between
  719. // each word x-ferred.
  720. DmaRegs.CH6.DST_BURST_STEP = desbstep; // Increment dest addr between each
  721. // word x-ferred.
  722. EDIS;
  723. }
  724. //
  725. // DMACH6TransferConfig - DMA channel 6 transfer size configuration
  726. //
  727. void DMACH6TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
  728. {
  729. EALLOW;
  730. //
  731. // Set up TRANSFER registers:
  732. //
  733. DmaRegs.CH6.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
  734. // DMA interrupt will occur after
  735. // completed transfer.
  736. DmaRegs.CH6.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored when
  737. // WRAP occurs.
  738. DmaRegs.CH6.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored when
  739. // WRAP occurs.
  740. EDIS;
  741. }
  742. //
  743. // DMACH6WrapConfig - DMA Channel 6 wrap size configuration
  744. //
  745. void DMACH6WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
  746. int16 deswstep)
  747. {
  748. EALLOW;
  749. //
  750. // Set up WRAP registers:
  751. //
  752. DmaRegs.CH6.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
  753. DmaRegs.CH6.SRC_WRAP_STEP = srcwstep; // Step for source wrap
  754. DmaRegs.CH6.DST_WRAP_SIZE = deswsize; // Wrap destination address after N
  755. // bursts.
  756. DmaRegs.CH6.DST_WRAP_STEP = deswstep; // Step for destination wrap
  757. EDIS;
  758. }
  759. //
  760. // DMACH6ModeConfig - DMA Channel 6 mode configuration
  761. //
  762. void DMACH6ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
  763. Uint16 cont, Uint16 synce, Uint16 syncsel,
  764. Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
  765. Uint16 chinte)
  766. {
  767. EALLOW;
  768. //
  769. // Set up MODE Register:
  770. // persel - Source select
  771. // PERINTSEL - Should be hard coded to channel, above now selects source
  772. // PERINTE - Peripheral interrupt enable
  773. // ONESHOT - Oneshot enable
  774. // CONTINUOUS - Continuous enable
  775. // OVRINTE - Enable/disable the overflow interrupt
  776. // DATASIZE - 16-bit/32-bit data size transfers
  777. // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
  778. // CHINTE - Channel Interrupt to CPU enable
  779. //
  780. DmaClaSrcSelRegs.DMACHSRCSEL2.bit.CH6 = persel;
  781. DmaRegs.CH6.MODE.bit.PERINTSEL = 6;
  782. DmaRegs.CH6.MODE.bit.PERINTE = perinte;
  783. DmaRegs.CH6.MODE.bit.ONESHOT = oneshot;
  784. DmaRegs.CH6.MODE.bit.CONTINUOUS = cont;
  785. DmaRegs.CH6.MODE.bit.OVRINTE = ovrinte;
  786. DmaRegs.CH6.MODE.bit.DATASIZE = datasize;
  787. DmaRegs.CH6.MODE.bit.CHINTMODE = chintmode;
  788. DmaRegs.CH6.MODE.bit.CHINTE = chinte;
  789. //
  790. // Clear any spurious flags: Interrupt flags and sync error flags
  791. //
  792. DmaRegs.CH6.CONTROL.bit.PERINTCLR = 1;
  793. DmaRegs.CH6.CONTROL.bit.ERRCLR = 1;
  794. //
  795. // Initialize PIE vector for CPU interrupt:
  796. // Enable DMA CH6 interrupt in PIE
  797. //
  798. PieCtrlRegs.PIEIER7.bit.INTx6 = 1;
  799. EDIS;
  800. }
  801. //
  802. // StartDMACH6 - This function starts DMA Channel 6.
  803. //
  804. void StartDMACH6(void)
  805. {
  806. EALLOW;
  807. DmaRegs.CH6.CONTROL.bit.RUN = 1;
  808. EDIS;
  809. }
  810. //
  811. // NOTE:
  812. // Following functions are required for EMIF as the address is out of
  813. // 22bit range
  814. //
  815. //
  816. // DMACH1AddrConfig32bit - DMA Channel 1 address configuration for 32bit
  817. //
  818. void DMACH1AddrConfig32bit(volatile Uint32 *DMA_Dest,
  819. volatile Uint32 *DMA_Source)
  820. {
  821. EALLOW;
  822. //
  823. // Set up SOURCE address:
  824. //
  825. DmaRegs.CH1.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
  826. // of source buffer
  827. DmaRegs.CH1.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  828. //
  829. // Set up DESTINATION address:
  830. //
  831. DmaRegs.CH1.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
  832. // of destination
  833. // buffer
  834. DmaRegs.CH1.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  835. EDIS;
  836. }
  837. //
  838. // DMACH2AddrConfig32bit - DMA Channel 2 address configuration for 32bit
  839. //
  840. void DMACH2AddrConfig32bit(volatile Uint32 *DMA_Dest,
  841. volatile Uint32 *DMA_Source)
  842. {
  843. EALLOW;
  844. //
  845. // Set up SOURCE address:
  846. //
  847. DmaRegs.CH2.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
  848. // of source buffer
  849. DmaRegs.CH2.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  850. //
  851. // Set up DESTINATION address:
  852. //
  853. DmaRegs.CH2.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
  854. // of destination
  855. // buffer
  856. DmaRegs.CH2.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  857. EDIS;
  858. }
  859. //
  860. // DMACH3AddrConfig32bit - DMA Channel 3 address configuration for 32bit
  861. //
  862. void DMACH3AddrConfig32bit(volatile Uint32 *DMA_Dest,
  863. volatile Uint32 *DMA_Source)
  864. {
  865. EALLOW;
  866. //
  867. // Set up SOURCE address:
  868. //
  869. DmaRegs.CH3.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
  870. // of source buffer
  871. DmaRegs.CH3.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  872. //
  873. // Set up DESTINATION address:
  874. //
  875. DmaRegs.CH3.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
  876. // of destination
  877. // buffer.
  878. DmaRegs.CH3.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  879. EDIS;
  880. }
  881. //
  882. // DMACH4AddrConfig32bit - DMA Channel 4 address configuration for 32bit
  883. //
  884. void DMACH4AddrConfig32bit(volatile Uint32 *DMA_Dest,
  885. volatile Uint32 *DMA_Source)
  886. {
  887. EALLOW;
  888. //
  889. // Set up SOURCE address:
  890. //
  891. DmaRegs.CH4.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
  892. // of source buffer
  893. DmaRegs.CH4.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  894. //
  895. // Set up DESTINATION address:
  896. //
  897. DmaRegs.CH4.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
  898. // of destination
  899. // buffer
  900. DmaRegs.CH4.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  901. EDIS;
  902. }
  903. //
  904. // DMACH5AddrConfig32bit - DMA Channel 5 address configuration for 32bit
  905. //
  906. void DMACH5AddrConfig32bit(volatile Uint32 *DMA_Dest,
  907. volatile Uint32 *DMA_Source)
  908. {
  909. EALLOW;
  910. //
  911. // Set up SOURCE address:
  912. //
  913. DmaRegs.CH5.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
  914. // of source buffer
  915. DmaRegs.CH5.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  916. //
  917. // Set up DESTINATION address:
  918. //
  919. DmaRegs.CH5.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
  920. // of destination
  921. // buffer
  922. DmaRegs.CH5.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  923. EDIS;
  924. }
  925. //
  926. // DMACH6AddrConfig32bit - DMA Channel 6 address configuration for 32bit
  927. //
  928. void DMACH6AddrConfig32bit(volatile Uint32 *DMA_Dest,
  929. volatile Uint32 *DMA_Source)
  930. {
  931. EALLOW;
  932. //
  933. // Set up SOURCE address:
  934. //
  935. DmaRegs.CH6.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
  936. // of source buffer
  937. DmaRegs.CH6.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
  938. //
  939. // Set up DESTINATION address:
  940. //
  941. DmaRegs.CH6.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
  942. // of destination
  943. // buffer
  944. DmaRegs.CH6.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
  945. EDIS;
  946. }
  947. //
  948. // End of file
  949. //