os_port_ucos3.h
Go to the documentation of this file.
1 /**
2  * @file os_port_ucos3.h
3  * @brief RTOS abstraction layer (Micrium uC/OS-III)
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  *
23  * @author Oryx Embedded SARL (www.oryx-embedded.com)
24  * @version 1.9.0
25  **/
26 
27 #ifndef _OS_PORT_UCOS3_H
28 #define _OS_PORT_UCOS3_H
29 
30 //Dependencies
31 #include "os.h"
32 
33 //Task priority (normal)
34 #ifndef OS_TASK_PRIORITY_NORMAL
35  #define OS_TASK_PRIORITY_NORMAL (OS_CFG_PRIO_MAX - 2)
36 #endif
37 
38 //Task priority (high)
39 #ifndef OS_TASK_PRIORITY_HIGH
40  #define OS_TASK_PRIORITY_HIGH (OS_CFG_PRIO_MAX - 3)
41 #endif
42 
43 //Maximum number of tasks that can be dynamically created
44 #ifndef OS_PORT_MAX_TASKS
45  #define OS_PORT_MAX_TASKS 16
46 #elif (OS_PORT_MAX_TASKS < 1)
47  #error OS_PORT_MAX_TASKS parameter is not valid
48 #endif
49 
50 //Milliseconds to system ticks
51 #ifndef OS_MS_TO_SYSTICKS
52  #define OS_MS_TO_SYSTICKS(n) (n)
53 #endif
54 
55 //System ticks to milliseconds
56 #ifndef OS_SYSTICKS_TO_MS
57  #define OS_SYSTICKS_TO_MS(n) (n)
58 #endif
59 
60 //Enter interrupt service routine
61 #define osEnterIsr() OSIntEnter()
62 
63 //Leave interrupt service routine
64 #define osExitIsr(flag) OSIntExit()
65 
66 //C++ guard
67 #ifdef __cplusplus
68  extern "C" {
69 #endif
70 
71 
72 /**
73  * @brief Task object
74  **/
75 
76 typedef OS_TCB OsTask;
77 
78 
79 /**
80  * @brief Event object
81  **/
82 
83 typedef OS_FLAG_GRP OsEvent;
84 
85 
86 /**
87  * @brief Semaphore object
88  **/
89 
90 typedef OS_SEM OsSemaphore;
91 
92 
93 /**
94  * @brief Mutex object
95  **/
96 
97 typedef OS_MUTEX OsMutex;
98 
99 
100 /**
101  * @brief Task routine
102  **/
103 
104 typedef void (*OsTaskCode)(void *param);
105 
106 
107 //Kernel management
108 void osInitKernel(void);
109 void osStartKernel(void);
110 
111 //Task management
112 bool_t osCreateStaticTask(OsTask *task, const char_t *name, OsTaskCode taskCode,
113  void *param, void *stack, size_t stackSize, int_t priority);
114 
115 OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode,
116  void *param, size_t stackSize, int_t priority);
117 
118 void osDeleteTask(OsTask *task);
119 void osDelayTask(systime_t delay);
120 void osSwitchTask(void);
121 void osSuspendAllTasks(void);
122 void osResumeAllTasks(void);
123 
124 //Event management
126 void osDeleteEvent(OsEvent *event);
127 void osSetEvent(OsEvent *event);
128 void osResetEvent(OsEvent *event);
129 bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
131 
132 //Semaphore management
133 bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
134 void osDeleteSemaphore(OsSemaphore *semaphore);
135 bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
136 void osReleaseSemaphore(OsSemaphore *semaphore);
137 
138 //Mutex management
140 void osDeleteMutex(OsMutex *mutex);
141 void osAcquireMutex(OsMutex *mutex);
142 void osReleaseMutex(OsMutex *mutex);
143 
144 //System time
146 
147 //Memory management
148 void *osAllocMem(size_t size);
149 void osFreeMem(void *p);
150 
151 //Undefine conflicting definitions
152 #undef TRACE_LEVEL_OFF
153 #undef TRACE_LEVEL_INFO
154 
155 //C++ guard
156 #ifdef __cplusplus
157  }
158 #endif
159 
160 #endif
void osInitKernel(void)
Kernel initialization.
uint16_t priority
Definition: dns_common.h:219
uint32_t systime_t
Definition: compiler_port.h:44
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
bool_t osCreateEvent(OsEvent *event)
Create an event object.
void * osAllocMem(size_t size)
Allocate a memory block.
char char_t
Definition: compiler_port.h:41
OsTask * osCreateTask(const char_t *name, OsTaskCode taskCode, void *param, size_t stackSize, int_t priority)
Create a new task.
void(* OsTaskCode)(void *param)
Task routine.
void osReleaseSemaphore(OsSemaphore *semaphore)
Release the specified semaphore object.
uint8_t p
Definition: ndp.h:295
systime_t osGetSystemTime(void)
Retrieve system time.
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
OS_SEM OsSemaphore
Semaphore object.
Definition: os_port_ucos3.h:90
void osDeleteEvent(OsEvent *event)
Delete an event object.
bool_t osCreateStaticTask(OsTask *task, const char_t *name, OsTaskCode taskCode, void *param, void *stack, size_t stackSize, int_t priority)
Create a static task.
bool_t osCreateMutex(OsMutex *mutex)
Create a mutex object.
Event object.
void osDeleteSemaphore(OsSemaphore *semaphore)
Delete a semaphore object.
void osStartKernel(void)
Start kernel.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
Task object.
signed int int_t
Definition: compiler_port.h:42
char_t name[]
void osFreeMem(void *p)
Release a previously allocated memory block.
void osResetEvent(OsEvent *event)
Set the specified event object to the nonsignaled state.
void osResumeAllTasks(void)
Resume scheduler activity.
unsigned int uint_t
Definition: compiler_port.h:43
bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout)
Wait for the specified semaphore to be available.
Mutex object.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osSuspendAllTasks(void)
Suspend scheduler activity.
OS_TCB OsTask
Task object.
Definition: os_port_ucos3.h:76
OS_FLAG_GRP OsEvent
Event object.
Definition: os_port_ucos3.h:83
OS_MUTEX OsMutex
Mutex object.
Definition: os_port_ucos3.h:97
void osDelayTask(systime_t delay)
Delay routine.
void osDeleteTask(OsTask *task)
Delete a task.
bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count)
Create a semaphore object.
Semaphore object.
int bool_t
Definition: compiler_port.h:47
void osDeleteMutex(OsMutex *mutex)
Delete a mutex object.
bool_t osWaitForEvent(OsEvent *event, systime_t timeout)
Wait until the specified event is in the signaled state.
void osSwitchTask(void)
Yield control to the next task.