Fix timings for solid output
This commit is contained in:
parent
295d98359d
commit
3cb7fc1a57
1 changed files with 7 additions and 11 deletions
|
@ -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<T: OutputPin, U: OutputPin, V: OutputPin> {
|
||||
|
@ -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;",
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue