├── .gitignore ├── .vscode ├── c_cpp_properties.json ├── tasks.json └── launch.json ├── src └── main.c ├── Makefile └── include └── FreeRTOSConfig.h /.gitignore: -------------------------------------------------------------------------------- 1 | .sconsign.dblite 2 | build/ 3 | src/FreeRTOS 4 | src/FreeRTOS-Plus 5 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "${FREERTOS_PATH}/FreeRTOS/Source/include", 8 | "${FREERTOS_PATH}/FreeRTOS/Source/portable/ThirdParty/GCC/Posix" 9 | ], 10 | "defines": [], 11 | "compilerPath": "/usr/bin/gcc", 12 | "cStandard": "gnu17", 13 | "cppStandard": "gnu++14", 14 | "intelliSenseMode": "linux-gcc-x64" 15 | } 16 | ], 17 | "version": 4 18 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "make", 8 | "type": "shell", 9 | "command": "make", 10 | "problemMatcher": [], 11 | "group": { 12 | "kind": "build", 13 | "isDefault": true 14 | } 15 | }, 16 | { 17 | "label": "make clean", 18 | "type": "shell", 19 | "command": "make clean", 20 | "problemMatcher": [] 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /* Standard includes. */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | /* FreeRTOS kernel includes. */ 8 | #include "FreeRTOS.h" 9 | #include "task.h" 10 | 11 | void vTask1(void *pvParameters); 12 | void vTask2(void *pvParameters); 13 | 14 | int main(void) 15 | { 16 | xTaskCreate(&vTask1, "Task 1", 1024, NULL, 1, NULL); 17 | xTaskCreate(&vTask2, "Task 2", 1024, NULL, 1, NULL); 18 | 19 | vTaskStartScheduler(); 20 | 21 | return 0; 22 | } 23 | 24 | void vTask1(void *pvParameters) 25 | { 26 | for (;;) 27 | { 28 | printf("Task 1\r\n"); 29 | vTaskDelay(pdMS_TO_TICKS(1000)); 30 | } 31 | } 32 | 33 | void vTask2(void *pvParameters) 34 | { 35 | for (;;) 36 | { 37 | printf("Task 2\r\n"); 38 | vTaskDelay(pdMS_TO_TICKS(1000)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(gdb) Iniciar", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${workspaceFolder}/build/modelo-posix-gcc", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${workspaceFolder}", 15 | "environment": [], 16 | "MIMode": "gdb", 17 | "setupCommands": [ 18 | { 19 | "description": "Habilitar a reformatação automática para gdb", 20 | "text": "-enable-pretty-printing", 21 | "ignoreFailures": true 22 | } 23 | ] 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # https://freertos.org/Creating-a-new-FreeRTOS-project.html 2 | # Based on /opt/optsync/FreeRTOS/FreeRTOS/Demo/Posix_GCC/Makefile 3 | 4 | CC := gcc 5 | BIN := modelo-posix-gcc 6 | 7 | BUILD_DIR := build 8 | 9 | FREERTOS_DIR_REL := ${FREERTOS_PATH}/FreeRTOS 10 | FREERTOS_DIR := $(abspath $(FREERTOS_DIR_REL)) 11 | 12 | FREERTOS_PLUS_DIR_REL := ${FREERTOS_PATH}/FreeRTOS-Plus 13 | FREERTOS_PLUS_DIR := $(abspath $(FREERTOS_PLUS_DIR_REL)) 14 | 15 | INCLUDE_DIRS := -I./include 16 | INCLUDE_DIRS += -I${FREERTOS_DIR}/Source/include 17 | INCLUDE_DIRS += -I${FREERTOS_DIR}/Source/portable/ThirdParty/GCC/Posix 18 | 19 | SOURCE_FILES := $(wildcard ./src/*.c) 20 | SOURCE_FILES += ${FREERTOS_DIR}/Source/tasks.c 21 | SOURCE_FILES += ${FREERTOS_DIR}/Source/queue.c 22 | SOURCE_FILES += ${FREERTOS_DIR}/Source/list.c 23 | SOURCE_FILES += ${FREERTOS_DIR}/Source/timers.c 24 | # Memory manager (use malloc() / free()) 25 | SOURCE_FILES += ${FREERTOS_DIR}/Source/portable/MemMang/heap_3.c 26 | # Posix port 27 | SOURCE_FILES += ${FREERTOS_DIR}/Source/portable/ThirdParty/GCC/Posix/port.c 28 | SOURCE_FILES += ${FREERTOS_DIR}/Source/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c 29 | 30 | CFLAGS := -ggdb3 -O0 31 | LDFLAGS := -ggdb3 -O0 -pthread 32 | 33 | OBJ_FILES = $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.o) 34 | 35 | DEP_FILE = $(OBJ_FILES:%.o=%.d) 36 | 37 | ${BIN} : $(BUILD_DIR)/$(BIN) 38 | 39 | ${BUILD_DIR}/${BIN} : ${OBJ_FILES} 40 | -mkdir -p ${@D} 41 | $(CC) $^ $(CFLAGS) $(INCLUDE_DIRS) ${LDFLAGS} -o $@ 42 | 43 | -include ${DEP_FILE} 44 | 45 | ${BUILD_DIR}/%.o : %.c 46 | -mkdir -p $(@D) 47 | $(CC) $(CFLAGS) ${INCLUDE_DIRS} -MMD -c $< -o $@ 48 | 49 | .PHONY: clean 50 | 51 | clean: 52 | -rm -rf $(BUILD_DIR) -------------------------------------------------------------------------------- /include/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef FREERTOS_CONFIG_H 2 | #define FREERTOS_CONFIG_H 3 | 4 | /*----------------------------------------------------------- 5 | * Application specific definitions. 6 | * 7 | * These definitions should be adjusted for your particular hardware and 8 | * application requirements. 9 | * 10 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE 11 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. See 12 | * http://www.freertos.org/a00110.html 13 | *----------------------------------------------------------*/ 14 | 15 | #define configUSE_PREEMPTION 1 16 | #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 17 | #define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */ 18 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */ 19 | #define configMAX_TASK_NAME_LEN ( 12 ) 20 | #define configUSE_16_BIT_TICKS 0 21 | #define configIDLE_SHOULD_YIELD 0 22 | #define configUSE_MUTEXES 1 23 | #define configUSE_RECURSIVE_MUTEXES 1 24 | #define configQUEUE_REGISTRY_SIZE 20 25 | #define configUSE_APPLICATION_TASK_TAG 1 26 | #define configUSE_COUNTING_SEMAPHORES 1 27 | #define configUSE_ALTERNATIVE_API 0 28 | #define configUSE_QUEUE_SETS 1 29 | #define configUSE_TASK_NOTIFICATIONS 1 30 | 31 | 32 | #define configMAX_PRIORITIES ( 7 ) 33 | 34 | /* Memory allocation related definitions. */ 35 | #define configSUPPORT_STATIC_ALLOCATION 0 36 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 65 * 1024 ) ) 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 configuration options. */ 51 | #define configUSE_CO_ROUTINES 0 52 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 53 | 54 | /* Software timer related definitions. */ 55 | /* The maximum possible task priority is configMAX_PRIORITIES - 1. 56 | The priority of the timer task is deliberately set higher to ensure 57 | it is correctly capped back to configMAX_PRIORITIES - 1. */ 58 | #define configUSE_TIMERS 1 59 | #define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) 60 | #define configTIMER_QUEUE_LENGTH 20 61 | #define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 ) 62 | 63 | /* Define to trap errors during development. */ 64 | //#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ ) 65 | extern void vAssertCalled( const char * const pcFileName, unsigned long ulLine ); 66 | 67 | /* Enables the test whereby a stack larger than the total heap size is 68 | requested. */ 69 | //#define configSTACK_DEPTH_TYPE uint32_t 70 | 71 | /* Set the following definitions to 1 to include the API function, or zero 72 | to exclude the API function. In most cases the linker will remove unused 73 | functions anyway. */ 74 | #define INCLUDE_vTaskPrioritySet 1 75 | #define INCLUDE_uxTaskPriorityGet 1 76 | #define INCLUDE_vTaskDelete 1 77 | #define INCLUDE_vTaskCleanUpResources 0 78 | #define INCLUDE_vTaskSuspend 1 79 | #define INCLUDE_vTaskDelayUntil 1 80 | #define INCLUDE_vTaskDelay 1 81 | #define INCLUDE_uxTaskGetStackHighWaterMark 1 82 | #define INCLUDE_uxTaskGetStackHighWaterMark2 1 83 | #define INCLUDE_xTaskGetSchedulerState 1 84 | #define INCLUDE_xTimerGetTimerDaemonTaskHandle 1 85 | #define INCLUDE_xTaskGetIdleTaskHandle 1 86 | #define INCLUDE_xTaskGetHandle 1 87 | #define INCLUDE_eTaskGetState 1 88 | #define INCLUDE_xSemaphoreGetMutexHolder 1 89 | #define INCLUDE_xTimerPendFunctionCall 1 90 | #define INCLUDE_xTaskAbortDelay 1 91 | 92 | #endif /* FREERTOS_CONFIG_H */ 93 | --------------------------------------------------------------------------------