A simple library to access the DMA functionality.

Fork of SimpleDMA by Erik -

Revision:
6:e9ab0bb912c8
Parent:
5:d9f46ef80e20
--- a/SimpleDMA_LPC1768.cpp	Sat Jan 04 14:42:33 2014 +0000
+++ b/SimpleDMA_LPC1768.cpp	Tue Mar 18 12:44:46 2014 +0000
@@ -84,18 +84,23 @@
     _callback.call();
 }
 
+static inline bool isMemory(uint32_t addr)
+{
+    return (addr >> 28) == 0 || (addr >> 28) == 1 || ((addr >= 0x2007C000) && (addr < (0x2007C000 + 0x8000)));
+}
+
 uint32_t getTransferType(SimpleDMA_Trigger trig, uint32_t source, uint32_t destination) {
     //If it is always, simply put it on memory-to-memory
     if (trig == Trigger_ALWAYS)
         return 0;
-    else if ((source >> 28) == 0 || (source >> 28) == 1) {       //if source is RAM/Flash
-        if ((destination >> 28) == 0 || (destination >> 28) == 1)        //if destination is RAM/flash
+    else if (isMemory(source)) {       //if source is RAM/Flash
+        if (isMemory(destination))        //if destination is RAM/flash
             return 3;                                                               //Return p2p for m2m with a trigger (since I have no idea wtf you are trying to do)
         else
             return 1;                                                               //Source is memory, destination is peripheral, so m2p
         }
     else {
-        if ((destination >> 28) == 0 || (destination >> 28))
+        if (isMemory(destination))
             return 2;                                                               //Source is peripheral, destination is memory
         else
             return 3;                                                               //Both source and destination are peripherals