Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/ws281x: simple DMA implementation through SPI #20218

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

hugueslarrive
Copy link
Contributor

@hugueslarrive hugueslarrive commented Dec 30, 2023

Contribution description

This is a simple way to drive the ws1812b using DMA through SPI. I tested it on a nucleo-f303k8 but it should work on any MCU with similar SPI/DMA peripherals and a 2.4 to 4 MHz SPI clock. It uses 0b1110 for bit '1' and 0b1000 for bit '0' which effectively divides the frequency by 4. However, this requires the generation of a buffer copy of four times the buffer size.

Testing procedure

ws2812b_edit.mp4

Issues/PRs references

https://forum.riot-os.org/t/spi-through-dma/4083

@github-actions github-actions bot added Area: tests Area: tests and testing framework Area: drivers Area: Device drivers labels Dec 30, 2023
spiconf.dev = SPI_DEV(0);
spiconf.mode = SPI_MODE_0;
spiconf.clk = 4000000;
spiconf.cs = SPI_HWCS(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those should be configurable (and why do you need a chip select?)

Would it be possible to extend ws281x_t so we could have multiple instances of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made them configurable at compile time, but this doesn't allow multiple instances, which would have been great. The other compile time parameters WS281X_PARAM_PIN and WS281X_PARAM_NUMOF also prevent multiple instances. I don't know how to handle it properly.

@github-actions github-actions bot added Platform: ESP Platform: This PR/issue effects ESP-based platforms Area: cpu Area: CPU/MCU ports labels Jan 31, 2024
@benpicco
Copy link
Contributor

Please rebase - you can drop the ESP8266 changes now.

@maribu maribu mentioned this pull request Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers Area: tests Area: tests and testing framework Platform: ESP Platform: This PR/issue effects ESP-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants