FastLED Library and Hardware SPI

Status
Not open for further replies.

gfvalvo

Well-known member
Hi, I have a question about using FastLED library with Teensy. The FastLED web site claims to support hardware SPI with Teensy 3 / 3.1:
https://github.com/FastLED/FastLED/wiki/SPI-Hardware-or-Bit-banging
I would assume (hope) that this extends to other 3.x boards. I tried checking this on a 3.2 board. I used several forms of the ‘FastLED.addLeds’ method:
Code:
FastLED.addLeds<DOTSTAR, RGB>(leds, NUM_LEDS);
FastLED.addLeds<DOTSTAR, 11, 13, RGB>(leds, NUM_LEDS);
FastLED.addLeds<DOTSTAR, 7, 14, RGB>(leds, NUM_LEDS);
I then checked the Pin Control Registers for the SPI data and clock pins. In all cases, the MUX field in these registers was set to 3b001. I believe this is the setting for normal GPIO. The Hardware SPI setting for all of these pins is ALT2 (MUX = 3b010). All this leads me to believe that the FastLED library is using Bit-Bang SPI rather than Hardware SPI on (at least) the Teensy 3.2.

Would appreciate it if someone could check my analysis and / or provide their own experience.

Thanks.
 
Yes, to software Teensy 3.2 and 3.1 are identical. Programs written for one will run on the other.

Teensy 3.2 has an improved 3.3V regulator and a different bootloader chip, but from a software point of view it's identical.
 
Thanks Paul. So was something wrong my test method, or is FastLED actually using bit-bang SPI on the 3.2?
 
Thanks Paul. So was something wrong my test method, or is FastLED actually using bit-bang SPI on the 3.2?

I went through the FastLED library at GitHub, https://github.com/FastLED/FastLED

The first part is platform.h, which references the T3.2 at

Code:
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
// Include k20/T3 headers
#include "platforms/arm/k20/fastled_arm_k20.h"

which includes this header

Code:
#include "fastspi_arm_k20.h"

which is at https://github.com/FastLED/FastLED/blob/master/platforms/arm/k20/fastspi_arm_k20.h

and looks like it's using the hardware SPI to me as long as you use clock_pin 13 or 14, and data_pin 7 or 11 (lines 98 - 127, line 309 - 326).
 
Status
Not open for further replies.
Back
Top