From 68a2a3a373f01ec128221f2c7dec998bdd832a85 Mon Sep 17 00:00:00 2001 From: dweller Date: Mon, 16 Sep 2024 13:05:33 +0300 Subject: Initial commit --- main.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 main.c (limited to 'main.c') diff --git a/main.c b/main.c new file mode 100644 index 0000000..8a7250e --- /dev/null +++ b/main.c @@ -0,0 +1,49 @@ +#include +#include +#include +#include +#include +#include + +#include "pico/stdlib.h" +#include "hardware/gpio.h" +#include "hardware/pio.h" +#include "hardware/clocks.h" + +#include "ws2812.pio.h" + + +#define PIN_RGB 16 + + +int main(void) +{ + stdio_init_all(); + + gpio_init(PIN_RGB); + gpio_set_dir(PIN_RGB, GPIO_OUT); + gpio_put(PIN_RGB, 1); + + PIO pio = pio0; + int sm = 0; // XXX: ??? + uint32_t offset = pio_add_program(pio, &ws2812_program); + + ws2812_program_init(pio, sm, offset, PIN_RGB, 800000, false); + + uint32_t col = 0; + pio_sm_put_blocking(pio0, 0, col << 8u); + + sleep_ms(1000); + + col = 0x0000FF; + printf("Hell, world...\n"); + while(1) + { + pio_sm_put_blocking(pio0, 0, col); + col = col << 8u; + if(!col) col = 0x0000FF; + sleep_ms(250); + } + + return 0; +} -- cgit v1.2.3