summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-12-27 22:41:56 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2016-12-27 22:41:56 (GMT)
commit4d05c420d8fd273b63a6a88299c8213578692a95 (patch)
treefee011ea542bd260fc4140208fb5477ace9b64f8
parent979b989d0043e88ba0e37bb7bf1e685df0c161d1 (diff)
downloadabc80-4d05c420d8fd273b63a6a88299c8213578692a95.zip
abc80-4d05c420d8fd273b63a6a88299c8213578692a95.tar.gz
abc80-4d05c420d8fd273b63a6a88299c8213578692a95.tar.bz2
abc80-4d05c420d8fd273b63a6a88299c8213578692a95.tar.xz
neopixel: extend the reset period to handle WS2813
WS2813 extends the reset spec to 250 µs; this generates a 288 µs reset pulse. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--neopixel.v22
1 files changed, 19 insertions, 3 deletions
diff --git a/neopixel.v b/neopixel.v
index 5f69df6..ab6eacf 100644
--- a/neopixel.v
+++ b/neopixel.v
@@ -45,13 +45,14 @@ module neopixel (
//
// Documented times (in ns) are (±150 ns):
//
- // WS2811 WS2182 WS2812B SK6812
+ // WS2811 WS2182 WS2812B SK6812
// T0H 250/500 350 400 300
// T1H 400/800 800 800 600
// TH+TL 1250/2500 1250±600 1250±600 1250±600
//
// Our cycle time is 32x40 ns = 1280 ns.
//
+
parameter pulse0 = 8; // 320 ns
parameter pulse1 = 20; // 800 ns
@@ -141,8 +142,18 @@ module neopixel (
// Channel is enabled if plen > 0 or global disable
wire b_ena = |b_conf_plen & |b_conf_clen & g_enable;
- // True before stat ctr wrap. Cycles -1 and -2 are for reset
- wire b_stat_end = b_stat_cctr[8] & ~b_stat_cctr[0];
+ //
+ // This is true immediately before before stat ctr wrap.
+ //
+ // Chain reset (end of transmission) requires 250 µs starting
+ // with WS2813. This is 196 bit times; to simplify the circuitry
+ // and give us enough margin we implement this as
+ // 225 bit-times = 288 µs.
+ //
+ // We use negative numbers (2's complement) for reset;
+ // this therefore turns true for cycle -225.
+ //
+ wire b_stat_end = b_stat_cctr[8] & ~b_stat_cctr[7:5];
wire [7:0] b_stat_pctr_p1 = b_stat_pctr + 1'b1;
@@ -174,6 +185,11 @@ module neopixel (
// Byte address in RAM
// The WS2812 wants data in order GRB, so we swizzle the addresses
// slightly so we can use RGB order in memory.
+
+ // XXX: for a 32-bit version of this design, it would make more
+ // sense to count bytes rather than LEDs, and just drop this. This
+ // would provide better support for RGBW as well as a mix of LED types.
+
wire [1:0] b_ctr_byte = { b_ctr[9], ~b_ctr[9]^b_ctr[8] };
wire [15:0] b_stat_addr = b_conf_addr + b_stat_pctr*2'd3 + b_ctr_byte;