Skip to content

Commit 9e02f3b

Browse files
committed
Update to FreeRTOS 10.3.1 sources modified by ST
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 8b196df commit 9e02f3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+6757
-1056
lines changed

portable/CMSIS_RTOS_V2/cmsis_os2.c

+614-58
Large diffs are not rendered by default.
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* --------------------------------------------------------------------------
2+
* Copyright (c) 2013-2020 Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the License); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Name: freertos_mpool.h
19+
* Purpose: CMSIS RTOS2 wrapper for FreeRTOS
20+
*
21+
*---------------------------------------------------------------------------*/
22+
23+
#ifndef FREERTOS_MPOOL_H_
24+
#define FREERTOS_MPOOL_H_
25+
26+
#include <stdint.h>
27+
#include "FreeRTOS.h"
28+
#include "semphr.h"
29+
30+
/* Memory Pool implementation definitions */
31+
#define MPOOL_STATUS 0x5EED0000U
32+
33+
/* Memory Block header */
34+
typedef struct {
35+
void *next; /* Pointer to next block */
36+
} MemPoolBlock_t;
37+
38+
/* Memory Pool control block */
39+
typedef struct MemPoolDef_t {
40+
MemPoolBlock_t *head; /* Pointer to head block */
41+
SemaphoreHandle_t sem; /* Pool semaphore handle */
42+
uint8_t *mem_arr; /* Pool memory array */
43+
uint32_t mem_sz; /* Pool memory array size */
44+
const char *name; /* Pointer to name string */
45+
uint32_t bl_sz; /* Size of a single block */
46+
uint32_t bl_cnt; /* Number of blocks */
47+
uint32_t n; /* Block allocation index */
48+
volatile uint32_t status; /* Object status flags */
49+
#if (configSUPPORT_STATIC_ALLOCATION == 1)
50+
StaticSemaphore_t mem_sem; /* Semaphore object memory */
51+
#endif
52+
} MemPool_t;
53+
54+
/* No need to hide static object type, just align to coding style */
55+
#define StaticMemPool_t MemPool_t
56+
57+
/* Define memory pool control block size */
58+
#define MEMPOOL_CB_SIZE (sizeof(StaticMemPool_t))
59+
60+
/* Define size of the byte array required to create count of blocks of given size */
61+
#define MEMPOOL_ARR_SIZE(bl_count, bl_size) (((((bl_size) + (4 - 1)) / 4) * 4)*(bl_count))
62+
63+
#endif /* FREERTOS_MPOOL_H_ */

portable/CMSIS_RTOS_V2/freertos_os2.h

+310
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
/* --------------------------------------------------------------------------
2+
* Copyright (c) 2013-2020 Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the License); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Name: freertos_os2.h
19+
* Purpose: CMSIS RTOS2 wrapper for FreeRTOS
20+
*
21+
*---------------------------------------------------------------------------*/
22+
23+
#ifndef FREERTOS_OS2_H_
24+
#define FREERTOS_OS2_H_
25+
26+
#include <string.h>
27+
#include <stdint.h>
28+
29+
#include "FreeRTOS.h" // ARM.FreeRTOS::RTOS:Core
30+
31+
#include CMSIS_device_header
32+
33+
/*
34+
CMSIS-RTOS2 FreeRTOS image size optimization definitions.
35+
36+
Note: Definitions configUSE_OS2 can be used to optimize FreeRTOS image size when
37+
certain functionality is not required when using CMSIS-RTOS2 API.
38+
In general optimization decisions are left to the tool chain but in cases
39+
when coding style prevents it to optimize the code following optional
40+
definitions can be used.
41+
*/
42+
43+
/*
44+
Option to exclude CMSIS-RTOS2 functions osThreadSuspend and osThreadResume from
45+
the application image.
46+
*/
47+
#ifndef configUSE_OS2_THREAD_SUSPEND_RESUME
48+
#define configUSE_OS2_THREAD_SUSPEND_RESUME 1
49+
#endif
50+
51+
/*
52+
Option to exclude CMSIS-RTOS2 function osThreadEnumerate from the application image.
53+
*/
54+
#ifndef configUSE_OS2_THREAD_ENUMERATE
55+
#define configUSE_OS2_THREAD_ENUMERATE 1
56+
#endif
57+
58+
/*
59+
Option to disable CMSIS-RTOS2 function osEventFlagsSet and osEventFlagsClear
60+
operation from ISR.
61+
*/
62+
#ifndef configUSE_OS2_EVENTFLAGS_FROM_ISR
63+
#define configUSE_OS2_EVENTFLAGS_FROM_ISR 1
64+
#endif
65+
66+
/*
67+
Option to exclude CMSIS-RTOS2 Thread Flags API functions from the application image.
68+
*/
69+
#ifndef configUSE_OS2_THREAD_FLAGS
70+
#define configUSE_OS2_THREAD_FLAGS configUSE_TASK_NOTIFICATIONS
71+
#endif
72+
73+
/*
74+
Option to exclude CMSIS-RTOS2 Timer API functions from the application image.
75+
*/
76+
#ifndef configUSE_OS2_TIMER
77+
#define configUSE_OS2_TIMER configUSE_TIMERS
78+
#endif
79+
80+
/*
81+
Option to exclude CMSIS-RTOS2 Mutex API functions from the application image.
82+
*/
83+
#ifndef configUSE_OS2_MUTEX
84+
#define configUSE_OS2_MUTEX configUSE_MUTEXES
85+
#endif
86+
87+
88+
/*
89+
CMSIS-RTOS2 FreeRTOS configuration check (FreeRTOSConfig.h).
90+
91+
Note: CMSIS-RTOS API requires functions included by using following definitions.
92+
In case if certain API function is not used compiler will optimize it away.
93+
*/
94+
#if (INCLUDE_xSemaphoreGetMutexHolder == 0)
95+
/*
96+
CMSIS-RTOS2 function osMutexGetOwner uses FreeRTOS function xSemaphoreGetMutexHolder. In case if
97+
osMutexGetOwner is not used in the application image, compiler will optimize it away.
98+
Set #define INCLUDE_xSemaphoreGetMutexHolder 1 to fix this error.
99+
*/
100+
#error "Definition INCLUDE_xSemaphoreGetMutexHolder must equal 1 to implement Mutex Management API."
101+
#endif
102+
#if (INCLUDE_vTaskDelay == 0)
103+
/*
104+
CMSIS-RTOS2 function osDelay uses FreeRTOS function vTaskDelay. In case if
105+
osDelay is not used in the application image, compiler will optimize it away.
106+
Set #define INCLUDE_vTaskDelay 1 to fix this error.
107+
*/
108+
#error "Definition INCLUDE_vTaskDelay must equal 1 to implement Generic Wait Functions API."
109+
#endif
110+
#if (INCLUDE_vTaskDelayUntil == 0)
111+
/*
112+
CMSIS-RTOS2 function osDelayUntil uses FreeRTOS function vTaskDelayUntil. In case if
113+
osDelayUntil is not used in the application image, compiler will optimize it away.
114+
Set #define INCLUDE_vTaskDelayUntil 1 to fix this error.
115+
*/
116+
#error "Definition INCLUDE_vTaskDelayUntil must equal 1 to implement Generic Wait Functions API."
117+
#endif
118+
#if (INCLUDE_vTaskDelete == 0)
119+
/*
120+
CMSIS-RTOS2 function osThreadTerminate and osThreadExit uses FreeRTOS function
121+
vTaskDelete. In case if they are not used in the application image, compiler
122+
will optimize them away.
123+
Set #define INCLUDE_vTaskDelete 1 to fix this error.
124+
*/
125+
#error "Definition INCLUDE_vTaskDelete must equal 1 to implement Thread Management API."
126+
#endif
127+
#if (INCLUDE_xTaskGetCurrentTaskHandle == 0)
128+
/*
129+
CMSIS-RTOS2 API uses FreeRTOS function xTaskGetCurrentTaskHandle to implement
130+
functions osThreadGetId, osThreadFlagsClear and osThreadFlagsGet. In case if these
131+
functions are not used in the application image, compiler will optimize them away.
132+
Set #define INCLUDE_xTaskGetCurrentTaskHandle 1 to fix this error.
133+
*/
134+
#error "Definition INCLUDE_xTaskGetCurrentTaskHandle must equal 1 to implement Thread Management API."
135+
#endif
136+
#if (INCLUDE_xTaskGetSchedulerState == 0)
137+
/*
138+
CMSIS-RTOS2 API uses FreeRTOS function xTaskGetSchedulerState to implement Kernel
139+
tick handling and therefore it is vital that xTaskGetSchedulerState is included into
140+
the application image.
141+
Set #define INCLUDE_xTaskGetSchedulerState 1 to fix this error.
142+
*/
143+
#error "Definition INCLUDE_xTaskGetSchedulerState must equal 1 to implement Kernel Information and Control API."
144+
#endif
145+
#if (INCLUDE_uxTaskGetStackHighWaterMark == 0)
146+
/*
147+
CMSIS-RTOS2 function osThreadGetStackSpace uses FreeRTOS function uxTaskGetStackHighWaterMark.
148+
In case if osThreadGetStackSpace is not used in the application image, compiler will
149+
optimize it away.
150+
Set #define INCLUDE_uxTaskGetStackHighWaterMark 1 to fix this error.
151+
*/
152+
#error "Definition INCLUDE_uxTaskGetStackHighWaterMark must equal 1 to implement Thread Management API."
153+
#endif
154+
#if (INCLUDE_uxTaskPriorityGet == 0)
155+
/*
156+
CMSIS-RTOS2 function osThreadGetPriority uses FreeRTOS function uxTaskPriorityGet. In case if
157+
osThreadGetPriority is not used in the application image, compiler will optimize it away.
158+
Set #define INCLUDE_uxTaskPriorityGet 1 to fix this error.
159+
*/
160+
#error "Definition INCLUDE_uxTaskPriorityGet must equal 1 to implement Thread Management API."
161+
#endif
162+
#if (INCLUDE_vTaskPrioritySet == 0)
163+
/*
164+
CMSIS-RTOS2 function osThreadSetPriority uses FreeRTOS function vTaskPrioritySet. In case if
165+
osThreadSetPriority is not used in the application image, compiler will optimize it away.
166+
Set #define INCLUDE_vTaskPrioritySet 1 to fix this error.
167+
*/
168+
#error "Definition INCLUDE_vTaskPrioritySet must equal 1 to implement Thread Management API."
169+
#endif
170+
#if (INCLUDE_eTaskGetState == 0)
171+
/*
172+
CMSIS-RTOS2 API uses FreeRTOS function vTaskDelayUntil to implement functions osThreadGetState
173+
and osThreadTerminate. In case if these functions are not used in the application image,
174+
compiler will optimize them away.
175+
Set #define INCLUDE_eTaskGetState 1 to fix this error.
176+
*/
177+
#error "Definition INCLUDE_eTaskGetState must equal 1 to implement Thread Management API."
178+
#endif
179+
#if (INCLUDE_vTaskSuspend == 0)
180+
/*
181+
CMSIS-RTOS2 API uses FreeRTOS functions vTaskSuspend and vTaskResume to implement
182+
functions osThreadSuspend and osThreadResume. In case if these functions are not
183+
used in the application image, compiler will optimize them away.
184+
Set #define INCLUDE_vTaskSuspend 1 to fix this error.
185+
186+
Alternatively, if the application does not use osThreadSuspend and
187+
osThreadResume they can be excluded from the image code by setting:
188+
#define configUSE_OS2_THREAD_SUSPEND_RESUME 0 (in FreeRTOSConfig.h)
189+
*/
190+
#if (configUSE_OS2_THREAD_SUSPEND_RESUME == 1)
191+
#error "Definition INCLUDE_vTaskSuspend must equal 1 to implement Kernel Information and Control API."
192+
#endif
193+
#endif
194+
#if (INCLUDE_xTimerPendFunctionCall == 0)
195+
/*
196+
CMSIS-RTOS2 function osEventFlagsSet and osEventFlagsClear, when called from
197+
the ISR, call FreeRTOS functions xEventGroupSetBitsFromISR and
198+
xEventGroupClearBitsFromISR which are only enabled if timers are operational and
199+
xTimerPendFunctionCall in enabled.
200+
Set #define INCLUDE_xTimerPendFunctionCall 1 and #define configUSE_TIMERS 1
201+
to fix this error.
202+
203+
Alternatively, if the application does not use osEventFlagsSet and osEventFlagsClear
204+
from the ISR their operation from ISR can be restricted by setting:
205+
#define configUSE_OS2_EVENTFLAGS_FROM_ISR 0 (in FreeRTOSConfig.h)
206+
*/
207+
#if (configUSE_OS2_EVENTFLAGS_FROM_ISR == 1)
208+
#error "Definition INCLUDE_xTimerPendFunctionCall must equal 1 to implement Event Flags API."
209+
#endif
210+
#endif
211+
212+
#if (configUSE_TIMERS == 0)
213+
/*
214+
CMSIS-RTOS2 Timer Management API functions use FreeRTOS timer functions to implement
215+
timer management. In case if these functions are not used in the application image,
216+
compiler will optimize them away.
217+
Set #define configUSE_TIMERS 1 to fix this error.
218+
219+
Alternatively, if the application does not use timer functions they can be
220+
excluded from the image code by setting:
221+
#define configUSE_OS2_TIMER 0 (in FreeRTOSConfig.h)
222+
*/
223+
#if (configUSE_OS2_TIMER == 1)
224+
#error "Definition configUSE_TIMERS must equal 1 to implement Timer Management API."
225+
#endif
226+
#endif
227+
228+
#if (configUSE_MUTEXES == 0)
229+
/*
230+
CMSIS-RTOS2 Mutex Management API functions use FreeRTOS mutex functions to implement
231+
mutex management. In case if these functions are not used in the application image,
232+
compiler will optimize them away.
233+
Set #define configUSE_MUTEXES 1 to fix this error.
234+
235+
Alternatively, if the application does not use mutex functions they can be
236+
excluded from the image code by setting:
237+
#define configUSE_OS2_MUTEX 0 (in FreeRTOSConfig.h)
238+
*/
239+
#if (configUSE_OS2_MUTEX == 1)
240+
#error "Definition configUSE_MUTEXES must equal 1 to implement Mutex Management API."
241+
#endif
242+
#endif
243+
244+
#if (configUSE_COUNTING_SEMAPHORES == 0)
245+
/*
246+
CMSIS-RTOS2 Memory Pool functions use FreeRTOS function xSemaphoreCreateCounting
247+
to implement memory pools. In case if these functions are not used in the application image,
248+
compiler will optimize them away.
249+
Set #define configUSE_COUNTING_SEMAPHORES 1 to fix this error.
250+
*/
251+
#error "Definition configUSE_COUNTING_SEMAPHORES must equal 1 to implement Memory Pool API."
252+
#endif
253+
#if (configUSE_TASK_NOTIFICATIONS == 0)
254+
/*
255+
CMSIS-RTOS2 Thread Flags API functions use FreeRTOS Task Notification functions to implement
256+
thread flag management. In case if these functions are not used in the application image,
257+
compiler will optimize them away.
258+
Set #define configUSE_TASK_NOTIFICATIONS 1 to fix this error.
259+
260+
Alternatively, if the application does not use thread flags functions they can be
261+
excluded from the image code by setting:
262+
#define configUSE_OS2_THREAD_FLAGS 0 (in FreeRTOSConfig.h)
263+
*/
264+
#if (configUSE_OS2_THREAD_FLAGS == 1)
265+
#error "Definition configUSE_TASK_NOTIFICATIONS must equal 1 to implement Thread Flags API."
266+
#endif
267+
#endif
268+
269+
#if (configUSE_TRACE_FACILITY == 0)
270+
/*
271+
CMSIS-RTOS2 function osThreadEnumerate requires FreeRTOS function uxTaskGetSystemState
272+
which is only enabled if configUSE_TRACE_FACILITY == 1.
273+
Set #define configUSE_TRACE_FACILITY 1 to fix this error.
274+
275+
Alternatively, if the application does not use osThreadEnumerate it can be
276+
excluded from the image code by setting:
277+
#define configUSE_OS2_THREAD_ENUMERATE 0 (in FreeRTOSConfig.h)
278+
*/
279+
#if (configUSE_OS2_THREAD_ENUMERATE == 1)
280+
#error "Definition configUSE_TRACE_FACILITY must equal 1 to implement osThreadEnumerate."
281+
#endif
282+
#endif
283+
284+
#if (configUSE_16_BIT_TICKS == 1)
285+
/*
286+
CMSIS-RTOS2 wrapper for FreeRTOS relies on 32-bit tick timer which is also optimal on
287+
a 32-bit CPU architectures.
288+
Set #define configUSE_16_BIT_TICKS 0 to fix this error.
289+
*/
290+
#error "Definition configUSE_16_BIT_TICKS must be zero to implement CMSIS-RTOS2 API."
291+
#endif
292+
293+
#if (configMAX_PRIORITIES != 56)
294+
/*
295+
CMSIS-RTOS2 defines 56 different priorities (see osPriority_t) and portable CMSIS-RTOS2
296+
implementation should implement the same number of priorities.
297+
Set #define configMAX_PRIORITIES 56 to fix this error.
298+
*/
299+
#error "Definition configMAX_PRIORITIES must equal 56 to implement Thread Management API."
300+
#endif
301+
#if (configUSE_PORT_OPTIMISED_TASK_SELECTION != 0)
302+
/*
303+
CMSIS-RTOS2 requires handling of 56 different priorities (see osPriority_t) while FreeRTOS port
304+
optimised selection for Cortex core only handles 32 different priorities.
305+
Set #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 to fix this error.
306+
*/
307+
#error "Definition configUSE_PORT_OPTIMISED_TASK_SELECTION must be zero to implement Thread Management API."
308+
#endif
309+
310+
#endif /* FREERTOS_OS2_H_ */

0 commit comments

Comments
 (0)