aboutsummaryrefslogtreecommitdiffstats
path: root/src/neopix.c
blob: 107f354cb9cfb4c2aca33aacbae89c0a2d86bf72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "hardware/pio.h"

#include "neopix.h"
#include "ws2812.pio.h"

void
neopix_init(struct neopix *pix, PIO pio, uint sm, uint pin)
{
	uint offset;

	pix->sm = sm;
	pix->pio = pio;
	pix->pin = pin;
	offset = pio_add_program(pix->pio, &ws2812_program);
	ws2812_program_init(pix->pio, pix->sm, offset,
		pix->pin, 800000, false);
	pix->init = true;
}

void
neopix_put(struct neopix *pix, uint32_t rgb) {
	pio_sm_put_blocking(pix->pio, pix->sm, rgb << 8u);
}