A simple library to access the DMA functionality.
Fork of SimpleDMA by
SimpleDMA_common.cpp@5:d9f46ef80e20, 2014-01-04 (annotated)
- Committer:
- Sissors
- Date:
- Sat Jan 04 14:42:33 2014 +0000
- Revision:
- 5:d9f46ef80e20
Refactored code, added LPC1768 support
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 5:d9f46ef80e20 | 1 | #include "SimpleDMA.h" |
Sissors | 5:d9f46ef80e20 | 2 | |
Sissors | 5:d9f46ef80e20 | 3 | void SimpleDMA::channel(int chan) { |
Sissors | 5:d9f46ef80e20 | 4 | if (chan == -1) { |
Sissors | 5:d9f46ef80e20 | 5 | auto_channel = true; |
Sissors | 5:d9f46ef80e20 | 6 | _channel = 0; |
Sissors | 5:d9f46ef80e20 | 7 | } else { |
Sissors | 5:d9f46ef80e20 | 8 | auto_channel = false; |
Sissors | 5:d9f46ef80e20 | 9 | if (chan >= 0 && chan < DMA_CHANNELS) |
Sissors | 5:d9f46ef80e20 | 10 | _channel = chan; |
Sissors | 5:d9f46ef80e20 | 11 | else |
Sissors | 5:d9f46ef80e20 | 12 | _channel = DMA_CHANNELS-1; |
Sissors | 5:d9f46ef80e20 | 13 | } |
Sissors | 5:d9f46ef80e20 | 14 | } |
Sissors | 5:d9f46ef80e20 | 15 | |
Sissors | 5:d9f46ef80e20 | 16 | int SimpleDMA::getFreeChannel(void) { |
Sissors | 5:d9f46ef80e20 | 17 | int retval = 0; |
Sissors | 5:d9f46ef80e20 | 18 | while(1) { |
Sissors | 5:d9f46ef80e20 | 19 | if (!isBusy(retval)) |
Sissors | 5:d9f46ef80e20 | 20 | return retval; |
Sissors | 5:d9f46ef80e20 | 21 | retval++; |
Sissors | 5:d9f46ef80e20 | 22 | if (retval >= DMA_CHANNELS) |
Sissors | 5:d9f46ef80e20 | 23 | retval = 0; |
Sissors | 5:d9f46ef80e20 | 24 | } |
Sissors | 5:d9f46ef80e20 | 25 | } |