Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers os_port_cmsis_rtos2.h Source File

os_port_cmsis_rtos2.h

Go to the documentation of this file.
00001 /**
00002  * @file os_port_cmsis_rtos2.h
00003  * @brief RTOS abstraction layer (CMSIS-RTOS 2 / RTX v5)
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License
00011  * as published by the Free Software Foundation; either version 2
00012  * of the License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software Foundation,
00021  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00022  *
00023  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00024  * @version 1.7.6
00025  **/
00026 
00027 #ifndef _OS_PORT_CMSIS_RTOS2_H
00028 #define _OS_PORT_CMSIS_RTOS2_H
00029 
00030 //Dependencies
00031 #include "cmsis_os2.h"
00032 #include "rtx_os.h"
00033 
00034 //Task priority (normal)
00035 #ifndef OS_TASK_PRIORITY_NORMAL
00036    #define OS_TASK_PRIORITY_NORMAL osPriorityNormal
00037 #endif
00038 
00039 //Task priority (high)
00040 #ifndef OS_TASK_PRIORITY_HIGH
00041    #define OS_TASK_PRIORITY_HIGH osPriorityAboveNormal
00042 #endif
00043 
00044 //Milliseconds to system ticks
00045 #ifndef OS_MS_TO_SYSTICKS
00046    #define OS_MS_TO_SYSTICKS(n) (n)
00047 #endif
00048 
00049 //System ticks to milliseconds
00050 #ifndef OS_SYSTICKS_TO_MS
00051    #define OS_SYSTICKS_TO_MS(n) (n)
00052 #endif
00053 
00054 //Enter interrupt service routine
00055 #define osEnterIsr()
00056 
00057 //Leave interrupt service routine
00058 #define osExitIsr(flag)
00059 
00060 
00061 /**
00062  * @brief Task object
00063  **/
00064 
00065 typedef void OsTask;
00066 
00067 
00068 /**
00069  * @brief Event object
00070  **/
00071 
00072 typedef struct
00073 {
00074    osSemaphoreId_t id;
00075 #if defined(os_CMSIS_RTX)
00076    os_semaphore_t cb;
00077 #endif
00078 } OsEvent;
00079 
00080 
00081 /**
00082  * @brief Semaphore object
00083  **/
00084 
00085 typedef struct
00086 {
00087    osSemaphoreId_t id;
00088 #if defined(os_CMSIS_RTX)
00089    os_semaphore_t cb;
00090 #endif
00091 } OsSemaphore;
00092 
00093 
00094 /**
00095  * @brief Mutex object
00096  **/
00097 
00098 typedef struct
00099 {
00100    osMutexId_t id;
00101 #if defined(os_CMSIS_RTX)
00102    os_mutex_t cb;
00103 #endif
00104 } OsMutex;
00105 
00106 
00107 /**
00108  * @brief Task routine
00109  **/
00110 
00111 typedef void (*OsTaskCode)(void *params);
00112 
00113 
00114 //Kernel management
00115 void osInitKernel(void);
00116 void osStartKernel(void);
00117 
00118 //Task management
00119 OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode,
00120    void *params, size_t stackSize, int_t priority);
00121 
00122 void osDeleteTask(OsTask *task);
00123 void osDelayTask(systime_t delay);
00124 void osSwitchTask(void);
00125 void osSuspendAllTasks(void);
00126 void osResumeAllTasks(void);
00127 
00128 //Event management
00129 bool_t osCreateEvent(OsEvent *event);
00130 void osDeleteEvent(OsEvent *event);
00131 void osSetEvent(OsEvent *event);
00132 void osResetEvent(OsEvent *event);
00133 bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
00134 bool_t osSetEventFromIsr(OsEvent *event);
00135 
00136 //Semaphore management
00137 bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
00138 void osDeleteSemaphore(OsSemaphore *semaphore);
00139 bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
00140 void osReleaseSemaphore(OsSemaphore *semaphore);
00141 
00142 //Mutex management
00143 bool_t osCreateMutex(OsMutex *mutex);
00144 void osDeleteMutex(OsMutex *mutex);
00145 void osAcquireMutex(OsMutex *mutex);
00146 void osReleaseMutex(OsMutex *mutex);
00147 
00148 //System time
00149 systime_t osGetSystemTime(void);
00150 
00151 //Memory management
00152 void *osAllocMem(size_t size);
00153 void osFreeMem(void *p);
00154 
00155 #endif
00156