forked from Oryx-Embedded/Common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_port_rtx.h
181 lines (140 loc) · 3.81 KB
/
os_port_rtx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/**
* @file os_port_rtx.h
* @brief RTOS abstraction layer (Keil RTX)
*
* @section License
*
* Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @author Oryx Embedded SARL (www.oryx-embedded.com)
* @version 1.8.6
**/
#ifndef _OS_PORT_RTX_H
#define _OS_PORT_RTX_H
//Dependencies
#ifdef RTX_CUSTOM_HEADER
#include RTX_CUSTOM_HEADER
#else
#include "rtl.h"
#endif
//Maximum number of tasks that can be dynamically created
#ifndef OS_PORT_MAX_TASKS
#define OS_PORT_MAX_TASKS 16
#elif (OS_PORT_MAX_TASKS < 1)
#error OS_PORT_MAX_TASKS parameter is not valid
#endif
//Task priority (normal)
#ifndef OS_TASK_PRIORITY_NORMAL
#define OS_TASK_PRIORITY_NORMAL 1
#endif
//Task priority (high)
#ifndef OS_TASK_PRIORITY_HIGH
#define OS_TASK_PRIORITY_HIGH 2
#endif
//Milliseconds to system ticks
#ifndef OS_MS_TO_SYSTICKS
#define OS_MS_TO_SYSTICKS(n) (n)
#endif
//System ticks to milliseconds
#ifndef OS_SYSTICKS_TO_MS
#define OS_SYSTICKS_TO_MS(n) (n)
#endif
//Enter interrupt service routine
#define osEnterIsr()
//Leave interrupt service routine
#define osExitIsr(flag)
//C++ guard
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Task object
**/
typedef struct
{
OS_TID tid;
} OsTask;
/**
* @brief Event object
**/
typedef OS_SEM OsEvent;
/**
* @brief Semaphore object
**/
typedef OS_SEM OsSemaphore;
/**
* @brief Mutex object
**/
typedef OS_MUT OsMutex;
/**
* @brief Task routine
**/
typedef void (*OsTaskCode)(void *param);
/**
* @brief Initialization task
**/
typedef void (*OsInitTaskCode)(void);
//Kernel management
void osInitKernel(void);
void osStartKernel(OsInitTaskCode task);
//Task management
bool_t osCreateStaticTask(OsTask *task, const char_t *name, OsTaskCode taskCode,
void *param, void *stack, size_t stackSize, int_t priority);
OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode,
void *param, size_t stackSize, int_t priority);
void osDeleteTask(OsTask *task);
void osDelayTask(systime_t delay);
void osSwitchTask(void);
void osSuspendAllTasks(void);
void osResumeAllTasks(void);
//Event management
bool_t osCreateEvent(OsEvent *event);
void osDeleteEvent(OsEvent *event);
void osSetEvent(OsEvent *event);
void osResetEvent(OsEvent *event);
bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
bool_t osSetEventFromIsr(OsEvent *event);
//Semaphore management
bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
void osDeleteSemaphore(OsSemaphore *semaphore);
bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
void osReleaseSemaphore(OsSemaphore *semaphore);
//Mutex management
bool_t osCreateMutex(OsMutex *mutex);
void osDeleteMutex(OsMutex *mutex);
void osAcquireMutex(OsMutex *mutex);
void osReleaseMutex(OsMutex *mutex);
//System time
systime_t osGetSystemTime(void);
//Memory management
void *osAllocMem(size_t size);
void osFreeMem(void *p);
//Undefine conflicting definitions
#undef htons
#undef htonl
#undef ntohs
#undef ntohl
#undef TCP_STATE_CLOSED
#undef TCP_STATE_LISTEN
#undef TCP_STATE_SYN_SENT
#undef TCP_STATE_CLOSING
#undef TCP_STATE_LAST_ACK
//C++ guard
#ifdef __cplusplus
}
#endif
#endif