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.h
- Revision:
- 2:fe2fcaa72434
- Parent:
- 1:0b73b00bcee8
- Child:
- 3:34f5bf8adfa0
--- a/SimpleDMA.h Fri Dec 20 20:48:17 2013 +0000 +++ b/SimpleDMA.h Sun Dec 22 21:42:49 2013 +0000 @@ -1,8 +1,11 @@ #ifndef SIMPLEDMA_H #define SIMPLEDMA_H +#ifdef RTOS_H +#include "rtos.h" +#endif + #include "mbed.h" -#include "rtos.h" #include "SimpleDMA_KL25.h" @@ -35,7 +38,7 @@ */ template<typename Type> int source(Type* pointer, bool autoinc, int size = sizeof(Type*)) { - return setMemory((uint32_t)pointer, size, true, autoinc); + return setAddress((uint32_t)pointer, size, true, autoinc); } /** @@ -56,7 +59,7 @@ */ template<typename Type> int destination(Type* pointer, bool autoinc, int size = sizeof(Type*)) { - return setMemory((uint32_t)pointer, size, false, autoinc); + return setAddress((uint32_t)pointer, size, false, autoinc); } /** @@ -102,13 +105,14 @@ _callback.attach(object, member); } -void wait(void) { +#ifdef RTOS_H +void wait(int length) { id = Thread::gettid(); this->attach(this, &SimpleDMA::waitCallback); - this->start(8); + this->start(length); Thread::signal_wait(0x1); } - +#endif protected: /** @@ -117,15 +121,17 @@ * @param chan - DMA channel to use */ void channel(int chan); +int setAddress(uint32_t address, int wordsize, bool source, bool autoinc); -int setMemory(uint32_t address, int wordsize, bool source, bool autoinc); int _channel; +uint32_t SAR, DAR, DSR, DCR; +uint8_t CHCFG; + +//IRQ handlers FunctionPointer _callback; bool irq_en; void irq_handler(void); -//IRQ handlers - static SimpleDMA *irq_owner[4]; static void irq_handler0( void ) { @@ -144,14 +150,14 @@ if (irq_owner[3]!=NULL) irq_owner[3]->irq_handler(); } -public: + + +#ifdef RTOS_H osThreadId id; void waitCallback(void) { - - //id = Thread::gettid(); - osSignalSet(id, 0x1); - + osSignalSet(id, 0x1); } +#endif }; #endif \ No newline at end of file