Arnaud VALLEY / Mbed 2 deprecated Pinscape_Controller_V2_arnoz

Dependencies:   mbed FastIO FastPWM USBDevice

SimpleDMA/SimpleDMA_common.cpp

Committer:
mjr
Date:
2016-02-15
Revision:
45:c42166b2878c

File content as of revision 45:c42166b2878c:

#include "SimpleDMA.h"

void SimpleDMA::channel(int chan) {
    if (chan == -1) {
        auto_channel = true;
        _channel = 0;
    } else {
        auto_channel = false;
        if (chan >= 0 && chan < DMA_CHANNELS)
            _channel = chan;
        else
            _channel = DMA_CHANNELS-1;
    }
}

int SimpleDMA::getFreeChannel(void) {
    int retval = 0;
    while(1) {
        if (!isBusy(retval))
            return retval;
        retval++;
        if (retval >= DMA_CHANNELS)
            retval = 0;
    }  
}