steven niu / mDMA Featured

Dependents:   test_mDMA

Embed: (wiki syntax)

« Back to documentation index

mbed Namespace Reference

mbed Namespace Reference

A generic DMA for transfer data without hanging the CPU. More...


Detailed Description

A generic DMA for transfer data without hanging the CPU.

It can be used for m2m, m2p, p2m, m2m transfer It will choose the DMA with the priority you have set. Lower number means higher prority. If no prority is set, it will choose which ever free channel. Example:

 // Send the memory data "Hello world" in source address to destination address via DMA
 // attach a function to swtich LED on when the transfer finish
  char src[] = "Hello world\r\n";
  uint8_t size = sizeof (src);
  char *dst  = (char *) malloc(size);
  memset (dst, '\0', size);
  LPC_SC->PCONP |= (1 << 29);    // Enable LPC1768 GPDMA clock
  DMA dma1 (0) ;
  dma1.source (src,0,1);
  dma1.destination (dst,0,1);
  dma1.attach_TC(led_switchon) ;
  dma1.start(size);
  dma1.wait();
  printf("dst text: %s", dst);