RISC-V/V203F6P6/ws2812b/main.cpp
2025-01-25 12:21:08 +01:00

32 lines
758 B
C++

#include "fifo.h"
#include "spiclass.h"
#include "system.h"
#include "gpio.h"
extern "C" {
extern const unsigned table []; // generováno linux/graph.py
};
static FIFO<uint32_t, FIFOLEN> ring;
static ws2812b driver(ring);
static SpiClass spi (driver);
static GpioClass led (GPIOB, 8);
static constexpr unsigned timeout = 10'000u;
int main () {
led << true;
delay_init();
spi.Init();
unsigned counter = 0u;
for (;;) {
delay_us(timeout);
const bool b = counter & 0x100u;
led << b;
counter += 1u;
for (unsigned n=0u; n<NUMLEDS; n++) {
unsigned cmd = ((counter + 64u * n) & 0xFFu);
cmd = table [cmd] | (n << 24);
ring.Write (cmd);
}
}
return 0;
}