├── .gitignore ├── .gitmodules ├── ProjectFiles ├── CMakeLists.txt └── main.c ├── CMakeLists.txt ├── freertos ├── CMakeLists.txt └── FreeRTOSConfig.h └── pico_sdk_import.cmake /.gitignore: -------------------------------------------------------------------------------- 1 | build -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "freertos/FreeRTOS-Kernel"] 2 | path = freertos/FreeRTOS-Kernel 3 | url = https://github.com/FreeRTOS/FreeRTOS-Kernel 4 | -------------------------------------------------------------------------------- /ProjectFiles/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(blink 2 | main.c 3 | ) 4 | 5 | target_link_libraries(blink pico_stdlib freertos) 6 | pico_add_extra_outputs(blink) 7 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | include(pico_sdk_import.cmake) 4 | 5 | project(Pico-FreeRTOS) 6 | 7 | pico_sdk_init() 8 | 9 | add_subdirectory(freertos) 10 | add_subdirectory(ProjectFiles) 11 | -------------------------------------------------------------------------------- /ProjectFiles/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "pico/stdlib.h" 5 | 6 | 7 | void led_task() 8 | { 9 | const uint LED_PIN = PICO_DEFAULT_LED_PIN; 10 | gpio_init(LED_PIN); 11 | gpio_set_dir(LED_PIN, GPIO_OUT); 12 | while (true) { 13 | gpio_put(LED_PIN, 1); 14 | vTaskDelay(100); 15 | gpio_put(LED_PIN, 0); 16 | vTaskDelay(100); 17 | } 18 | } 19 | 20 | int main() 21 | { 22 | stdio_init_all(); 23 | 24 | xTaskCreate(led_task, "LED_Task", 256, NULL, 1, NULL); 25 | vTaskStartScheduler(); 26 | 27 | while(1){}; 28 | } 29 | -------------------------------------------------------------------------------- /freertos/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(PICO_SDK_FREERTOS_SOURCE FreeRTOS-Kernel) 2 | 3 | add_library(freertos 4 | ${PICO_SDK_FREERTOS_SOURCE}/event_groups.c 5 | ${PICO_SDK_FREERTOS_SOURCE}/list.c 6 | ${PICO_SDK_FREERTOS_SOURCE}/queue.c 7 | ${PICO_SDK_FREERTOS_SOURCE}/stream_buffer.c 8 | ${PICO_SDK_FREERTOS_SOURCE}/tasks.c 9 | ${PICO_SDK_FREERTOS_SOURCE}/timers.c 10 | ${PICO_SDK_FREERTOS_SOURCE}/portable/MemMang/heap_3.c 11 | ${PICO_SDK_FREERTOS_SOURCE}/portable/GCC/ARM_CM0/port.c 12 | ) 13 | 14 | target_include_directories(freertos PUBLIC 15 | . 16 | ${PICO_SDK_FREERTOS_SOURCE}/include 17 | ${PICO_SDK_FREERTOS_SOURCE}/portable/GCC/ARM_CM0 18 | ) 19 | -------------------------------------------------------------------------------- /pico_sdk_import.cmake: -------------------------------------------------------------------------------- 1 | # This is a copy of /external/pico_sdk_import.cmake 2 | 3 | # This can be dropped into an external project to help locate this SDK 4 | # It should be include()ed prior to project() 5 | 6 | # todo document 7 | 8 | if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) 9 | set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) 10 | message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") 11 | endif () 12 | 13 | if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT)) 14 | set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT}) 15 | message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')") 16 | endif () 17 | 18 | if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH)) 19 | set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH}) 20 | message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") 21 | endif () 22 | 23 | set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the PICO SDK") 24 | set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of PICO SDK from git if not otherwise locatable") 25 | set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") 26 | 27 | if (NOT PICO_SDK_PATH) 28 | if (PICO_SDK_FETCH_FROM_GIT) 29 | include(FetchContent) 30 | set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) 31 | if (PICO_SDK_FETCH_FROM_GIT_PATH) 32 | get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") 33 | endif () 34 | FetchContent_Declare( 35 | pico_sdk 36 | GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk 37 | GIT_TAG master 38 | ) 39 | if (NOT pico_sdk) 40 | message("Downloading PICO SDK") 41 | FetchContent_Populate(pico_sdk) 42 | set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) 43 | endif () 44 | set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) 45 | else () 46 | message(FATAL_ERROR 47 | "PICO SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." 48 | ) 49 | endif () 50 | endif () 51 | 52 | get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") 53 | if (NOT EXISTS ${PICO_SDK_PATH}) 54 | message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found") 55 | endif () 56 | 57 | set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) 58 | if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) 59 | message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the PICO SDK") 60 | endif () 61 | 62 | set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the PICO SDK" FORCE) 63 | 64 | include(${PICO_SDK_INIT_CMAKE_FILE}) 65 | -------------------------------------------------------------------------------- /freertos/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef FREERTOS_CONFIG_H 2 | #define FREERTOS_CONFIG_H 3 | 4 | /* Use Pico SDK ISR handlers */ 5 | #define vPortSVCHandler isr_svcall 6 | #define xPortPendSVHandler isr_pendsv 7 | #define xPortSysTickHandler isr_systick 8 | 9 | #define configUSE_PREEMPTION 1 10 | #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 11 | #define configUSE_TICKLESS_IDLE 0 12 | #define configCPU_CLOCK_HZ 133000000 13 | #define configTICK_RATE_HZ 100 14 | #define configMAX_PRIORITIES 5 15 | #define configMINIMAL_STACK_SIZE 128 16 | #define configMAX_TASK_NAME_LEN 16 17 | #define configUSE_16_BIT_TICKS 0 18 | #define configIDLE_SHOULD_YIELD 1 19 | #define configUSE_TASK_NOTIFICATIONS 1 20 | #define configTASK_NOTIFICATION_ARRAY_ENTRIES 3 21 | #define configUSE_MUTEXES 0 22 | #define configUSE_RECURSIVE_MUTEXES 0 23 | #define configUSE_COUNTING_SEMAPHORES 0 24 | #define configQUEUE_REGISTRY_SIZE 10 25 | #define configUSE_QUEUE_SETS 0 26 | #define configUSE_TIME_SLICING 0 27 | #define configUSE_NEWLIB_REENTRANT 0 28 | #define configENABLE_BACKWARD_COMPATIBILITY 0 29 | #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 30 | #define configSTACK_DEPTH_TYPE uint16_t 31 | #define configMESSAGE_BUFFER_LENGTH_TYPE size_t 32 | 33 | /* Memory allocation related definitions. */ 34 | #define configSUPPORT_STATIC_ALLOCATION 0 35 | #define configSUPPORT_DYNAMIC_ALLOCATION 1 36 | #define configAPPLICATION_ALLOCATED_HEAP 1 37 | 38 | /* Hook function related definitions. */ 39 | #define configUSE_IDLE_HOOK 0 40 | #define configUSE_TICK_HOOK 0 41 | #define configCHECK_FOR_STACK_OVERFLOW 0 42 | #define configUSE_MALLOC_FAILED_HOOK 0 43 | #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 44 | 45 | /* Run time and task stats gathering related definitions. */ 46 | #define configGENERATE_RUN_TIME_STATS 0 47 | #define configUSE_TRACE_FACILITY 0 48 | #define configUSE_STATS_FORMATTING_FUNCTIONS 0 49 | 50 | /* Co-routine related definitions. */ 51 | #define configUSE_CO_ROUTINES 0 52 | #define configMAX_CO_ROUTINE_PRIORITIES 1 53 | 54 | /* Software timer related definitions. */ 55 | #define configUSE_TIMERS 1 56 | #define configTIMER_TASK_PRIORITY 3 57 | #define configTIMER_QUEUE_LENGTH 10 58 | #define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE 59 | 60 | /* Define to trap errors during development. */ 61 | #define configASSERT( x ) 62 | 63 | /* Optional functions - most linkers will remove unused functions anyway. */ 64 | #define INCLUDE_vTaskPrioritySet 1 65 | #define INCLUDE_uxTaskPriorityGet 1 66 | #define INCLUDE_vTaskDelete 1 67 | #define INCLUDE_vTaskSuspend 1 68 | #define INCLUDE_xResumeFromISR 1 69 | #define INCLUDE_vTaskDelayUntil 1 70 | #define INCLUDE_vTaskDelay 1 71 | #define INCLUDE_xTaskGetSchedulerState 1 72 | #define INCLUDE_xTaskGetCurrentTaskHandle 1 73 | #define INCLUDE_uxTaskGetStackHighWaterMark 0 74 | #define INCLUDE_xTaskGetIdleTaskHandle 0 75 | #define INCLUDE_eTaskGetState 0 76 | #define INCLUDE_xEventGroupSetBitFromISR 1 77 | #define INCLUDE_xTimerPendFunctionCall 0 78 | #define INCLUDE_xTaskAbortDelay 0 79 | #define INCLUDE_xTaskGetHandle 0 80 | #define INCLUDE_xTaskResumeFromISR 1 81 | 82 | /* A header file that defines trace macro can be included here. */ 83 | 84 | #endif /* FREERTOS_CONFIG_H */ 85 | --------------------------------------------------------------------------------