HelloWorld program showing SimpleDMA with mainly UART stuff
Dependencies: SimpleDMA mbed-rtos mbed
Diff: main.cpp
- Revision:
- 1:418889681f13
- Parent:
- 0:cf18a31facd6
--- a/main.cpp Thu Dec 26 16:32:59 2013 +0000 +++ b/main.cpp Sat Jan 04 14:58:41 2014 +0000 @@ -3,7 +3,7 @@ #include "SimpleDMA.h" DigitalOut led1(LED1); -SimpleDMA dma; +SimpleDMA dma(0); RawSerial pc(USBTX, USBRX); void callback(void) { @@ -41,10 +41,16 @@ //Now to UART, enable DMA in UART, destination is now //a fixed address, so address pointer should not be incremented, //thus second argument is false. Also set trigger to UART0_RX. - //This sends a new value to the UART as soon as it is possible + //This sends a new value to the UART as soon as it is possible + #ifdef TARGET_LPC1768 + LPC_UART0->FCR |= 1<<3; + dma.destination(&LPC_UART0->THR, false); + #endif + #ifdef TARGET_KL25Z UART0->C5 |= (1<<7) | (1<<5); + dma.destination(&UART0->D, false); + #endif dma.source(characters2, true); - dma.destination(&UART0->D, false); dma.trigger(Trigger_UART0_TX); dma.start(10); @@ -65,7 +71,13 @@ Thread thread(led_thread); thread.set_priority(osPriorityLow); + #ifdef TARGET_LPC1768 + dma.source(&LPC_UART0->THR, false); + #endif + #ifdef TARGET_KL25Z dma.source(&UART0->D, false); + #endif + //Trigger is now the receiving on the UART dma.trigger(Trigger_UART0_RX);