Counter

Dependencies:   EthernetInterface NTPClient SDFileSystem TextLCD WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip FATFileSystem

Committer:
Tuxitheone
Date:
Mon Feb 29 18:59:15 2016 +0000
Revision:
0:ecaf3e593122
TankCounter

Who changed what in which revision?

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