Procházet zdrojové kódy

Add DMAChannel begin()

teensy4-core
PaulStoffregen před 10 roky
rodič
revize
a15be57b1d
2 změnil soubory, kde provedl 13 přidání a 5 odebrání
  1. +9
    -1
      teensy3/DMAChannel.cpp
  2. +4
    -4
      teensy3/DMAChannel.h

+ 9
- 1
teensy3/DMAChannel.cpp Zobrazit soubor

@@ -4,10 +4,18 @@
// so C-only code can reserve DMA channels
uint16_t dma_channel_allocated_mask = 0;

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

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

+ 4
- 4
teensy3/DMAChannel.h Zobrazit soubor

@@ -17,9 +17,9 @@
// https://github.com/pixelmatix/SmartMatrix
// https://github.com/crteensy/DmaSpi


#ifdef __cplusplus

#define DMACHANNEL_HAS_BEGIN

class DMABaseClass {
public:
@@ -371,14 +371,14 @@ public:
/*************************************************/

DMAChannel() {
init();
begin();
}
DMAChannel(const DMAChannel &c) {
TCD = c.TCD;
channel = c.channel;
}
DMAChannel(const DMASetting &c) {
init();
begin();
copy_tcd(TCD, c.TCD);
}
DMAChannel & operator = (const DMAChannel &rhs) {
@@ -396,8 +396,8 @@ public:
~DMAChannel() {
release();
}
void begin(void);
private:
void init(void);
void release(void);

public:

Načítá se…
Zrušit
Uložit