DMA library for the KL25Z
Dependents: SimpleDMA_HelloWorld RTOS_SPI spiDMAtest Pinscape_Controller_v1 ... more
Introduction
SimpleDMA is a standard library for different DMA peripherals. Currently the LPC1768, KL46Z and KL25Z are supported. It provided one set of functions for different peripherals. It does not allow for usage of all the advanced functions, partially because the goal was to provide a simple interface, and partially because they are different for different microcontrollers.
Examples
Helloworld: http://mbed.org/users/Sissors/code/SimpleDMA_HelloWorld/
Example in a library (SPI): http://mbed.org/users/Sissors/code/RTOS_SPI/
Diff: SimpleDMA_LPC1768.cpp
- Revision:
- 6:e9ab0bb912c8
- Parent:
- 5:d9f46ef80e20
- Child:
- 8:876f3b55e6f5
diff -r d9f46ef80e20 -r e9ab0bb912c8 SimpleDMA_LPC1768.cpp --- 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