aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-03-31 16:34:59 +0200
committerlonkaars <loek@pipeframe.xyz>2024-03-31 16:34:59 +0200
commit41932400f68b7af671ee18df958c078e0c8d06e1 (patch)
tree1d9089134e0003f35db75b476d17d641128785cf /main
parent5ebe21c85c7001053c00d20d25195fececbcc7ce (diff)
wifi hello world working
Diffstat (limited to 'main')
-rw-r--r--main/.gitignore2
-rw-r--r--main/CMakeLists.txt22
-rw-r--r--main/config.def.h5
m---------main/lib/pico-sdk0
-rw-r--r--main/lwipopts.h85
-rw-r--r--main/main.cpp25
6 files changed, 139 insertions, 0 deletions
diff --git a/main/.gitignore b/main/.gitignore
new file mode 100644
index 0000000..dd1a9a8
--- /dev/null
+++ b/main/.gitignore
@@ -0,0 +1,2 @@
+config.h
+build
diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt
new file mode 100644
index 0000000..11b12c5
--- /dev/null
+++ b/main/CMakeLists.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.29)
+
+include(lib/pico-sdk/pico_sdk_init.cmake)
+
+project(puzzlebox_main C CXX ASM)
+
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_CXX_STANDARD 17)
+set(PICO_BOARD pico_w)
+
+pico_sdk_init()
+
+add_executable(main
+ main.cpp
+)
+
+pico_enable_stdio_usb(main 1)
+# pico_enable_stdio_uart(main 1)
+pico_add_extra_outputs(main)
+target_include_directories(main PRIVATE ${CMAKE_CURRENT_LIST_DIR})
+target_link_libraries(main pico_cyw43_arch_lwip_threadsafe_background pico_stdlib)
+
diff --git a/main/config.def.h b/main/config.def.h
new file mode 100644
index 0000000..a02915f
--- /dev/null
+++ b/main/config.def.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#define CONF_NET_SSID "network name"
+#define CONF_NET_PASS "network password"
+
diff --git a/main/lib/pico-sdk b/main/lib/pico-sdk
new file mode 160000
+Subproject 6a7db34ff63345a7badec79ebea3aaef1712f37
diff --git a/main/lwipopts.h b/main/lwipopts.h
new file mode 100644
index 0000000..75a57ee
--- /dev/null
+++ b/main/lwipopts.h
@@ -0,0 +1,85 @@
+#pragma once
+
+// allow override in some examples
+#ifndef NO_SYS
+#define NO_SYS 1
+#endif
+
+#ifndef LWIP_SOCKET
+#define LWIP_SOCKET 0
+#endif
+
+#if PICO_CYW43_ARCH_POLL
+#define MEM_LIBC_MALLOC 1
+#else
+#define MEM_LIBC_MALLOC 0
+#endif
+
+#define MEM_ALIGNMENT 4
+#define MEM_SIZE 4000
+#define MEMP_NUM_TCP_SEG 32
+#define MEMP_NUM_ARP_QUEUE 10
+#define PBUF_POOL_SIZE 24
+#define LWIP_ARP 1
+#define LWIP_ETHERNET 1
+#define LWIP_ICMP 1
+#define LWIP_RAW 1
+#define TCP_WND (8 * TCP_MSS)
+#define TCP_MSS 1460
+#define TCP_SND_BUF (8 * TCP_MSS)
+#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
+#define LWIP_NETIF_STATUS_CALLBACK 1
+#define LWIP_NETIF_LINK_CALLBACK 1
+#define LWIP_NETIF_HOSTNAME 1
+#define LWIP_NETCONN 0
+#define MEM_STATS 0
+#define SYS_STATS 0
+#define MEMP_STATS 0
+#define LINK_STATS 0
+// #define ETH_PAD_SIZE 2
+#define LWIP_CHKSUM_ALGORITHM 3
+#define LWIP_DHCP 1
+#define LWIP_IPV4 1
+#define LWIP_TCP 1
+#define LWIP_UDP 1
+#define LWIP_DNS 1
+#define LWIP_TCP_KEEPALIVE 1
+#define LWIP_NETIF_TX_SINGLE_PBUF 1
+#define DHCP_DOES_ARP_CHECK 0
+#define LWIP_DHCP_DOES_ACD_CHECK 0
+
+#ifndef NDEBUG
+#define LWIP_DEBUG 1
+#define LWIP_STATS 1
+#define LWIP_STATS_DISPLAY 1
+#endif
+
+#define ETHARP_DEBUG LWIP_DBG_OFF
+#define NETIF_DEBUG LWIP_DBG_OFF
+#define PBUF_DEBUG LWIP_DBG_OFF
+#define API_LIB_DEBUG LWIP_DBG_OFF
+#define API_MSG_DEBUG LWIP_DBG_OFF
+#define SOCKETS_DEBUG LWIP_DBG_OFF
+#define ICMP_DEBUG LWIP_DBG_OFF
+#define INET_DEBUG LWIP_DBG_OFF
+#define IP_DEBUG LWIP_DBG_OFF
+#define IP_REASS_DEBUG LWIP_DBG_OFF
+#define RAW_DEBUG LWIP_DBG_OFF
+#define MEM_DEBUG LWIP_DBG_OFF
+#define MEMP_DEBUG LWIP_DBG_OFF
+#define SYS_DEBUG LWIP_DBG_OFF
+#define TCP_DEBUG LWIP_DBG_OFF
+#define TCP_INPUT_DEBUG LWIP_DBG_OFF
+#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
+#define TCP_RTO_DEBUG LWIP_DBG_OFF
+#define TCP_CWND_DEBUG LWIP_DBG_OFF
+#define TCP_WND_DEBUG LWIP_DBG_OFF
+#define TCP_FR_DEBUG LWIP_DBG_OFF
+#define TCP_QLEN_DEBUG LWIP_DBG_OFF
+#define TCP_RST_DEBUG LWIP_DBG_OFF
+#define UDP_DEBUG LWIP_DBG_OFF
+#define TCPIP_DEBUG LWIP_DBG_OFF
+#define PPP_DEBUG LWIP_DBG_OFF
+#define SLIP_DEBUG LWIP_DBG_OFF
+#define DHCP_DEBUG LWIP_DBG_OFF
+
diff --git a/main/main.cpp b/main/main.cpp
new file mode 100644
index 0000000..e3e3b92
--- /dev/null
+++ b/main/main.cpp
@@ -0,0 +1,25 @@
+#include <stdio.h>
+
+#include "config.h"
+
+#include "pico/stdlib.h"
+#include "pico/cyw43_arch.h"
+
+int main() {
+ stdio_init_all();
+
+ if (cyw43_arch_init_with_country(CYW43_COUNTRY_UK)) {
+ printf("failed to initialize\n");
+ return 1;
+ }
+ printf("initialised\n");
+
+ cyw43_arch_enable_sta_mode();
+
+ if (cyw43_arch_wifi_connect_timeout_ms(CONF_NET_SSID, CONF_NET_PASS, CYW43_AUTH_WPA2_AES_PSK, 10000)) {
+ printf("failed to connect\n");
+ return 1;
+ }
+ printf("connected\n");
+}
+