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