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