diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -0,0 +1,49 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <stdint.h> +#include <string.h> +#include <assert.h> + +#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; +} |