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.
dma.cpp
00001 #include "dma.h" 00002 00003 namespace mbed { 00004 00005 00006 DMA::DMA (int priority): 00007 channel_num(_channel_num) 00008 { 00009 chan = chooseFreeChannel(priority) ; 00010 // channel_num = _channel_num; 00011 DMA_reset(chan);// reset the register value to default and clear the interrupts 00012 dma_init_struct = DMA_struct_create(); // initialize the dma data structure to default value 00013 } 00014 00015 00016 DMA::~DMA() 00017 { 00018 DMA_struct_delete(dma_init_struct); 00019 DMA_IRQ_detach(chan); 00020 } 00021 00022 // if no channel choosed, choose whichever free channel, otherwise, wait until the channel is free 00023 int DMA::chooseFreeChannel (int channel) 00024 { 00025 int reval=channel; 00026 if (channel > (channel_num-1) || channel < 0) 00027 { 00028 reval = 0; 00029 while (1) { //if not chosen channel, round robin checked which channel is free 00030 if (!DMA_channel_active(reval)) 00031 return reval; 00032 reval++; 00033 if (reval>(channel_num-1)) 00034 reval=0; 00035 } 00036 } 00037 else 00038 { 00039 while (DMA_channel_active(reval));//if has chosen the channel, wait until the channel is free 00040 } 00041 00042 return reval; 00043 } 00044 00045 void DMA::TriggerSource(TriggerType trig) 00046 { 00047 DMA_trigger_source(dma_init_struct, trig); 00048 } 00049 00050 void DMA::TriggerDestination(TriggerType trig) 00051 { 00052 DMA_trigger_destination(dma_init_struct, trig); 00053 } 00054 00055 /* 00056 void DMA::next(LLI* list) 00057 { 00058 DMA_next(dma_init_struct, list); 00059 } 00060 */ 00061 00062 void DMA::next(const uint32_t src, const uint32_t dst, uint32_t size) 00063 { 00064 DMA_next(dma_init_struct, src, dst, size); 00065 } 00066 00067 void DMA::start (unsigned int len) 00068 { 00069 DMA_init(chan,dma_init_struct); 00070 DMA_start(chan, dma_init_struct, len); 00071 } 00072 00073 void DMA::wait() 00074 { 00075 while (DMA_channel_active(chan)); 00076 } 00077 00078 bool DMA::finished() 00079 { 00080 return !DMA_channel_active(chan); 00081 } 00082 }
Generated on Sat Jul 16 2022 23:21:49 by
1.7.2