aboutsummaryrefslogtreecommitdiff
path: root/main/init.h
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-05-09 15:18:51 +0200
committerlonkaars <loek@pipeframe.xyz>2024-05-09 15:18:51 +0200
commit21bfc93676c56e2265f330170d319da2c480987d (patch)
tree78caa1526cf0c570118d893e52df3301eb9e02a8 /main/init.h
parentefc9870fb1ddd286954fc056b79dddf39f68353a (diff)
working FreeRTOS + lwIP blink/wifi connect example again
Diffstat (limited to 'main/init.h')
-rw-r--r--main/init.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/main/init.h b/main/init.h
index 1f931dc..97b2e20 100644
--- a/main/init.h
+++ b/main/init.h
@@ -1,5 +1,38 @@
#pragma once
-/** @brief initialize all peripherals on the pico */
+#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();
+