aboutsummaryrefslogtreecommitdiff
path: root/main/init.cpp
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-04-25 15:54:24 +0200
committerlonkaars <loek@pipeframe.xyz>2024-04-25 15:54:24 +0200
commit6df58f546db68047fe38f3809ee4f6cbff4c6f89 (patch)
tree8964f9bdc736e301dad7c11b24c03b2891e3916f /main/init.cpp
parent42b3b8abd73d0f38efd607fc9dfcf768341549a1 (diff)
clean up init
Diffstat (limited to 'main/init.cpp')
-rw-r--r--main/init.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/main/init.cpp b/main/init.cpp
new file mode 100644
index 0000000..425f591
--- /dev/null
+++ b/main/init.cpp
@@ -0,0 +1,32 @@
+#include "config.h"
+#include "init.h"
+
+#include <pico/stdio.h>
+#include <pico/cyw43_arch.h>
+
+static void init_stdio() {
+ stdio_init_all();
+}
+
+static void init_cyw34() {
+ if (cyw43_arch_init_with_country(CONF_NET_COUNTRY))
+ panic("cyw43_arch_init_with_country failed\n");
+}
+
+static void init_wifi() {
+ // enable 'station' mode (connect to an access point instead of acting like one)
+ cyw43_arch_enable_sta_mode();
+
+ if (cyw43_arch_wifi_connect_timeout_ms(CONF_NET_SSID, CONF_NET_PASS, CYW43_AUTH_WPA2_AES_PSK, CONF_NET_CONN_TIMEOUT))
+ panic("cyw43_arch_wifi_connect failed\n");
+
+ // TODO: announce hostname
+}
+
+void init() {
+ init_stdio();
+ init_cyw34();
+ init_wifi();
+ // TODO: initialize i2c
+}
+