Browse Source

Update DMAChannel.h

Changed  DMABaseClass::source() and destination() to use p's address instead of its value in the if-clause. Taking the value could result in unwated read operations from I/O locations, resulting in data loss.
teensy4-core
crteensy 10 years ago
parent
commit
e0fdda1918
1 changed files with 6 additions and 6 deletions
  1. +6
    -6
      teensy3/DMAChannel.h

+ 6
- 6
teensy3/DMAChannel.h View File

TCD->SADDR = &p; TCD->SADDR = &p;
TCD->SOFF = 0; TCD->SOFF = 0;
TCD->ATTR_SRC = 0; TCD->ATTR_SRC = 0;
if ((uint32_t)p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 1;
if ((uint32_t)&p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 1;
TCD->SLAST = 0; TCD->SLAST = 0;
} }
void source(volatile const signed short &p) { source(*(volatile const uint16_t *)&p); } void source(volatile const signed short &p) { source(*(volatile const uint16_t *)&p); }
TCD->SADDR = &p; TCD->SADDR = &p;
TCD->SOFF = 0; TCD->SOFF = 0;
TCD->ATTR_SRC = 1; TCD->ATTR_SRC = 1;
if ((uint32_t)p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 2;
if ((uint32_t)&p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 2;
TCD->SLAST = 0; TCD->SLAST = 0;
} }
void source(volatile const signed int &p) { source(*(volatile const uint32_t *)&p); } void source(volatile const signed int &p) { source(*(volatile const uint32_t *)&p); }
TCD->SADDR = &p; TCD->SADDR = &p;
TCD->SOFF = 0; TCD->SOFF = 0;
TCD->ATTR_SRC = 2; TCD->ATTR_SRC = 2;
if ((uint32_t)p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 4;
if ((uint32_t)&p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 4;
TCD->SLAST = 0; TCD->SLAST = 0;
} }


TCD->DADDR = &p; TCD->DADDR = &p;
TCD->DOFF = 0; TCD->DOFF = 0;
TCD->ATTR_DST = 0; TCD->ATTR_DST = 0;
if ((uint32_t)p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 1;
if ((uint32_t)&p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 1;
TCD->DLASTSGA = 0; TCD->DLASTSGA = 0;
} }
void destination(volatile signed short &p) { destination(*(volatile uint16_t *)&p); } void destination(volatile signed short &p) { destination(*(volatile uint16_t *)&p); }
TCD->DADDR = &p; TCD->DADDR = &p;
TCD->DOFF = 0; TCD->DOFF = 0;
TCD->ATTR_DST = 1; TCD->ATTR_DST = 1;
if ((uint32_t)p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 2;
if ((uint32_t)&p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 2;
TCD->DLASTSGA = 0; TCD->DLASTSGA = 0;
} }
void destination(volatile signed int &p) { destination(*(volatile uint32_t *)&p); } void destination(volatile signed int &p) { destination(*(volatile uint32_t *)&p); }
TCD->DADDR = &p; TCD->DADDR = &p;
TCD->DOFF = 0; TCD->DOFF = 0;
TCD->ATTR_DST = 2; TCD->ATTR_DST = 2;
if ((uint32_t)p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 4;
if ((uint32_t)&p < 0x40000000 || TCD->NBYTES == 0) TCD->NBYTES = 4;
TCD->DLASTSGA = 0; TCD->DLASTSGA = 0;
} }



Loading…
Cancel
Save