Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers os_port_cmsis_rtos.h Source File

os_port_cmsis_rtos.h

Go to the documentation of this file.
00001 /**
00002  * @file os_port_cmsis_rtos.h
00003  * @brief RTOS abstraction layer (CMSIS-RTOS)
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_RTOS_H
00028 #define _OS_PORT_CMSIS_RTOS_H
00029 
00030 //Dependencies
00031 #include "cmsis_os.h"
00032 
00033 //Task priority (normal)
00034 #ifndef OS_TASK_PRIORITY_NORMAL
00035    #define OS_TASK_PRIORITY_NORMAL osPriorityNormal
00036 #endif
00037 
00038 //Task priority (high)
00039 #ifndef OS_TASK_PRIORITY_HIGH
00040    #define OS_TASK_PRIORITY_HIGH osPriorityAboveNormal
00041 #endif
00042 
00043 //Milliseconds to system ticks
00044 #ifndef OS_MS_TO_SYSTICKS
00045    #define OS_MS_TO_SYSTICKS(n) (n)
00046 #endif
00047 
00048 //System ticks to milliseconds
00049 #ifndef OS_SYSTICKS_TO_MS
00050    #define OS_SYSTICKS_TO_MS(n) (n)
00051 #endif
00052 
00053 //Enter interrupt service routine
00054 #define osEnterIsr()
00055 
00056 //Leave interrupt service routine
00057 #define osExitIsr(flag)
00058 
00059 
00060 /**
00061  * @brief Task object
00062  **/
00063 
00064 typedef void OsTask;
00065 
00066 
00067 /**
00068  * @brief Event object
00069  **/
00070 
00071 typedef struct
00072 {
00073    osSemaphoreId id;
00074 #if defined(osCMSIS_RTX)
00075    uint32_t cb[2];
00076 #endif
00077 } OsEvent;
00078 
00079 
00080 /**
00081  * @brief Semaphore object
00082  **/
00083 
00084 typedef struct
00085 {
00086    osSemaphoreId id;
00087 #if defined(osCMSIS_RTX)
00088    uint32_t cb[2];
00089 #endif
00090 } OsSemaphore;
00091 
00092 
00093 /**
00094  * @brief Mutex object
00095  **/
00096 
00097 typedef struct
00098 {
00099    osMutexId id;
00100 #if defined(osCMSIS_RTX)
00101    uint32_t cb[4];
00102 #endif
00103 } OsMutex;
00104 
00105 
00106 /**
00107  * @brief Task routine
00108  **/
00109 
00110 typedef void (*OsTaskCode)(void *params);
00111 
00112 
00113 //Kernel management
00114 void osInitKernel(void);
00115 void osStartKernel(void);
00116 
00117 //Task management
00118 OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode,
00119    void *params, size_t stackSize, int_t priority);
00120 
00121 void osDeleteTask(OsTask *task);
00122 void osDelayTask(systime_t delay);
00123 void osSwitchTask(void);
00124 void osSuspendAllTasks(void);
00125 void osResumeAllTasks(void);
00126 
00127 //Event management
00128 bool_t osCreateEvent(OsEvent *event);
00129 void osDeleteEvent(OsEvent *event);
00130 void osSetEvent(OsEvent *event);
00131 void osResetEvent(OsEvent *event);
00132 bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
00133 bool_t osSetEventFromIsr(OsEvent *event);
00134 
00135 //Semaphore management
00136 bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
00137 void osDeleteSemaphore(OsSemaphore *semaphore);
00138 bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
00139 void osReleaseSemaphore(OsSemaphore *semaphore);
00140 
00141 //Mutex management
00142 bool_t osCreateMutex(OsMutex *mutex);
00143 void osDeleteMutex(OsMutex *mutex);
00144 void osAcquireMutex(OsMutex *mutex);
00145 void osReleaseMutex(OsMutex *mutex);
00146 
00147 //System time
00148 systime_t osGetSystemTime(void);
00149 
00150 //Memory management
00151 void *osAllocMem(size_t size);
00152 void osFreeMem(void *p);
00153 
00154 #endif
00155