Teensy 4.1 WIP (works, but broke other boards)

This commit is contained in:
Phillip Burgess 2020-05-21 18:19:39 -07:00
parent 7daa236e41
commit 8c53b2515c
3 changed files with 23 additions and 3 deletions

14
arch.h
View file

@ -1217,6 +1217,14 @@ __attribute__((noinline)) void _PM_convert_565_byte(Protomatter_core *core,
dest += core->bufferSize * (1 - core->activeBuffer);
}
#if defined(_PM_portToggleRegister) && !defined(_PM_STRICT_32BIT_IO)
// core->clockMask mask is already an 8-bit value
uint8_t clockMask = core->clockMask;
#else
// core->clockMask mask is 32-bit, shift down to 8-bit for this func.
uint8_t clockMask = core->clockMask >> (core->portOffset * 8);
#endif
// No need to clear matrix buffer, loops below do a full overwrite
// (except for any scanline pad, which was already initialized in the
// begin() function and won't be touched here).
@ -1267,7 +1275,7 @@ __attribute__((noinline)) void _PM_convert_565_byte(Protomatter_core *core,
uint32_t blueBit = initialBlueBit;
for (uint8_t plane = 0; plane < core->numPlanes; plane++) {
#if defined(_PM_portToggleRegister)
uint8_t prior = core->clockMask; // Set clock bit on 1st out
uint8_t prior = clockMask; // Set clock bit on 1st out
#endif
for (uint16_t x = 0; x < width; x++) {
uint16_t upperRGB = upperSrc[x]; // Pixel in upper half
@ -1287,7 +1295,7 @@ __attribute__((noinline)) void _PM_convert_565_byte(Protomatter_core *core,
result |= pinMask[5];
#if defined(_PM_portToggleRegister)
dest[x] = result ^ prior;
prior = result | core->clockMask; // Set clock bit on next out
prior = result | clockMask; // Set clock bit on next out
#else
dest[x] = result;
#endif
@ -1312,7 +1320,7 @@ __attribute__((noinline)) void _PM_convert_565_byte(Protomatter_core *core,
// so idle clock appears LOW -- but really the matrix samples on
// a rising edge and we could leave it high, but at this stage
// in development just want the scope "readable."
dest[-pad] &= ~core->clockMask; // Negative index is legal & intentional
dest[-pad] &= ~clockMask; // Negative index is legal & intentional
#endif
dest += bitplaneSize; // Advance one scanline in dest buffer
} // end plane

View file

@ -114,6 +114,12 @@ RGB+clock are on different PORTs on nRF52840.
uint8_t clockPin = 23; // A9
uint8_t latchPin = 6;
uint8_t oePin = 9;
#elif defined(ARDUINO_TEENSY41)
uint8_t rgbPins[] = {26, 27, 38, 20, 21, 22}; // A12-14, A6-A8 (yes that's a 38, NOT 28!)
uint8_t addrPins[] = {2, 3, 4, 5};
uint8_t clockPin = 23; // A9
uint8_t latchPin = 6;
uint8_t oePin = 9;
#endif
// Last arg here enables double-buffering

View file

@ -114,6 +114,12 @@ RGB+clock are on different PORTs on nRF52840.
uint8_t clockPin = 23; // A9
uint8_t latchPin = 6;
uint8_t oePin = 9;
#elif defined(ARDUINO_TEENSY41)
uint8_t rgbPins[] = {26, 27, 38, 20, 21, 22}; // A12-14, A6-A8 (yes that's a 38, NOT 28!)
uint8_t addrPins[] = {2, 3, 4, 5};
uint8_t clockPin = 23; // A9
uint8_t latchPin = 6;
uint8_t oePin = 9;
#endif
Adafruit_Protomatter matrix(