Skip to content

Commit 03eba7d

Browse files
committed
Introduced header to cope with the environment (device, tool, configuration) specifics (#35).
1 parent 237d033 commit 03eba7d

3 files changed

Lines changed: 104 additions & 16 deletions

File tree

ARM.CMSIS-FreeRTOS.pdsc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<releases>
1111
<release version="10.2.1-dev2">
12+
- Moved device and environment specifics into separate header
1213
- Added implementation of the osMemoryPool functions using FreeRTOS
1314
- Removed Cortex-A example (will be available in separate pack)
1415
</release>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/* --------------------------------------------------------------------------
2+
* Copyright (c) 2013-2019 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 "RTE_Components.h" // Component selection
32+
#include CMSIS_device_header
33+
34+
/* Configuration and component setup check */
35+
#if defined(RTE_Compiler_EventRecorder)
36+
#define USE_TRACE_EVENT_RECORDER
37+
#endif
38+
39+
#if defined(RTE_RTOS_FreeRTOS_HEAP_1)
40+
#define USE_FreeRTOS_HEAP_1
41+
#endif
42+
43+
#if defined(RTE_RTOS_FreeRTOS_HEAP_5)
44+
#define USE_FreeRTOS_HEAP_5
45+
#endif
46+
47+
/* Check FreeRTOSConfig.h include definitions.
48+
Note: CMSIS-RTOS API requires functions included by using following definitions.
49+
In case if certain API function is not used compiler will optimize it away.
50+
*/
51+
#if (INCLUDE_xSemaphoreGetMutexHolder == 0)
52+
#error "Definition INCLUDE_xSemaphoreGetMutexHolder must be non-zero to implement Mutex Management API."
53+
#endif
54+
#if (INCLUDE_vTaskDelay == 0)
55+
#error "Definition INCLUDE_vTaskDelay must be non-zero to implement Generic Wait Functions API."
56+
#endif
57+
#if (INCLUDE_vTaskDelayUntil == 0)
58+
#error "Definition INCLUDE_vTaskDelayUntil must be non-zero to implement Generic Wait Functions API."
59+
#endif
60+
#if (INCLUDE_vTaskDelete == 0)
61+
#error "Definition INCLUDE_vTaskDelete must be non-zero to implement Thread Management API."
62+
#endif
63+
#if (INCLUDE_xTaskGetCurrentTaskHandle == 0)
64+
#error "Definition INCLUDE_xTaskGetCurrentTaskHandle must be non-zero to implement Thread Management API."
65+
#endif
66+
#if (INCLUDE_xTaskGetSchedulerState == 0)
67+
#error "Definition INCLUDE_xTaskGetSchedulerState must be non-zero to implement Kernel Information and Control API."
68+
#endif
69+
#if (INCLUDE_uxTaskGetStackHighWaterMark == 0)
70+
#error "Definition INCLUDE_uxTaskGetStackHighWaterMark must be non-zero to implement Thread Management API."
71+
#endif
72+
#if (INCLUDE_uxTaskPriorityGet == 0)
73+
#error "Definition INCLUDE_uxTaskPriorityGet must be non-zero to implement Thread Management API."
74+
#endif
75+
#if (INCLUDE_vTaskPrioritySet == 0)
76+
#error "Definition INCLUDE_vTaskPrioritySet must be non-zero to implement Thread Management API."
77+
#endif
78+
#if (INCLUDE_eTaskGetState == 0)
79+
#error "Definition INCLUDE_eTaskGetState must be non-zero to implement Thread Management API."
80+
#endif
81+
#if (INCLUDE_vTaskSuspend == 0)
82+
#error "Definition INCLUDE_vTaskSuspend must be non-zero to implement Kernel Information and Control API."
83+
#endif
84+
#if (INCLUDE_xTimerPendFunctionCall == 0)
85+
#error "Definition INCLUDE_xTimerPendFunctionCall must be non-zero to implement Event Flags API."
86+
#endif
87+
88+
#endif /* FREERTOS_OS2_H_ */

CMSIS/RTOS2/FreeRTOS/Source/cmsis_os2.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,17 @@
2222

2323
#include <string.h>
2424

25-
#include "RTE_Components.h" // Component selection
26-
2725
#include "cmsis_os2.h" // ::CMSIS:RTOS2
28-
#include "cmsis_compiler.h"
29-
#include "os_tick.h"
26+
#include "cmsis_compiler.h" // Compiler agnostic definitions
27+
#include "os_tick.h" // OS Tick API
3028

3129
#include "FreeRTOS.h" // ARM.FreeRTOS::RTOS:Core
3230
#include "task.h" // ARM.FreeRTOS::RTOS:Core
3331
#include "event_groups.h" // ARM.FreeRTOS::RTOS:Event Groups
3432
#include "semphr.h" // ARM.FreeRTOS::RTOS:Core
3533

36-
#include "freertos_mpool.h"
34+
#include "freertos_mpool.h" // osMemoryPool definitions
35+
#include "freertos_os2.h" // Configuration check and setup
3736

3837
/*---------------------------------------------------------------------------*/
3938
#ifndef __ARM_ARCH_6M__
@@ -112,7 +111,7 @@ static osKernelState_t KernelState = osKernelInactive;
112111
definition configHEAP_5_REGIONS as parameter. Overriding configHEAP_5_REGIONS
113112
is possible by defining it globally or in FreeRTOSConfig.h.
114113
*/
115-
#if defined(RTE_RTOS_FreeRTOS_HEAP_5)
114+
#if defined(USE_FreeRTOS_HEAP_5)
116115
#if (configAPPLICATION_ALLOCATED_HEAP == 0)
117116
/*
118117
FreeRTOS heap is not defined by the application.
@@ -142,7 +141,7 @@ static osKernelState_t KernelState = osKernelInactive;
142141
*/
143142
#define HEAP_5_REGION_SETUP 0
144143
#endif /* configAPPLICATION_ALLOCATED_HEAP */
145-
#endif /* RTE_RTOS_FreeRTOS_HEAP_5 */
144+
#endif /* USE_FreeRTOS_HEAP_5 */
146145

147146
#if defined(SysTick)
148147
#undef SysTick_Handler
@@ -195,10 +194,10 @@ osStatus_t osKernelInitialize (void) {
195194
}
196195
else {
197196
if (KernelState == osKernelInactive) {
198-
#if defined(RTE_Compiler_EventRecorder)
197+
#if defined(USE_TRACE_EVENT_RECORDER)
199198
EvrFreeRTOSSetup(0U);
200199
#endif
201-
#if defined(RTE_RTOS_FreeRTOS_HEAP_5) && (HEAP_5_REGION_SETUP == 1)
200+
#if defined(USE_FreeRTOS_HEAP_5) && (HEAP_5_REGION_SETUP == 1)
202201
vPortDefineHeapRegions (configHEAP_5_REGIONS);
203202
#endif
204203
KernelState = osKernelReady;
@@ -618,7 +617,7 @@ osStatus_t osThreadResume (osThreadId_t thread_id) {
618617
}
619618

620619
__NO_RETURN void osThreadExit (void) {
621-
#ifndef RTE_RTOS_FreeRTOS_HEAP_1
620+
#ifndef USE_FreeRTOS_HEAP_1
622621
vTaskDelete (NULL);
623622
#endif
624623
for (;;);
@@ -627,7 +626,7 @@ __NO_RETURN void osThreadExit (void) {
627626
osStatus_t osThreadTerminate (osThreadId_t thread_id) {
628627
TaskHandle_t hTask = (TaskHandle_t)thread_id;
629628
osStatus_t stat;
630-
#ifndef RTE_RTOS_FreeRTOS_HEAP_1
629+
#ifndef USE_FreeRTOS_HEAP_1
631630
eTaskState tstate;
632631

633632
if (IS_IRQ()) {
@@ -1035,7 +1034,7 @@ uint32_t osTimerIsRunning (osTimerId_t timer_id) {
10351034
osStatus_t osTimerDelete (osTimerId_t timer_id) {
10361035
TimerHandle_t hTimer = (TimerHandle_t)timer_id;
10371036
osStatus_t stat;
1038-
#ifndef RTE_RTOS_FreeRTOS_HEAP_1
1037+
#ifndef USE_FreeRTOS_HEAP_1
10391038
TimerCallback_t *callb;
10401039

10411040
if (IS_IRQ()) {
@@ -1216,7 +1215,7 @@ osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id) {
12161215
EventGroupHandle_t hEventGroup = (EventGroupHandle_t)ef_id;
12171216
osStatus_t stat;
12181217

1219-
#ifndef RTE_RTOS_FreeRTOS_HEAP_1
1218+
#ifndef USE_FreeRTOS_HEAP_1
12201219
if (IS_IRQ()) {
12211220
stat = osErrorISR;
12221221
}
@@ -1406,7 +1405,7 @@ osThreadId_t osMutexGetOwner (osMutexId_t mutex_id) {
14061405

14071406
osStatus_t osMutexDelete (osMutexId_t mutex_id) {
14081407
osStatus_t stat;
1409-
#ifndef RTE_RTOS_FreeRTOS_HEAP_1
1408+
#ifndef USE_FreeRTOS_HEAP_1
14101409
SemaphoreHandle_t hMutex;
14111410

14121411
hMutex = (SemaphoreHandle_t)((uint32_t)mutex_id & ~1U);
@@ -1585,7 +1584,7 @@ osStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id) {
15851584
SemaphoreHandle_t hSemaphore = (SemaphoreHandle_t)semaphore_id;
15861585
osStatus_t stat;
15871586

1588-
#ifndef RTE_RTOS_FreeRTOS_HEAP_1
1587+
#ifndef USE_FreeRTOS_HEAP_1
15891588
if (IS_IRQ()) {
15901589
stat = osErrorISR;
15911590
}
@@ -1834,7 +1833,7 @@ osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id) {
18341833
QueueHandle_t hQueue = (QueueHandle_t)mq_id;
18351834
osStatus_t stat;
18361835

1837-
#ifndef RTE_RTOS_FreeRTOS_HEAP_1
1836+
#ifndef USE_FreeRTOS_HEAP_1
18381837
if (IS_IRQ()) {
18391838
stat = osErrorISR;
18401839
}

0 commit comments

Comments
 (0)