Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "SimpleDMA.h" 00003 #include <algorithm> 00004 00005 RawSerial pc(USBTX, USBRX); // PC tx, rx 00006 RawSerial device(PTE0, PTE1); // UART1 tx, rx 00007 00008 DigitalOut led1(LED_RED); 00009 DigitalOut led2(LED_GREEN); 00010 00011 SimpleDMA dma_pc; 00012 SimpleDMA dma_device; 00013 00014 int main() 00015 { 00016 // Enable the TX and RX dma on UART1 00017 UART1->C2 |= UART_C2_RIE_MASK | UART_C2_TIE_MASK ; 00018 UART1->C4 |= UART_C4_RDMAS_MASK | UART_C4_TDMAS_MASK; 00019 00020 // TODO: Configure dma_device to transfer data from UART1 to UART0 00021 // ... 00022 00023 uint8_t buffer[128]; 00024 uint8_t buffer_ptr = 0; 00025 00026 while(1) { 00027 char c = pc.getc(); 00028 buffer[buffer_ptr] = c; 00029 buffer_ptr = (buffer_ptr + 1) % sizeof(buffer); 00030 00031 if(c == '\r') 00032 { 00033 buffer[buffer_ptr] = '\n'; 00034 ++buffer_ptr; 00035 00036 led2 = !led2; 00037 00038 // TODO: Trigger dma_pc to transfer data from the buffer to UART1 00039 // .... 00040 00041 buffer_ptr = 0; 00042 } 00043 } 00044 } 00045 00046
Generated on Thu Aug 4 2022 03:14:04 by
1.7.2