Sergey Pastor / 1

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers os_port_rtx.h Source File

os_port_rtx.h

Go to the documentation of this file.
00001 /**
00002  * @file os_port_rtx.h
00003  * @brief RTOS abstraction layer (Keil RTX)
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_RTX_H
00028 #define _OS_PORT_RTX_H
00029 
00030 //Dependencies
00031 #ifdef RTX_CUSTOM_HEADER
00032    #include RTX_CUSTOM_HEADER
00033 #else
00034    #include "rtl.h"
00035 #endif
00036 
00037 //Maximum number of tasks that can be dynamically created
00038 #ifndef OS_PORT_MAX_TASKS
00039    #define OS_PORT_MAX_TASKS 16
00040 #elif (OS_PORT_MAX_TASKS < 1)
00041    #error OS_PORT_MAX_TASKS parameter is not valid
00042 #endif
00043 
00044 //Task priority (normal)
00045 #ifndef OS_TASK_PRIORITY_NORMAL
00046    #define OS_TASK_PRIORITY_NORMAL 1
00047 #endif
00048 
00049 //Task priority (high)
00050 #ifndef OS_TASK_PRIORITY_HIGH
00051    #define OS_TASK_PRIORITY_HIGH 2
00052 #endif
00053 
00054 //Milliseconds to system ticks
00055 #ifndef OS_MS_TO_SYSTICKS
00056    #define OS_MS_TO_SYSTICKS(n) (n)
00057 #endif
00058 
00059 //System ticks to milliseconds
00060 #ifndef OS_SYSTICKS_TO_MS
00061    #define OS_SYSTICKS_TO_MS(n) (n)
00062 #endif
00063 
00064 //Enter interrupt service routine
00065 #define osEnterIsr()
00066 
00067 //Leave interrupt service routine
00068 #define osExitIsr(flag)
00069 
00070 
00071 /**
00072  * @brief Task object
00073  **/
00074 
00075 typedef struct
00076 {
00077    OS_TID tid;
00078 } OsTask;
00079 
00080 
00081 /**
00082  * @brief Event object
00083  **/
00084 
00085 typedef OS_SEM OsEvent;
00086 
00087 
00088 /**
00089  * @brief Semaphore object
00090  **/
00091 
00092 typedef OS_SEM OsSemaphore;
00093 
00094 
00095 /**
00096  * @brief Mutex object
00097  **/
00098 
00099 typedef OS_MUT OsMutex;
00100 
00101 
00102 /**
00103  * @brief Task routine
00104  **/
00105 
00106 typedef void (*OsTaskCode)(void *params);
00107 
00108 
00109 /**
00110  * @brief Initialization task
00111  **/
00112 
00113 typedef void (*OsInitTaskCode)(void);
00114 
00115 
00116 //Kernel management
00117 void osInitKernel(void);
00118 void osStartKernel(OsInitTaskCode task);
00119 
00120 //Task management
00121 bool_t osCreateStaticTask(OsTask *task, const char_t *name, OsTaskCode taskCode,
00122    void *params, void *stack, size_t stackSize, int_t priority);
00123 
00124 OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode,
00125    void *params, size_t stackSize, int_t priority);
00126 
00127 void osDeleteTask(OsTask *task);
00128 void osDelayTask(systime_t delay);
00129 void osSwitchTask(void);
00130 void osSuspendAllTasks(void);
00131 void osResumeAllTasks(void);
00132 
00133 //Event management
00134 bool_t osCreateEvent(OsEvent *event);
00135 void osDeleteEvent(OsEvent *event);
00136 void osSetEvent(OsEvent *event);
00137 void osResetEvent(OsEvent *event);
00138 bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
00139 bool_t osSetEventFromIsr(OsEvent *event);
00140 
00141 //Semaphore management
00142 bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
00143 void osDeleteSemaphore(OsSemaphore *semaphore);
00144 bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
00145 void osReleaseSemaphore(OsSemaphore *semaphore);
00146 
00147 //Mutex management
00148 bool_t osCreateMutex(OsMutex *mutex);
00149 void osDeleteMutex(OsMutex *mutex);
00150 void osAcquireMutex(OsMutex *mutex);
00151 void osReleaseMutex(OsMutex *mutex);
00152 
00153 //System time
00154 systime_t osGetSystemTime(void);
00155 
00156 //Memory management
00157 void *osAllocMem(size_t size);
00158 void osFreeMem(void *p);
00159 
00160 //Undefine conflicting definitions
00161 #undef htons
00162 #undef htonl
00163 #undef ntohs
00164 #undef ntohl
00165 #undef TCP_STATE_CLOSED
00166 #undef TCP_STATE_LISTEN
00167 #undef TCP_STATE_SYN_SENT
00168 #undef TCP_STATE_CLOSING
00169 #undef TCP_STATE_LAST_ACK
00170 
00171 #endif
00172