Skip to content

Commit

Permalink
ws2812_rpi_pico_pio output-pin property change to in-gpio
Browse files Browse the repository at this point in the history
  • Loading branch information
soburi committed Feb 5, 2024
1 parent bc6301b commit 850ff4e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion boards/arm/adafruit_kb2040/adafruit_kb2040.dts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

ws2812: ws2812 {
status = "okay";
output-pin = <17>;
gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>;
chain-length = <1>;
color-mapping = <LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/adafruit_qt_py_rp2040/adafruit_qt_py_rp2040.dts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@

ws2812: ws2812 {
status = "okay";
output-pin = <12>;
gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
chain-length = <1>;
color-mapping = <LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
Expand Down
9 changes: 5 additions & 4 deletions drivers/led_strip/ws2812_rpi_pico_pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/led_strip.h>
#include <zephyr/drivers/misc/pio_rpi_pico/pio_rpi_pico.h>
Expand All @@ -21,7 +22,7 @@ struct ws2812_led_strip_data {

struct ws2812_led_strip_config {
const struct device *piodev;
uint32_t output_pin;
const uint8_t gpio_pin;
uint8_t num_colors;
uint32_t frequency;
const uint8_t *const color_mapping;
Expand Down Expand Up @@ -52,11 +53,11 @@ static int ws2812_led_strip_sm_init(const struct device *dev)
}

sm_config_set_sideset(&sm_config, 1, false, false);
sm_config_set_sideset_pins(&sm_config, config->output_pin);
sm_config_set_sideset_pins(&sm_config, config->gpio_pin);
sm_config_set_out_shift(&sm_config, false, true, (config->num_colors == 4 ? 32 : 24));
sm_config_set_fifo_join(&sm_config, PIO_FIFO_JOIN_TX);
sm_config_set_clkdiv(&sm_config, clkdiv);
pio_sm_set_consecutive_pindirs(pio, sm, config->output_pin, 1, true);
pio_sm_set_consecutive_pindirs(pio, sm, config->gpio_pin, 1, true);
pio_sm_init(pio, sm, -1, &sm_config);
pio_sm_set_enabled(pio, sm, true);

Expand Down Expand Up @@ -187,7 +188,7 @@ static int ws2812_rpi_pico_pio_init(const struct device *dev)
\
static const struct ws2812_led_strip_config ws2812_led_strip_##node##_config = { \
.piodev = DEVICE_DT_GET(DT_PARENT(DT_PARENT(node))), \
.output_pin = DT_PROP(node, output_pin), \
.gpio_pin = DT_GPIO_PIN_BY_IDX(node, gpios, 0), \
.num_colors = DT_PROP_LEN(node, color_mapping), \
.color_mapping = ws2812_led_strip_##node##_color_mapping, \
.reset_delay = DT_PROP(node, reset_delay), \
Expand Down
8 changes: 3 additions & 5 deletions dts/bindings/led_strip/worldsemi,ws2812-rpi_pico-pio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ child-binding:
Worldsemi WS2812 or compatible LED strip driver based on RaspberryPi Pico's PIO
The LED strip node can put up to 4 instances under a single PIO node.
include: ws2812.yaml
include: "worldsemi,ws2812-gpio.yaml"

properties:
output-pin:
type: int
required: true
gpios:
description: |
Select the output pin.
Inherit from worldsemi,ws2812-gpio.
Note: This driver does not configure the output pin.
You need to configure the pin with pinctrl that is in the parent node configuration
Expand Down

0 comments on commit 850ff4e

Please sign in to comment.