summaryrefslogtreecommitdiff
path: root/main.c
blob: 8a7250e9a3c157e9d9a8881eb9d0b4a78dc926aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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;
}