os_port_embos.h
Go to the documentation of this file.
1 /**
2  * @file os_port_embos.h
3  * @brief RTOS abstraction layer (Segger embOS)
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_EMBOS_H
30 #define _OS_PORT_EMBOS_H
31 
32 //Dependencies
33 #include "rtos.h"
34 
35 //Maximum number of tasks that can be dynamically created
36 #ifndef OS_PORT_MAX_TASKS
37  #define OS_PORT_MAX_TASKS 16
38 #elif (OS_PORT_MAX_TASKS < 1)
39  #error OS_PORT_MAX_TASKS parameter is not valid
40 #endif
41 
42 //Task priority (normal)
43 #ifndef OS_TASK_PRIORITY_NORMAL
44  #define OS_TASK_PRIORITY_NORMAL 1
45 #endif
46 
47 //Task priority (high)
48 #ifndef OS_TASK_PRIORITY_HIGH
49  #define OS_TASK_PRIORITY_HIGH 2
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() OS_EnterNestableInterrupt()
66 //Interrupt service routine epilogue
67 #define osExitIsr(flag) OS_LeaveNestableInterrupt()
68 
69 //C++ guard
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 
75 /**
76  * @brief Task object
77  **/
78 
79 typedef OS_TASK OsTask;
80 
81 
82 /**
83  * @brief Event object
84  **/
85 
86 typedef OS_EVENT OsEvent;
87 
88 
89 /**
90  * @brief Semaphore object
91  **/
92 
93 typedef OS_CSEMA OsSemaphore;
94 
95 
96 /**
97  * @brief Mutex object
98  **/
99 
100 typedef OS_RSEMA 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 //C++ guard
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif
void osResumeAllTasks(void)
Resume scheduler activity.
OS_RSEMA OsMutex
Mutex object.
int bool_t
Definition: compiler_port.h:49
void osSuspendAllTasks(void)
Suspend scheduler activity.
signed int int_t
Definition: compiler_port.h:44
void osInitKernel(void)
Kernel initialization.
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 osWaitForEvent(OsEvent *event, systime_t timeout)
Wait until the specified event is in the signaled state.
uint8_t p
Definition: ndp.h:298
void osFreeMem(void *p)
Release a previously allocated memory block.
Event object.
OS_EVENT OsEvent
Event object.
Definition: os_port_embos.h:86
char_t name[]
OS_CSEMA OsSemaphore
Semaphore object.
Definition: os_port_embos.h:93
OsTask * osCreateTask(const char_t *name, OsTaskCode taskCode, void *param, size_t stackSize, int_t priority)
Create a new task.
Semaphore object.
void osResetEvent(OsEvent *event)
Set the specified event object to the nonsignaled state.
bool_t osCreateEvent(OsEvent *event)
Create an event object.
bool_t osCreateMutex(OsMutex *mutex)
Create a mutex object.
void osDeleteSemaphore(OsSemaphore *semaphore)
Delete a semaphore object.
OS_TASK OsTask
Task object.
Definition: os_port_embos.h:79
void(* OsTaskCode)(void *param)
Task routine.
Task object.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
void osReleaseSemaphore(OsSemaphore *semaphore)
Release the specified semaphore object.
bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count)
Create a semaphore object.
Mutex object.
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
char char_t
Definition: compiler_port.h:43
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osStartKernel(void)
Start kernel.
systime_t osGetSystemTime(void)
Retrieve system time.
void osDeleteTask(OsTask *task)
Delete a task.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
void osDelayTask(systime_t delay)
Delay routine.
void osSwitchTask(void)
Yield control to the next task.
unsigned int uint_t
Definition: compiler_port.h:45
void * osAllocMem(size_t size)
Allocate a memory block.
bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout)
Wait for the specified semaphore to be available.
uint16_t priority
Definition: dns_common.h:221
uint32_t systime_t
Definition: compiler_port.h:46
void osDeleteEvent(OsEvent *event)
Delete an event object.
void osDeleteMutex(OsMutex *mutex)
Delete a mutex object.