summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authordweller <dweller@cabin.digital>2024-09-16 13:05:33 +0300
committerdweller <dweller@cabin.digital>2024-09-16 13:05:33 +0300
commit68a2a3a373f01ec128221f2c7dec998bdd832a85 (patch)
treef08d2dc8567b9ce18649c2e7ba6280aa5420bf0e /main.c
Initial commit
Diffstat (limited to '')
-rw-r--r--main.c49
1 files changed, 49 insertions, 0 deletions
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 <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;
+}