forked from Oryx-Embedded/Common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_port.h
129 lines (111 loc) · 3.05 KB
/
os_port.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
/**
* @file os_port.h
* @brief RTOS abstraction layer
*
* @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_H
#define _OS_PORT_H
//Dependencies
#include "os_port_config.h"
#include "compiler_port.h"
//Compilation flags used to enable/disable features
#define ENABLED 1
#define DISABLED 0
#define PTR_OFFSET(addr, offset) ((void *) ((uint8_t *) (addr) + (offset)))
#define timeCompare(t1, t2) ((int32_t) ((t1) - (t2)))
//Miscellaneous macros
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef LSB
#define LSB(x) ((x) & 0xFF)
#endif
#ifndef MSB
#define MSB(x) (((x) >> 8) & 0xFF)
#endif
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef arraysize
#define arraysize(a) (sizeof(a) / sizeof(a[0]))
#endif
//Infinite delay
#define INFINITE_DELAY ((uint_t) -1)
//Maximum delay
#define MAX_DELAY (INFINITE_DELAY / 2)
//Invalid handle value
#define OS_INVALID_HANDLE NULL
//No RTOS?
#if defined(USE_NO_RTOS)
#include "os_port_none.h"
//ChibiOS/RT port?
#elif defined(USE_CHIBIOS)
#include "os_port_chibios.h"
//CMSIS-RTOS port?
#elif defined(USE_CMSIS_RTOS)
#include "os_port_cmsis_rtos.h"
//CMSIS-RTOS2 port?
#elif defined(USE_CMSIS_RTOS2)
#include "os_port_cmsis_rtos2.h"
//FreeRTOS port?
#elif defined(USE_FREERTOS)
#include "os_port_freertos.h"
//Keil RTX port?
#elif defined(USE_RTX)
#include "os_port_rtx.h"
//Micrium uC/OS-II port?
#elif defined(USE_UCOS2)
#include "os_port_ucos2.h"
//Micrium uC/OS-III port?
#elif defined(USE_UCOS3)
#include "os_port_ucos3.h"
//Nut/OS port?
#elif defined(USE_NUTOS)
#include "os_port_nutos.h"
//Segger embOS port?
#elif defined(USE_EMBOS)
#include "os_port_embos.h"
//TI SYS/BIOS port?
#elif defined(USE_SYS_BIOS)
#include "os_port_sys_bios.h"
//Windows port?
#elif defined(_WIN32)
#include "os_port_windows.h"
//POSIX Threads port?
#elif defined(__linux__) || defined(__FreeBSD__)
#include "os_port_posix.h"
#endif
//Delay routines
#ifndef usleep
#define usleep(delay) {volatile uint32_t n = delay * 4; while(n > 0) n--;}
#endif
#ifndef sleep
#define sleep(delay) {volatile uint32_t n = delay * 4000; while(n > 0) n--;}
#endif
#endif