Trying to move project->FreeRTOS (WIP)
This commit is contained in:
@@ -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})
|
||||
|
||||
@@ -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
@@ -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_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_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(${FREERTOS_ROOT}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake)
|
||||
set(CMAKE_PREFIX_PATH
|
||||
${CMAKE_PREFIX_PATH}
|
||||
${FREERTOS_ROOT}
|
||||
${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)
|
||||
pico_sdk_init()
|
||||
|
||||
message(STATUS "Pico SDK dir is ${PICO_SDK_PATH}")
|
||||
message(STATUS "FreeRTOS root is ${FREERTOS_ROOT}")
|
||||
|
||||
pico_enable_stdio_usb(${BINARY_NAME} 1)
|
||||
pico_enable_stdio_uart(${BINARY_NAME} 0)
|
||||
|
||||
pico_add_extra_outputs(${BINARY_NAME})
|
||||
|
||||
add_library(FreeRTOS STATIC
|
||||
${FREERTOS_SRC_DIRECTORY}/event_groups.c
|
||||
${FREERTOS_SRC_DIRECTORY}/list.c
|
||||
${FREERTOS_SRC_DIRECTORY}/queue.c
|
||||
${FREERTOS_SRC_DIRECTORY}/stream_buffer.c
|
||||
${FREERTOS_SRC_DIRECTORY}/tasks.c
|
||||
${FREERTOS_SRC_DIRECTORY}/timers.c
|
||||
${FREERTOS_SRC_DIRECTORY}/portable/MemMang/heap_3.c
|
||||
${FREERTOS_SRC_DIRECTORY}/portable/GCC/ARM_CM0/port.c
|
||||
# add_library(FreeRTOS STATIC
|
||||
# ${FREERTOS_ROOT}/event_groups.c
|
||||
# ${FREERTOS_ROOT}/list.c
|
||||
# ${FREERTOS_ROOT}/queue.c
|
||||
# ${FREERTOS_ROOT}/stream_buffer.c
|
||||
# ${FREERTOS_ROOT}/tasks.c
|
||||
# ${FREERTOS_ROOT}/timers.c
|
||||
# ${FREERTOS_ROOT}/portable/MemMang/heap_3.c
|
||||
# ${FREERTOS_ROOT}/portable/GCC/ARM_CM0/port.c
|
||||
# )
|
||||
#
|
||||
include_directories(PUBLIC
|
||||
${FREERTOS_CFG_DIRECTORY}
|
||||
${FREERTOS_ROOT}/include/
|
||||
${FREERTOS_ROOT}/portable/GCC/ARM_CM0/
|
||||
)
|
||||
|
||||
target_include_directories(FreeRTOS PUBLIC
|
||||
${FREERTOS_CFG_DIRECTORY}/
|
||||
${FREERTOS_SRC_DIRECTORY}/include
|
||||
${FREERTOS_SRC_DIRECTORY}/portable/GCC/ARM_CM0
|
||||
)
|
||||
|
||||
|
||||
|
||||
add_subdirectory(./Blinky)
|
||||
add_subdirectory(./Listener)
|
||||
add_subdirectory(./Yeller)
|
||||
|
||||
|
||||
+38
-53
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeRTOS V202107.00
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* FreeRTOS
|
||||
* 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
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
* https://www.FreeRTOS.org
|
||||
* https://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* 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
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/* Use Pico SDK ISR handlers */
|
||||
#define vPortSVCHandler isr_svcall
|
||||
#define xPortPendSVHandler isr_pendsv
|
||||
#define xPortSysTickHandler isr_systick
|
||||
|
||||
/* 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_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 configCPU_CLOCK_HZ 133000000 // 133MHz for RP2040
|
||||
#define configTICK_RATE_HZ (TickType_t)1000 // FreeRTOS beats per second
|
||||
#define configMAX_PRIORITIES 24 // Max number of priority values (0-24)
|
||||
#define configMINIMAL_STACK_SIZE (configSTACK_DEPTH_TYPE)512
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configMAX_TASK_NAME_LEN 16
|
||||
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3
|
||||
|
||||
/* Synchronization Related */
|
||||
#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_MUTEXES 0
|
||||
#define configUSE_RECURSIVE_MUTEXES 0
|
||||
#define configUSE_COUNTING_SEMAPHORES 0
|
||||
#define configUSE_TASK_NOTIFICATIONS 1
|
||||
#define configUSE_QUEUE_SETS 0
|
||||
#define configQUEUE_REGISTRY_SIZE 10
|
||||
#define configUSE_NEWLIB_REENTRANT 0
|
||||
#define configENABLE_BACKWARD_COMPATIBILITY 0
|
||||
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
|
||||
|
||||
/* System */
|
||||
#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. */
|
||||
#define configSUPPORT_STATIC_ALLOCATION 0
|
||||
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||
#define configTOTAL_HEAP_SIZE (128*1024)
|
||||
#define configSUPPORT_DYNAMIC_ALLOCATION 1 // Get FreeRTOS to allocation task memory
|
||||
#define configAPPLICATION_ALLOCATED_HEAP 0
|
||||
#define configTOTAL_HEAP_SIZE (128*1024)
|
||||
|
||||
/* Hook function related definitions. */
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||
#define configUSE_MALLOC_FAILED_HOOK 0
|
||||
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
|
||||
|
||||
/* Run time and task stats gathering related definitions. */
|
||||
#define configGENERATE_RUN_TIME_STATS 0
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_TRACE_FACILITY 0
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
|
||||
|
||||
/* Co-routine related definitions. */
|
||||
@@ -94,29 +91,15 @@
|
||||
#define configTIMER_QUEUE_LENGTH 10
|
||||
#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 */
|
||||
#define configSUPPORT_PICO_SYNC_INTEROP 1
|
||||
#define configSUPPORT_PICO_TIME_INTEROP 1
|
||||
|
||||
#include <assert.h>
|
||||
/* 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
|
||||
to exclude the API function. */
|
||||
/* Optional functions - most linkers will remove unused functions anyway. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
@@ -128,11 +111,13 @@ to exclude the API function. */
|
||||
#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
|
||||
#define INCLUDE_xResumeFromISR 1
|
||||
#define INCLUDE_xEventGroupSetBitFromISR 1
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
|
||||
/* A header file that defines trace macro can be included here. */
|
||||
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user