diff --git a/itsybitsy_m0_lights/src/lib.rs b/itsybitsy_m0_lights/src/lib.rs index e8ffef8..66b3b6c 100644 --- a/itsybitsy_m0_lights/src/lib.rs +++ b/itsybitsy_m0_lights/src/lib.rs @@ -39,19 +39,13 @@ pub fn boot() -> NeopixelLights< } } -// WS2815 lighting times +// WS2815 ideal lighting times // approx. 20ns per clock cycle; // const ZERO_HIGH_CYCLES: u32 = 11; // about 220ns // const ONE_HIGH_CYCLES: u32 = 29; // about 580ns // const ZERO_LOW_CYCLES: u32 = 29; // about 580ns // const ONE_LOW_CYCLES: u32 = 11; // about 220ns -// experimentally, there is some unknown overhead -// but these timings appear to work for me: -const ZERO_HIGH_CYCLES: u32 = 2; -const ONE_HIGH_CYCLES: u32 = 9; -const ZERO_LOW_CYCLES: u32 = 10; -const ONE_LOW_CYCLES: u32 = 10; const LATCH_CYCLES: u32 = 15000; // about 300us pub struct NeopixelLights { @@ -72,11 +66,13 @@ where // go high self.high_out.set_high().unwrap(); + // experimentally, there is some unknown overhead + // but these timings appear to work for me unsafe { compiler_fence(Ordering::SeqCst); asm!( - // ? nops - "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", + // 8 nops + "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", ); compiler_fence(Ordering::SeqCst); } @@ -85,7 +81,7 @@ where unsafe { compiler_fence(Ordering::SeqCst); asm!( - // 7 nops + // 14 nops "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", ); @@ -99,7 +95,7 @@ where unsafe { compiler_fence(Ordering::SeqCst); asm!( - // 2 nops + // 15 nops "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", "nop;", );