12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100 |
- //###########################################################################
- //
- // FILE: F2837xD_DMA.c
- //
- // TITLE: F2837xD Device DMA Initialization & Support Functions.
- //
- //###########################################################################
- // $TI Release: F2837xD Support Library v3.05.00.00 $
- // $Release Date: Tue Jun 26 03:15:23 CDT 2018 $
- // $Copyright:
- // Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/
- //
- // Redistribution and use in source and binary forms, with or without
- // modification, are permitted provided that the following conditions
- // are met:
- //
- // Redistributions of source code must retain the above copyright
- // notice, this list of conditions and the following disclaimer.
- //
- // Redistributions in binary form must reproduce the above copyright
- // notice, this list of conditions and the following disclaimer in the
- // documentation and/or other materials provided with the
- // distribution.
- //
- // Neither the name of Texas Instruments Incorporated nor the names of
- // its contributors may be used to endorse or promote products derived
- // from this software without specific prior written permission.
- //
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- // $
- //###########################################################################
- //
- // Included Files
- //
- #include "F2837xD_device.h"
- #include "F2837xD_Examples.h"
- //
- // DMAInitialize - This function initializes the DMA to a known state.
- //
- void DMAInitialize(void)
- {
- EALLOW;
- //
- // Perform a hard reset on DMA
- //
- DmaRegs.DMACTRL.bit.HARDRESET = 1;
- __asm (" nop"); // one NOP required after HARDRESET
- //
- // Allow DMA to run free on emulation suspend
- //
- DmaRegs.DEBUGCTRL.bit.FREE = 1;
- EDIS;
- }
- //
- // DMACH1AddrConfig - DMA Channel 1 Address Configuration
- //
- void DMACH1AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH1.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to
- // beginning of
- // source buffer
- DmaRegs.CH1.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH1.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to
- // beginning of
- // destination buffer
- DmaRegs.CH1.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // DMACH1BurstConfig - DMA Channel 1 Burst size configuration
- //
- void DMACH1BurstConfig(Uint16 bsize, int16 srcbstep, int16 desbstep)
- {
- EALLOW;
- //
- // Set up BURST registers:
- //
- DmaRegs.CH1.BURST_SIZE.all = bsize; // Number of words(X-1)
- // x-ferred in a burst.
- DmaRegs.CH1.SRC_BURST_STEP = srcbstep; // Increment source addr between
- // each word x-ferred.
- DmaRegs.CH1.DST_BURST_STEP = desbstep; // Increment dest addr between
- // each word x-ferred.
- EDIS;
- }
- //
- // DMACH1TransferConfig - DMA Channel 1 Transfer size configuration
- //
- void DMACH1TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
- {
- EALLOW;
- //
- // Set up TRANSFER registers:
- //
- DmaRegs.CH1.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
- // DMA interrupt will occur after
- // completed transfer.
- DmaRegs.CH1.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored
- // when WRAP occurs.
- DmaRegs.CH1.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored
- // when WRAP occurs.
- EDIS;
- }
- //
- // DMACH1WrapConfig - DMA Channel 1 Wrap size configuration
- //
- void DMACH1WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
- int16 deswstep)
- {
- EALLOW;
- //
- // Set up WRAP registers:
- //
- DmaRegs.CH1.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
- DmaRegs.CH1.SRC_WRAP_STEP = srcwstep; // Step for source wrap
- DmaRegs.CH1.DST_WRAP_SIZE = deswsize; // Wrap destination address after
- // N bursts.
- DmaRegs.CH1.DST_WRAP_STEP = deswstep; // Step for destination wrap
- EDIS;
- }
- //
- // DMACH1ModeConfig - DMA Channel 1 Mode configuration
- //
- void DMACH1ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
- Uint16 cont, Uint16 synce, Uint16 syncsel,
- Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
- Uint16 chinte)
- {
- EALLOW;
- //
- // Set up MODE Register:
- // persel - Source select
- // PERINTSEL - Should be hard coded to channel, above now selects source
- // PERINTE - Peripheral interrupt enable
- // ONESHOT - Oneshot enable
- // CONTINUOUS - Continuous enable
- // OVRINTE - Enable/disable the overflow interrupt
- // DATASIZE - 16-bit/32-bit data size transfers
- // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
- // CHINTE - Channel Interrupt to CPU enable
- //
- DmaClaSrcSelRegs.DMACHSRCSEL1.bit.CH1 = persel;
- DmaRegs.CH1.MODE.bit.PERINTSEL = 1;
- DmaRegs.CH1.MODE.bit.PERINTE = perinte;
- DmaRegs.CH1.MODE.bit.ONESHOT = oneshot;
- DmaRegs.CH1.MODE.bit.CONTINUOUS = cont;
- DmaRegs.CH1.MODE.bit.OVRINTE = ovrinte;
- DmaRegs.CH1.MODE.bit.DATASIZE = datasize;
- DmaRegs.CH1.MODE.bit.CHINTMODE = chintmode;
- DmaRegs.CH1.MODE.bit.CHINTE = chinte;
- //
- // Clear any spurious flags: interrupt and sync error flags
- //
- DmaRegs.CH1.CONTROL.bit.PERINTCLR = 1;
- DmaRegs.CH1.CONTROL.bit.ERRCLR = 1;
- //
- // Initialize PIE vector for CPU interrupt:
- // Enable DMA CH1 interrupt in PIE
- //
- PieCtrlRegs.PIEIER7.bit.INTx1 = 1;
- EDIS;
- }
- //
- // StartDMACH1 - This function starts DMA Channel 1.
- //
- void StartDMACH1(void)
- {
- EALLOW;
- DmaRegs.CH1.CONTROL.bit.RUN = 1;
- EDIS;
- }
- //
- // DMACH2AddrConfig - DMA Channel 2 Address Configuration
- //
- void DMACH2AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH2.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to
- // beginning of
- // source buffer.
- DmaRegs.CH2.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH2.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
- // of destination
- // buffer.
- DmaRegs.CH2.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // DMACH2BurstConfig - DMA Channel 2 Burst size configuration
- //
- void DMACH2BurstConfig(Uint16 bsize, int16 srcbstep, int16 desbstep)
- {
- EALLOW;
- //
- // Set up BURST registers:
- //
- DmaRegs.CH2.BURST_SIZE.all = bsize; // Number of words(X-1) x-ferred in
- // a burst.
- DmaRegs.CH2.SRC_BURST_STEP = srcbstep; // Increment source addr between
- // each word x-ferred.
- DmaRegs.CH2.DST_BURST_STEP = desbstep; // Increment dest addr between each
- // word x-ferred.
- EDIS;
- }
- //
- // DMACH2TransferConfig - DMA Channel 2 Transfer size Configuration
- //
- void DMACH2TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
- {
- EALLOW;
- //
- // Set up TRANSFER registers:
- //
- DmaRegs.CH2.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
- // DMA interrupt will occur after
- // completed transfer.
- DmaRegs.CH2.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored when
- // WRAP occurs.
- DmaRegs.CH2.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored when
- // WRAP occurs.
- EDIS;
- }
- //
- // DMACH2WrapConfig - DMA Channel 2 Wrap size configuration
- //
- void DMACH2WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
- int16 deswstep)
- {
- EALLOW;
- //
- // Set up WRAP registers:
- //
- DmaRegs.CH2.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
- DmaRegs.CH2.SRC_WRAP_STEP = srcwstep; // Step for source wrap
- DmaRegs.CH2.DST_WRAP_SIZE = deswsize; // Wrap destination address after
- // N bursts.
- DmaRegs.CH2.DST_WRAP_STEP = deswstep; // Step for destination wrap
- EDIS;
- }
- //
- // DMACH2ModeConfig - DMA Channel 2 Mode configuration
- //
- void DMACH2ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
- Uint16 cont, Uint16 synce, Uint16 syncsel,
- Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
- Uint16 chinte)
- {
- EALLOW;
- //
- // Set up MODE Register:
- // persel - Source select
- // PERINTSEL - Should be hard coded to channel, above now selects source
- // PERINTE - Peripheral interrupt enable
- // ONESHOT - Oneshot enable
- // CONTINUOUS - Continuous enable
- // OVRINTE - Enable/disable the overflow interrupt
- // DATASIZE - 16-bit/32-bit data size transfers
- // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
- // CHINTE - Channel Interrupt to CPU enable
- //
- DmaClaSrcSelRegs.DMACHSRCSEL1.bit.CH2 = persel;
- DmaRegs.CH2.MODE.bit.PERINTSEL = 2;
- DmaRegs.CH2.MODE.bit.PERINTE = perinte;
- DmaRegs.CH2.MODE.bit.ONESHOT = oneshot;
- DmaRegs.CH2.MODE.bit.CONTINUOUS = cont;
- DmaRegs.CH2.MODE.bit.OVRINTE = ovrinte;
- DmaRegs.CH2.MODE.bit.DATASIZE = datasize;
- DmaRegs.CH2.MODE.bit.CHINTMODE = chintmode;
- DmaRegs.CH2.MODE.bit.CHINTE = chinte;
- //
- // Clear any spurious flags: Interrupt flags and sync error flags
- //
- DmaRegs.CH2.CONTROL.bit.PERINTCLR = 1;
- DmaRegs.CH2.CONTROL.bit.ERRCLR = 1;
- //
- // Initialize PIE vector for CPU interrupt:
- // Enable DMA CH2 interrupt in PIE
- //
- PieCtrlRegs.PIEIER7.bit.INTx2 = 1;
- EDIS;
- }
- //
- // StartDMACH2 - This function starts DMA Channel 2.
- //
- void StartDMACH2(void)
- {
- EALLOW;
- DmaRegs.CH2.CONTROL.bit.RUN = 1;
- EDIS;
- }
- //
- // DMACH3AddrConfig - DMA Channel 3 Address configuration
- //
- void DMACH3AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH3.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
- // of source buffer.
- DmaRegs.CH3.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH3.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
- // of destination
- // buffer.
- DmaRegs.CH3.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // DMACH3BurstConfig - DMA Channel 3 burst size configuration
- //
- void DMACH3BurstConfig(Uint16 bsize, int16 srcbstep, int16 desbstep)
- {
- EALLOW;
- //
- // Set up BURST registers:
- //
- DmaRegs.CH3.BURST_SIZE.all = bsize; // Number of words(X-1) x-ferred in
- // a burst.
- DmaRegs.CH3.SRC_BURST_STEP = srcbstep; // Increment source addr between
- // each word x-ferred.
- DmaRegs.CH3.DST_BURST_STEP = desbstep; // Increment dest addr between each
- // word x-ferred.
- EDIS;
- }
- //
- // DMACH3TransferConfig - DMA channel 3 transfer size configuration
- //
- void DMACH3TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
- {
- EALLOW;
- //
- // Set up TRANSFER registers:
- //
- DmaRegs.CH3.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
- // DMA interrupt will occur after
- // completed transfer.
- DmaRegs.CH3.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored when
- // WRAP occurs.
- DmaRegs.CH3.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored when
- // WRAP occurs.
- EDIS;
- }
- //
- // DMACH3WrapConfig - DMA Channel 3 wrap size configuration
- //
- void DMACH3WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
- int16 deswstep)
- {
- EALLOW;
- //
- // Set up WRAP registers:
- //
- DmaRegs.CH3.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
- DmaRegs.CH3.SRC_WRAP_STEP = srcwstep; // Step for source wrap
- DmaRegs.CH3.DST_WRAP_SIZE = deswsize; // Wrap destination address after N
- // bursts.
- DmaRegs.CH3.DST_WRAP_STEP = deswstep; // Step for destination wrap
- EDIS;
- }
- //
- // DMACH3ModeConfig - DMA Channel 3 mode configuration
- //
- void DMACH3ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
- Uint16 cont, Uint16 synce, Uint16 syncsel,
- Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
- Uint16 chinte)
- {
- EALLOW;
- //
- // Set up MODE Register:
- // persel - Source select
- // PERINTSEL - Should be hard coded to channel, above now selects source
- // PERINTE - Peripheral interrupt enable
- // ONESHOT - Oneshot enable
- // CONTINUOUS - Continuous enable
- // OVRINTE - Enable/disable the overflow interrupt
- // DATASIZE - 16-bit/32-bit data size transfers
- // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
- // CHINTE - Channel Interrupt to CPU enable
- //
- DmaClaSrcSelRegs.DMACHSRCSEL1.bit.CH3 = persel;
- DmaRegs.CH3.MODE.bit.PERINTSEL = 3;
- DmaRegs.CH3.MODE.bit.PERINTE = perinte;
- DmaRegs.CH3.MODE.bit.ONESHOT = oneshot;
- DmaRegs.CH3.MODE.bit.CONTINUOUS = cont;
- DmaRegs.CH3.MODE.bit.OVRINTE = ovrinte;
- DmaRegs.CH3.MODE.bit.DATASIZE = datasize;
- DmaRegs.CH3.MODE.bit.CHINTMODE = chintmode;
- DmaRegs.CH3.MODE.bit.CHINTE = chinte;
- //
- // Clear any spurious flags: interrupt flags and sync error flags
- //
- DmaRegs.CH3.CONTROL.bit.PERINTCLR = 1;
- DmaRegs.CH3.CONTROL.bit.ERRCLR = 1;
- //
- // Initialize PIE vector for CPU interrupt:
- // Enable DMA CH3 interrupt in PIE
- //
- PieCtrlRegs.PIEIER7.bit.INTx3 = 1;
- EDIS;
- }
- //
- // StartDMACH3 - This function starts DMA Channel 3.
- //
- void StartDMACH3(void)
- {
- EALLOW;
- DmaRegs.CH3.CONTROL.bit.RUN = 1;
- EDIS;
- }
- //
- // DMACH4AddrConfig - DMA Channel 4 address configuration
- //
- void DMACH4AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH4.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
- // of source buffer.
- DmaRegs.CH4.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH4.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
- // of destination
- // buffer.
- DmaRegs.CH4.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // DMACH4BurstConfig - DMA Channel 4 burst size configuration
- //
- void DMACH4BurstConfig(Uint16 bsize, int16 srcbstep, int16 desbstep)
- {
- EALLOW;
- //
- // Set up BURST registers:
- //
- DmaRegs.CH4.BURST_SIZE.all = bsize; // Number of words(X-1) x-ferred in
- // a burst.
- DmaRegs.CH4.SRC_BURST_STEP = srcbstep; // Increment source addr between
- // each word x-ferred.
- DmaRegs.CH4.DST_BURST_STEP = desbstep; // Increment dest addr between each
- // word x-ferred.
- EDIS;
- }
- //
- // DMACH4TransferConfig - DMA channel 4 transfer size configuration
- //
- void DMACH4TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
- {
- EALLOW;
- //
- // Set up TRANSFER registers:
- //
- DmaRegs.CH4.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
- // DMA interrupt will occur after
- // completed transfer.
- DmaRegs.CH4.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored when
- // WRAP occurs.
- DmaRegs.CH4.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored when
- // WRAP occurs.
- EDIS;
- }
- //
- // DMACH4WrapConfig - DMA channel 4 wrap size configuration
- //
- void DMACH4WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
- int16 deswstep)
- {
- EALLOW;
- //
- // Set up WRAP registers:
- //
- DmaRegs.CH4.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
- DmaRegs.CH4.SRC_WRAP_STEP = srcwstep; // Step for source wrap
- DmaRegs.CH4.DST_WRAP_SIZE = deswsize; // Wrap destination address after
- // N bursts.
- DmaRegs.CH4.DST_WRAP_STEP = deswstep; // Step for destination wrap
- EDIS;
- }
- //
- // DMACH4ModeConfig - DMA Channel 4 mode configuration
- //
- void DMACH4ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
- Uint16 cont, Uint16 synce, Uint16 syncsel,
- Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
- Uint16 chinte)
- {
- EALLOW;
- //
- // Set up MODE Register:
- // persel - Source select
- // PERINTSEL - Should be hard coded to channel, above now selects source
- // PERINTE - Peripheral interrupt enable
- // ONESHOT - Oneshot enable
- // CONTINUOUS - Continuous enable
- // OVRINTE - Enable/disable the overflow interrupt
- // DATASIZE - 16-bit/32-bit data size transfers
- // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
- // CHINTE - Channel Interrupt to CPU enable
- //
- DmaClaSrcSelRegs.DMACHSRCSEL1.bit.CH4 = persel;
- DmaRegs.CH4.MODE.bit.PERINTSEL = 4;
- DmaRegs.CH4.MODE.bit.PERINTE = perinte;
- DmaRegs.CH4.MODE.bit.ONESHOT = oneshot;
- DmaRegs.CH4.MODE.bit.CONTINUOUS = cont;
- DmaRegs.CH4.MODE.bit.OVRINTE = ovrinte;
- DmaRegs.CH4.MODE.bit.DATASIZE = datasize;
- DmaRegs.CH4.MODE.bit.CHINTMODE = chintmode;
- DmaRegs.CH4.MODE.bit.CHINTE = chinte;
- //
- // Clear any spurious flags: Interrupt flags and sync error flags
- //
- DmaRegs.CH4.CONTROL.bit.PERINTCLR = 1;
- DmaRegs.CH4.CONTROL.bit.ERRCLR = 1;
- //
- // Initialize PIE vector for CPU interrupt:
- // Enable DMA CH4 interrupt in PIE
- //
- PieCtrlRegs.PIEIER7.bit.INTx4 = 1;
- EDIS;
- }
- //
- // StartDMACH4 - This function starts DMA Channel 4.
- //
- void StartDMACH4(void)
- {
- EALLOW;
- DmaRegs.CH4.CONTROL.bit.RUN = 1;
- EDIS;
- }
- //
- // DMACH5AddrConfig - DMA channel 5 address configuration
- //
- void DMACH5AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH5.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
- // of source buffer
- DmaRegs.CH5.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH5.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
- // of destination
- // buffer.
- DmaRegs.CH5.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // DMACH5BurstConfig - DMA Channel 5 burst size configuration
- //
- void DMACH5BurstConfig(Uint16 bsize, int16 srcbstep, int16 desbstep)
- {
- EALLOW;
- //
- // Set up BURST registers:
- //
- DmaRegs.CH5.BURST_SIZE.all = bsize; // Number of words(X-1) x-ferred in
- // a burst.
- DmaRegs.CH5.SRC_BURST_STEP = srcbstep; // Increment source addr between
- // each word x-ferred.
- DmaRegs.CH5.DST_BURST_STEP = desbstep; // Increment dest addr between each
- // word x-ferred.
- EDIS;
- }
- //
- // DMACH5TransferConfig - DMA channel 5 transfer size configuration
- //
- void DMACH5TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
- {
- EALLOW;
- //
- // Set up TRANSFER registers:
- //
- DmaRegs.CH5.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
- // DMA interrupt will occur after
- // completed transfer.
- DmaRegs.CH5.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored when
- // WRAP occurs.
- DmaRegs.CH5.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored when
- // WRAP occurs.
- EDIS;
- }
- //
- // DMACH5WrapConfig - DMA Channel 5 wrap size configuration
- //
- void DMACH5WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
- int16 deswstep)
- {
- EALLOW;
- //
- // Set up WRAP registers:
- //
- DmaRegs.CH5.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
- DmaRegs.CH5.SRC_WRAP_STEP = srcwstep; // Step for source wrap
- DmaRegs.CH5.DST_WRAP_SIZE = deswsize; // Wrap destination address after
- // N bursts.
- DmaRegs.CH5.DST_WRAP_STEP = deswstep; // Step for destination wrap
- EDIS;
- }
- //
- // DMACH5ModeConfig - DMA Channel 5 mode configuration
- //
- void DMACH5ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
- Uint16 cont, Uint16 synce, Uint16 syncsel,
- Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
- Uint16 chinte)
- {
- EALLOW;
- //
- // Set up MODE Register:
- // persel - Source select
- // PERINTSEL - Should be hard coded to channel, above now selects source
- // PERINTE - Peripheral interrupt enable
- // ONESHOT - Oneshot enable
- // CONTINUOUS - Continuous enable
- // OVRINTE - Enable/disable the overflow interrupt
- // DATASIZE - 16-bit/32-bit data size transfers
- // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
- // CHINTE - Channel Interrupt to CPU enable
- //
- DmaClaSrcSelRegs.DMACHSRCSEL2.bit.CH5 = persel;
- DmaRegs.CH5.MODE.bit.PERINTSEL = 5;
- DmaRegs.CH5.MODE.bit.PERINTE = perinte;
- DmaRegs.CH5.MODE.bit.ONESHOT = oneshot;
- DmaRegs.CH5.MODE.bit.CONTINUOUS = cont;
- DmaRegs.CH5.MODE.bit.OVRINTE = ovrinte;
- DmaRegs.CH5.MODE.bit.DATASIZE = datasize;
- DmaRegs.CH5.MODE.bit.CHINTMODE = chintmode;
- DmaRegs.CH5.MODE.bit.CHINTE = chinte;
- //
- // Clear any spurious flags: Interrupt flags and sync error flags
- //
- DmaRegs.CH5.CONTROL.bit.PERINTCLR = 1;
- DmaRegs.CH5.CONTROL.bit.ERRCLR = 1;
- //
- // Initialize PIE vector for CPU interrupt:
- // Enable DMA CH5 interrupt in PIE
- //
- PieCtrlRegs.PIEIER7.bit.INTx5 = 1;
- EDIS;
- }
- //
- // StartDMACH5 - This function starts DMA Channel 5.
- //
- void StartDMACH5(void)
- {
- EALLOW;
- DmaRegs.CH5.CONTROL.bit.RUN = 1;
- EDIS;
- }
- //
- // DMACH6AddrConfig - DMA Channel 6 address configuration
- //
- void DMACH6AddrConfig(volatile Uint16 *DMA_Dest,volatile Uint16 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH6.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
- // of source buffer.
- DmaRegs.CH6.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH6.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
- // of destination
- // buffer.
- DmaRegs.CH6.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // DMACH6BurstConfig - DMA Channel 6 burst size configuration
- //
- void DMACH6BurstConfig(Uint16 bsize,Uint16 srcbstep, int16 desbstep)
- {
- EALLOW;
- //
- // Set up BURST registers:
- //
- DmaRegs.CH6.BURST_SIZE.all = bsize; // Number of words(X-1) x-ferred in
- // a burst.
- DmaRegs.CH6.SRC_BURST_STEP = srcbstep; // Increment source addr between
- // each word x-ferred.
- DmaRegs.CH6.DST_BURST_STEP = desbstep; // Increment dest addr between each
- // word x-ferred.
- EDIS;
- }
- //
- // DMACH6TransferConfig - DMA channel 6 transfer size configuration
- //
- void DMACH6TransferConfig(Uint16 tsize, int16 srctstep, int16 deststep)
- {
- EALLOW;
- //
- // Set up TRANSFER registers:
- //
- DmaRegs.CH6.TRANSFER_SIZE = tsize; // Number of bursts per transfer,
- // DMA interrupt will occur after
- // completed transfer.
- DmaRegs.CH6.SRC_TRANSFER_STEP = srctstep; // TRANSFER_STEP is ignored when
- // WRAP occurs.
- DmaRegs.CH6.DST_TRANSFER_STEP = deststep; // TRANSFER_STEP is ignored when
- // WRAP occurs.
- EDIS;
- }
- //
- // DMACH6WrapConfig - DMA Channel 6 wrap size configuration
- //
- void DMACH6WrapConfig(Uint16 srcwsize, int16 srcwstep, Uint16 deswsize,
- int16 deswstep)
- {
- EALLOW;
- //
- // Set up WRAP registers:
- //
- DmaRegs.CH6.SRC_WRAP_SIZE = srcwsize; // Wrap source address after N bursts
- DmaRegs.CH6.SRC_WRAP_STEP = srcwstep; // Step for source wrap
- DmaRegs.CH6.DST_WRAP_SIZE = deswsize; // Wrap destination address after N
- // bursts.
- DmaRegs.CH6.DST_WRAP_STEP = deswstep; // Step for destination wrap
- EDIS;
- }
- //
- // DMACH6ModeConfig - DMA Channel 6 mode configuration
- //
- void DMACH6ModeConfig(Uint16 persel, Uint16 perinte, Uint16 oneshot,
- Uint16 cont, Uint16 synce, Uint16 syncsel,
- Uint16 ovrinte, Uint16 datasize, Uint16 chintmode,
- Uint16 chinte)
- {
- EALLOW;
- //
- // Set up MODE Register:
- // persel - Source select
- // PERINTSEL - Should be hard coded to channel, above now selects source
- // PERINTE - Peripheral interrupt enable
- // ONESHOT - Oneshot enable
- // CONTINUOUS - Continuous enable
- // OVRINTE - Enable/disable the overflow interrupt
- // DATASIZE - 16-bit/32-bit data size transfers
- // CHINTMODE - Generate interrupt to CPU at beginning/end of transfer
- // CHINTE - Channel Interrupt to CPU enable
- //
- DmaClaSrcSelRegs.DMACHSRCSEL2.bit.CH6 = persel;
- DmaRegs.CH6.MODE.bit.PERINTSEL = 6;
- DmaRegs.CH6.MODE.bit.PERINTE = perinte;
- DmaRegs.CH6.MODE.bit.ONESHOT = oneshot;
- DmaRegs.CH6.MODE.bit.CONTINUOUS = cont;
- DmaRegs.CH6.MODE.bit.OVRINTE = ovrinte;
- DmaRegs.CH6.MODE.bit.DATASIZE = datasize;
- DmaRegs.CH6.MODE.bit.CHINTMODE = chintmode;
- DmaRegs.CH6.MODE.bit.CHINTE = chinte;
- //
- // Clear any spurious flags: Interrupt flags and sync error flags
- //
- DmaRegs.CH6.CONTROL.bit.PERINTCLR = 1;
- DmaRegs.CH6.CONTROL.bit.ERRCLR = 1;
- //
- // Initialize PIE vector for CPU interrupt:
- // Enable DMA CH6 interrupt in PIE
- //
- PieCtrlRegs.PIEIER7.bit.INTx6 = 1;
- EDIS;
- }
- //
- // StartDMACH6 - This function starts DMA Channel 6.
- //
- void StartDMACH6(void)
- {
- EALLOW;
- DmaRegs.CH6.CONTROL.bit.RUN = 1;
- EDIS;
- }
- //
- // NOTE:
- // Following functions are required for EMIF as the address is out of
- // 22bit range
- //
- //
- // DMACH1AddrConfig32bit - DMA Channel 1 address configuration for 32bit
- //
- void DMACH1AddrConfig32bit(volatile Uint32 *DMA_Dest,
- volatile Uint32 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH1.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
- // of source buffer
- DmaRegs.CH1.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH1.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
- // of destination
- // buffer
- DmaRegs.CH1.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // DMACH2AddrConfig32bit - DMA Channel 2 address configuration for 32bit
- //
- void DMACH2AddrConfig32bit(volatile Uint32 *DMA_Dest,
- volatile Uint32 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH2.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
- // of source buffer
- DmaRegs.CH2.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH2.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
- // of destination
- // buffer
- DmaRegs.CH2.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // DMACH3AddrConfig32bit - DMA Channel 3 address configuration for 32bit
- //
- void DMACH3AddrConfig32bit(volatile Uint32 *DMA_Dest,
- volatile Uint32 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH3.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
- // of source buffer
- DmaRegs.CH3.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH3.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
- // of destination
- // buffer.
- DmaRegs.CH3.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // DMACH4AddrConfig32bit - DMA Channel 4 address configuration for 32bit
- //
- void DMACH4AddrConfig32bit(volatile Uint32 *DMA_Dest,
- volatile Uint32 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH4.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
- // of source buffer
- DmaRegs.CH4.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH4.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
- // of destination
- // buffer
- DmaRegs.CH4.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // DMACH5AddrConfig32bit - DMA Channel 5 address configuration for 32bit
- //
- void DMACH5AddrConfig32bit(volatile Uint32 *DMA_Dest,
- volatile Uint32 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH5.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
- // of source buffer
- DmaRegs.CH5.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH5.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
- // of destination
- // buffer
- DmaRegs.CH5.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // DMACH6AddrConfig32bit - DMA Channel 6 address configuration for 32bit
- //
- void DMACH6AddrConfig32bit(volatile Uint32 *DMA_Dest,
- volatile Uint32 *DMA_Source)
- {
- EALLOW;
- //
- // Set up SOURCE address:
- //
- DmaRegs.CH6.SRC_BEG_ADDR_SHADOW = (Uint32)DMA_Source; // Point to beginning
- // of source buffer
- DmaRegs.CH6.SRC_ADDR_SHADOW = (Uint32)DMA_Source;
- //
- // Set up DESTINATION address:
- //
- DmaRegs.CH6.DST_BEG_ADDR_SHADOW = (Uint32)DMA_Dest; // Point to beginning
- // of destination
- // buffer
- DmaRegs.CH6.DST_ADDR_SHADOW = (Uint32)DMA_Dest;
- EDIS;
- }
- //
- // End of file
- //
|