Skip to content

Commit ee52d8a

Browse files
committed
update to 11.1.0 release
1 parent 5bcf511 commit ee52d8a

28 files changed

+2061
-1715
lines changed

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name=FreeRTOS
2-
version=11.0.1-5
2+
version=11.1.0-0
33
author=Richard Barry <[email protected]>
44
maintainer=Phillip Stevens <[email protected]>
5-
sentence=FreeRTOS Real Time Operating System implemented for AVR (Uno, Nano, Leonardo, Mega).
5+
sentence=FreeRTOS Real Time Operating System implemented for Arduino Uno R3, Nano, Leonardo, Mega, and related Microchip ATmega devices.
66
paragraph=The primary design goals are: Easy to use, Small footprint, Robust. Uses Watchdog Timer for 15ms resolution. Slow blink = stack overflow. Fast blink = heap malloc() failure.
77
category=Timing
88
url=https://github.com/feilipu/Arduino_FreeRTOS_Library

readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
This is a fork of Richard Barry's freeRTOS, optimised for the Arduino AVR devices.
1+
This is a fork of Richard Barry's FreeRTOS, optimised for the Arduino Microchip ATmega devices.
22

33
It has been created to provide access to FreeRTOS capabilities, with full compatibility to the Arduino IDE environment.
44
It does this by keeping hands off almost everything, and only touching the minimum of hardware to be successful.
55

6-
If you want to use FreeRTOS on the Renesas family of Arduino like the Arduino UNO R4, it is [already included](https://github.com/arduino/ArduinoCore-renesas/tree/main/libraries/Arduino_FreeRTOS). All that is required is to include the header file `Arduino_FreeRTOS.h` provided by the Arduino IDE, as follow the information noted below.
6+
If you want to use FreeRTOS on the Renesas family of Arduino like the Arduino UNO R4, it is [already included](https://github.com/arduino/ArduinoCore-renesas/tree/main/libraries/Arduino_FreeRTOS) in the default Arduino IDE. All that is required is to include the header file `Arduino_FreeRTOS.h` provided by the Arduino IDE, as follow the information noted below.
77

88
## Usage & Further Reading
99

@@ -15,22 +15,22 @@ My other [AVRfreeRTOS Sourceforge Repository](https://sourceforge.net/projects/a
1515

1616
This library was the genesis of [generalised support for the ATmega platform within FreeRTOS](https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/48), and improvement of the [stack depth type management](https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/942).
1717

18-
Over the past few years freeRTOS development has become increasingly 32-bit orientated, now including symmetric multiprocessing, with little change or improvement for the 8-bit world. As such I'm treating this FreeRTOS V11.0.1 (updated January 23 2024) as my LTS release.
18+
Over the past few years FreeRTOS development has become increasingly 32-bit orientated, now including symmetric multiprocessing, with little change or improvement for the 8-bit world. As such I'm treating this FreeRTOS V11.1.0 (updated April 22 2024) as my LTS release.
1919

2020
## General
2121

2222
FreeRTOS has a multitude of configuration options, which can be specified from within the FreeRTOSConfig.h file.
2323
To keep commonality with all of the Arduino hardware options, some sensible defaults have been selected. Feel free to change these defaults as you gain experience with FreeRTOS.
2424

25-
Normally, the AVR Watchdog Timer is used to generate 15ms time slices (Ticks). For applications requiring high precision timing, the Ticks can be sourced from a hardware timer or external clock. See chapter [Scheduler Tick Sources](./doc/tick_sources.md) for the configuration details.
25+
Normally, the ATmega Watchdog Timer is used to generate 15ms time slices (Ticks). For applications requiring high precision timing, the Ticks can be sourced from a hardware timer or external clock. See chapter [Scheduler Tick Sources](./doc/tick_sources.md) for the configuration details.
2626

2727
Tasks that suspend or delay before their allocated time slice completes will revert execution back to the Scheduler.
2828

2929
The Arduino `delay()` function has been redefined to automatically use the FreeRTOS `vTaskDelay()` function when the delay required is one Tick or longer, by setting `configUSE_PORT_DELAY` to `1`, so that simple Arduino example sketches and tutorials work as expected. If you would like to measure a short millisecond delay of less than one Tick, then preferably use [`millis()`](https://www.arduino.cc/reference/en/language/functions/time/millis/) (or with greater granularity use [`micros()`](https://www.arduino.cc/reference/en/language/functions/time/micros/)) to achieve this outcome (for example see [BlinkWithoutDelay](https://docs.arduino.cc/built-in-examples/digital/BlinkWithoutDelay)). However, when the delay requested is less than one Tick then the original Arduino `delay()` function will be automatically selected.
3030

31-
The 8-bit AVR Timer0 has been added as an option for the experienced user. Please examine the Timer0 source code example to figure out how to use it. Reconfiguring Timer0 for the FreeRTOS Tick will break Arduino `millis()` and `micros()` though, as these functions rely on Timer0. Example support for the Logic Green hardware using Timer 3 is provided via an open PR.
31+
The 8-bit ATmega Timer0 has been added as an option for the experienced user. Please examine the Timer0 source code example to figure out how to use it. Reconfiguring Timer0 for the FreeRTOS Tick will break Arduino `millis()` and `micros()` though, as these functions rely on the Arduino IDE configuring Timer0. Example support for the Logic Green hardware using Timer 3 is provided via an open PR.
3232

33-
Stack for the `loop()` function has been set at 192 Bytes. This can be configured by adjusting the `configMINIMAL_STACK_SIZE` parameter. If you have stack overflow issues just increase it (within the SRAM limitations of your hardware). Users should prefer to allocate larger structures, arrays, or buffers using `pvPortMalloc()`, rather than defining them locally on the stack. Ideally you should __not__ use `loop()` for your sketches, and then the Idle Task stack size can be reduced down to 85 Bytes which will save some valuable memory.
33+
Stack for the `loop()` function has been set at 192 Bytes. This can be configured by adjusting the `configMINIMAL_STACK_SIZE` parameter. If you have stack overflow issues just increase it (within the SRAM limitations of your hardware). Users should prefer to allocate larger structures, arrays, or buffers on the heap using `pvPortMalloc()`, rather than defining them locally on the stack. Ideally you should __not__ use `loop()` for your sketches, and then the Idle Task stack size can be reduced down to 92 Bytes which will save some valuable memory.
3434

3535
Memory for the heap is allocated by the normal C `malloc()` function, wrapped by the FreeRTOS `pvPortMalloc()` function. This option has been selected because it is automatically adjusted to use the capabilities of each device. Other heap allocation schemes are supported by FreeRTOS, and they can used with some additional configuration.
3636

@@ -73,7 +73,7 @@ The Arduino IDE supporting the Arduino UNO R4 already includes FreeRTOS as stand
7373

7474
* `Arduino_FreeRTOS.h` : Must always be `#include` first. It references other configuration files, and sets defaults where necessary.
7575
* `FreeRTOSConfig.h` : Contains a multitude of API and environment configurations.
76-
* `FreeRTOSVariant.h` : Contains the AVR specific configurations for this port of freeRTOS.
76+
* `FreeRTOSVariant.h` : Contains the ATmega specific configurations for this port of FreeRTOS.
7777
* `heap_3.c` : Contains the heap allocation scheme based on `malloc()`. Other schemes are available, but depend on user configuration for specific MCU choice.
7878

7979
### PlatformIO

src/Arduino_FreeRTOS.h

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* FreeRTOS Kernel V11.0.1
3-
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* FreeRTOS Kernel V11.1.0
3+
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* SPDX-License-Identifier: MIT
66
*
@@ -96,6 +96,10 @@
9696
#define configNUMBER_OF_CORES 1
9797
#endif
9898

99+
#ifndef configUSE_MALLOC_FAILED_HOOK
100+
#define configUSE_MALLOC_FAILED_HOOK 0
101+
#endif
102+
99103
/* Basic FreeRTOS definitions. */
100104
#include "projdefs.h"
101105

@@ -284,10 +288,6 @@
284288
#warning Co-routines have been removed from FreeRTOS-Kernel versions released after V10.5.1. You can view previous versions of the FreeRTOS Kernel at github.com/freertos/freertos-kernel/tree/V10.5.1.
285289
#endif
286290

287-
#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK
288-
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
289-
#endif
290-
291291
#ifndef configUSE_APPLICATION_TASK_TAG
292292
#define configUSE_APPLICATION_TASK_TAG 0
293293
#endif
@@ -308,6 +308,24 @@
308308
#define configUSE_TIMERS 0
309309
#endif
310310

311+
#ifndef configUSE_EVENT_GROUPS
312+
#define configUSE_EVENT_GROUPS 1
313+
#endif
314+
315+
#ifndef configUSE_STREAM_BUFFERS
316+
#define configUSE_STREAM_BUFFERS 1
317+
#endif
318+
319+
#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK
320+
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
321+
#endif
322+
323+
#if ( configUSE_DAEMON_TASK_STARTUP_HOOK != 0 )
324+
#if ( configUSE_TIMERS == 0 )
325+
#error configUSE_DAEMON_TASK_STARTUP_HOOK is set, but the daemon task is not created because configUSE_TIMERS is 0.
326+
#endif
327+
#endif
328+
311329
#ifndef configUSE_COUNTING_SEMAPHORES
312330
#define configUSE_COUNTING_SEMAPHORES 0
313331
#endif
@@ -474,6 +492,12 @@
474492
#define configUSE_CORE_AFFINITY 0
475493
#endif /* configUSE_CORE_AFFINITY */
476494

495+
#if ( ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
496+
#ifndef configTASK_DEFAULT_CORE_AFFINITY
497+
#define configTASK_DEFAULT_CORE_AFFINITY tskNO_AFFINITY
498+
#endif
499+
#endif
500+
477501
#ifndef configUSE_PASSIVE_IDLE_HOOK
478502
#define configUSE_PASSIVE_IDLE_HOOK 0
479503
#endif /* configUSE_PASSIVE_IDLE_HOOK */
@@ -948,15 +972,15 @@
948972
#endif
949973

950974
#ifndef traceSTREAM_BUFFER_CREATE_FAILED
951-
#define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer )
975+
#define traceSTREAM_BUFFER_CREATE_FAILED( xStreamBufferType )
952976
#endif
953977

954978
#ifndef traceSTREAM_BUFFER_CREATE_STATIC_FAILED
955-
#define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer )
979+
#define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xStreamBufferType )
956980
#endif
957981

958982
#ifndef traceSTREAM_BUFFER_CREATE
959-
#define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer )
983+
#define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xStreamBufferType )
960984
#endif
961985

962986
#ifndef traceSTREAM_BUFFER_DELETE
@@ -967,6 +991,10 @@
967991
#define traceSTREAM_BUFFER_RESET( xStreamBuffer )
968992
#endif
969993

994+
#ifndef traceSTREAM_BUFFER_RESET_FROM_ISR
995+
#define traceSTREAM_BUFFER_RESET_FROM_ISR( xStreamBuffer )
996+
#endif
997+
970998
#ifndef traceBLOCKING_ON_STREAM_BUFFER_SEND
971999
#define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer )
9721000
#endif
@@ -2364,15 +2392,15 @@
23642392
#endif
23652393

23662394
#ifndef traceENTER_xStreamBufferGenericCreate
2367-
#define traceENTER_xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, xIsMessageBuffer, pxSendCompletedCallback, pxReceiveCompletedCallback )
2395+
#define traceENTER_xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, xStreamBufferType, pxSendCompletedCallback, pxReceiveCompletedCallback )
23682396
#endif
23692397

23702398
#ifndef traceRETURN_xStreamBufferGenericCreate
23712399
#define traceRETURN_xStreamBufferGenericCreate( pvAllocatedMemory )
23722400
#endif
23732401

23742402
#ifndef traceENTER_xStreamBufferGenericCreateStatic
2375-
#define traceENTER_xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, xIsMessageBuffer, pucStreamBufferStorageArea, pxStaticStreamBuffer, pxSendCompletedCallback, pxReceiveCompletedCallback )
2403+
#define traceENTER_xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, xStreamBufferType, pucStreamBufferStorageArea, pxStaticStreamBuffer, pxSendCompletedCallback, pxReceiveCompletedCallback )
23762404
#endif
23772405

23782406
#ifndef traceRETURN_xStreamBufferGenericCreateStatic
@@ -2403,6 +2431,14 @@
24032431
#define traceRETURN_xStreamBufferReset( xReturn )
24042432
#endif
24052433

2434+
#ifndef traceENTER_xStreamBufferResetFromISR
2435+
#define traceENTER_xStreamBufferResetFromISR( xStreamBuffer )
2436+
#endif
2437+
2438+
#ifndef traceRETURN_xStreamBufferResetFromISR
2439+
#define traceRETURN_xStreamBufferResetFromISR( xReturn )
2440+
#endif
2441+
24062442
#ifndef traceENTER_xStreamBufferSetTriggerLevel
24072443
#define traceENTER_xStreamBufferSetTriggerLevel( xStreamBuffer, xTriggerLevel )
24082444
#endif
@@ -2633,10 +2669,6 @@
26332669
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
26342670
#endif
26352671

2636-
#ifndef configUSE_MALLOC_FAILED_HOOK
2637-
#define configUSE_MALLOC_FAILED_HOOK 0
2638-
#endif
2639-
26402672
#ifndef portPRIVILEGE_BIT
26412673
#define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 )
26422674
#endif
@@ -2789,9 +2821,9 @@
27892821

27902822
#ifndef configSTACK_DEPTH_TYPE
27912823

2792-
/* Defaults to uint16_t for backward compatibility, but can be overridden
2793-
* in FreeRTOSConfig.h if uint16_t is too restrictive. */
2794-
#define configSTACK_DEPTH_TYPE uint16_t
2824+
/* Defaults to StackType_t for backward compatibility, but can be overridden
2825+
* in FreeRTOSConfig.h if StackType_t is too restrictive. */
2826+
#define configSTACK_DEPTH_TYPE StackType_t
27952827
#endif
27962828

27972829
#ifndef configRUN_TIME_COUNTER_TYPE
@@ -3292,4 +3324,3 @@ typedef StaticStreamBuffer_t StaticMessageBuffer_t;
32923324
#include "FreeRTOSVariant.h"
32933325

32943326
#endif /* INC_ARDUINO_FREERTOS_H */
3295-

src/FreeRTOSConfig.h

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* FreeRTOS Kernel V11.0.1
3-
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* FreeRTOS Kernel V11.1.0
3+
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* SPDX-License-Identifier: MIT
66
*
@@ -41,67 +41,73 @@
4141
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
4242
*
4343
* See https://www.freertos.org/a00110.html.
44+
4445
*----------------------------------------------------------*/
4546

47+
/* Delay definition - here, the user can choose which delay implementation is required.
48+
* The default is to change nothing. */
49+
#define configUSE_PORT_DELAY 1
50+
4651
/* And on to the things the same no matter the AVR type... */
4752
#define configUSE_PREEMPTION 1
4853

4954
#define configCPU_CLOCK_HZ ( ( uint32_t ) F_CPU ) // This F_CPU variable set by the environment
55+
#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_16_BITS
56+
5057
#define configMAX_PRIORITIES 4
51-
#define configIDLE_SHOULD_YIELD 1
52-
#define configMINIMAL_STACK_SIZE ( 192 )
53-
#define configMAX_TASK_NAME_LEN ( 8 )
58+
#define configMAX_TASK_NAME_LEN 16
5459

55-
#define configQUEUE_REGISTRY_SIZE 0
56-
#define configCHECK_FOR_STACK_OVERFLOW 1
60+
/* Set the stack depth type to be uint16_t, otherwise it defaults to StackType_t */
61+
#define configSTACK_DEPTH_TYPE uint16_t
5762

63+
#define configMINIMAL_STACK_SIZE 192
64+
#define configCHECK_FOR_STACK_OVERFLOW 0
5865
#define configUSE_TRACE_FACILITY 0
59-
#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_16_BITS
6066

6167
#define configUSE_MUTEXES 1
6268
#define configUSE_RECURSIVE_MUTEXES 1
6369
#define configUSE_COUNTING_SEMAPHORES 1
6470
#define configUSE_TIME_SLICING 1
65-
#define configUSE_QUEUE_SETS 0
66-
#define configUSE_MALLOC_FAILED_HOOK 1
6771

72+
#define configUSE_QUEUE_SETS 0
73+
#define configUSE_APPLICATION_TASK_TAG 0
74+
#define configUSE_MALLOC_FAILED_HOOK 0
75+
#define configQUEUE_REGISTRY_SIZE 0
6876
#define configSUPPORT_DYNAMIC_ALLOCATION 1
6977
#define configSUPPORT_STATIC_ALLOCATION 0
7078

7179
#define configUSE_IDLE_HOOK 1
80+
#define configIDLE_SHOULD_YIELD 1
7281
#define configUSE_TICK_HOOK 0
7382

74-
/* Delay definition - here, the user can choose which delay implementation is required.
75-
* The default is to change nothing. */
76-
#define configUSE_PORT_DELAY 1
77-
7883
/* Timer definitions. */
7984
#define configUSE_TIMERS 1
80-
#define configTIMER_TASK_PRIORITY configMAX_PRIORITIES-1
81-
#define configTIMER_QUEUE_LENGTH ( 10 )
82-
#define configTIMER_TASK_STACK_DEPTH ( 85 )
83-
84-
/* Set the stack depth type to be uint16_t, otherwise it defaults to StackType_t */
85-
#define configSTACK_DEPTH_TYPE uint16_t
86-
87-
/* Set the stack pointer type to be uint16_t, otherwise it defaults to unsigned long */
88-
#define portPOINTER_SIZE_TYPE uint16_t
85+
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES-1 )
86+
#define configTIMER_TASK_STACK_DEPTH 92
87+
#define configTIMER_QUEUE_LENGTH 10
8988

9089
/* Set the following definitions to 1 to include the API function, or zero
9190
to exclude the API function. */
9291

93-
#define INCLUDE_vTaskPrioritySet 1
94-
#define INCLUDE_uxTaskPriorityGet 1
95-
#define INCLUDE_vTaskDelete 1
96-
#define INCLUDE_vTaskCleanUpResources 1
97-
#define INCLUDE_vTaskSuspend 1
98-
#define INCLUDE_vResumeFromISR 1
99-
#define INCLUDE_xTaskDelayUntil 1
100-
#define INCLUDE_vTaskDelay 1
101-
#define INCLUDE_xTaskGetSchedulerState 0
102-
#define INCLUDE_xTaskGetIdleTaskHandle 0 // create an idle task handle.
103-
#define INCLUDE_xTaskGetCurrentTaskHandle 1
104-
#define INCLUDE_uxTaskGetStackHighWaterMark 1
92+
/* Set the following INCLUDE_* constants to 1 to incldue the named API function,
93+
* or 0 to exclude the named API function. Most linkers will remove unused
94+
* functions even when the constant is 1. */
95+
#define INCLUDE_vTaskPrioritySet 1
96+
#define INCLUDE_uxTaskPriorityGet 1
97+
#define INCLUDE_vTaskDelete 1
98+
#define INCLUDE_vTaskSuspend 1
99+
#define INCLUDE_xTaskResumeFromISR 1
100+
#define INCLUDE_xTaskDelayUntil 1
101+
#define INCLUDE_vTaskDelay 1
102+
#define INCLUDE_xTaskGetSchedulerState 0
103+
#define INCLUDE_xTaskGetCurrentTaskHandle 1
104+
#define INCLUDE_uxTaskGetStackHighWaterMark 1
105+
#define INCLUDE_xTaskGetIdleTaskHandle 0
106+
#define INCLUDE_eTaskGetState 0
107+
#define INCLUDE_xEventGroupSetBitFromISR 1
108+
#define INCLUDE_xTimerPendFunctionCall 0
109+
#define INCLUDE_xTaskAbortDelay 0
110+
#define INCLUDE_xTaskGetHandle 0
105111

106112
#define configMAX(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
107113
#define configMIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })

src/FreeRTOSVariant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extern "C" {
5959
#else
6060
#warning "Variant configuration must define `configTICK_RATE_HZ` and `portTICK_PERIOD_MS` as either a macro or a constant"
6161
#define configTICK_RATE_HZ 1
62-
#define portTICK_PERIOD_MS ( (TickType_t) 1000 / configTICK_RATE_HZ )
62+
#define portTICK_PERIOD_MS ( (TickType_t) ( 1000 / configTICK_RATE_HZ ) )
6363
#endif
6464

6565
/*-----------------------------------------------------------*/

0 commit comments

Comments
 (0)