-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from mutablelogic/dev
Merge dev into main
- Loading branch information
Showing
127 changed files
with
8,090 additions
and
1,045 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
[submodule "lib/pico-sdk"] | ||
path = lib/pico-sdk | ||
url = https://github.com/raspberrypi/pico-sdk | ||
branch = 1.5.1 | ||
url = https://github.com/raspberrypi/pico-sdk.git | ||
branch = 2.0.0 | ||
|
||
[submodule "lib/picotool"] | ||
path = lib/picotool | ||
url = https://github.com/raspberrypi/picotool.git | ||
branch = 1.1.2 | ||
branch = 2.0.0 |
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 |
---|---|---|
@@ -1,68 +1,46 @@ | ||
# Versions | ||
cmake_minimum_required(VERSION 3.12) | ||
cmake_minimum_required(VERSION 3.13) | ||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
# PICO_BOARD | ||
if (DEFINED ENV{PICO_BOARD}) | ||
set(PICO_BOARD $ENV{PICO_BOARD}) | ||
message("Using PICO_BOARD from environment ('${PICO_BOARD}')") | ||
set(PICO_BOARD "$ENV{PICO_BOARD}") | ||
set(TARGET_OS "pico") | ||
include(lib/pico-sdk/pico_sdk_init.cmake) | ||
else() | ||
if (NOT PICO_BOARD) | ||
set(PICO_BOARD "pico") | ||
message("Defaulting PICO target board to ${PICO_BOARD} since not specified") | ||
else() | ||
message("PICO target board is ${PICO_BOARD}") | ||
endif() | ||
set(TARGET_OS ${CMAKE_HOST_SYSTEM_NAME}) | ||
string(TOLOWER ${TARGET_OS} TARGET_OS) | ||
endif() | ||
message("Target ${TARGET_OS}") | ||
|
||
# TARGET set to linux, darwin or pico depending on PICO_BOARD | ||
if(PICO_BOARD STREQUAL "linux") | ||
set(TARGET "linux") | ||
add_compile_definitions(TARGET_LINUX) | ||
add_compile_definitions(TARGET_POSIX) | ||
elseif(PICO_BOARD STREQUAL "darwin") | ||
set(TARGET "darwin") | ||
# TARGET_DARWIN, TARGET_LINUX and TARGET_PICO | ||
if (TARGET_OS STREQUAL "darwin") | ||
add_compile_definitions(TARGET_DARWIN) | ||
add_compile_definitions(TARGET_POSIX) | ||
else() | ||
set(TARGET "pico") | ||
elseif (TARGET_OS STREQUAL "linux") | ||
add_compile_definitions(TARGET_LINUX) | ||
elseif (TARGET_OS STREQUAL "pico") | ||
add_compile_definitions(TARGET_PICO) | ||
include(lib/pico-sdk/pico_sdk_init.cmake) | ||
endif() | ||
|
||
# Define project | ||
project(fuse CXX C ASM) | ||
project(picofuse CXX C ASM) | ||
|
||
# TODO!!! | ||
add_compile_definitions(DEBUG) | ||
|
||
# Pico libraries | ||
if(${TARGET} STREQUAL "pico") | ||
pico_sdk_init() | ||
endif() | ||
|
||
# Libraries | ||
# picofuse libraries | ||
add_subdirectory(src/fuse) | ||
if(${TARGET} STREQUAL "pico") | ||
if(TARGET_OS STREQUAL "pico") | ||
pico_sdk_init() | ||
add_subdirectory(src/picofuse) | ||
endif() | ||
|
||
# Tests | ||
include(CTest) | ||
add_subdirectory(tests/fuse) | ||
|
||
# Tests - fuse | ||
add_subdirectory(tests/app) | ||
add_subdirectory(tests/list) | ||
add_subdirectory(tests/map) | ||
add_subdirectory(tests/panic) | ||
add_subdirectory(tests/pool) | ||
add_subdirectory(tests/random) | ||
add_subdirectory(tests/value) | ||
|
||
# Tests - picofuse | ||
if(${TARGET} STREQUAL "pico") | ||
add_subdirectory(tests/blink) | ||
add_subdirectory(tests/temperature) | ||
# Examples | ||
add_subdirectory(examples/fuse) | ||
if(TARGET_OS STREQUAL "pico") | ||
add_subdirectory(examples/picofuse) | ||
endif() | ||
|
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
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
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 @@ | ||
|
||
############################################################################## | ||
|
||
set(NAME "helloworld") | ||
|
||
add_executable(${NAME} | ||
common/main.c | ||
helloworld/run.c | ||
) | ||
target_include_directories(${NAME} PRIVATE | ||
${CMAKE_CURRENT_LIST_DIR}/../../include | ||
) | ||
target_link_libraries(${NAME} fuse) | ||
|
||
if(TARGET_OS STREQUAL "pico") | ||
# enable usb output, disable uart output | ||
pico_enable_stdio_usb(${NAME} 1) | ||
pico_enable_stdio_uart(${NAME} 0) | ||
|
||
# create map/bin/hex/uf2 file etc. | ||
pico_add_extra_outputs(${NAME}) | ||
endif() |
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,13 @@ | ||
#include <fuse/fuse.h> | ||
|
||
int run(fuse_t *fuse); | ||
|
||
int main() | ||
{ | ||
fuse_t *fuse = fuse_new(); | ||
assert(fuse); | ||
fuse_run(fuse, run); | ||
|
||
// Destroy the applicatiom, return exit code | ||
return fuse_destroy(fuse); | ||
} |
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,53 @@ | ||
#include <fuse/fuse.h> | ||
|
||
int run(fuse_t *fuse) | ||
{ | ||
// Make and free a NULL value | ||
fuse_value_t *value = fuse_alloc(fuse, FUSE_MAGIC_NULL, NULL); | ||
fuse_printf(fuse, "null value=%q\n", value); | ||
fuse_free(fuse, value); | ||
|
||
// Make and free a DATA value | ||
value = fuse_alloc(fuse, FUSE_MAGIC_DATA, NULL); | ||
fuse_printf(fuse, "data value=%q\n", value); | ||
fuse_free(fuse, value); | ||
|
||
// Make and free a U8 value | ||
value = fuse_alloc(fuse, FUSE_MAGIC_U8, (void *)0xFF); | ||
fuse_printf(fuse, "u8 value=%q\n", value); | ||
fuse_free(fuse, value); | ||
|
||
// Make and free a U16 value | ||
value = fuse_alloc(fuse, FUSE_MAGIC_U16, (void *)0xFFFF); | ||
fuse_printf(fuse, "u16 value=%q\n", value); | ||
fuse_free(fuse, value); | ||
|
||
// Make and free a U32 value | ||
value = fuse_alloc(fuse, FUSE_MAGIC_U32, (void *)0xFFFFFFFF); | ||
fuse_printf(fuse, "u32 value=%q\n", value); | ||
fuse_free(fuse, value); | ||
|
||
// Make and free a U64 value | ||
value = fuse_alloc(fuse, FUSE_MAGIC_U64, (void *)0xFFFFFFFFFFFFFFFF); | ||
fuse_printf(fuse, "u64 value=%q\n", value); | ||
fuse_free(fuse, value); | ||
|
||
// Make and free a S8 value | ||
value = fuse_alloc(fuse, FUSE_MAGIC_S8, (void *)0x7F); | ||
fuse_printf(fuse, "s8 value=%v\n", value); | ||
fuse_free(fuse, value); | ||
|
||
// Make and free a S16 value | ||
value = fuse_alloc(fuse, FUSE_MAGIC_S16, (void *)0x7FFF); | ||
fuse_printf(fuse, "s16 value=%q\n", value); | ||
fuse_free(fuse, value); | ||
|
||
// Make a list | ||
fuse_value_t *list = fuse_alloc(fuse, FUSE_MAGIC_LIST, 0); | ||
fuse_printf(fuse, "list value=%q\n", value); | ||
|
||
// Free the list | ||
fuse_free(fuse, list); | ||
|
||
return 0; | ||
} |
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,20 @@ | ||
|
||
############################################################################## | ||
|
||
set(NAME "gpio_in") | ||
|
||
add_executable(${NAME} | ||
common/main.c | ||
gpio_in/run.c | ||
) | ||
target_include_directories(${NAME} PRIVATE | ||
${CMAKE_CURRENT_LIST_DIR}/../../include | ||
) | ||
target_link_libraries(${NAME} picofuse) | ||
|
||
# enable usb output, disable uart output | ||
pico_enable_stdio_usb(${NAME} 1) | ||
pico_enable_stdio_uart(${NAME} 0) | ||
|
||
# create map/bin/hex/uf2 file etc. | ||
pico_add_extra_outputs(${NAME}) |
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,17 @@ | ||
#include <picofuse/picofuse.h> | ||
|
||
#define LED_DELAY_MS 250 | ||
|
||
int run(fuse_t* fuse) { | ||
fuse_led_new(); | ||
|
||
while (true) { | ||
fuse_led_set(1); | ||
sleep_ms(LED_DELAY_MS); | ||
fuse_led_set(0); | ||
sleep_ms(LED_DELAY_MS); | ||
} | ||
|
||
fuse_led_destroy(); | ||
return 0; | ||
} |
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,13 @@ | ||
#include <fuse/fuse.h> | ||
|
||
int run(fuse_t *fuse); | ||
|
||
int main() | ||
{ | ||
fuse_t *fuse = fuse_new(); | ||
assert(fuse); | ||
fuse_run(fuse, run); | ||
|
||
// Destroy the applicatiom, return exit code | ||
return fuse_destroy(fuse); | ||
} |
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,10 @@ | ||
#include <picofuse/picofuse.h> | ||
|
||
int run(fuse_t *fuse) | ||
{ | ||
// GPIO Pin 26 input | ||
fuse_gpio_t *pin = fuse_new_gpio(fuse, 26, FUSE_GPIO_IN); | ||
assert(pin); | ||
|
||
return 0; | ||
} |
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 @@ | ||
#include <picofuse/picofuse.h> | ||
|
||
int run(fuse_t *fuse) | ||
{ | ||
// Register the wifi module for DE country code and station mode, | ||
// scanning for WiFi networks | ||
fuse_wifi_userdata_t wifi_params = { | ||
.country_code = "DE", | ||
.mode = FUSE_WIFI_STATION | FUSE_WIFI_SCAN}; | ||
fuse_context_t *wifi = fuse_register(fuse, &fuse_wifi, &wifi_params); | ||
assert(wifi); | ||
|
||
// Register MQTT module to connect to 192.168.86.12 | ||
fuse_mqtt_userdata_t mqtt_params = { | ||
.host = "192.168.86.12", | ||
.port = 1883}; | ||
fuse_context_t *mqtt = fuse_register(fuse, &fuse_mqtt, &mqtt_params); | ||
assert(mqtt); | ||
|
||
// Run fuse | ||
return 0; //fuse_runloop(fuse); | ||
} |
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,7 @@ | ||
#include <picofuse/picofuse.h> | ||
|
||
int run(fuse_t *fuse) | ||
{ | ||
fuse_panic("This is a really bad thing that happened!", __FILE__, __LINE__); | ||
return 0; | ||
} |
Oops, something went wrong.