Skip to content

Commit

Permalink
drivers/ws281x: added arm backend, leveraging the light_ws2812 package
Browse files Browse the repository at this point in the history
  • Loading branch information
david-vankampen committed Apr 17, 2024
1 parent 80f315f commit 89ec78f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
6 changes: 5 additions & 1 deletion drivers/ws281x/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Actually |(periph_timer_poll and periph_gpio_ll), but that's too complex for FEATURES_REQUIRED_ANY to express
FEATURES_REQUIRED_ANY += cpu_core_atmega|arch_esp32|arch_native|periph_timer_poll
FEATURES_REQUIRED_ANY += cpu_core_atmega|arch_esp32|arch_native|periph_timer_poll|arch_arm

ifeq (,$(filter ws281x_%,$(USEMODULE)))
ifneq (,$(filter cpu_core_atmega,$(FEATURES_USED)))
Expand All @@ -15,6 +15,10 @@ ifeq (,$(filter ws281x_%,$(USEMODULE)))
ifeq (-periph_timer_poll,$(filter ws281x_%,$(USEMODULE))-$(filter periph_timer_poll,$(FEATURES_USED)))
USEMODULE += ws281x_timer_gpio_ll
endif
ifneq (,$(filter arch_arm,$(FEATURES_USED)))
USEMODULE += ws281x_arm
USEPKG += light_ws2812
endif
endif

ifneq (,$(filter ws281x_atmega,$(USEMODULE)))
Expand Down
36 changes: 36 additions & 0 deletions drivers/ws281x/arm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2022 BISSELL Homecare, Inc.
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup drivers_ws281x
*
* @{
*
* @file
* @brief Implementation of `ws281x_write_buffer()` for the ARM CPU
*
* @author David VanKampen <[email protected]>
*
* @}
*/
#include <assert.h>
#include <errno.h>
#include <stdint.h>
#include <string.h>

#include "ws281x.h"
#include "ws281x_params.h"
#include "ws281x_constants.h"

#include "light_ws2812_cortex.h"

void ws281x_write_buffer(ws281x_t *dev, const void *buf, size_t size)
{
assert(dev);
ws2812_sendarray((uint8_t*)buf, size);
}
9 changes: 8 additions & 1 deletion drivers/ws281x/include/ws281x_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ extern "C" {
* @{
*/
#ifdef MODULE_WS281X_TIMER_GPIO_LL
#define WS281X_HAVE_INIT (1)
#define WS281X_HAVE_INIT (1)
/** @} */

/**
* @name Properties of the ARM backend.
* @{
*/
#ifdef MODULE_WS281X_ARM
#endif
/** @} */

Expand Down
2 changes: 1 addition & 1 deletion examples/light_ws2812/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int main(void)
{
puts("Generated RIOT application: 'light_ws2812'");
random_init(SEED);
while(1) {
while (1) {
for (uint8_t idx = 0; idx < NUM_LEDS; idx++) {
leds[idx] = (uint8_t)random_uint32();
}
Expand Down

0 comments on commit 89ec78f

Please sign in to comment.