61 static void wait() __attribute__((always_inline)) { }
88 static void writeByte(uint8_t b, clock_ptr_t clockpin, data_ptr_t datapin) {
102 static void writeByte(uint8_t b, data_ptr_t datapin,
103 data_t hival, data_t loval,
104 clock_t hiclock, clock_t loclock) {
105 writeBit<7>(b, datapin, hival, loval, hiclock, loclock);
106 writeBit<6>(b, datapin, hival, loval, hiclock, loclock);
107 writeBit<5>(b, datapin, hival, loval, hiclock, loclock);
108 writeBit<4>(b, datapin, hival, loval, hiclock, loclock);
109 writeBit<3>(b, datapin, hival, loval, hiclock, loclock);
110 writeBit<2>(b, datapin, hival, loval, hiclock, loclock);
111 writeBit<1>(b, datapin, hival, loval, hiclock, loclock);
112 writeBit<0>(b, datapin, hival, loval, hiclock, loclock);
119 static void writeByte(uint8_t b, clock_ptr_t clockpin, data_ptr_t datapin,
120 data_t hival, data_t loval,
121 clock_t hiclock, clock_t loclock) {
122 writeBit<7>(b, clockpin, datapin, hival, loval, hiclock, loclock);
123 writeBit<6>(b, clockpin, datapin, hival, loval, hiclock, loclock);
124 writeBit<5>(b, clockpin, datapin, hival, loval, hiclock, loclock);
125 writeBit<4>(b, clockpin, datapin, hival, loval, hiclock, loclock);
126 writeBit<3>(b, clockpin, datapin, hival, loval, hiclock, loclock);
127 writeBit<2>(b, clockpin, datapin, hival, loval, hiclock, loclock);
128 writeBit<1>(b, clockpin, datapin, hival, loval, hiclock, loclock);
129 writeBit<0>(b, clockpin, datapin, hival, loval, hiclock, loclock);
134#if defined(FASTLED_TEENSY4)
135 #define DELAY_NS (1000 / (SPI_SPEED/1000000))
136 #define CLOCK_HI_DELAY do { delayNanoseconds((DELAY_NS/4)); } while(0);
137 #define CLOCK_LO_DELAY do { delayNanoseconds((DELAY_NS/4)); } while(0);
140 #define MIN_DELAY ((NS(35)>3) ? (NS(35) - 3) : 1)
143 #define CLOCK_HI_DELAY do { delaycycles<MIN_DELAY>(); delaycycles<((SPI_SPEED > 10) ? (((SPI_SPEED-6) / 2) - MIN_DELAY) : (SPI_SPEED))>(); } while(0);
145 #define CLOCK_LO_DELAY do { delaycycles<((SPI_SPEED > 10) ? ((SPI_SPEED-6) / 2) : (SPI_SPEED))>(); } while(0);
151 template <u
int8_t BIT> __attribute__((always_inline, hot))
inline static void writeBit(uint8_t b) {
179 template <u
int8_t BIT> FASTLED_FORCE_INLINE
static void writeBit(uint8_t b, clock_ptr_t clockpin, data_ptr_t datapin) {
194 template <u
int8_t BIT> FASTLED_FORCE_INLINE
static void writeBit(uint8_t b, clock_ptr_t clockpin, data_ptr_t datapin,
195 data_t hival, data_t loval, clock_t hiclock, clock_t loclock) {
211 template <u
int8_t BIT> FASTLED_FORCE_INLINE
static void writeBit(uint8_t b, data_ptr_t clockdatapin,
212 data_t datahiclockhi, data_t dataloclockhi,
213 data_t datahiclocklo, data_t dataloclocklo) {
255#ifdef FAST_SPI_INTERRUPTS_WRITE_PINS
274 writeByte(value, clockpin, datapin, datahi, datalo, clockhi, clocklo);
285 writeByte(value, datapin, datahi_clockhi, datalo_clockhi, datahi_clocklo, datalo_clocklo);
296 template <
class D>
void writeBytes(FASTLED_REGISTER uint8_t *data,
int len) {
298#ifdef FAST_SPI_INTERRUPTS_WRITE_PINS
299 uint8_t *end = data + len;
314 uint8_t *end = data + len;
317 writeByte(D::adjust(*data++), clockpin, datapin, datahi, datalo, clockhi, clocklo);
328 uint8_t *end = data + len;
331 writeByte(D::adjust(*data++), datapin, datahi_clockhi, datalo_clockhi, datahi_clocklo, datalo_clocklo);
353 FASTLED_UNUSED(context);
355 int len = pixels.
mLen;
357#ifdef FAST_SPI_INTERRUPTS_WRITE_PINS
360 while(pixels.
has(1)) {
384 while(pixels.
has(1)) {
386 writeBit<0>(1, clockpin, datapin, datahi, datalo, clockhi, clocklo);
402 while(pixels.
has(1)) {
404 writeBit<0>(1, datapin, datahi_clockhi, datalo_clockhi, datahi_clocklo, datalo_clocklo);
406 writeByte(D::adjust(pixels.
loadAndScale0()), datapin, datahi_clockhi, datalo_clockhi, datahi_clocklo, datalo_clocklo);
407 writeByte(D::adjust(pixels.
loadAndScale1()), datapin, datahi_clockhi, datalo_clockhi, datahi_clocklo, datalo_clocklo);
408 writeByte(D::adjust(pixels.
loadAndScale2()), datapin, datahi_clockhi, datalo_clockhi, datahi_clocklo, datalo_clocklo);