
Originally Posted by
molleonair
Hi Paul thnx for Help
i found the Problem
i add
SerialFlash.begin (6);
to setup and it works
it was realy difficult to find this in the Web
Maybe someone should add an Example in Arduino Teensy Audio Folder
but now i have to add Fastled to this Teensy and i dont understand when i have to deselect the SerialFlash CS Line (Pin6)
and Select the PIN7 to enable Fastled Data on Prop Shield cause they connected to the same SPI Signals
i want play a sound file and update LED Matrix while playing this file
may you have a tip for me
I ran into problems switching back and forth between using the SPI device (in my case it was driving two ST7735 displays) and using the prop shield for doing ws2812b/neopixels.
Here is the thread where it was discussed, and Paul S. and KurtE's answers:
This is the code that I use in a wrapper function around the basic neopixel objects. I don't think I've used this in some time, so the code may have bit-rotted.
Code:
#ifdef SPI_HAS_TRANSACTION
// Return true if the pin is one of the special SPI0 pins for ouptut
static inline bool
is_spi0_pin (Neopixel_pin_t pin)
{
if (pin < 0)
return false;
#if PROCESSOR_TEENSY_ARM
switch (pin)
{
default:
break;
#if PROCESSOR_TEENSY_3_5 || PROCESSOR_TEENSY_3_6
case 27: // 3.5/3.6 alternate SCLK0
case 28: // 3.5/3.6 alternate MOSI0
#endif
case 7: // alternate MOSI0
case 11: // normal MOSI0
case 13: // normal SCLK
case 14: // alternate SCLK
return true;
}
#endif
return false;
}
#endif
// display the pixels and possibly blink the LED
void
Neopixel_object::show (void)
{
if (lowlevel)
{
#ifdef SPI_HAS_TRANSACTION
bool pin_spi_p = do_spi_reserve && is_spi0_pin (pin_neopixel);
bool pin2_spi_p = do_spi_reserve && is_spi0_pin (pin_neopixel2);
if (do_spi_reserve)
{
// beginTransaction prevents SPI bus conflicts
// We need to reset 11 & 13 to being digital pins
// https://forum.pjrc.com/threads/46640-Neopixels-with-SPI-transactions-on-prop-shield-working-with-ST7735-SSD1351-displays
SPI.beginTransaction (SPISettings(24000000, MSBFIRST, SPI_MODE0));
if (pin_spi_p)
pinMode (pin_neopixel, OUTPUT);
if (pin2_spi_p)
pinMode (pin_neopixel2, OUTPUT);
// Doing uncanny eyes, we need a slight delay after doing the beingTransaction so that the first LED doesn't glitch
if (do_spi_delay)
delay (do_spi_delay);
}
#endif
if (pin_enable >= 0)
digitalWrite (pin_enable, HIGH);
lowlevel->show ();
if (do_blink)
blink ();
if (pin_enable >= 0)
digitalWrite (pin_enable, LOW);
#ifdef SPI_HAS_TRANSACTION
if (do_spi_reserve)
{
// allow other libs to use SPI again
SPI.endTransaction ();
#if PROCESSOR_TEENSY_3_X || PROCESSOR_TEENSY_LC
if (pin_spi_p)
{
volatile uint32_t *reg = portConfigRegister (pin_neopixel);
*reg = PORT_PCR_MUX (2);
}
if (pin2_spi_p)
{
volatile uint32_t *reg = portConfigRegister (pin_neopixel2);
*reg = PORT_PCR_MUX (2);
}
#elif PROCESSOR_TEENSY_4_x
if (pin_spi_p || pin_spi2_p)
Serial.println ("Need to add Teensy 4.0 transaction support");
#endif
}
#endif
}
else
abort_with_message ("Neopixel_object::show, no lowlevel neopixel");
}
Here is the code that sets the various PROCESSOR_TEEENSY macros:
Code:
#if defined(__MK20DX128__)
#define PROCESSOR_TEENSY_3_0 1
#define PROCESSOR_TEENSY_3_X 1
#define PROCESSOR_TEENSY_3_OR_4_X 1
#define PROCESSOR_TEENSY_ARM 1
#define PROCESSOR_NAME "PJRC Teensy 3.0"
#elif defined(__MK20DX256__)
#define PROCESSOR_TEENSY_3_1 1 // 3.1 and 3.2 are identical except for the voltage regulator
#define PROCESSOR_TEENSY_3_2 1
#define PROCESSOR_TEENSY_3_X 1
#define PROCESSOR_TEENSY_3_OR_4_X 1
#define PROCESSOR_TEENSY_ARM 1
#define PROCESSOR_NAME "PJRC Teensy 3.2"
#elif defined(__MKL26Z64__)
#define PROCESSOR_TEENSY_LC 1
#define PROCESSOR_NAME "PJRC Teensy LC"
#elif defined(__MK64FX512__)
#define PROCESSOR_TEENSY_3_5 1
#define PROCESSOR_TEENSY_3_X 1
#define PROCESSOR_TEENSY_3_OR_4_X 1
#define PROCESSOR_TEENSY_ARM 1
#define PROCESSOR_NAME "PJRC Teensy 3.5"
#elif defined(__MK66FX1M0__)
#define PROCESSOR_TEENSY_3_6 1
#define PROCESSOR_TEENSY_3_X 1
#define PROCESSOR_TEENSY_3_OR_4_X 1
#define PROCESSOR_TEENSY_ARM 1
#define PROCESSOR_NAME "PJRC Teensy 3.6"
#elif defined(__IMXRT1052__)
#define PROCESSOR_TEENSY_4_BETA1 1
#define PROCESSOR_TEENSY_4_X 1
#define PROCESSOR_TEENSY_3_OR_4_X 1
#define PROCESSOR_TEENSY_ARM 1
#define PROCESSOR_NAME "PJRC Teensy 4.0 Beta1"
#elif defined(__IMXRT1062__)
#define PROCESSOR_TEENSY_4 1
#define PROCESSOR_TEENSY_4_X 1
#define PROCESSOR_TEENSY_3_OR_4_X 1
#define PROCESSOR_TEENSY_ARM 1
#if defined(ARDUINO_TEENSY40)
#define PROCESSOR_TEENSY_4_0 1
#define PROCESSOR_TEENSY_4_1 1
#define PROCESSOR_NAME "PJRC Teensy 4.0"
#elif defined(ARDUINO_TEENSY41)
#define PROCESSOR_TEENSY_4_0 0
#define PROCESSOR_TEENSY_4_1 1
#define PROCESSOR_NAME "PJRC Teensy 4.1"
#else
#define PROCESSOR_TEENSY_4_0 0
#define PROCESSOR_TEENSY_4_1 0
#define PROCESSOR_NAME "PJRC Teensy 4.x"
#endif
#else
#warning "Unknown Teensy, fix Meissner_Config_Teensy.h"
#define PROCESSOR_NAME "PJRC Unknown Teensy"
#endif