Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of F7_Ethernet by
sys_arch.h
00001 /* Copyright (C) 2012 mbed.org, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00005 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00006 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00007 * furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 #ifndef __ARCH_SYS_ARCH_H__ 00019 #define __ARCH_SYS_ARCH_H__ 00020 00021 #include "lwip/opt.h" 00022 00023 #if NO_SYS == 0 00024 #include "cmsis_os.h" 00025 00026 // === SEMAPHORE === 00027 typedef struct { 00028 osSemaphoreId id; 00029 osSemaphoreDef_t def; 00030 #ifdef CMSIS_OS_RTX 00031 uint32_t data[2]; 00032 #endif 00033 } sys_sem_t; 00034 00035 #define sys_sem_valid(x) (((*x).id == NULL) ? 0 : 1) 00036 #define sys_sem_set_invalid(x) ( (*x).id = NULL) 00037 00038 // === MUTEX === 00039 typedef struct { 00040 osMutexId id; 00041 osMutexDef_t def; 00042 #ifdef CMSIS_OS_RTX 00043 #if defined(__MBED_CMSIS_RTOS_CA9) || defined(__MBED_CMSIS_RTOS_CM) 00044 int32_t data[4]; 00045 #else 00046 int32_t data[3]; 00047 #endif 00048 #endif 00049 } sys_mutex_t; 00050 00051 // === MAIL BOX === 00052 #define MB_SIZE 8 00053 00054 typedef struct { 00055 osMessageQId id; 00056 osMessageQDef_t def; 00057 #ifdef CMSIS_OS_RTX 00058 uint32_t queue[4+MB_SIZE]; /* The +4 is required for RTX OS_MCB overhead. */ 00059 #endif 00060 } sys_mbox_t; 00061 00062 #define SYS_MBOX_NULL ((uint32_t) NULL) 00063 #define sys_mbox_valid(x) (((*x).id == NULL) ? 0 : 1 ) 00064 #define sys_mbox_set_invalid(x) ( (*x).id = NULL ) 00065 00066 #if ((DEFAULT_RAW_RECVMBOX_SIZE) > (MB_SIZE)) || \ 00067 ((DEFAULT_UDP_RECVMBOX_SIZE) > (MB_SIZE)) || \ 00068 ((DEFAULT_TCP_RECVMBOX_SIZE) > (MB_SIZE)) || \ 00069 ((DEFAULT_ACCEPTMBOX_SIZE) > (MB_SIZE)) || \ 00070 ((TCPIP_MBOX_SIZE) > (MB_SIZE)) 00071 # error Mailbox size not supported 00072 #endif 00073 00074 // === THREAD === 00075 typedef struct { 00076 osThreadId id; 00077 osThreadDef_t def; 00078 } sys_thread_data_t; 00079 typedef sys_thread_data_t* sys_thread_t; 00080 00081 #define SYS_THREAD_POOL_N 6 00082 #define SYS_DEFAULT_THREAD_STACK_DEPTH DEFAULT_STACK_SIZE 00083 00084 // === PROTECTION === 00085 typedef int sys_prot_t; 00086 00087 #else 00088 #ifdef __cplusplus 00089 extern "C" { 00090 #endif 00091 00092 /** \brief Init systick to 1ms rate 00093 * 00094 * This init the systick to 1ms rate. This function is only used in standalone 00095 * systems. 00096 */ 00097 void SysTick_Init(void); 00098 00099 00100 /** \brief Get the current systick time in milliSeconds 00101 * 00102 * Returns the current systick time in milliSeconds. This function is only 00103 * used in standalone systems. 00104 * 00105 * /returns current systick time in milliSeconds 00106 */ 00107 uint32_t SysTick_GetMS(void); 00108 00109 /** \brief Delay for the specified number of milliSeconds 00110 * 00111 * For standalone systems. This function will block for the specified 00112 * number of milliSconds. For RTOS based systems, this function will delay 00113 * the task by the specified number of milliSeconds. 00114 * 00115 * \param[in] ms Time in milliSeconds to delay 00116 */ 00117 void osDelay(uint32_t ms); 00118 00119 #ifdef __cplusplus 00120 } 00121 #endif 00122 #endif 00123 00124 #endif /* __ARCH_SYS_ARCH_H__ */
Generated on Wed Jul 13 2022 02:45:41 by
1.7.2
