Browse Source

Add force init option to DMAChannel begin()

teensy4-core
PaulStoffregen 10 years ago
parent
commit
dc356076ed
2 changed files with 5 additions and 5 deletions
  1. +4
    -4
      teensy3/DMAChannel.cpp
  2. +1
    -1
      teensy3/DMAChannel.h

+ 4
- 4
teensy3/DMAChannel.cpp View File

// so C-only code can reserve DMA channels // so C-only code can reserve DMA channels
uint16_t dma_channel_allocated_mask = 0; uint16_t dma_channel_allocated_mask = 0;


void DMAChannel::begin(void)
void DMAChannel::begin(bool force_initialization)
{ {
uint32_t ch = 0; uint32_t ch = 0;


__disable_irq(); __disable_irq();
if (TCD && ch < DMA_NUM_CHANNELS
&& (dma_channel_allocated_mask & (1 << ch))
&& (uint32_t)TCD == (0x40009000 + ch * 32)) {
if (!force_initialization && TCD && channel < DMA_NUM_CHANNELS
&& (dma_channel_allocated_mask & (1 << channel))
&& (uint32_t)TCD == (0x40009000 + channel * 32)) {
// DMA channel already allocated // DMA channel already allocated
__enable_irq(); __enable_irq();
return; return;

+ 1
- 1
teensy3/DMAChannel.h View File

~DMAChannel() { ~DMAChannel() {
release(); release();
} }
void begin(void);
void begin(bool force_initialization = false);
private: private:
void release(void); void release(void);



Loading…
Cancel
Save