The current driver contains assembly code which is specific for the nRF51 SOC which makes it incompatible with other SOC's. This patch adds support for other nRF SOC's as well. The timing is calucated based on the CPU clock frequency, but can be configured manually as well if needed. Changes have been verified on a Adafruit Feather nRF52840 Express board, which contains a single NeoPixel RGB LED. Timings have been verified using a scope connected to the WS1812 data line. Signed-off-by: Chaim Zax <chaim.zax@zaxx.pro>
103 lines
3.9 KiB
Plaintext
103 lines
3.9 KiB
Plaintext
# Copyright (c) 2017 Linaro Limited
|
|
# Copyright (c) 2019 Nordic Semiconductor ASA
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# The following blog post is an excellent resource about pulse timing:
|
|
#
|
|
# https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/
|
|
|
|
config WS2812_STRIP_SPI
|
|
bool "WS2812 LED strip SPI driver"
|
|
default y
|
|
depends on DT_HAS_WORLDSEMI_WS2812_SPI_ENABLED
|
|
select SPI if $(dt_compat_on_bus,$(DT_COMPAT_WORLDSEMI_WS2812_SPI),spi)
|
|
help
|
|
Enable driver for WS2812 (and compatibles) LED strip using SPI.
|
|
The SPI driver is portable, but requires significantly more
|
|
memory (1 byte of overhead per bit of pixel data).
|
|
|
|
config WS2812_STRIP_I2S
|
|
bool "WS2812 LED strip I2S driver"
|
|
default y
|
|
depends on DT_HAS_WORLDSEMI_WS2812_I2S_ENABLED
|
|
select I2S if $(dt_compat_on_bus,$(DT_COMPAT_WORLDSEMI_WS2812_I2S),i2s)
|
|
help
|
|
Enable driver for WS2812 (and compatibles) LED strip using I2S.
|
|
Uses the I2S peripheral, memory usage is 4 bytes per color,
|
|
times the number of pixels. A few more for the start and end
|
|
delay. The reset delay has a coarse resolution of ~20us.
|
|
|
|
config WS2812_STRIP_GPIO
|
|
bool "WS2812 LED strip GPIO driver"
|
|
# Only an Cortex-M inline assembly implementation for the nRF91, nRF51,
|
|
# nRF52 and nRF53 is supported currently.
|
|
default y
|
|
depends on DT_HAS_WORLDSEMI_WS2812_GPIO_ENABLED
|
|
depends on (SOC_SERIES_NRF91X || SOC_SERIES_NRF51X || SOC_SERIES_NRF52X || SOC_SERIES_NRF53X)
|
|
select LED_STRIP_RGB_SCRATCH
|
|
help
|
|
Enable driver for WS2812 (and compatibles) LED strip directly
|
|
controlling with GPIO. The GPIO driver does bit-banging with inline
|
|
assembly, and is not available on all SoCs.
|
|
|
|
Note that this driver is not compatible with the Everlight B1414
|
|
controller.
|
|
|
|
if WS2812_STRIP_GPIO
|
|
|
|
DT_CHOSEN_LED_STRIP := zephyr,led-strip
|
|
DT_CHOSEN_LED_STRIP_PATH := $(dt_chosen_path,$(DT_CHOSEN_LED_STRIP))
|
|
|
|
config DELAY_T1H
|
|
int "Delay 1 bit high pulse"
|
|
default $(dt_node_int_prop_int,$(DT_CHOSEN_LED_STRIP_PATH),delay-t1h) \
|
|
if $(dt_node_has_prop,$(DT_CHOSEN_LED_STRIP_PATH),delay-t1h)
|
|
default $(div,$(mul,700,$(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)),1000000000) \
|
|
if $(dt_node_has_prop,/cpus/cpu@0,clock-frequency)
|
|
default 7
|
|
help
|
|
Number of NOP assembly operations to create a delay for a 1 bit, high voltage period (default 700 nsec)
|
|
|
|
config DELAY_T1L
|
|
int "Delay 1 bit low pulse"
|
|
default $(dt_node_int_prop_int,$(DT_CHOSEN_LED_STRIP_PATH),delay-t1l) \
|
|
if $(dt_node_has_prop,$(DT_CHOSEN_LED_STRIP_PATH),delay-t1l)
|
|
default $(div,$(mul,600,$(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)),1000000000) \
|
|
if $(dt_node_has_prop,/cpus/cpu@0,clock-frequency)
|
|
default 6
|
|
help
|
|
Number of NOP assembly operations to create a delay for a 1 bit, low voltage period (default 600 nsec)
|
|
|
|
config DELAY_T0H
|
|
int "Delay 0 bit high pulse"
|
|
default $(dt_node_int_prop_int,$(DT_CHOSEN_LED_STRIP_PATH),delay-t0h) \
|
|
if $(dt_node_has_prop,$(DT_CHOSEN_LED_STRIP_PATH),delay-t0h)
|
|
default $(div,$(mul,350,$(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)),1000000000) \
|
|
if $(dt_node_has_prop,/cpus/cpu@0,clock-frequency)
|
|
default 3
|
|
help
|
|
Number of NOP assembly operations to create a delay for a 0 bit, high voltage period (default 350 nsec)
|
|
|
|
config DELAY_T0L
|
|
int "Delay 0 bit low pulse"
|
|
default $(dt_node_int_prop_int,$(DT_CHOSEN_LED_STRIP_PATH),delay-t0l) \
|
|
if $(dt_node_has_prop,$(DT_CHOSEN_LED_STRIP_PATH),delay-t0l)
|
|
default $(div,$(mul,800,$(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)),1000000000) \
|
|
if $(dt_node_has_prop,/cpus/cpu@0,clock-frequency)
|
|
default 8
|
|
help
|
|
Number of NOP assembly operations to create a delay for a 0 bit, low voltage period (default 800 nsec)
|
|
|
|
endif
|
|
|
|
|
|
config WS2812_STRIP_RPI_PICO_PIO
|
|
bool "WS2812 LED strip Raspberry Pi Pico PIO driver"
|
|
default y
|
|
depends on DT_HAS_WORLDSEMI_WS2812_RPI_PICO_PIO_ENABLED
|
|
select PICOSDK_USE_PIO
|
|
help
|
|
Enable driver for WS2812 (and compatibles) LED strip using
|
|
the RaspberryPi Pico's PIO.
|