Lines Matching +full:portable +full:- +full:device

6  * SPDX-License-Identifier: Apache-2.0
22 #include <zephyr/device.h>
25 #include <zephyr/dt-bindings/led/led.h>
41 * We should be able to make this portable using the results of
42 * https://github.com/zephyrproject-rtos/zephyr/issues/11917.
44 * We already have the GPIO device stashed in ws2812_gpio_config, so
47 * Per Arm docs, both Rd and Rn must be r0-r7, so we use the "l"
76 static int send_buf(const struct device *dev, uint8_t *buf, size_t len) in send_buf()
78 const struct ws2812_gpio_cfg *config = dev->config; in send_buf()
79 volatile uint32_t *base = (uint32_t *)&NRF_GPIO->OUTSET; in send_buf()
80 const uint32_t val = BIT(config->gpio.pin); in send_buf()
99 while (len--) { in send_buf()
107 * inter-bit time will be longer than TxL, but the in send_buf()
114 for (i = 7; i >= 0; i--) { in send_buf()
126 /* Returns non-negative value on success. Cap to 0 as API states. */ in send_buf()
132 static int ws2812_gpio_update_rgb(const struct device *dev, in ws2812_gpio_update_rgb()
136 const struct ws2812_gpio_cfg *config = dev->config; in ws2812_gpio_update_rgb()
140 /* Convert from RGB to on-wire format (e.g. GRB, GRBW, RGB, etc) */ in ws2812_gpio_update_rgb()
144 for (j = 0; j < config->num_colors; j++) { in ws2812_gpio_update_rgb()
145 switch (config->color_mapping[j]) { in ws2812_gpio_update_rgb()
160 return -EINVAL; in ws2812_gpio_update_rgb()
165 return send_buf(dev, (uint8_t *)pixels, num_pixels * config->num_colors); in ws2812_gpio_update_rgb()
168 static size_t ws2812_gpio_length(const struct device *dev) in ws2812_gpio_length()
170 const struct ws2812_gpio_cfg *config = dev->config; in ws2812_gpio_length()
172 return config->length; in ws2812_gpio_length()
182 * "color-mapping" DT property.
194 * TODO: try to make this portable, or at least port to more devices.
199 static int ws2812_gpio_##idx##_init(const struct device *dev) \
201 const struct ws2812_gpio_cfg *cfg = dev->config; \
204 if (!gpio_is_ready_dt(&cfg->gpio)) { \
205 LOG_ERR("GPIO device not ready"); \
206 return -ENODEV; \
209 for (i = 0; i < cfg->num_colors; i++) { \
210 switch (cfg->color_mapping[i]) { \
218 " Check the color-mapping DT property", \
219 dev->name); \
220 return -EINVAL; \
224 return gpio_pin_configure_dt(&cfg->gpio, GPIO_OUTPUT); \