os_port_none.h
Go to the documentation of this file.
1 /**
2  * @file os_port_none.h
3  * @brief RTOS-less environment
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_NONE_H
28 #define _OS_PORT_NONE_H
29 
30 //Task priority (normal)
31 #ifndef OS_TASK_PRIORITY_NORMAL
32  #define OS_TASK_PRIORITY_NORMAL 0
33 #endif
34 
35 //Task priority (high)
36 #ifndef OS_TASK_PRIORITY_HIGH
37  #define OS_TASK_PRIORITY_HIGH 0
38 #endif
39 
40 //Milliseconds to system ticks
41 #ifndef OS_MS_TO_SYSTICKS
42  #define OS_MS_TO_SYSTICKS(n) (n)
43 #endif
44 
45 //System ticks to milliseconds
46 #ifndef OS_SYSTICKS_TO_MS
47  #define OS_SYSTICKS_TO_MS(n) (n)
48 #endif
49 
50 //Enter interrupt service routine
51 #ifndef osEnterIsr
52  #define osEnterIsr()
53 #endif
54 
55 //Leave interrupt service routine
56 #ifndef osExitIsr
57  #define osExitIsr(flag) (void) flag
58 #endif
59 
60 //C++ guard
61 #ifdef __cplusplus
62  extern "C" {
63 #endif
64 
65 
66 /**
67  * @brief Task object
68  **/
69 
70 typedef void OsTask;
71 
72 
73 /**
74  * @brief Event object
75  **/
76 
77 typedef uint_t OsEvent;
78 
79 
80 /**
81  * @brief Semaphore object
82  **/
83 
85 
86 
87 /**
88  * @brief Mutex object
89  **/
90 
91 typedef uint_t OsMutex;
92 
93 
94 /**
95  * @brief Task routine
96  **/
97 
98 typedef void (*OsTaskCode)(void *param);
99 
100 //Tick count
101 extern systime_t systemTicks;
102 
103 //Kernel management
104 void osInitKernel(void);
105 void osStartKernel(void);
106 
107 //Task management
108 OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode,
109  void *param, size_t stackSize, int_t priority);
110 
111 void osDeleteTask(OsTask *task);
112 void osDelayTask(systime_t delay);
113 void osSwitchTask(void);
114 void osSuspendAllTasks(void);
115 void osResumeAllTasks(void);
116 
117 //Event management
119 void osDeleteEvent(OsEvent *event);
120 void osSetEvent(OsEvent *event);
121 void osResetEvent(OsEvent *event);
122 bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
124 
125 //Semaphore management
126 bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
127 void osDeleteSemaphore(OsSemaphore *semaphore);
128 bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
129 void osReleaseSemaphore(OsSemaphore *semaphore);
130 
131 //Mutex management
133 void osDeleteMutex(OsMutex *mutex);
134 void osAcquireMutex(OsMutex *mutex);
135 void osReleaseMutex(OsMutex *mutex);
136 
137 //System time
139 
140 //Memory management
141 void *osAllocMem(size_t size);
142 void osFreeMem(void *p);
143 
144 //C++ guard
145 #ifdef __cplusplus
146  }
147 #endif
148 
149 #endif
uint16_t priority
Definition: dns_common.h:219
uint32_t systime_t
Definition: compiler_port.h:44
void osFreeMem(void *p)
Release a previously allocated memory block.
char char_t
Definition: compiler_port.h:41
uint8_t p
Definition: ndp.h:295
void osDelayTask(systime_t delay)
Delay routine.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
void osInitKernel(void)
Kernel initialization.
void osDeleteSemaphore(OsSemaphore *semaphore)
Delete a semaphore object.
Event object.
bool_t osCreateEvent(OsEvent *event)
Create an event object.
OsTask * osCreateTask(const char_t *name, OsTaskCode taskCode, void *param, size_t stackSize, int_t priority)
Create a new task.
void osDeleteTask(OsTask *task)
Delete a task.
uint_t OsMutex
Mutex object.
Definition: os_port_none.h:91
void osStartKernel(void)
Start kernel.
void OsTask
Task object.
Definition: os_port_none.h:70
systime_t systemTicks
Definition: os_port_none.c:45
uint_t OsSemaphore
Semaphore object.
Definition: os_port_none.h:84
Task object.
signed int int_t
Definition: compiler_port.h:42
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
char_t name[]
bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout)
Wait for the specified semaphore to be available.
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
void osSuspendAllTasks(void)
Suspend scheduler activity.
void * osAllocMem(size_t size)
Allocate a memory block.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
void osDeleteEvent(OsEvent *event)
Delete an event object.
void osResumeAllTasks(void)
Resume scheduler activity.
unsigned int uint_t
Definition: compiler_port.h:43
uint_t OsEvent
Event object.
Definition: os_port_none.h:77
systime_t osGetSystemTime(void)
Retrieve system time.
Mutex object.
void osSwitchTask(void)
Yield control to the next task.
void osDeleteMutex(OsMutex *mutex)
Delete a mutex object.
void osReleaseSemaphore(OsSemaphore *semaphore)
Release the specified semaphore object.
void(* OsTaskCode)(void *param)
Task routine.
Definition: os_port_none.h:98
void osResetEvent(OsEvent *event)
Set the specified event object to the nonsignaled state.
Semaphore object.
bool_t osCreateMutex(OsMutex *mutex)
Create a mutex object.
int bool_t
Definition: compiler_port.h:47
bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count)
Create a semaphore object.
bool_t osWaitForEvent(OsEvent *event, systime_t timeout)
Wait until the specified event is in the signaled state.