aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.h
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-12-02 16:06:32 +0100
committerLouis Burda <quent.burda@gmail.com>2022-12-02 17:18:16 +0100
commit0392766bc379448c907de2bce45d6b57621d95b5 (patch)
treeb87705bfb60a6569769b3c0125a910144c784436 /src/util.h
parent6defee37f9939991bbf3152e2cd4e18593baa541 (diff)
downloadsxkbd-0392766bc379448c907de2bce45d6b57621d95b5.tar.gz
sxkbd-0392766bc379448c907de2bce45d6b57621d95b5.zip
Added split uart support based on chibios impl
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/util.h b/src/util.h
index 9844360..8b33e2c 100644
--- a/src/util.h
+++ b/src/util.h
@@ -1,6 +1,9 @@
#pragma once
+#include "ws2812.h"
+
#include <stdbool.h>
+#include <stdint.h>
#include <stdarg.h>
#define ARRLEN(x) (sizeof(x) / sizeof((x)[0]))
@@ -10,12 +13,17 @@
#define INFO(...) stdio_log(LOG_INFO, "INFO : " __VA_ARGS__)
#define DEBUG(...) stdio_log(LOG_DEBUG, "DEBUG: " __VA_ARGS__)
-#define PANIC(...) blink_panic(__VA_ARGS__);
+#define PANIC(...) blink_panic(200, WS2812_U32RGB(255, 0, 0), __VA_ARGS__);
#define ASSERT(cond) do { \
- if (!(cond)) blink_panic("Assertion failed: (%s) in %s:%i", \
+ if (!(cond)) PANIC("Assertion failed: (%s) in %s:%i", \
#cond, __FILE__, __LINE__); \
} while (0)
+#define CLAIM_UNUSED_SM(pio) ({ \
+ int tmp = pio_claim_unused_sm(pio, false); \
+ ASSERT(tmp >= 0); \
+ (uint) tmp; })
+
enum {
LOG_NONE,
LOG_ERR,
@@ -26,6 +34,6 @@ enum {
void stdio_log(int loglevel, const char *fmtstr, ...);
-void blink_panic(const char *fmtstr, ...);
+void blink_panic(uint32_t blink_ms, uint32_t rgb, const char *fmtstr, ...);
extern int loglevel;