-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
701 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
examples/pico-sdk/pico-2-w-picosdk-baremetal-builtin/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
include(pico-sdk/pico_sdk_init.cmake) | ||
|
||
project(firmware) | ||
pico_sdk_init() | ||
|
||
add_executable(firmware | ||
main.c | ||
mongoose.c | ||
net.c | ||
packed_fs.c | ||
) | ||
|
||
target_include_directories(firmware PUBLIC | ||
. | ||
) | ||
|
||
target_link_libraries(firmware pico_stdlib pico_rand pico_cyw43_driver pico_cyw43_arch_none) | ||
pico_add_extra_outputs(firmware) # create map/bin/hex file etc. | ||
|
||
pico_enable_stdio_usb(firmware 1) # Route stdio | ||
pico_enable_stdio_uart(firmware 0) # to USB | ||
|
||
# Mongoose build flags in mongoose_config.h | ||
|
||
# Example build options | ||
add_definitions(-DHTTP_URL="http://0.0.0.0/") | ||
|
22 changes: 22 additions & 0 deletions
22
examples/pico-sdk/pico-2-w-picosdk-baremetal-builtin/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
RM = rm -rf | ||
MKBUILD = rm -rf build && mkdir -p build # test -d build || mkdir build | ||
ifeq ($(OS),Windows_NT) | ||
RM = cmd /C del /Q /F /S | ||
MKBUILD = if not exist build mkdir build | ||
endif | ||
|
||
all example: | ||
true | ||
|
||
build: pico-sdk build/firmware.uf2 | ||
|
||
build/firmware.uf2: | ||
$(MKBUILD) | ||
cd build && cmake -DPICO_BOARD="pico2_w" -G "Unix Makefiles" .. && make | ||
|
||
pico-sdk: | ||
git clone --depth 1 -b 2.1.0 https://github.com/raspberrypi/pico-sdk $@ | ||
cd $@ && git submodule update --init | ||
|
||
clean: | ||
$(RM) pico-sdk build |
4 changes: 4 additions & 0 deletions
4
examples/pico-sdk/pico-2-w-picosdk-baremetal-builtin/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
# Mongoose on PICO 2 W | ||
|
||
|
48 changes: 48 additions & 0 deletions
48
examples/pico-sdk/pico-2-w-picosdk-baremetal-builtin/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) 2024 Cesanta Software Limited | ||
// All rights reserved | ||
|
||
#include "mongoose.h" | ||
#include "net.h" | ||
|
||
|
||
#define WIFI_SSID "yourWiFiSSID" | ||
#define WIFI_PASS "yourWiFiPassword" | ||
|
||
|
||
int main(void) { | ||
// initialize stdio | ||
stdio_init_all(); | ||
|
||
struct mg_mgr mgr; // Initialise Mongoose event manager | ||
mg_mgr_init(&mgr); // and attach it to the interface | ||
mg_log_set(MG_LL_DEBUG); // Set log level | ||
|
||
// Initialise WiFi creds | ||
struct mg_tcpip_driver_pico_w_data driver_data = { | ||
.ssid = WIFI_SSID, | ||
.pass = WIFI_PASS | ||
}; | ||
// Initialise Mongoose network stack | ||
// Either set use_dhcp or enter a static config. | ||
// For static configuration, specify IP/mask/GW in network byte order | ||
struct mg_tcpip_if mif = { | ||
.ip = 0, | ||
.driver = &mg_tcpip_driver_pico_w, | ||
.driver_data = &driver_data, | ||
.recv_queue.size = 8192 | ||
}; | ||
|
||
mg_tcpip_init(&mgr, &mif); | ||
MG_INFO(("Init done, starting main loop")); | ||
|
||
MG_INFO(("Initialising application...")); | ||
web_init(&mgr); | ||
|
||
MG_INFO(("Starting event loop")); | ||
for (;;) { | ||
mg_mgr_poll(&mgr, 0); | ||
} | ||
|
||
return 0; | ||
} | ||
|
1 change: 1 addition & 0 deletions
1
examples/pico-sdk/pico-2-w-picosdk-baremetal-builtin/mongoose.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../mongoose.c |
1 change: 1 addition & 0 deletions
1
examples/pico-sdk/pico-2-w-picosdk-baremetal-builtin/mongoose.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../mongoose.h |
6 changes: 6 additions & 0 deletions
6
examples/pico-sdk/pico-2-w-picosdk-baremetal-builtin/mongoose_config.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#define MG_ARCH MG_ARCH_PICOSDK | ||
|
||
#define MG_ENABLE_TCPIP 1 | ||
#define MG_ENABLE_DRIVER_PICO_W 1 | ||
#define MG_ENABLE_TCPIP_DRIVER_INIT 0 | ||
#define MG_ENABLE_PACKED_FS 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../device-dashboard/net.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../device-dashboard/net.h |
1 change: 1 addition & 0 deletions
1
examples/pico-sdk/pico-2-w-picosdk-baremetal-builtin/packed_fs.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../device-dashboard/packed_fs.c |
84 changes: 84 additions & 0 deletions
84
examples/pico-sdk/pico-2-w-picosdk-baremetal-builtin/pico_sdk_import.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# This is a copy of <PICO_SDK_PATH>/external/pico_sdk_import.cmake | ||
|
||
# This can be dropped into an external project to help locate this SDK | ||
# It should be include()ed prior to project() | ||
|
||
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) | ||
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) | ||
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") | ||
endif () | ||
|
||
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT)) | ||
set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT}) | ||
message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')") | ||
endif () | ||
|
||
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH)) | ||
set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH}) | ||
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") | ||
endif () | ||
|
||
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_TAG} AND (NOT PICO_SDK_FETCH_FROM_GIT_TAG)) | ||
set(PICO_SDK_FETCH_FROM_GIT_TAG $ENV{PICO_SDK_FETCH_FROM_GIT_TAG}) | ||
message("Using PICO_SDK_FETCH_FROM_GIT_TAG from environment ('${PICO_SDK_FETCH_FROM_GIT_TAG}')") | ||
endif () | ||
|
||
if (PICO_SDK_FETCH_FROM_GIT AND NOT PICO_SDK_FETCH_FROM_GIT_TAG) | ||
set(PICO_SDK_FETCH_FROM_GIT_TAG "master") | ||
message("Using master as default value for PICO_SDK_FETCH_FROM_GIT_TAG") | ||
endif() | ||
|
||
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK") | ||
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable") | ||
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") | ||
set(PICO_SDK_FETCH_FROM_GIT_TAG "${PICO_SDK_FETCH_FROM_GIT_TAG}" CACHE FILEPATH "release tag for SDK") | ||
|
||
if (NOT PICO_SDK_PATH) | ||
if (PICO_SDK_FETCH_FROM_GIT) | ||
include(FetchContent) | ||
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) | ||
if (PICO_SDK_FETCH_FROM_GIT_PATH) | ||
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") | ||
endif () | ||
# GIT_SUBMODULES_RECURSE was added in 3.17 | ||
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0") | ||
FetchContent_Declare( | ||
pico_sdk | ||
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk | ||
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG} | ||
GIT_SUBMODULES_RECURSE FALSE | ||
) | ||
else () | ||
FetchContent_Declare( | ||
pico_sdk | ||
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk | ||
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG} | ||
) | ||
endif () | ||
|
||
if (NOT pico_sdk) | ||
message("Downloading Raspberry Pi Pico SDK") | ||
FetchContent_Populate(pico_sdk) | ||
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) | ||
endif () | ||
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) | ||
else () | ||
message(FATAL_ERROR | ||
"SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." | ||
) | ||
endif () | ||
endif () | ||
|
||
get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") | ||
if (NOT EXISTS ${PICO_SDK_PATH}) | ||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found") | ||
endif () | ||
|
||
set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) | ||
if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) | ||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK") | ||
endif () | ||
|
||
set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE) | ||
|
||
include(${PICO_SDK_INIT_CMAKE_FILE}) |
33 changes: 33 additions & 0 deletions
33
examples/pico-sdk/pico-2-w-picosdk-freertos-lwip/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
include(pico-sdk/pico_sdk_init.cmake) | ||
include(FreeRTOS_Kernel_import.cmake) | ||
|
||
project(firmware) | ||
pico_sdk_init() | ||
|
||
add_executable(firmware | ||
main.c | ||
mongoose.c | ||
net.c | ||
packed_fs.c | ||
) | ||
|
||
target_include_directories(firmware PUBLIC | ||
. | ||
) | ||
|
||
target_link_libraries(firmware | ||
pico_stdlib | ||
pico_rand | ||
pico_cyw43_arch_lwip_sys_freertos | ||
FreeRTOS-Kernel-Heap4 | ||
) | ||
pico_add_extra_outputs(firmware) # create map/bin/hex file etc. | ||
|
||
pico_enable_stdio_usb(firmware 1) # Route stdio | ||
pico_enable_stdio_uart(firmware 0) # to USB | ||
|
||
# Mongoose build flags in mongoose_config.h | ||
|
||
# Example build options | ||
add_definitions(-DHTTP_URL="http://0.0.0.0/") |
Oops, something went wrong.