Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
led_strip: ws2812: HACK: memory-hungry pulse timing bugfix
At least on nRF52 devices, we are taking too much time between pixels dealing with overhead inside the SPI driver transceive calls. This is leading to dropped frames, because the dead time between frames is long enough (5000ns+) to look like a reset pulse to the LED strip. Given this SPI driver limitation, it seems this LED driver's design decision to rely on SPI peripherals as efficient pulse generators doesn't work well in practice. The right way to handle this is probably to switch from SPI to efficient inline assembly which bit-bangs the pulses with interrupts disabled. This is what other efficient libraries do to drive this type of LED (e.g. FastLED uses C++ templates that expand into such assembly). The Zephyr GPIO API doesn't support doing that in a portable fashion, unfortunately. For now, we'll cheat by pre-allocating enough buffer space to send the entire strip's worth of data. This is preposterously inefficient (8x memory overhead since there's one byte to make a SPI frame for each bit of color), but makes the driver work correctly. (Note that using timer peripherals as pulse generators, when combined with DMA for efficiency, would also lead to similar levels of overhead.) Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
- Loading branch information