Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Garcia <danielgarcia@gmail.com>2014-04-02 13:03:59 +0400
committerDaniel Garcia <danielgarcia@gmail.com>2014-04-02 13:03:59 +0400
commit276926272da6be767b3fe5189ab59c657f9ca026 (patch)
tree9c29fa1f8d71bbf47b721c9f8e0922d7be0fba0a
parent949ff41fd6c5272919db568661c926b9d6c2d4aa (diff)
Fix teensy @24Mhz for WS2812.
-rw-r--r--clockless_arm_k20.h35
1 files changed, 20 insertions, 15 deletions
diff --git a/clockless_arm_k20.h b/clockless_arm_k20.h
index 319dd471..003e470f 100644
--- a/clockless_arm_k20.h
+++ b/clockless_arm_k20.h
@@ -66,30 +66,32 @@ public:
}
#endif
- template<int BITS, int PX> __attribute__ ((always_inline)) inline static void writeBits(register uint32_t & next_mark, register data_ptr_t port, register data_t hi, register data_t lo, PixelController<RGB_ORDER> & pixels, register uint8_t & b) {
+ template<int BITS> __attribute__ ((always_inline)) inline static void writeBits(register uint32_t & next_mark, register data_ptr_t port, register data_t hi, register data_t lo, register uint8_t & b) {
for(register uint32_t i = BITS-1; i > 0; i--) {
while(ARM_DWT_CYCCNT < next_mark);
next_mark = ARM_DWT_CYCCNT + (T1+T2+T3);
FastPin<DATA_PIN>::fastset(port, hi);
- uint32_t flip_mark = next_mark - ((b&0x80) ? (T3) : (T2+T3));
+ if(b&0x80) {
+ while((next_mark - ARM_DWT_CYCCNT) > T3);
+ FastPin<DATA_PIN>::fastset(port, lo);
+ } else {
+ while((next_mark - ARM_DWT_CYCCNT) > (T2+T3+1));
+ FastPin<DATA_PIN>::fastset(port, lo);
+ }
b <<= 1;
- while(ARM_DWT_CYCCNT < flip_mark);
- FastPin<DATA_PIN>::fastset(port, lo);
}
while(ARM_DWT_CYCCNT < next_mark);
next_mark = ARM_DWT_CYCCNT + (T1+T2+T3);
FastPin<DATA_PIN>::fastset(port, hi);
- uint32_t flip_mark = next_mark - ((b&0x80) ? (T3) : (T2+T3));
- // load the next byte in the gap where we would've bit shifted in the past
- switch(PX) {
- case 0: b = pixels.advanceAndLoadAndScale0(); break;
- case 1: b = pixels.loadAndScale1(); break;
- case 2: b = pixels.loadAndScale2(); break;
+ if(b&0x80) {
+ while((next_mark - ARM_DWT_CYCCNT) > T3);
+ FastPin<DATA_PIN>::fastset(port, lo);
+ } else {
+ while((next_mark - ARM_DWT_CYCCNT) > (T2+T3+1));
+ FastPin<DATA_PIN>::fastset(port, lo);
}
- while(ARM_DWT_CYCCNT < flip_mark);
- FastPin<DATA_PIN>::fastset(port, lo);
}
// This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then
@@ -114,13 +116,16 @@ public:
pixels.stepDithering();
// Write first byte, read next byte
- writeBits<8+XTRA0,1>(next_mark, port, hi, lo, pixels, b);
+ writeBits<8+XTRA0>(next_mark, port, hi, lo, b);
+ b = pixels.loadAndScale1();
// Write second byte, read 3rd byte
- writeBits<8+XTRA0,2>(next_mark, port, hi, lo, pixels, b);
+ writeBits<8+XTRA0>(next_mark, port, hi, lo, b);
+ b = pixels.loadAndScale2();
// Write third byte, read 1st byte of next pixel
- writeBits<8+XTRA0,0>(next_mark, port, hi, lo, pixels, b);
+ writeBits<8+XTRA0>(next_mark, port, hi, lo, b);
+ b = pixels.advanceAndLoadAndScale0();
};
}
};