aboutsummaryrefslogtreecommitdiff
path: root/main/init.h
diff options
context:
space:
mode:
authorElwin Hammer <elwinhammer@gmail.com>2024-05-29 21:41:24 +0200
committerGitHub <noreply@github.com>2024-05-29 21:41:24 +0200
commit1f78927e2e399a504368fb9b407de12d06dddcb5 (patch)
treef80ba30274ca75704075610a39fc28930f7ac4fa /main/init.h
parentd7616546dd5e8ba35c2b1b1ece736bca60e0b990 (diff)
parent8894d20ff0d1c1dde69879a21e756e01bcfa5262 (diff)
Merge pull request #11 from lonkaars/masterprot/software-puzzle
Bring software-puzzle up-to-date
Diffstat (limited to 'main/init.h')
-rw-r--r--main/init.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/main/init.h b/main/init.h
new file mode 100644
index 0000000..de9023c
--- /dev/null
+++ b/main/init.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include <FreeRTOS.h>
+#include <event_groups.h>
+
+/**
+ * \brief init function complete event group handle
+ *
+ * This is required to make sure the main task waits until initialization is
+ * complete. Due to the combination of FreeRTOS + lwIP, the initialization
+ * should be done while the task scheduler is running. Specifically the
+ * cyw43_arch_init functions make the pico hang indefinitely when used while
+ * the task scheduler is not running.
+ *
+ * \note `init_complete` only utilizes LSB, so `uxBitsToWaitFor` should always
+ * be set to *1*
+ */
+extern EventGroupHandle_t init_complete;
+
+/**
+ * \brief initialize all peripherals on the pico
+ *
+ * This function only synchronously initializes the standard input/output (used
+ * for `printf` and `panic`), and queues all other types of initialization in
+ * the `init` task using FreeRTOS.
+ *
+ * \note Tasks dependent on the wifi being initialized should use the
+ * `init_complete` event group to wait for initialization to complete!
+ */
+void init();
+
+/**
+ * \brief block task until all initialization is complete
+ *
+ * utility function, see above comments
+ */
+void await_init();
+