]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/net/lwip/lwip-sys/arch/sys_arch.h
Merge commit '20b787fc1284176834cbe7ca2134e4b36bec5828'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / net / lwip / lwip-sys / arch / sys_arch.h
1 /* Copyright (C) 2012 mbed.org, MIT License
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7 * furnished to do so, subject to the following conditions:
8 *
9 * The above copyright notice and this permission notice shall be included in all copies or
10 * substantial portions of the Software.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 */
18 #ifndef __ARCH_SYS_ARCH_H__
19 #define __ARCH_SYS_ARCH_H__
20
21 #include "lwip/opt.h"
22
23 #if NO_SYS == 0
24 #include "cmsis_os.h"
25
26 // === SEMAPHORE ===
27 typedef struct {
28 osSemaphoreId id;
29 osSemaphoreDef_t def;
30 #ifdef CMSIS_OS_RTX
31 uint32_t data[2];
32 #endif
33 } sys_sem_t;
34
35 #define sys_sem_valid(x) (((*x).id == NULL) ? 0 : 1)
36 #define sys_sem_set_invalid(x) ( (*x).id = NULL)
37
38 // === MUTEX ===
39 typedef struct {
40 osMutexId id;
41 osMutexDef_t def;
42 #ifdef CMSIS_OS_RTX
43 int32_t data[3];
44 #endif
45 } sys_mutex_t;
46
47 // === MAIL BOX ===
48 #define MB_SIZE 8
49
50 typedef struct {
51 osMessageQId id;
52 osMessageQDef_t def;
53 #ifdef CMSIS_OS_RTX
54 uint32_t queue[4+MB_SIZE]; /* The +4 is required for RTX OS_MCB overhead. */
55 #endif
56 } sys_mbox_t;
57
58 #define SYS_MBOX_NULL ((uint32_t) NULL)
59 #define sys_mbox_valid(x) (((*x).id == NULL) ? 0 : 1 )
60 #define sys_mbox_set_invalid(x) ( (*x).id = NULL )
61
62 #if ((DEFAULT_RAW_RECVMBOX_SIZE) > (MB_SIZE)) || \
63 ((DEFAULT_UDP_RECVMBOX_SIZE) > (MB_SIZE)) || \
64 ((DEFAULT_TCP_RECVMBOX_SIZE) > (MB_SIZE)) || \
65 ((DEFAULT_ACCEPTMBOX_SIZE) > (MB_SIZE)) || \
66 ((TCPIP_MBOX_SIZE) > (MB_SIZE))
67 # error Mailbox size not supported
68 #endif
69
70 // === THREAD ===
71 typedef struct {
72 osThreadId id;
73 osThreadDef_t def;
74 } sys_thread_data_t;
75 typedef sys_thread_data_t* sys_thread_t;
76
77 #define SYS_THREAD_POOL_N 6
78 #define SYS_DEFAULT_THREAD_STACK_DEPTH DEFAULT_STACK_SIZE
79
80 // === PROTECTION ===
81 typedef int sys_prot_t;
82
83 #else
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87
88 /** \brief Init systick to 1ms rate
89 *
90 * This init the systick to 1ms rate. This function is only used in standalone
91 * systems.
92 */
93 void SysTick_Init(void);
94
95
96 /** \brief Get the current systick time in milliSeconds
97 *
98 * Returns the current systick time in milliSeconds. This function is only
99 * used in standalone systems.
100 *
101 * /returns current systick time in milliSeconds
102 */
103 uint32_t SysTick_GetMS(void);
104
105 /** \brief Delay for the specified number of milliSeconds
106 *
107 * For standalone systems. This function will block for the specified
108 * number of milliSconds. For RTOS based systems, this function will delay
109 * the task by the specified number of milliSeconds.
110 *
111 * \param[in] ms Time in milliSeconds to delay
112 */
113 void osDelay(uint32_t ms);
114
115 #ifdef __cplusplus
116 }
117 #endif
118 #endif
119
120 #endif /* __ARCH_SYS_ARCH_H__ */
Imprint / Impressum