aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h41
1 files changed, 28 insertions, 13 deletions
diff --git a/src/util.h b/src/util.h
index 8f727f7..9226983 100644
--- a/src/util.h
+++ b/src/util.h
@@ -6,12 +6,13 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdarg.h>
+#include <sys/types.h>
#define ARRLEN(x) (sizeof(x) / sizeof((x)[0]))
-#define WARN(...) stdio_log(LOG_WARN, "WARN : " __VA_ARGS__)
-#define INFO(...) stdio_log(LOG_INFO, "INFO : " __VA_ARGS__)
-#define DEBUG(...) stdio_log(LOG_DEBUG, "DEBUG: " __VA_ARGS__)
+#define WARN(group, ...) stdio_log(group, LOG_WARN, "WARN : " __VA_ARGS__)
+#define INFO(group, ...) stdio_log(group, LOG_INFO, "INFO : " __VA_ARGS__)
+#define DEBUG(group, ...) stdio_log(group, LOG_DEBUG, "DEBUG: " __VA_ARGS__)
#define PANIC(...) blink_panic(200, HARD_RED, __VA_ARGS__);
#define ASSERT(cond) do { \
@@ -19,21 +20,35 @@
#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_WARN,
+ LOG_DEBUG,
LOG_INFO,
- LOG_DEBUG
+ LOG_WARN
};
-void stdio_log(int loglevel, const char *fmtstr, ...);
+enum {
+ LOG_NONE = 0b000000,
+ LOG_MISC = 0b000001,
+ LOG_KEYMAT = 0b000010,
+ LOG_KEYMAP = 0b000100,
+ LOG_HID = 0b001000,
+ LOG_TIMING = 0b010000,
+ LOG_SPLIT = 0b100000,
+ LOG_ALL = 0b111111,
+};
+
+void stdio_log(int group, int level, const char *fmtstr, ...);
void blink_panic(uint32_t blink_ms, uint32_t rgb, const char *fmtstr, ...);
+static inline uint
+claim_unused_sm(PIO pio)
+{
+ int tmp = pio_claim_unused_sm(pio, false);
+ ASSERT(tmp >= 0);
+ return (uint) tmp;
+}
+
extern char warnlog[];
-extern int loglevel;
+extern int log_level_min;
+extern int log_group_mask;