Hi Alan, Thanks for the historical explanation.
The board is already done. I designed it to work with arduino. For the ws2812 leds (actually it is tiny EC3210 working with SK6812 protocol which is compatible with ws2812b) I used a library which uses pwm : https://github.com/adafruit/Adafruit_NeoPixel. I was hoping to port my project to Nuttx to deal with task priorities and semaphores to improve the efficiency. And also because I want to learn Nuttx. I suppose I have only 2 options : - Try to port this library. Do you think it is possible? advices? - Redo everything. The pin can be configure in SPI MISO which is the wrong way. I need to check if I can cut the trace and rewire it to a MOSI capable pin. I would prefer option 1... I have an oscilloscope. But anyway I will most likely have to deal with WS2812 because of the form factor of the EC3210 which is exactly what I need. Regards, Bert. Le dim. 15 oct. 2023 à 22:14, Alan C. Assis <acas...@gmail.com> a écrit : > Hi Bert, > > On 10/15/23, Bert Voldenuit <bertvolden...@gmail.com> wrote: > > Hello, > > > > I am trying use ws2812 driver with a samd21 mcu. > > > > I took example from the /boards/arm/rp2040. > > > > added to board.h: > > #define BOARD_GPIO_WS2812_PIN 5 /* verifier pin #5 = PA15 */ > > > > added to sam_bringup.c: > > > > #ifdef CONFIG_WS2812 > > /* Configure and initialize the WS2812 LEDs. */ > > #ifdef CONFIG_WS2812_NON_SPI_DRIVER > > #pragma message ("Configure and initialize the WS2812 LEDs with non spi > > driver") > > > > if (sam_ws2812_setup("/dev/leds0", > > 5, > > 1, > > CONFIG_WS2812_LED_COUNT, > > HAS_WHITE) == NULL) > > { > > syslog(LOG_ERR, "Failed to initialize WS2812: %d\n", errno); > > return -errno; > > } > > else > > ret = OK; > > > > #else > > #pragma message ("Configure and initialize the WS2812 LEDs with spi > > driver") > > > > ret = board_ws2812_initialize(0, WS2812_SPI, CONFIG_WS2812_LED_COUNT); > > if (ret < 0) > > { > > syslog(LOG_ERR, "ERROR: board_ws2812_initialize() failed: %d\n", ret); > > } > > > > #endif > > > > #endif > > > > > > > > In arch/arm/src/samd2l2 I copied rp2040_ws2812.c and rp2040_ws2812.h and > I > > replaced 'rp2040_' with 'sam_'. > > > > The problem I have is that I can not convert #include rp2040_pio.h. It > > looks like "rp2040_pio.h", "rp2040_pio.c", "rp2040_pio_instructions.h" > > are specifically designed for rp2040. > > > > Am I on the good path? > > Do you have any advice to use ws2812 with samd? I would like to use > ws2812 > > driver without spi driver as all the sercom (com ports) are used. I have > 12 > > leds on the strip and I only need to refresh once per 0.1s. > > > > I think before you trying to do the board you need to understand what > driver to use: > > 1) The original drivers/leds/ws2812.c driver was created by Brennan to > work with SPI and tested initially on STM32. (So > CONFIG_WS2812_NON_SPI_DRIVER shouldn't be defined) > > 2) Then later a contributor called "curuvar" implemented a version > using rp2040 PIO engine to control the WS2812. This driver is only for > this chip! (In this case CONFIG_WS2812_NON_SPI_DRIVER show be y) > > 3) Later on, another NuttX contributor (Victor Benso) created a driver > for ESP32 that used the RMT peripheral to control the WS2812. (In this > case CONFIG_WS2812_NON_SPI_DRIVER show be y) > > Since SAMD21 doesn't have a separated driver to control WS2812 you > will need use option 1. Be in mind that using SPI is not a piece of > cake. You need to fine tune the SPI to generate the right wave form. > > If you don't have an oscilloscope (or doesn't have experience with > it), I suggest to use the APA102 LED Strip. It is a little bit more > expensive than WS2812, but it uses default SPI standard. So APA102 > works fine with all microcontrollers. > > BR, > > Alan >