Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
common/os_port_cmsis_rtos2.h@0:8918a71cdbe9, 2017-02-04 (annotated)
- Committer:
- Sergunb
- Date:
- Sat Feb 04 18:15:49 2017 +0000
- Revision:
- 0:8918a71cdbe9
nothing else
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Sergunb | 0:8918a71cdbe9 | 1 | /** |
| Sergunb | 0:8918a71cdbe9 | 2 | * @file os_port_cmsis_rtos2.h |
| Sergunb | 0:8918a71cdbe9 | 3 | * @brief RTOS abstraction layer (CMSIS-RTOS 2 / RTX v5) |
| Sergunb | 0:8918a71cdbe9 | 4 | * |
| Sergunb | 0:8918a71cdbe9 | 5 | * @section License |
| Sergunb | 0:8918a71cdbe9 | 6 | * |
| Sergunb | 0:8918a71cdbe9 | 7 | * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. |
| Sergunb | 0:8918a71cdbe9 | 8 | * |
| Sergunb | 0:8918a71cdbe9 | 9 | * This program is free software; you can redistribute it and/or |
| Sergunb | 0:8918a71cdbe9 | 10 | * modify it under the terms of the GNU General Public License |
| Sergunb | 0:8918a71cdbe9 | 11 | * as published by the Free Software Foundation; either version 2 |
| Sergunb | 0:8918a71cdbe9 | 12 | * of the License, or (at your option) any later version. |
| Sergunb | 0:8918a71cdbe9 | 13 | * |
| Sergunb | 0:8918a71cdbe9 | 14 | * This program is distributed in the hope that it will be useful, |
| Sergunb | 0:8918a71cdbe9 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| Sergunb | 0:8918a71cdbe9 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| Sergunb | 0:8918a71cdbe9 | 17 | * GNU General Public License for more details. |
| Sergunb | 0:8918a71cdbe9 | 18 | * |
| Sergunb | 0:8918a71cdbe9 | 19 | * You should have received a copy of the GNU General Public License |
| Sergunb | 0:8918a71cdbe9 | 20 | * along with this program; if not, write to the Free Software Foundation, |
| Sergunb | 0:8918a71cdbe9 | 21 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| Sergunb | 0:8918a71cdbe9 | 22 | * |
| Sergunb | 0:8918a71cdbe9 | 23 | * @author Oryx Embedded SARL (www.oryx-embedded.com) |
| Sergunb | 0:8918a71cdbe9 | 24 | * @version 1.7.6 |
| Sergunb | 0:8918a71cdbe9 | 25 | **/ |
| Sergunb | 0:8918a71cdbe9 | 26 | |
| Sergunb | 0:8918a71cdbe9 | 27 | #ifndef _OS_PORT_CMSIS_RTOS2_H |
| Sergunb | 0:8918a71cdbe9 | 28 | #define _OS_PORT_CMSIS_RTOS2_H |
| Sergunb | 0:8918a71cdbe9 | 29 | |
| Sergunb | 0:8918a71cdbe9 | 30 | //Dependencies |
| Sergunb | 0:8918a71cdbe9 | 31 | #include "cmsis_os2.h" |
| Sergunb | 0:8918a71cdbe9 | 32 | #include "rtx_os.h" |
| Sergunb | 0:8918a71cdbe9 | 33 | |
| Sergunb | 0:8918a71cdbe9 | 34 | //Task priority (normal) |
| Sergunb | 0:8918a71cdbe9 | 35 | #ifndef OS_TASK_PRIORITY_NORMAL |
| Sergunb | 0:8918a71cdbe9 | 36 | #define OS_TASK_PRIORITY_NORMAL osPriorityNormal |
| Sergunb | 0:8918a71cdbe9 | 37 | #endif |
| Sergunb | 0:8918a71cdbe9 | 38 | |
| Sergunb | 0:8918a71cdbe9 | 39 | //Task priority (high) |
| Sergunb | 0:8918a71cdbe9 | 40 | #ifndef OS_TASK_PRIORITY_HIGH |
| Sergunb | 0:8918a71cdbe9 | 41 | #define OS_TASK_PRIORITY_HIGH osPriorityAboveNormal |
| Sergunb | 0:8918a71cdbe9 | 42 | #endif |
| Sergunb | 0:8918a71cdbe9 | 43 | |
| Sergunb | 0:8918a71cdbe9 | 44 | //Milliseconds to system ticks |
| Sergunb | 0:8918a71cdbe9 | 45 | #ifndef OS_MS_TO_SYSTICKS |
| Sergunb | 0:8918a71cdbe9 | 46 | #define OS_MS_TO_SYSTICKS(n) (n) |
| Sergunb | 0:8918a71cdbe9 | 47 | #endif |
| Sergunb | 0:8918a71cdbe9 | 48 | |
| Sergunb | 0:8918a71cdbe9 | 49 | //System ticks to milliseconds |
| Sergunb | 0:8918a71cdbe9 | 50 | #ifndef OS_SYSTICKS_TO_MS |
| Sergunb | 0:8918a71cdbe9 | 51 | #define OS_SYSTICKS_TO_MS(n) (n) |
| Sergunb | 0:8918a71cdbe9 | 52 | #endif |
| Sergunb | 0:8918a71cdbe9 | 53 | |
| Sergunb | 0:8918a71cdbe9 | 54 | //Enter interrupt service routine |
| Sergunb | 0:8918a71cdbe9 | 55 | #define osEnterIsr() |
| Sergunb | 0:8918a71cdbe9 | 56 | |
| Sergunb | 0:8918a71cdbe9 | 57 | //Leave interrupt service routine |
| Sergunb | 0:8918a71cdbe9 | 58 | #define osExitIsr(flag) |
| Sergunb | 0:8918a71cdbe9 | 59 | |
| Sergunb | 0:8918a71cdbe9 | 60 | |
| Sergunb | 0:8918a71cdbe9 | 61 | /** |
| Sergunb | 0:8918a71cdbe9 | 62 | * @brief Task object |
| Sergunb | 0:8918a71cdbe9 | 63 | **/ |
| Sergunb | 0:8918a71cdbe9 | 64 | |
| Sergunb | 0:8918a71cdbe9 | 65 | typedef void OsTask; |
| Sergunb | 0:8918a71cdbe9 | 66 | |
| Sergunb | 0:8918a71cdbe9 | 67 | |
| Sergunb | 0:8918a71cdbe9 | 68 | /** |
| Sergunb | 0:8918a71cdbe9 | 69 | * @brief Event object |
| Sergunb | 0:8918a71cdbe9 | 70 | **/ |
| Sergunb | 0:8918a71cdbe9 | 71 | |
| Sergunb | 0:8918a71cdbe9 | 72 | typedef struct |
| Sergunb | 0:8918a71cdbe9 | 73 | { |
| Sergunb | 0:8918a71cdbe9 | 74 | osSemaphoreId_t id; |
| Sergunb | 0:8918a71cdbe9 | 75 | #if defined(os_CMSIS_RTX) |
| Sergunb | 0:8918a71cdbe9 | 76 | os_semaphore_t cb; |
| Sergunb | 0:8918a71cdbe9 | 77 | #endif |
| Sergunb | 0:8918a71cdbe9 | 78 | } OsEvent; |
| Sergunb | 0:8918a71cdbe9 | 79 | |
| Sergunb | 0:8918a71cdbe9 | 80 | |
| Sergunb | 0:8918a71cdbe9 | 81 | /** |
| Sergunb | 0:8918a71cdbe9 | 82 | * @brief Semaphore object |
| Sergunb | 0:8918a71cdbe9 | 83 | **/ |
| Sergunb | 0:8918a71cdbe9 | 84 | |
| Sergunb | 0:8918a71cdbe9 | 85 | typedef struct |
| Sergunb | 0:8918a71cdbe9 | 86 | { |
| Sergunb | 0:8918a71cdbe9 | 87 | osSemaphoreId_t id; |
| Sergunb | 0:8918a71cdbe9 | 88 | #if defined(os_CMSIS_RTX) |
| Sergunb | 0:8918a71cdbe9 | 89 | os_semaphore_t cb; |
| Sergunb | 0:8918a71cdbe9 | 90 | #endif |
| Sergunb | 0:8918a71cdbe9 | 91 | } OsSemaphore; |
| Sergunb | 0:8918a71cdbe9 | 92 | |
| Sergunb | 0:8918a71cdbe9 | 93 | |
| Sergunb | 0:8918a71cdbe9 | 94 | /** |
| Sergunb | 0:8918a71cdbe9 | 95 | * @brief Mutex object |
| Sergunb | 0:8918a71cdbe9 | 96 | **/ |
| Sergunb | 0:8918a71cdbe9 | 97 | |
| Sergunb | 0:8918a71cdbe9 | 98 | typedef struct |
| Sergunb | 0:8918a71cdbe9 | 99 | { |
| Sergunb | 0:8918a71cdbe9 | 100 | osMutexId_t id; |
| Sergunb | 0:8918a71cdbe9 | 101 | #if defined(os_CMSIS_RTX) |
| Sergunb | 0:8918a71cdbe9 | 102 | os_mutex_t cb; |
| Sergunb | 0:8918a71cdbe9 | 103 | #endif |
| Sergunb | 0:8918a71cdbe9 | 104 | } OsMutex; |
| Sergunb | 0:8918a71cdbe9 | 105 | |
| Sergunb | 0:8918a71cdbe9 | 106 | |
| Sergunb | 0:8918a71cdbe9 | 107 | /** |
| Sergunb | 0:8918a71cdbe9 | 108 | * @brief Task routine |
| Sergunb | 0:8918a71cdbe9 | 109 | **/ |
| Sergunb | 0:8918a71cdbe9 | 110 | |
| Sergunb | 0:8918a71cdbe9 | 111 | typedef void (*OsTaskCode)(void *params); |
| Sergunb | 0:8918a71cdbe9 | 112 | |
| Sergunb | 0:8918a71cdbe9 | 113 | |
| Sergunb | 0:8918a71cdbe9 | 114 | //Kernel management |
| Sergunb | 0:8918a71cdbe9 | 115 | void osInitKernel(void); |
| Sergunb | 0:8918a71cdbe9 | 116 | void osStartKernel(void); |
| Sergunb | 0:8918a71cdbe9 | 117 | |
| Sergunb | 0:8918a71cdbe9 | 118 | //Task management |
| Sergunb | 0:8918a71cdbe9 | 119 | OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode, |
| Sergunb | 0:8918a71cdbe9 | 120 | void *params, size_t stackSize, int_t priority); |
| Sergunb | 0:8918a71cdbe9 | 121 | |
| Sergunb | 0:8918a71cdbe9 | 122 | void osDeleteTask(OsTask *task); |
| Sergunb | 0:8918a71cdbe9 | 123 | void osDelayTask(systime_t delay); |
| Sergunb | 0:8918a71cdbe9 | 124 | void osSwitchTask(void); |
| Sergunb | 0:8918a71cdbe9 | 125 | void osSuspendAllTasks(void); |
| Sergunb | 0:8918a71cdbe9 | 126 | void osResumeAllTasks(void); |
| Sergunb | 0:8918a71cdbe9 | 127 | |
| Sergunb | 0:8918a71cdbe9 | 128 | //Event management |
| Sergunb | 0:8918a71cdbe9 | 129 | bool_t osCreateEvent(OsEvent *event); |
| Sergunb | 0:8918a71cdbe9 | 130 | void osDeleteEvent(OsEvent *event); |
| Sergunb | 0:8918a71cdbe9 | 131 | void osSetEvent(OsEvent *event); |
| Sergunb | 0:8918a71cdbe9 | 132 | void osResetEvent(OsEvent *event); |
| Sergunb | 0:8918a71cdbe9 | 133 | bool_t osWaitForEvent(OsEvent *event, systime_t timeout); |
| Sergunb | 0:8918a71cdbe9 | 134 | bool_t osSetEventFromIsr(OsEvent *event); |
| Sergunb | 0:8918a71cdbe9 | 135 | |
| Sergunb | 0:8918a71cdbe9 | 136 | //Semaphore management |
| Sergunb | 0:8918a71cdbe9 | 137 | bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count); |
| Sergunb | 0:8918a71cdbe9 | 138 | void osDeleteSemaphore(OsSemaphore *semaphore); |
| Sergunb | 0:8918a71cdbe9 | 139 | bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout); |
| Sergunb | 0:8918a71cdbe9 | 140 | void osReleaseSemaphore(OsSemaphore *semaphore); |
| Sergunb | 0:8918a71cdbe9 | 141 | |
| Sergunb | 0:8918a71cdbe9 | 142 | //Mutex management |
| Sergunb | 0:8918a71cdbe9 | 143 | bool_t osCreateMutex(OsMutex *mutex); |
| Sergunb | 0:8918a71cdbe9 | 144 | void osDeleteMutex(OsMutex *mutex); |
| Sergunb | 0:8918a71cdbe9 | 145 | void osAcquireMutex(OsMutex *mutex); |
| Sergunb | 0:8918a71cdbe9 | 146 | void osReleaseMutex(OsMutex *mutex); |
| Sergunb | 0:8918a71cdbe9 | 147 | |
| Sergunb | 0:8918a71cdbe9 | 148 | //System time |
| Sergunb | 0:8918a71cdbe9 | 149 | systime_t osGetSystemTime(void); |
| Sergunb | 0:8918a71cdbe9 | 150 | |
| Sergunb | 0:8918a71cdbe9 | 151 | //Memory management |
| Sergunb | 0:8918a71cdbe9 | 152 | void *osAllocMem(size_t size); |
| Sergunb | 0:8918a71cdbe9 | 153 | void osFreeMem(void *p); |
| Sergunb | 0:8918a71cdbe9 | 154 | |
| Sergunb | 0:8918a71cdbe9 | 155 | #endif |
| Sergunb | 0:8918a71cdbe9 | 156 |