Trying to move project->FreeRTOS (WIP)

This commit is contained in:
NaifBanana
2026-10-20 03:18:23 -05:00
parent c683975fd0
commit 92d1ba591b
8 changed files with 249 additions and 79 deletions
+27
View File
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.5.0)
set(APP_NAME "Blinky")
add_executable(${APP_NAME}
./main.c
)
target_include_directories(Blinky
PUBLIC ${FREERTOS_ROOT}/include/
)
target_link_libraries(Blinky LINK_PUBLIC
pico_stdlib
FreeRTOS-Kernel
FreeRTOS-Kernel-Heap4
)
get_test_property(FUCKASS Blinky INCLUDE_DIRECTORIES)
message(STATUS "Includes are ${FUCKASS}")
pico_enable_stdio_usb(${APP_NAME} 1)
pico_enable_stdio_uart(${APP_NAME} 0)
pico_add_extra_outputs(${APP_NAME})
+20
View File
@@ -0,0 +1,20 @@
#include <pico/stdlib.h>
#include <FreeRTOS.h>
#include <task.h>
void vBlinkTask() {
for (;;) {
gpio_put(PICO_DEFAULT_LED_PIN, 1);
vTaskDelay(250);
gpio_put(PICO_DEFAULT_LED_PIN, 0);
vTaskDelay(250);
}
}
void main() {
gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
xTaskCreate(vBlinkTask, "Blink task", 128, NULL, 1, NULL);
vTaskStartScheduler();
}
+23 -25
View File
@@ -5,46 +5,44 @@ set(PROJECT_NAME "GateOpener")
set(PICO_SDK_PATH "C:/Users/naifa/Documents/Projects/Hardware/Microcontroller/SDK/PicoC++/pico-sdk") set(PICO_SDK_PATH "C:/Users/naifa/Documents/Projects/Hardware/Microcontroller/SDK/PicoC++/pico-sdk")
set(PICO_TOOLCHAIN_PATH "C:/Users/naifa/Documents/Projects/Hardware/Microcontroller/SDK/arm-gnu-toolchain-15.3.rel2-mingw-w64-x86_64-arm-none-eabi" ) set(PICO_TOOLCHAIN_PATH "C:/Users/naifa/Documents/Projects/Hardware/Microcontroller/SDK/arm-gnu-toolchain-15.3.rel2-mingw-w64-x86_64-arm-none-eabi" )
set(RADIOLIB_PATH "C:/Program Files (x86)/radiolib")
set(FREERTOS_ROOT "C:/Users/naifa/Documents/Projects/Hardware/FreeRTOS-Kernel") set(FREERTOS_ROOT "C:/Users/naifa/Documents/Projects/Hardware/FreeRTOS-Kernel")
set(FREERTOS_CFG_DIRECTORY "${CMAKE_SOURCE_DIR}/Config") set(FREERTOS_CFG_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/Config")
set(RADIOLIB_PATH "C:/Program Files (x86)/radiolib")
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake) include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
include(${FREERTOS_ROOT}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake)
set(CMAKE_PREFIX_PATH set(CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH}
${FREERTOS_ROOT}
${RADIOLIB_PATH} ${RADIOLIB_PATH}
) )
include(${FREERTOS_ROOT}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake) # include(${FREERTOS_ROOT}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake)
project(${PROJECT_NAME} VERSION ${VERSION} LANGUAGES CXX C ASM) project(${PROJECT_NAME} VERSION ${VERSION} LANGUAGES CXX C ASM)
pico_sdk_init() pico_sdk_init()
message(STATUS "Pico SDK dir is ${PICO_SDK_PATH}") message(STATUS "Pico SDK dir is ${PICO_SDK_PATH}")
message(STATUS "FreeRTOS root is ${FREERTOS_ROOT}") message(STATUS "FreeRTOS root is ${FREERTOS_ROOT}")
pico_enable_stdio_usb(${BINARY_NAME} 1) # add_library(FreeRTOS STATIC
pico_enable_stdio_uart(${BINARY_NAME} 0) # ${FREERTOS_ROOT}/event_groups.c
# ${FREERTOS_ROOT}/list.c
pico_add_extra_outputs(${BINARY_NAME}) # ${FREERTOS_ROOT}/queue.c
# ${FREERTOS_ROOT}/stream_buffer.c
add_library(FreeRTOS STATIC # ${FREERTOS_ROOT}/tasks.c
${FREERTOS_SRC_DIRECTORY}/event_groups.c # ${FREERTOS_ROOT}/timers.c
${FREERTOS_SRC_DIRECTORY}/list.c # ${FREERTOS_ROOT}/portable/MemMang/heap_3.c
${FREERTOS_SRC_DIRECTORY}/queue.c # ${FREERTOS_ROOT}/portable/GCC/ARM_CM0/port.c
${FREERTOS_SRC_DIRECTORY}/stream_buffer.c # )
${FREERTOS_SRC_DIRECTORY}/tasks.c #
${FREERTOS_SRC_DIRECTORY}/timers.c include_directories(PUBLIC
${FREERTOS_SRC_DIRECTORY}/portable/MemMang/heap_3.c ${FREERTOS_CFG_DIRECTORY}
${FREERTOS_SRC_DIRECTORY}/portable/GCC/ARM_CM0/port.c ${FREERTOS_ROOT}/include/
${FREERTOS_ROOT}/portable/GCC/ARM_CM0/
) )
target_include_directories(FreeRTOS PUBLIC add_subdirectory(./Blinky)
${FREERTOS_CFG_DIRECTORY}/
${FREERTOS_SRC_DIRECTORY}/include
${FREERTOS_SRC_DIRECTORY}/portable/GCC/ARM_CM0
)
add_subdirectory(./Listener) add_subdirectory(./Listener)
add_subdirectory(./Yeller)
+39 -54
View File
@@ -1,6 +1,6 @@
/* /*
* FreeRTOS V202107.00 * FreeRTOS
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,69 +19,66 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://aws.amazon.com/freertos
* *
* 1 tab == 4 spaces!
*/ */
#ifndef FREERTOS_CONFIG_H #ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H #define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
* Application specific definitions. /* Use Pico SDK ISR handlers */
* #define vPortSVCHandler isr_svcall
* These definitions should be adjusted for your particular hardware and #define xPortPendSVHandler isr_pendsv
* application requirements. #define xPortSysTickHandler isr_systick
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*
* See http://www.freertos.org/a00110.html
*----------------------------------------------------------*/
/* Scheduler Related */ /* Scheduler Related */
#define configUSE_PREEMPTION 1 #define configUSE_PREEMPTION 1 // Allow tasks to be pre-empted
#define configUSE_TIME_SLICING 1 // Allow FreeRTOS to switch tasks at each tick
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configUSE_TICKLESS_IDLE 0 #define configUSE_TICKLESS_IDLE 0
#define configUSE_IDLE_HOOK 0 #define configCPU_CLOCK_HZ 133000000 // 133MHz for RP2040
#define configUSE_TICK_HOOK 0 #define configTICK_RATE_HZ (TickType_t)1000 // FreeRTOS beats per second
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) #define configMAX_PRIORITIES 24 // Max number of priority values (0-24)
#define configMAX_PRIORITIES 32 #define configMINIMAL_STACK_SIZE (configSTACK_DEPTH_TYPE)512
#define configMINIMAL_STACK_SIZE ( configSTACK_DEPTH_TYPE ) 256
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1 #define configIDLE_SHOULD_YIELD 1
#define configMAX_TASK_NAME_LEN 16
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3
/* Synchronization Related */ /* Synchronization Related */
#define configUSE_MUTEXES 1 #define configUSE_MUTEXES 0
#define configUSE_RECURSIVE_MUTEXES 1 #define configUSE_RECURSIVE_MUTEXES 0
#define configUSE_APPLICATION_TASK_TAG 0 #define configUSE_COUNTING_SEMAPHORES 0
#define configUSE_COUNTING_SEMAPHORES 1 #define configUSE_TASK_NOTIFICATIONS 1
#define configQUEUE_REGISTRY_SIZE 8 #define configUSE_QUEUE_SETS 0
#define configUSE_QUEUE_SETS 1 #define configQUEUE_REGISTRY_SIZE 10
#define configUSE_TIME_SLICING 1
#define configUSE_NEWLIB_REENTRANT 0 #define configUSE_NEWLIB_REENTRANT 0
#define configENABLE_BACKWARD_COMPATIBILITY 0 #define configENABLE_BACKWARD_COMPATIBILITY 0
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
/* System */ /* System */
#define configSTACK_DEPTH_TYPE uint32_t #define configSTACK_DEPTH_TYPE uint32_t
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t #define configMESSAGE_BUFFER_LENGTH_TYPE size_t // Defaults to size_t for backward compatibility,
// but can be changed if lengths will always be less
// than the number of bytes in a size_t.
/* Memory allocation related definitions. */ /* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION 0 #define configSUPPORT_STATIC_ALLOCATION 0
#define configSUPPORT_DYNAMIC_ALLOCATION 1 #define configSUPPORT_DYNAMIC_ALLOCATION 1 // Get FreeRTOS to allocation task memory
#define configTOTAL_HEAP_SIZE (128*1024)
#define configAPPLICATION_ALLOCATED_HEAP 0 #define configAPPLICATION_ALLOCATED_HEAP 0
#define configTOTAL_HEAP_SIZE (128*1024)
/* Hook function related definitions. */ /* Hook function related definitions. */
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configCHECK_FOR_STACK_OVERFLOW 0 #define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_MALLOC_FAILED_HOOK 0 #define configUSE_MALLOC_FAILED_HOOK 0
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0 #define configUSE_DAEMON_TASK_STARTUP_HOOK 0
/* Run time and task stats gathering related definitions. */ /* Run time and task stats gathering related definitions. */
#define configGENERATE_RUN_TIME_STATS 0 #define configGENERATE_RUN_TIME_STATS 0
#define configUSE_TRACE_FACILITY 1 #define configUSE_TRACE_FACILITY 0
#define configUSE_STATS_FORMATTING_FUNCTIONS 0 #define configUSE_STATS_FORMATTING_FUNCTIONS 0
/* Co-routine related definitions. */ /* Co-routine related definitions. */
@@ -90,33 +87,19 @@
/* Software timer related definitions. */ /* Software timer related definitions. */
#define configUSE_TIMERS 1 #define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) #define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1)
#define configTIMER_QUEUE_LENGTH 10 #define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH 1024 #define configTIMER_TASK_STACK_DEPTH 1024
/* Interrupt nesting behaviour configuration. */
/*
#define configKERNEL_INTERRUPT_PRIORITY [dependent of processor]
#define configMAX_SYSCALL_INTERRUPT_PRIORITY [dependent on processor and application]
#define configMAX_API_CALL_INTERRUPT_PRIORITY [dependent on processor and application]
*/
/* SMP port only */
#define configNUM_CORES 2
#define configTICK_CORE 0
#define configRUN_MULTIPLE_PRIORITIES 1
#define configUSE_CORE_AFFINITY 1
/* RP2040 specific */ /* RP2040 specific */
#define configSUPPORT_PICO_SYNC_INTEROP 1 #define configSUPPORT_PICO_SYNC_INTEROP 1
#define configSUPPORT_PICO_TIME_INTEROP 1 #define configSUPPORT_PICO_TIME_INTEROP 1
#include <assert.h>
/* Define to trap errors during development. */ /* Define to trap errors during development. */
#define configASSERT(x) assert(x) #include <assert.h>
#define configASSERT( x )
/* Set the following definitions to 1 to include the API function, or zero /* Optional functions - most linkers will remove unused functions anyway. */
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 1 #define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1 #define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1 #define INCLUDE_vTaskDelete 1
@@ -128,11 +111,13 @@ to exclude the API function. */
#define INCLUDE_uxTaskGetStackHighWaterMark 1 #define INCLUDE_uxTaskGetStackHighWaterMark 1
#define INCLUDE_xTaskGetIdleTaskHandle 1 #define INCLUDE_xTaskGetIdleTaskHandle 1
#define INCLUDE_eTaskGetState 1 #define INCLUDE_eTaskGetState 1
#define INCLUDE_xTimerPendFunctionCall 1
#define INCLUDE_xTaskAbortDelay 1 #define INCLUDE_xTaskAbortDelay 1
#define INCLUDE_xTaskGetHandle 1 #define INCLUDE_xTaskGetHandle 1
#define INCLUDE_xTaskResumeFromISR 1 #define INCLUDE_xTaskResumeFromISR 1
#define INCLUDE_xQueueGetMutexHolder 1 #define INCLUDE_xQueueGetMutexHolder 1
#define INCLUDE_xResumeFromISR 1
#define INCLUDE_xEventGroupSetBitFromISR 1
#define INCLUDE_xTimerPendFunctionCall 1
/* A header file that defines trace macro can be included here. */ /* A header file that defines trace macro can be included here. */
+18
View File
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.5.0)
set(APP_NAME "Listener")
add_executable(${APP_NAME}
./main.cpp
)
target_link_libraries(${APP_NAME} LINK_PUBLIC
pico_stdlib
FreeRTOS
)
pico_enable_stdio_usb(${APP_NAME} 1)
pico_enable_stdio_uart(${APP_NAME} 0)
pico_add_extra_outputs(${APP_NAME})
+71
View File
@@ -0,0 +1,71 @@
#include "Config/FreeRTOSConfig.h"
#include "FreeRTOS.h"
#include <pico/error.h>
#include <pico/stdio.h>
#include <pico/time.h>
#include <RadioLib/RadioLib.h>
#include <RadioLib/>
const char NULLCHAR = '\0';
char* read_buffer;
int readInput() {
unsigned int len = 0;
int ret;
unsigned char ret_char;
while(true) {
ret = getchar_timeout_us(0);
if (ret == PICO_ERROR_TIMEOUT) {
continue;
} else {
ret_char = (char)ret;
printf("%c", ret);
sleep_ms(50);
if (ret_char & 0xE0) {
memcpy(read_buffer+len*sizeof(char), &ret_char, sizeof(char));
sleep_ms(50);
len++;
} else {
bool should_break = false;
if (len==0) { continue; }
switch(ret_char) {
case 8:
len--;
break;
case 10:
case 13:
should_break = true;
break;
default:
break;
}
if (should_break) { break; }
}
}
}
memcpy(read_buffer+len*sizeof(char), &NULLCHAR, sizeof(char));
sleep_ms(50);
return len;
}
int main() {
stdio_init_all();
int num;
int len;
read_buffer = malloc(256 * sizeof(char));
while(true) {
printf("Give a number: \n");
sleep_ms(50);
num = readInput();
if (num) {
printf("Printed %d characters: ", num);
printf("%s\n", read_buffer);
} else {
printf("Got empty line\n");
}
sleep_ms(50);
}
return 0;
}
+18
View File
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.5.0)
set(APP_NAME "Yeller")
add_executable(${APP_NAME}
./main.cpp
)
target_link_libraries(${APP_NAME} LINK_PUBLIC
pico_stdlib
FreeRTOS
)
pico_enable_stdio_usb(${APP_NAME} 1)
pico_enable_stdio_uart(${APP_NAME} 0)
pico_add_extra_outputs(${APP_NAME})
+33
View File
@@ -0,0 +1,33 @@
#include "Config/FreeRTOSConfig.h"
#include "FreeRTOS.h"
#include <pico/stdlib.h>
#include <RadioLib/RadioLib.h>
#include <RadioLib/Module.h>>
int main() {
// Currently written as numbered 1-40th pin on Pico
SX1262 radio = new Module(5, 26, 20, 4);
ConfigLoRa_t config;
config.frequency = 915;
int state = radio.begin(config);
if (state == RADIOLIB_ERR_NONE) {
printf("LoRa module initialized\n");
while(true) {
state = radio.startTransmit("Howdiddly doo");
if (state == RADIOLIB_ERR_NONE) {
printf("Transmitted properly!\n");
} else {
printf("Transmission failed\n");
}
sleep_ms(2000);
}
} else {
printf("Could not initialize LoRa module\n");
while(true) {
printf("Fuuuuuck\n");
sleep_ms(2000);
}
}
}