Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers os_port_ucos2.h Source File

os_port_ucos2.h

Go to the documentation of this file.
00001 /**
00002  * @file os_port_ucos2.h
00003  * @brief RTOS abstraction layer (Micrium uC/OS-II)
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_UCOS2_H
00028 #define _OS_PORT_UCOS2_H
00029 
00030 //Dependencies
00031 #include "ucos_ii.h"
00032 
00033 //Maximum number of tasks that can be dynamically created
00034 #ifndef OS_PORT_MAX_TASKS
00035    #define OS_PORT_MAX_TASKS 16
00036 #elif (OS_PORT_MAX_TASKS < 1)
00037    #error OS_PORT_MAX_TASKS parameter is not valid
00038 #endif
00039 
00040 //Task priority (normal)
00041 #ifndef OS_TASK_PRIORITY_NORMAL
00042    #define OS_TASK_PRIORITY_NORMAL 0
00043 #endif
00044 
00045 //Task priority (high)
00046 #ifndef OS_TASK_PRIORITY_HIGH
00047    #define OS_TASK_PRIORITY_HIGH 0
00048 #endif
00049 
00050 //Milliseconds to system ticks
00051 #ifndef OS_MS_TO_SYSTICKS
00052    #define OS_MS_TO_SYSTICKS(n) (n)
00053 #endif
00054 
00055 //System ticks to milliseconds
00056 #ifndef OS_SYSTICKS_TO_MS
00057    #define OS_SYSTICKS_TO_MS(n) (n)
00058 #endif
00059 
00060 //Enter interrupt service routine
00061 #define osEnterIsr() OSIntEnter()
00062 
00063 //Leave interrupt service routine
00064 #define osExitIsr(flag) OSIntExit()
00065 
00066 
00067 /**
00068  * @brief Task object
00069  **/
00070 
00071 typedef struct
00072 {
00073    INT8U prio;
00074 } OsTask;
00075 
00076 
00077 /**
00078  * @brief Event object
00079  **/
00080 
00081 typedef struct
00082 {
00083    OS_FLAG_GRP *p;
00084 } OsEvent;
00085 
00086 
00087 /**
00088  * @brief Semaphore object
00089  **/
00090 
00091 typedef struct
00092 {
00093    OS_EVENT *p;
00094 } OsSemaphore;
00095 
00096 
00097 /**
00098  * @brief Mutex object
00099  **/
00100 
00101 typedef struct
00102 {
00103    OS_EVENT *p;
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 bool_t osCreateStaticTask(OsTask *task, const char_t *name, OsTaskCode taskCode,
00120    void *params, void *stack, size_t stackSize, int_t priority);
00121 
00122 OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode,
00123    void *params, size_t stackSize, int_t priority);
00124 
00125 void osDeleteTask(OsTask *task);
00126 void osDelayTask(systime_t delay);
00127 void osSwitchTask(void);
00128 void osSuspendAllTasks(void);
00129 void osResumeAllTasks(void);
00130 
00131 //Event management
00132 bool_t osCreateEvent(OsEvent *event);
00133 void osDeleteEvent(OsEvent *event);
00134 void osSetEvent(OsEvent *event);
00135 void osResetEvent(OsEvent *event);
00136 bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
00137 bool_t osSetEventFromIsr(OsEvent *event);
00138 
00139 //Semaphore management
00140 bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
00141 void osDeleteSemaphore(OsSemaphore *semaphore);
00142 bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
00143 void osReleaseSemaphore(OsSemaphore *semaphore);
00144 
00145 //Mutex management
00146 bool_t osCreateMutex(OsMutex *mutex);
00147 void osDeleteMutex(OsMutex *mutex);
00148 void osAcquireMutex(OsMutex *mutex);
00149 void osReleaseMutex(OsMutex *mutex);
00150 
00151 //System time
00152 systime_t osGetSystemTime(void);
00153 
00154 //Memory management
00155 void *osAllocMem(size_t size);
00156 void osFreeMem(void *p);
00157 
00158 //Undefine conflicting definitions
00159 #undef TRACE_LEVEL_OFF
00160 #undef TRACE_LEVEL_INFO
00161 
00162 #endif
00163