mbed client lightswitch demo

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by Austin Blackstone

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 11:cada08fc8a70 1 /*----------------------------------------------------------------------------
mbedAustin 11:cada08fc8a70 2 * RL-ARM - RTX
mbedAustin 11:cada08fc8a70 3 *----------------------------------------------------------------------------
mbedAustin 11:cada08fc8a70 4 * Name: RT_TYPEDEF.H
mbedAustin 11:cada08fc8a70 5 * Purpose: Type Definitions
mbedAustin 11:cada08fc8a70 6 * Rev.: V4.73 (plus large stack)
mbedAustin 11:cada08fc8a70 7 *----------------------------------------------------------------------------
mbedAustin 11:cada08fc8a70 8 *
mbedAustin 11:cada08fc8a70 9 * Copyright (c) 1999-2009 KEIL, 2009-2015 ARM Germany GmbH
mbedAustin 11:cada08fc8a70 10 * All rights reserved.
mbedAustin 11:cada08fc8a70 11 * Redistribution and use in source and binary forms, with or without
mbedAustin 11:cada08fc8a70 12 * modification, are permitted provided that the following conditions are met:
mbedAustin 11:cada08fc8a70 13 * - Redistributions of source code must retain the above copyright
mbedAustin 11:cada08fc8a70 14 * notice, this list of conditions and the following disclaimer.
mbedAustin 11:cada08fc8a70 15 * - Redistributions in binary form must reproduce the above copyright
mbedAustin 11:cada08fc8a70 16 * notice, this list of conditions and the following disclaimer in the
mbedAustin 11:cada08fc8a70 17 * documentation and/or other materials provided with the distribution.
mbedAustin 11:cada08fc8a70 18 * - Neither the name of ARM nor the names of its contributors may be used
mbedAustin 11:cada08fc8a70 19 * to endorse or promote products derived from this software without
mbedAustin 11:cada08fc8a70 20 * specific prior written permission.
mbedAustin 11:cada08fc8a70 21 *
mbedAustin 11:cada08fc8a70 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbedAustin 11:cada08fc8a70 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbedAustin 11:cada08fc8a70 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
mbedAustin 11:cada08fc8a70 25 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
mbedAustin 11:cada08fc8a70 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
mbedAustin 11:cada08fc8a70 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
mbedAustin 11:cada08fc8a70 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
mbedAustin 11:cada08fc8a70 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
mbedAustin 11:cada08fc8a70 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
mbedAustin 11:cada08fc8a70 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
mbedAustin 11:cada08fc8a70 32 * POSSIBILITY OF SUCH DAMAGE.
mbedAustin 11:cada08fc8a70 33 *---------------------------------------------------------------------------*/
mbedAustin 11:cada08fc8a70 34
mbedAustin 11:cada08fc8a70 35 /* Types */
mbedAustin 11:cada08fc8a70 36 typedef char S8;
mbedAustin 11:cada08fc8a70 37 typedef unsigned char U8;
mbedAustin 11:cada08fc8a70 38 typedef short S16;
mbedAustin 11:cada08fc8a70 39 typedef unsigned short U16;
mbedAustin 11:cada08fc8a70 40 typedef int S32;
mbedAustin 11:cada08fc8a70 41 typedef unsigned int U32;
mbedAustin 11:cada08fc8a70 42 typedef long long S64;
mbedAustin 11:cada08fc8a70 43 typedef unsigned long long U64;
mbedAustin 11:cada08fc8a70 44 typedef unsigned char BIT;
mbedAustin 11:cada08fc8a70 45 typedef unsigned int BOOL;
mbedAustin 11:cada08fc8a70 46 typedef void (*FUNCP)(void);
mbedAustin 11:cada08fc8a70 47
mbedAustin 11:cada08fc8a70 48 typedef U32 OS_TID;
mbedAustin 11:cada08fc8a70 49 typedef void *OS_ID;
mbedAustin 11:cada08fc8a70 50 typedef U32 OS_RESULT;
mbedAustin 11:cada08fc8a70 51
mbedAustin 11:cada08fc8a70 52 typedef struct OS_TCB {
mbedAustin 11:cada08fc8a70 53 /* General part: identical for all implementations. */
mbedAustin 11:cada08fc8a70 54 U8 cb_type; /* Control Block Type */
mbedAustin 11:cada08fc8a70 55 U8 state; /* Task state */
mbedAustin 11:cada08fc8a70 56 U8 prio; /* Execution priority */
mbedAustin 11:cada08fc8a70 57 U8 task_id; /* Task ID value for optimized TCB access */
mbedAustin 11:cada08fc8a70 58 struct OS_TCB *p_lnk; /* Link pointer for ready/sem. wait list */
mbedAustin 11:cada08fc8a70 59 struct OS_TCB *p_rlnk; /* Link pointer for sem./mbx lst backwards */
mbedAustin 11:cada08fc8a70 60 struct OS_TCB *p_dlnk; /* Link pointer for delay list */
mbedAustin 11:cada08fc8a70 61 struct OS_TCB *p_blnk; /* Link pointer for delay list backwards */
mbedAustin 11:cada08fc8a70 62 U16 delta_time; /* Time until time out */
mbedAustin 11:cada08fc8a70 63 U16 interval_time; /* Time interval for periodic waits */
mbedAustin 11:cada08fc8a70 64 U16 events; /* Event flags */
mbedAustin 11:cada08fc8a70 65 U16 waits; /* Wait flags */
mbedAustin 11:cada08fc8a70 66 void **msg; /* Direct message passing when task waits */
mbedAustin 11:cada08fc8a70 67 struct OS_MUCB *p_mlnk; /* Link pointer for mutex owner list */
mbedAustin 11:cada08fc8a70 68 U8 prio_base; /* Base priority */
mbedAustin 11:cada08fc8a70 69
mbedAustin 11:cada08fc8a70 70 /* Hardware dependant part: specific for Cortex processor */
mbedAustin 11:cada08fc8a70 71 U8 stack_frame; /* Stack frame: 0x0 Basic, 0x1 Extended, 0x2 VFP/D16 stacked, 0x4 NEON/D32 stacked */
mbedAustin 11:cada08fc8a70 72 #if defined (__ICCARM__)
mbedAustin 11:cada08fc8a70 73 #ifndef __LARGE_PRIV_STACK
mbedAustin 11:cada08fc8a70 74 U16 priv_stack; /* Private stack size, 0= system assigned */
mbedAustin 11:cada08fc8a70 75 #else
mbedAustin 11:cada08fc8a70 76 U16 reserved; /* Reserved (padding) */
mbedAustin 11:cada08fc8a70 77 U32 priv_stack; /* Private stack size for LARGE_STACK, 0= system assigned */
mbedAustin 11:cada08fc8a70 78 #endif /* __LARGE_PRIV_STACK */
mbedAustin 11:cada08fc8a70 79 #else
mbedAustin 11:cada08fc8a70 80 U16 reserved; /* Reserved (padding) */
mbedAustin 11:cada08fc8a70 81 U32 priv_stack; /* Private stack size for LARGE_STACK, 0= system assigned */
mbedAustin 11:cada08fc8a70 82 #endif
mbedAustin 11:cada08fc8a70 83 U32 tsk_stack; /* Current task Stack pointer (R13) */
mbedAustin 11:cada08fc8a70 84 U32 *stack; /* Pointer to Task Stack memory block */
mbedAustin 11:cada08fc8a70 85
mbedAustin 11:cada08fc8a70 86 /* Task entry point used for uVision debugger */
mbedAustin 11:cada08fc8a70 87 FUNCP ptask; /* Task entry address */
mbedAustin 11:cada08fc8a70 88 } *P_TCB;
mbedAustin 11:cada08fc8a70 89 #define TCB_TID 3 /* 'task id' offset */
mbedAustin 11:cada08fc8a70 90 #define TCB_STACKF 37 /* 'stack_frame' offset */
mbedAustin 11:cada08fc8a70 91 #if defined (__ICCARM__)
mbedAustin 11:cada08fc8a70 92 #ifndef __LARGE_PRIV_STACK
mbedAustin 11:cada08fc8a70 93 #define TCB_TSTACK 40 /* 'tsk_stack' offset */
mbedAustin 11:cada08fc8a70 94 #else
mbedAustin 11:cada08fc8a70 95 #define TCB_TSTACK 44 /* 'tsk_stack' offset for LARGE_STACK */
mbedAustin 11:cada08fc8a70 96 #endif /* __LARGE_PRIV_STACK */
mbedAustin 11:cada08fc8a70 97 #else
mbedAustin 11:cada08fc8a70 98 #define TCB_TSTACK 44 /* 'tsk_stack' offset for LARGE_STACK */
mbedAustin 11:cada08fc8a70 99 #endif
mbedAustin 11:cada08fc8a70 100
mbedAustin 11:cada08fc8a70 101 typedef struct OS_PSFE { /* Post Service Fifo Entry */
mbedAustin 11:cada08fc8a70 102 void *id; /* Object Identification */
mbedAustin 11:cada08fc8a70 103 U32 arg; /* Object Argument */
mbedAustin 11:cada08fc8a70 104 } *P_PSFE;
mbedAustin 11:cada08fc8a70 105
mbedAustin 11:cada08fc8a70 106 typedef struct OS_PSQ { /* Post Service Queue */
mbedAustin 11:cada08fc8a70 107 U8 first; /* FIFO Head Index */
mbedAustin 11:cada08fc8a70 108 U8 last; /* FIFO Tail Index */
mbedAustin 11:cada08fc8a70 109 U8 count; /* Number of stored items in FIFO */
mbedAustin 11:cada08fc8a70 110 U8 size; /* FIFO Size */
mbedAustin 11:cada08fc8a70 111 struct OS_PSFE q[1]; /* FIFO Content */
mbedAustin 11:cada08fc8a70 112 } *P_PSQ;
mbedAustin 11:cada08fc8a70 113
mbedAustin 11:cada08fc8a70 114 typedef struct OS_TSK {
mbedAustin 11:cada08fc8a70 115 P_TCB run; /* Current running task */
mbedAustin 11:cada08fc8a70 116 P_TCB new_tsk; /* Scheduled task to run */
mbedAustin 11:cada08fc8a70 117 } *P_TSK;
mbedAustin 11:cada08fc8a70 118
mbedAustin 11:cada08fc8a70 119 typedef struct OS_ROBIN { /* Round Robin Control */
mbedAustin 11:cada08fc8a70 120 P_TCB task; /* Round Robin task */
mbedAustin 11:cada08fc8a70 121 U16 time; /* Round Robin switch time */
mbedAustin 11:cada08fc8a70 122 U16 tout; /* Round Robin timeout */
mbedAustin 11:cada08fc8a70 123 } *P_ROBIN;
mbedAustin 11:cada08fc8a70 124
mbedAustin 11:cada08fc8a70 125 typedef struct OS_XCB {
mbedAustin 11:cada08fc8a70 126 U8 cb_type; /* Control Block Type */
mbedAustin 11:cada08fc8a70 127 struct OS_TCB *p_lnk; /* Link pointer for ready/sem. wait list */
mbedAustin 11:cada08fc8a70 128 struct OS_TCB *p_rlnk; /* Link pointer for sem./mbx lst backwards */
mbedAustin 11:cada08fc8a70 129 struct OS_TCB *p_dlnk; /* Link pointer for delay list */
mbedAustin 11:cada08fc8a70 130 struct OS_TCB *p_blnk; /* Link pointer for delay list backwards */
mbedAustin 11:cada08fc8a70 131 U16 delta_time; /* Time until time out */
mbedAustin 11:cada08fc8a70 132 } *P_XCB;
mbedAustin 11:cada08fc8a70 133
mbedAustin 11:cada08fc8a70 134 typedef struct OS_MCB {
mbedAustin 11:cada08fc8a70 135 U8 cb_type; /* Control Block Type */
mbedAustin 11:cada08fc8a70 136 U8 state; /* State flag variable */
mbedAustin 11:cada08fc8a70 137 U8 isr_st; /* State flag variable for isr functions */
mbedAustin 11:cada08fc8a70 138 struct OS_TCB *p_lnk; /* Chain of tasks waiting for message */
mbedAustin 11:cada08fc8a70 139 U16 first; /* Index of the message list begin */
mbedAustin 11:cada08fc8a70 140 U16 last; /* Index of the message list end */
mbedAustin 11:cada08fc8a70 141 U16 count; /* Actual number of stored messages */
mbedAustin 11:cada08fc8a70 142 U16 size; /* Maximum number of stored messages */
mbedAustin 11:cada08fc8a70 143 void *msg[1]; /* FIFO for Message pointers 1st element */
mbedAustin 11:cada08fc8a70 144 } *P_MCB;
mbedAustin 11:cada08fc8a70 145
mbedAustin 11:cada08fc8a70 146 typedef struct OS_SCB {
mbedAustin 11:cada08fc8a70 147 U8 cb_type; /* Control Block Type */
mbedAustin 11:cada08fc8a70 148 U8 mask; /* Semaphore token mask */
mbedAustin 11:cada08fc8a70 149 U16 tokens; /* Semaphore tokens */
mbedAustin 11:cada08fc8a70 150 struct OS_TCB *p_lnk; /* Chain of tasks waiting for tokens */
mbedAustin 11:cada08fc8a70 151 } *P_SCB;
mbedAustin 11:cada08fc8a70 152
mbedAustin 11:cada08fc8a70 153 typedef struct OS_MUCB {
mbedAustin 11:cada08fc8a70 154 U8 cb_type; /* Control Block Type */
mbedAustin 11:cada08fc8a70 155 U16 level; /* Call nesting level */
mbedAustin 11:cada08fc8a70 156 struct OS_TCB *p_lnk; /* Chain of tasks waiting for mutex */
mbedAustin 11:cada08fc8a70 157 struct OS_TCB *owner; /* Mutex owner task */
mbedAustin 11:cada08fc8a70 158 struct OS_MUCB *p_mlnk; /* Chain of mutexes by owner task */
mbedAustin 11:cada08fc8a70 159 } *P_MUCB;
mbedAustin 11:cada08fc8a70 160
mbedAustin 11:cada08fc8a70 161 typedef struct OS_XTMR {
mbedAustin 11:cada08fc8a70 162 struct OS_TMR *next;
mbedAustin 11:cada08fc8a70 163 U16 tcnt;
mbedAustin 11:cada08fc8a70 164 } *P_XTMR;
mbedAustin 11:cada08fc8a70 165
mbedAustin 11:cada08fc8a70 166 typedef struct OS_TMR {
mbedAustin 11:cada08fc8a70 167 struct OS_TMR *next; /* Link pointer to Next timer */
mbedAustin 11:cada08fc8a70 168 U16 tcnt; /* Timer delay count */
mbedAustin 11:cada08fc8a70 169 U16 info; /* User defined call info */
mbedAustin 11:cada08fc8a70 170 } *P_TMR;
mbedAustin 11:cada08fc8a70 171
mbedAustin 11:cada08fc8a70 172 typedef struct OS_BM {
mbedAustin 11:cada08fc8a70 173 void *free; /* Pointer to first free memory block */
mbedAustin 11:cada08fc8a70 174 void *end; /* Pointer to memory block end */
mbedAustin 11:cada08fc8a70 175 U32 blk_size; /* Memory block size */
mbedAustin 11:cada08fc8a70 176 } *P_BM;
mbedAustin 11:cada08fc8a70 177
mbedAustin 11:cada08fc8a70 178 /* Definitions */
mbedAustin 11:cada08fc8a70 179 #define __TRUE 1
mbedAustin 11:cada08fc8a70 180 #define __FALSE 0
mbedAustin 11:cada08fc8a70 181 #define NULL ((void *) 0)
mbedAustin 11:cada08fc8a70 182
mbedAustin 11:cada08fc8a70 183 /*----------------------------------------------------------------------------
mbedAustin 11:cada08fc8a70 184 * end of file
mbedAustin 11:cada08fc8a70 185 *---------------------------------------------------------------------------*/
mbedAustin 11:cada08fc8a70 186