Mistake on this page?
Report an issue in GitHub or email us
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 #include "mbed_rtos_storage.h"
23 
24 #include <stdbool.h>
25 
26 extern u8_t lwip_ram_heap[];
27 
28 #if NO_SYS == 0
29 #include "cmsis_os2.h"
30 
31 // === SEMAPHORE ===
32 typedef struct {
33  osSemaphoreId_t id;
34  osSemaphoreAttr_t attr;
35  mbed_rtos_storage_semaphore_t data;
36 } sys_sem_t;
37 
38 #define sys_sem_valid(x) (((*x).id == NULL) ? 0 : 1)
39 #define sys_sem_set_invalid(x) ( (*x).id = NULL)
40 
41 // === MUTEX ===
42 typedef struct {
43  osMutexId_t id;
44  osMutexAttr_t attr;
45  mbed_rtos_storage_mutex_t data;
46 } sys_mutex_t;
47 
48 // === MAIL BOX ===
49 #define MB_SIZE MBED_CONF_LWIP_MBOX_SIZE
50 
51 typedef struct {
52  osEventFlagsId_t id;
53  osEventFlagsAttr_t attr;
54  mbed_rtos_storage_event_flags_t data;
55 
56  uint8_t post_idx;
57  uint8_t fetch_idx;
58  void* queue[MB_SIZE];
59 } sys_mbox_t;
60 
61 #define SYS_MBOX_FETCH_EVENT 0x1
62 #define SYS_MBOX_POST_EVENT 0x2
63 
64 #define SYS_MBOX_NULL ((uint32_t) NULL)
65 #define sys_mbox_valid(x) (((*x).id == NULL) ? 0 : 1)
66 #define sys_mbox_set_invalid(x) ( (*x).id = NULL)
67 
68 #if ((DEFAULT_RAW_RECVMBOX_SIZE) > (MB_SIZE)) || \
69  ((DEFAULT_UDP_RECVMBOX_SIZE) > (MB_SIZE)) || \
70  ((DEFAULT_TCP_RECVMBOX_SIZE) > (MB_SIZE)) || \
71  ((DEFAULT_ACCEPTMBOX_SIZE) > (MB_SIZE)) || \
72  ((TCPIP_MBOX_SIZE) > (MB_SIZE))
73 # error Mailbox size not supported
74 #endif
75 
76 // === THREAD ===
77 typedef struct {
78  osThreadId_t id;
79  osThreadAttr_t attr;
80  mbed_rtos_storage_thread_t data;
82 typedef sys_thread_data_t* sys_thread_t;
83 
84 #define SYS_THREAD_POOL_N 6
85 #define SYS_DEFAULT_THREAD_STACK_DEPTH OS_STACK_SIZE
86 
87 // === PROTECTION ===
88 typedef int sys_prot_t;
89 
90 void sys_tcpip_thread_set(void);
91 bool sys_tcpip_thread_check(void);
92 
93 #else
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97 
98 /** \brief Init systick to 1ms rate
99  *
100  * This init the systick to 1ms rate. This function is only used in standalone
101  * systems.
102  */
103 void SysTick_Init(void);
104 
105 
106 /** \brief Get the current systick time in milliSeconds
107  *
108  * Returns the current systick time in milliSeconds. This function is only
109  * used in standalone systems.
110  *
111  * /returns current systick time in milliSeconds
112  */
113 uint32_t SysTick_GetMS(void);
114 
115 /** \brief Delay for the specified number of milliSeconds
116  *
117  * For standalone systems. This function will block for the specified
118  * number of milliSconds. For RTOS based systems, this function will delay
119  * the task by the specified number of milliSeconds.
120  *
121  * \param[in] ms Time in milliSeconds to delay
122  */
123 void osDelay(uint32_t ms);
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 #endif
129 
130 #endif /* __ARCH_SYS_ARCH_H__ */
lwIP Options Configuration
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.