aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/CMakeLists.txt19
-rw-r--r--main/FreeRTOSConfig.h69
m---------main/lib/FreeRTOS-Kernel0
-rw-r--r--main/main.cpp29
-rw-r--r--main/makefile2
5 files changed, 102 insertions, 17 deletions
diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt
index e24d9a5..590d516 100644
--- a/main/CMakeLists.txt
+++ b/main/CMakeLists.txt
@@ -1,22 +1,29 @@
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(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(PICO_BOARD pico_w)
+include(lib/pico-sdk/pico_sdk_init.cmake)
+include(lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake)
+
+project(puzzlebox_main C CXX ASM)
+
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)
+target_link_libraries(main
+ pico_cyw43_arch_lwip_threadsafe_background
+ pico_stdlib
+ FreeRTOS-Kernel
+ )
+
diff --git a/main/FreeRTOSConfig.h b/main/FreeRTOSConfig.h
new file mode 100644
index 0000000..305bcb4
--- /dev/null
+++ b/main/FreeRTOSConfig.h
@@ -0,0 +1,69 @@
+#pragma once
+// values from pico-examples/pico_w/wifi/freertos
+
+#define configUSE_PREEMPTION 1
+#define configUSE_TICKLESS_IDLE 0
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configTICK_RATE_HZ ((TickType_t) 1000)
+#define configMAX_PRIORITIES 32
+#define configMINIMAL_STACK_SIZE ((configSTACK_DEPTH_TYPE) 256)
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 8
+#define configUSE_QUEUE_SETS 1
+#define configUSE_TIME_SLICING 1
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
+#define configSTACK_DEPTH_TYPE uint32_t
+#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
+#define configSUPPORT_STATIC_ALLOCATION 0
+#define configSUPPORT_DYNAMIC_ALLOCATION 1
+#define configTOTAL_HEAP_SIZE (128 * 1024)
+#define configAPPLICATION_ALLOCATED_HEAP 0
+#define configCHECK_FOR_STACK_OVERFLOW 0
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
+#define configGENERATE_RUN_TIME_STATS 0
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 1
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1)
+#define configTIMER_QUEUE_LENGTH 10
+#define configTIMER_TASK_STACK_DEPTH 1024
+
+// #define configNUM_CORES 2
+// #define configTICK_CORE 0
+// #define configRUN_MULTIPLE_PRIORITIES 1
+// #define configUSE_CORE_AFFINITY 1
+
+#define configSUPPORT_PICO_SYNC_INTEROP 1
+#define configSUPPORT_PICO_TIME_INTEROP 1
+
+#include <assert.h>
+#define configASSERT(x) assert(x)
+
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetIdleTaskHandle 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_xTaskAbortDelay 1
+#define INCLUDE_xTaskGetHandle 1
+#define INCLUDE_xTaskResumeFromISR 1
+#define INCLUDE_xQueueGetMutexHolder 1
+
diff --git a/main/lib/FreeRTOS-Kernel b/main/lib/FreeRTOS-Kernel
new file mode 160000
+Subproject dbf70559b27d39c1fdb68dfb9a32140b6a6777a
diff --git a/main/main.cpp b/main/main.cpp
index 9fd3123..d118de2 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1,12 +1,23 @@
-#include <stdio.h>
-
#include "config.h"
-#include "pico/stdlib.h"
-#include "pico/cyw43_arch.h"
+#include <FreeRTOS.h>
+#include <task.h>
+
+#include <pico/stdlib.h>
+#include <pico/stdio.h>
+#include <pico/cyw43_arch.h>
const unsigned int LED_PIN = CYW43_WL_GPIO_LED_PIN;
+void blink_task() {
+ while (true) {
+ cyw43_arch_gpio_put(LED_PIN, 0);
+ sleep_ms(250);
+ cyw43_arch_gpio_put(LED_PIN, 1);
+ sleep_ms(250);
+ }
+}
+
int main() {
stdio_init_all();
sleep_ms(2000);
@@ -16,6 +27,8 @@ int main() {
return 1;
}
cyw43_arch_gpio_put(LED_PIN, 1);
+
+
printf("initialised\n");
cyw43_arch_enable_sta_mode();
@@ -26,11 +39,7 @@ int main() {
}
printf("connected\n");
- while (true) {
- cyw43_arch_gpio_put(LED_PIN, 0);
- sleep_ms(250);
- cyw43_arch_gpio_put(LED_PIN, 1);
- sleep_ms(250);
- }
+ xTaskCreate((TaskFunction_t) blink_task, "blink", 128, NULL, 1, NULL);
+ vTaskStartScheduler();
}
diff --git a/main/makefile b/main/makefile
index 833fd02..1986cd3 100644
--- a/main/makefile
+++ b/main/makefile
@@ -6,7 +6,7 @@ all: FORCE build/main.uf2
build/build.ninja: CMakeLists.txt
mkdir -p build
- cmake -B build -G Ninja
+ cmake -B build -G Ninja --fresh --log-level WARNING
build/main.uf2: build/build.ninja FORCE
ninja -C build