GPDMA (Direct Memory Access) and LLI (Link List Item) test see: http://mbed.org/users/okini3939/notebook/dma_jp/

Dependencies:   mbed

Committer:
okini3939
Date:
Fri Sep 13 14:49:52 2013 +0000
Revision:
0:de79d4a48e63
GPDMA (Direct Memory Access) and LLI (Link List Item) test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 0:de79d4a48e63 1 /*
okini3939 0:de79d4a48e63 2 Copyright (c) 2010 Andy Kirkham
okini3939 0:de79d4a48e63 3
okini3939 0:de79d4a48e63 4 Permission is hereby granted, free of charge, to any person obtaining a copy
okini3939 0:de79d4a48e63 5 of this software and associated documentation files (the "Software"), to deal
okini3939 0:de79d4a48e63 6 in the Software without restriction, including without limitation the rights
okini3939 0:de79d4a48e63 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
okini3939 0:de79d4a48e63 8 copies of the Software, and to permit persons to whom the Software is
okini3939 0:de79d4a48e63 9 furnished to do so, subject to the following conditions:
okini3939 0:de79d4a48e63 10
okini3939 0:de79d4a48e63 11 The above copyright notice and this permission notice shall be included in
okini3939 0:de79d4a48e63 12 all copies or substantial portions of the Software.
okini3939 0:de79d4a48e63 13
okini3939 0:de79d4a48e63 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
okini3939 0:de79d4a48e63 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
okini3939 0:de79d4a48e63 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
okini3939 0:de79d4a48e63 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
okini3939 0:de79d4a48e63 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
okini3939 0:de79d4a48e63 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
okini3939 0:de79d4a48e63 20 THE SOFTWARE.
okini3939 0:de79d4a48e63 21 */
okini3939 0:de79d4a48e63 22
okini3939 0:de79d4a48e63 23 #include "MODDMA.h"
okini3939 0:de79d4a48e63 24
okini3939 0:de79d4a48e63 25 namespace AjK {
okini3939 0:de79d4a48e63 26
okini3939 0:de79d4a48e63 27 extern uint32_t oldDMAHandler;
okini3939 0:de79d4a48e63 28 extern "C" void MODDMA_IRQHandler(void);
okini3939 0:de79d4a48e63 29 extern class MODDMA *moddma_p;
okini3939 0:de79d4a48e63 30
okini3939 0:de79d4a48e63 31 void
okini3939 0:de79d4a48e63 32 MODDMA::init(bool isConstructorCalling, int Channels, int Tc, int Err)
okini3939 0:de79d4a48e63 33 {
okini3939 0:de79d4a48e63 34 if (isConstructorCalling) {
okini3939 0:de79d4a48e63 35 if (LPC_SC->PCONP & (1UL << 29)) {
okini3939 0:de79d4a48e63 36 if (LPC_GPDMA->DMACConfig & 1) {
okini3939 0:de79d4a48e63 37 error("Only one instance of MODDMA can exist.");
okini3939 0:de79d4a48e63 38 }
okini3939 0:de79d4a48e63 39 }
okini3939 0:de79d4a48e63 40 LPC_SC->PCONP |= (1UL << 29);
okini3939 0:de79d4a48e63 41 LPC_GPDMA->DMACConfig = 1;
okini3939 0:de79d4a48e63 42 moddma_p = this;
okini3939 0:de79d4a48e63 43 for (int i = 0; i < 8; i++) {
okini3939 0:de79d4a48e63 44 setups[i] = (MODDMA_Config *)NULL;
okini3939 0:de79d4a48e63 45 }
okini3939 0:de79d4a48e63 46 }
okini3939 0:de79d4a48e63 47
okini3939 0:de79d4a48e63 48 // Reset channel configuration register(s)
okini3939 0:de79d4a48e63 49 if (Channels & 0x01) LPC_GPDMACH0->DMACCConfig = 0;
okini3939 0:de79d4a48e63 50 if (Channels & 0x02) LPC_GPDMACH1->DMACCConfig = 0;
okini3939 0:de79d4a48e63 51 if (Channels & 0x04) LPC_GPDMACH2->DMACCConfig = 0;
okini3939 0:de79d4a48e63 52 if (Channels & 0x08) LPC_GPDMACH3->DMACCConfig = 0;
okini3939 0:de79d4a48e63 53 if (Channels & 0x10) LPC_GPDMACH4->DMACCConfig = 0;
okini3939 0:de79d4a48e63 54 if (Channels & 0x20) LPC_GPDMACH5->DMACCConfig = 0;
okini3939 0:de79d4a48e63 55 if (Channels & 0x40) LPC_GPDMACH6->DMACCConfig = 0;
okini3939 0:de79d4a48e63 56 if (Channels & 0x80) LPC_GPDMACH7->DMACCConfig = 0;
okini3939 0:de79d4a48e63 57
okini3939 0:de79d4a48e63 58 /* Clear DMA interrupt and error flag */
okini3939 0:de79d4a48e63 59 LPC_GPDMA->DMACIntTCClear = Tc;
okini3939 0:de79d4a48e63 60 LPC_GPDMA->DMACIntErrClr = Err;
okini3939 0:de79d4a48e63 61
okini3939 0:de79d4a48e63 62 if (isConstructorCalling) {
okini3939 0:de79d4a48e63 63 oldDMAHandler = NVIC_GetVector(DMA_IRQn);
okini3939 0:de79d4a48e63 64 NVIC_SetVector(DMA_IRQn, (uint32_t)MODDMA_IRQHandler);
okini3939 0:de79d4a48e63 65 NVIC_EnableIRQ(DMA_IRQn);
okini3939 0:de79d4a48e63 66 }
okini3939 0:de79d4a48e63 67 }
okini3939 0:de79d4a48e63 68
okini3939 0:de79d4a48e63 69 }; // namespace AjK ends