Skip to content

Commit 2f14ebc

Browse files
committed
Merge remote-tracking branch 'origin/freertos' into HEAD
2 parents 02efe1e + 19093fb commit 2f14ebc

35 files changed

+32824
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/**************************************************************************************
2+
* INCLUDE
3+
**************************************************************************************/
4+
5+
#include <Arduino_FreeRTOS.h>
6+
7+
/**************************************************************************************
8+
* GLOBAL VARIABLES
9+
**************************************************************************************/
10+
11+
TaskHandle_t loop_task, blinky_task;
12+
13+
/**************************************************************************************
14+
* SETUP/LOOP
15+
**************************************************************************************/
16+
17+
void setup()
18+
{
19+
Serial.begin(115200);
20+
while (!Serial) { }
21+
22+
pinMode(LEDR, OUTPUT);
23+
digitalWrite(LEDR, LOW);
24+
25+
/* Init a task that calls 'loop'
26+
* since after the call to
27+
* 'vTaskStartScheduler' we'll never
28+
* get out of setup() and therefore
29+
* would never get to loop(), as we
30+
* are leaving the default execution
31+
* flow.
32+
*/
33+
#if 1
34+
auto const rc_loop = xTaskCreate
35+
(
36+
loop_thread_func,
37+
static_cast<const char*>("Loop Thread"),
38+
512 / 4, /* usStackDepth in words */
39+
nullptr, /* pvParameters */
40+
1, /* uxPriority */
41+
&loop_task /* pxCreatedTask */
42+
);
43+
44+
if (rc_loop != pdPASS) {
45+
Serial.println("Failed to create 'loop' thread");
46+
return;
47+
}
48+
#endif
49+
#if 1
50+
auto const rc_blinky = xTaskCreate
51+
(
52+
blinky_thread_func,
53+
static_cast<const char*>("Blinky Thread"),
54+
512 / 4, /* usStackDepth in words */
55+
nullptr, /* pvParameters */
56+
1, /* uxPriority */
57+
&blinky_task /* pxCreatedTask */
58+
);
59+
60+
if (rc_blinky != pdPASS) {
61+
Serial.println("Failed to create 'loop' thread");
62+
return;
63+
}
64+
#endif
65+
Serial.println("Starting scheduler ...");
66+
/* Start the scheduler. */
67+
vTaskStartScheduler();
68+
/* We'll never get here. */
69+
for( ;; );
70+
}
71+
72+
void loop()
73+
{
74+
digitalWrite(LEDR, !digitalRead(LEDR));
75+
vTaskDelay(configTICK_RATE_HZ/4);
76+
}
77+
78+
void loop_thread_func(void *pvParameters)
79+
{
80+
for(;;)
81+
{
82+
loop();
83+
taskYIELD();
84+
}
85+
}
86+
87+
void blinky_thread_func(void *pvParameters)
88+
{
89+
/* setup() */
90+
pinMode(LED_BUILTIN, OUTPUT);
91+
digitalWrite(LED_BUILTIN, LOW);
92+
93+
/* loop() */
94+
for(;;)
95+
{
96+
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
97+
vTaskDelay(configTICK_RATE_HZ);
98+
}
99+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=Arduino_FreeRTOS
2+
version=1.0.0
3+
author=Arduino
4+
maintainer=Arduino <[email protected]>
5+
sentence=This library provides FreeRTOS for the Portenta C33.
6+
paragraph=
7+
category=Other
8+
url=
9+
architectures=renesas
10+
include=Arduino_FreeRTOS.h
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2022 by Alexander Entinger <[email protected]>
3+
* CAN library for Arduino.
4+
*
5+
* This file is free software; you can redistribute it and/or modify
6+
* it under the terms of either the GNU General Public License version 2
7+
* or the GNU Lesser General Public License version 2.1, both as
8+
* published by the Free Software Foundation.
9+
*/
10+
11+
#pragma once
12+
13+
#ifndef ARDUINO_PORTENTA_H33
14+
# error "FreeRTOS is currently only supported for the Portenta C33."
15+
#endif
16+
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
#include "FreeRTOSConfig.h"
22+
23+
#include "lib/FreeRTOS-Kernel-v10.5.1/FreeRTOS.h"
24+
#include "lib/FreeRTOS-Kernel-v10.5.1/croutine.h"
25+
#include "lib/FreeRTOS-Kernel-v10.5.1/event_groups.h"
26+
#include "lib/FreeRTOS-Kernel-v10.5.1/queue.h"
27+
#include "lib/FreeRTOS-Kernel-v10.5.1/semphr.h"
28+
#include "lib/FreeRTOS-Kernel-v10.5.1/task.h"
29+
#include "lib/FreeRTOS-Kernel-v10.5.1/timers.h"
30+
31+
#ifdef __cplusplus
32+
}
33+
#endif
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
/* generated configuration header file - do not edit */
2+
#ifndef FREERTOSCONFIG_H_
3+
#define FREERTOSCONFIG_H_
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.
12+
*
13+
* See http://www.freertos.org/a00110.html
14+
*----------------------------------------------------------*/
15+
#include "bsp_api.h"
16+
17+
/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
18+
FSP_HEADER
19+
20+
#ifndef configUSE_PREEMPTION
21+
#define configUSE_PREEMPTION (1)
22+
#endif
23+
#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
24+
#define configUSE_PORT_OPTIMISED_TASK_SELECTION (0)
25+
#endif
26+
#ifndef configUSE_TICKLESS_IDLE
27+
#define configUSE_TICKLESS_IDLE (0)
28+
#endif
29+
#ifndef configUSE_IDLE_HOOK
30+
#define configUSE_IDLE_HOOK (1)
31+
#endif
32+
#ifndef configUSE_MALLOC_FAILED_HOOK
33+
#define configUSE_MALLOC_FAILED_HOOK (0)
34+
#endif
35+
#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK
36+
#define configUSE_DAEMON_TASK_STARTUP_HOOK (0)
37+
#endif
38+
#ifndef configUSE_TICK_HOOK
39+
#define configUSE_TICK_HOOK (0)
40+
#endif
41+
#ifndef configCPU_CLOCK_HZ
42+
#define configCPU_CLOCK_HZ (SystemCoreClock)
43+
#endif
44+
#ifndef configTICK_RATE_HZ
45+
#define configTICK_RATE_HZ (1000)
46+
#endif
47+
#ifndef configMAX_PRIORITIES
48+
#define configMAX_PRIORITIES (5)
49+
#endif
50+
#ifndef configMINIMAL_STACK_SIZE
51+
#define configMINIMAL_STACK_SIZE (128)
52+
#endif
53+
#ifndef configMINIMAL_SECURE_STACK_SIZE
54+
#define configMINIMAL_SECURE_STACK_SIZE (256U) /* Unused in RA port. */
55+
#endif
56+
#ifndef configMAX_TASK_NAME_LEN
57+
#define configMAX_TASK_NAME_LEN (16)
58+
#endif
59+
#ifndef configUSE_TRACE_FACILITY
60+
#define configUSE_TRACE_FACILITY (0)
61+
#endif
62+
#ifndef configUSE_STATS_FORMATTING_FUNCTIONS
63+
#define configUSE_STATS_FORMATTING_FUNCTIONS (0)
64+
#endif
65+
#ifndef configUSE_16_BIT_TICKS
66+
#define configUSE_16_BIT_TICKS (0)
67+
#endif
68+
#ifndef configIDLE_SHOULD_YIELD
69+
#define configIDLE_SHOULD_YIELD (1)
70+
#endif
71+
#ifndef configUSE_TASK_NOTIFICATIONS
72+
#define configUSE_TASK_NOTIFICATIONS (1)
73+
#endif
74+
#ifndef configUSE_MUTEXES
75+
#define configUSE_MUTEXES (0)
76+
#endif
77+
#ifndef configUSE_RECURSIVE_MUTEXES
78+
#define configUSE_RECURSIVE_MUTEXES (0)
79+
#endif
80+
#ifndef configUSE_COUNTING_SEMAPHORES
81+
#define configUSE_COUNTING_SEMAPHORES (1)
82+
#endif
83+
#ifndef configUSE_ALTERNATIVE_API
84+
#define configUSE_ALTERNATIVE_API (0U)
85+
#endif
86+
#ifndef configCHECK_FOR_STACK_OVERFLOW
87+
#define configCHECK_FOR_STACK_OVERFLOW (0)
88+
#endif
89+
#ifndef configQUEUE_REGISTRY_SIZE
90+
#define configQUEUE_REGISTRY_SIZE (10)
91+
#endif
92+
#ifndef configUSE_QUEUE_SETS
93+
#define configUSE_QUEUE_SETS (0)
94+
#endif
95+
#ifndef configUSE_TIME_SLICING
96+
#define configUSE_TIME_SLICING (0)
97+
#endif
98+
#ifndef configUSE_NEWLIB_REENTRANT
99+
#define configUSE_NEWLIB_REENTRANT (0)
100+
#endif
101+
#ifndef configENABLE_BACKWARD_COMPATIBILITY
102+
#define configENABLE_BACKWARD_COMPATIBILITY (0)
103+
#endif
104+
#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS
105+
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS (5)
106+
#endif
107+
#ifndef configSTACK_DEPTH_TYPE
108+
#define configSTACK_DEPTH_TYPE uint32_t
109+
#endif
110+
#ifndef configMESSAGE_BUFFER_LENGTH_TYPE
111+
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
112+
#endif
113+
#ifndef configSUPPORT_STATIC_ALLOCATION
114+
#define configSUPPORT_STATIC_ALLOCATION (0)
115+
#endif
116+
#ifndef configSUPPORT_DYNAMIC_ALLOCATION
117+
#define configSUPPORT_DYNAMIC_ALLOCATION (1)
118+
#endif
119+
#ifndef configTOTAL_HEAP_SIZE
120+
#define configTOTAL_HEAP_SIZE (0x8000)
121+
#endif
122+
#ifndef configAPPLICATION_ALLOCATED_HEAP
123+
#define configAPPLICATION_ALLOCATED_HEAP (4)
124+
#endif
125+
#ifndef configGENERATE_RUN_TIME_STATS
126+
#define configGENERATE_RUN_TIME_STATS (0)
127+
#endif
128+
#ifndef configUSE_CO_ROUTINES
129+
#define configUSE_CO_ROUTINES (0)
130+
#endif
131+
#ifndef configUSE_TIMERS
132+
#define configUSE_TIMERS (1)
133+
#endif
134+
#ifndef configTIMER_TASK_PRIORITY
135+
#define configTIMER_TASK_PRIORITY (3)
136+
#endif
137+
#ifndef configTIMER_QUEUE_LENGTH
138+
#define configTIMER_QUEUE_LENGTH (10)
139+
#endif
140+
#ifndef configTIMER_TASK_STACK_DEPTH
141+
#define configTIMER_TASK_STACK_DEPTH (128)
142+
#endif
143+
#ifndef configLIBRARY_LOWEST_INTERRUPT_PRIORITY
144+
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1 << __NVIC_PRIO_BITS) - 1)
145+
#endif
146+
#ifndef configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY
147+
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ((1))
148+
#endif
149+
#ifndef configMAX_SYSCALL_INTERRUPT_PRIORITY
150+
#define configMAX_SYSCALL_INTERRUPT_PRIORITY (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - __NVIC_PRIO_BITS))
151+
#endif
152+
#ifndef configMAX_API_CALL_INTERRUPT_PRIORITY
153+
#define configMAX_API_CALL_INTERRUPT_PRIORITY (configMAX_SYSCALL_INTERRUPT_PRIORITY)
154+
#endif
155+
#ifndef configASSERT
156+
#define configASSERT( x ) assert(x)
157+
#endif
158+
#ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS
159+
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS (0)
160+
#endif
161+
#ifndef INCLUDE_vTaskPrioritySet
162+
#define INCLUDE_vTaskPrioritySet (1)
163+
#endif
164+
#ifndef INCLUDE_uxTaskPriorityGet
165+
#define INCLUDE_uxTaskPriorityGet (1)
166+
#endif
167+
#ifndef INCLUDE_vTaskDelete
168+
#define INCLUDE_vTaskDelete (1)
169+
#endif
170+
#ifndef INCLUDE_vTaskSuspend
171+
#define INCLUDE_vTaskSuspend (1)
172+
#endif
173+
#ifndef INCLUDE_xResumeFromISR
174+
#define INCLUDE_xResumeFromISR (1)
175+
#endif
176+
#ifndef INCLUDE_vTaskDelayUntil
177+
#define INCLUDE_vTaskDelayUntil (1)
178+
#endif
179+
#ifndef INCLUDE_vTaskDelay
180+
#define INCLUDE_vTaskDelay (1)
181+
#endif
182+
#ifndef INCLUDE_xTaskGetSchedulerState
183+
#define INCLUDE_xTaskGetSchedulerState (1)
184+
#endif
185+
#ifndef INCLUDE_xTaskGetCurrentTaskHandle
186+
#define INCLUDE_xTaskGetCurrentTaskHandle (1)
187+
#endif
188+
#ifndef INCLUDE_uxTaskGetStackHighWaterMark
189+
#define INCLUDE_uxTaskGetStackHighWaterMark (0)
190+
#endif
191+
#ifndef INCLUDE_xTaskGetIdleTaskHandle
192+
#define INCLUDE_xTaskGetIdleTaskHandle (0)
193+
#endif
194+
#ifndef INCLUDE_eTaskGetState
195+
#define INCLUDE_eTaskGetState (0)
196+
#endif
197+
#ifndef INCLUDE_xEventGroupSetBitFromISR
198+
#define INCLUDE_xEventGroupSetBitFromISR (1)
199+
#endif
200+
#ifndef INCLUDE_xTimerPendFunctionCall
201+
#define INCLUDE_xTimerPendFunctionCall (0)
202+
#endif
203+
#ifndef INCLUDE_xTaskAbortDelay
204+
#define INCLUDE_xTaskAbortDelay (0)
205+
#endif
206+
#ifndef INCLUDE_xTaskGetHandle
207+
#define INCLUDE_xTaskGetHandle (0)
208+
#endif
209+
#ifndef INCLUDE_xTaskResumeFromISR
210+
#define INCLUDE_xTaskResumeFromISR (1)
211+
#endif
212+
#ifndef RM_FREERTOS_PORT_CFG_HW_STACK_MONITOR_ENABLE
213+
#define RM_FREERTOS_PORT_CFG_HW_STACK_MONITOR_ENABLE (0)
214+
#endif
215+
#ifndef configPRINT_STRING
216+
#define configPRINT_STRING(x) (printf(x))
217+
#endif
218+
#ifndef configLOGGING_INCLUDE_TIME_AND_TASK_NAME
219+
#define configLOGGING_INCLUDE_TIME_AND_TASK_NAME (0)
220+
#endif
221+
#ifndef configLOGGING_MAX_MESSAGE_LENGTH
222+
#define configLOGGING_MAX_MESSAGE_LENGTH (192)
223+
#endif
224+
225+
/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
226+
FSP_FOOTER
227+
#endif /* FREERTOSCONFIG_H_ */

0 commit comments

Comments
 (0)