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: RTX_Conf_CM.C
mbedAustin 11:cada08fc8a70 5 * Purpose: Configuration of CMSIS RTX Kernel for ARM7TDMI
mbedAustin 11:cada08fc8a70 6 * Rev.: V1.0
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 #include "cmsis_os.h"
mbedAustin 11:cada08fc8a70 36
mbedAustin 11:cada08fc8a70 37
mbedAustin 11:cada08fc8a70 38 /*----------------------------------------------------------------------------
mbedAustin 11:cada08fc8a70 39 * RTX User configuration part BEGIN
mbedAustin 11:cada08fc8a70 40 *---------------------------------------------------------------------------*/
mbedAustin 11:cada08fc8a70 41
mbedAustin 11:cada08fc8a70 42 //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
mbedAustin 11:cada08fc8a70 43 //
mbedAustin 11:cada08fc8a70 44 // <h>Thread Configuration
mbedAustin 11:cada08fc8a70 45 // =======================
mbedAustin 11:cada08fc8a70 46 //
mbedAustin 11:cada08fc8a70 47 // <o>Number of concurrent running threads <0-250>
mbedAustin 11:cada08fc8a70 48 // <i> Defines max. number of threads that will run at the same time.
mbedAustin 11:cada08fc8a70 49 // counting "main", but not counting "osTimerThread"
mbedAustin 11:cada08fc8a70 50 // <i> Default: 6
mbedAustin 11:cada08fc8a70 51 #ifndef OS_TASKCNT
mbedAustin 11:cada08fc8a70 52 # if defined(TARGET_LPC2368) || defined(TARGET_LPC2460)
mbedAustin 11:cada08fc8a70 53 # define OS_TASKCNT 14
mbedAustin 11:cada08fc8a70 54 # else
mbedAustin 11:cada08fc8a70 55 # error "no target defined"
mbedAustin 11:cada08fc8a70 56 # endif
mbedAustin 11:cada08fc8a70 57 #endif
mbedAustin 11:cada08fc8a70 58
mbedAustin 11:cada08fc8a70 59 // <o>Scheduler (+ interrupts) stack size [bytes] <64-4096:8><#/4>
mbedAustin 11:cada08fc8a70 60 #ifndef OS_SCHEDULERSTKSIZE
mbedAustin 11:cada08fc8a70 61 # if defined(TARGET_LPC2368) || defined(TARGET_LPC2460)
mbedAustin 11:cada08fc8a70 62 # define OS_SCHEDULERSTKSIZE (136*2)
mbedAustin 11:cada08fc8a70 63 # else
mbedAustin 11:cada08fc8a70 64 # error "no target defined"
mbedAustin 11:cada08fc8a70 65 # endif
mbedAustin 11:cada08fc8a70 66 #endif
mbedAustin 11:cada08fc8a70 67
mbedAustin 11:cada08fc8a70 68 // <o>Idle stack size [bytes] <64-4096:8><#/4>
mbedAustin 11:cada08fc8a70 69 // <i> Defines default stack size for the Idle thread.
mbedAustin 11:cada08fc8a70 70 #ifndef OS_IDLESTKSIZE
mbedAustin 11:cada08fc8a70 71 #define OS_IDLESTKSIZE 136
mbedAustin 11:cada08fc8a70 72 #endif
mbedAustin 11:cada08fc8a70 73
mbedAustin 11:cada08fc8a70 74 // <o>Timer Thread stack size [bytes] <64-4096:8><#/4>
mbedAustin 11:cada08fc8a70 75 // <i> Defines stack size for Timer thread.
mbedAustin 11:cada08fc8a70 76 // <i> Default: 200
mbedAustin 11:cada08fc8a70 77 #ifndef OS_TIMERSTKSZ
mbedAustin 11:cada08fc8a70 78 #define OS_TIMERSTKSZ WORDS_STACK_SIZE
mbedAustin 11:cada08fc8a70 79 #endif
mbedAustin 11:cada08fc8a70 80
mbedAustin 11:cada08fc8a70 81 // <q>Check for stack overflow
mbedAustin 11:cada08fc8a70 82 // <i> Includes the stack checking code for stack overflow.
mbedAustin 11:cada08fc8a70 83 // <i> Note that additional code reduces the Kernel performance.
mbedAustin 11:cada08fc8a70 84 #ifndef OS_STKCHECK
mbedAustin 11:cada08fc8a70 85 #define OS_STKCHECK 1
mbedAustin 11:cada08fc8a70 86 #endif
mbedAustin 11:cada08fc8a70 87
mbedAustin 11:cada08fc8a70 88 // <o>Processor mode for thread execution
mbedAustin 11:cada08fc8a70 89 // <0=> Unprivileged mode
mbedAustin 11:cada08fc8a70 90 // <1=> Privileged mode
mbedAustin 11:cada08fc8a70 91 // <i> Default: Privileged mode
mbedAustin 11:cada08fc8a70 92 #ifndef OS_RUNPRIV
mbedAustin 11:cada08fc8a70 93 #define OS_RUNPRIV 1
mbedAustin 11:cada08fc8a70 94 #endif
mbedAustin 11:cada08fc8a70 95
mbedAustin 11:cada08fc8a70 96 // </h>
mbedAustin 11:cada08fc8a70 97 // <h>SysTick Timer Configuration
mbedAustin 11:cada08fc8a70 98 // ==============================
mbedAustin 11:cada08fc8a70 99 //
mbedAustin 11:cada08fc8a70 100 // <o>Timer clock value [Hz] <1-1000000000>
mbedAustin 11:cada08fc8a70 101 // <i> Defines the timer clock value.
mbedAustin 11:cada08fc8a70 102 // <i> Default: 6000000 (6MHz)
mbedAustin 11:cada08fc8a70 103 #ifndef OS_CLOCK
mbedAustin 11:cada08fc8a70 104 # if defined(TARGET_LPC2368)
mbedAustin 11:cada08fc8a70 105 # define OS_CLOCK 96000000
mbedAustin 11:cada08fc8a70 106
mbedAustin 11:cada08fc8a70 107 # elif defined(TARGET_LPC2460)
mbedAustin 11:cada08fc8a70 108 # define OS_CLOCK 72000000
mbedAustin 11:cada08fc8a70 109
mbedAustin 11:cada08fc8a70 110 # else
mbedAustin 11:cada08fc8a70 111 # error "no target defined"
mbedAustin 11:cada08fc8a70 112 # endif
mbedAustin 11:cada08fc8a70 113 #endif
mbedAustin 11:cada08fc8a70 114
mbedAustin 11:cada08fc8a70 115 // <o>Timer tick value [us] <1-1000000>
mbedAustin 11:cada08fc8a70 116 // <i> Defines the timer tick value.
mbedAustin 11:cada08fc8a70 117 // <i> Default: 1000 (1ms)
mbedAustin 11:cada08fc8a70 118 #ifndef OS_TICK
mbedAustin 11:cada08fc8a70 119 #define OS_TICK 1000
mbedAustin 11:cada08fc8a70 120 #endif
mbedAustin 11:cada08fc8a70 121
mbedAustin 11:cada08fc8a70 122 // </h>
mbedAustin 11:cada08fc8a70 123
mbedAustin 11:cada08fc8a70 124 // <h>System Configuration
mbedAustin 11:cada08fc8a70 125 // =======================
mbedAustin 11:cada08fc8a70 126 //
mbedAustin 11:cada08fc8a70 127 // <e>Round-Robin Thread switching
mbedAustin 11:cada08fc8a70 128 // ===============================
mbedAustin 11:cada08fc8a70 129 //
mbedAustin 11:cada08fc8a70 130 // <i> Enables Round-Robin Thread switching.
mbedAustin 11:cada08fc8a70 131 #ifndef OS_ROBIN
mbedAustin 11:cada08fc8a70 132 #define OS_ROBIN 1
mbedAustin 11:cada08fc8a70 133 #endif
mbedAustin 11:cada08fc8a70 134
mbedAustin 11:cada08fc8a70 135 // <o>Round-Robin Timeout [ticks] <1-1000>
mbedAustin 11:cada08fc8a70 136 // <i> Defines how long a thread will execute before a thread switch.
mbedAustin 11:cada08fc8a70 137 // <i> Default: 5
mbedAustin 11:cada08fc8a70 138 #ifndef OS_ROBINTOUT
mbedAustin 11:cada08fc8a70 139 #define OS_ROBINTOUT 5
mbedAustin 11:cada08fc8a70 140 #endif
mbedAustin 11:cada08fc8a70 141
mbedAustin 11:cada08fc8a70 142 // </e>
mbedAustin 11:cada08fc8a70 143
mbedAustin 11:cada08fc8a70 144 // <e>User Timers
mbedAustin 11:cada08fc8a70 145 // ==============
mbedAustin 11:cada08fc8a70 146 // <i> Enables user Timers
mbedAustin 11:cada08fc8a70 147 #ifndef OS_TIMERS
mbedAustin 11:cada08fc8a70 148 #define OS_TIMERS 1
mbedAustin 11:cada08fc8a70 149 #endif
mbedAustin 11:cada08fc8a70 150
mbedAustin 11:cada08fc8a70 151 // <o>Timer Thread Priority
mbedAustin 11:cada08fc8a70 152 // <1=> Low
mbedAustin 11:cada08fc8a70 153 // <2=> Below Normal
mbedAustin 11:cada08fc8a70 154 // <3=> Normal
mbedAustin 11:cada08fc8a70 155 // <4=> Above Normal
mbedAustin 11:cada08fc8a70 156 // <5=> High
mbedAustin 11:cada08fc8a70 157 // <6=> Realtime (highest)
mbedAustin 11:cada08fc8a70 158 // <i> Defines priority for Timer Thread
mbedAustin 11:cada08fc8a70 159 // <i> Default: High
mbedAustin 11:cada08fc8a70 160 #ifndef OS_TIMERPRIO
mbedAustin 11:cada08fc8a70 161 #define OS_TIMERPRIO 5
mbedAustin 11:cada08fc8a70 162 #endif
mbedAustin 11:cada08fc8a70 163
mbedAustin 11:cada08fc8a70 164 // <o>Timer Callback Queue size <1-32>
mbedAustin 11:cada08fc8a70 165 // <i> Number of concurrent active timer callback functions.
mbedAustin 11:cada08fc8a70 166 // <i> Default: 4
mbedAustin 11:cada08fc8a70 167 #ifndef OS_TIMERCBQSZ
mbedAustin 11:cada08fc8a70 168 #define OS_TIMERCBQS 4
mbedAustin 11:cada08fc8a70 169 #endif
mbedAustin 11:cada08fc8a70 170
mbedAustin 11:cada08fc8a70 171 // </e>
mbedAustin 11:cada08fc8a70 172
mbedAustin 11:cada08fc8a70 173 // <o>ISR FIFO Queue size<4=> 4 entries <8=> 8 entries
mbedAustin 11:cada08fc8a70 174 // <12=> 12 entries <16=> 16 entries
mbedAustin 11:cada08fc8a70 175 // <24=> 24 entries <32=> 32 entries
mbedAustin 11:cada08fc8a70 176 // <48=> 48 entries <64=> 64 entries
mbedAustin 11:cada08fc8a70 177 // <96=> 96 entries
mbedAustin 11:cada08fc8a70 178 // <i> ISR functions store requests to this buffer,
mbedAustin 11:cada08fc8a70 179 // <i> when they are called from the interrupt handler.
mbedAustin 11:cada08fc8a70 180 // <i> Default: 16 entries
mbedAustin 11:cada08fc8a70 181 #ifndef OS_FIFOSZ
mbedAustin 11:cada08fc8a70 182 #define OS_FIFOSZ 16
mbedAustin 11:cada08fc8a70 183 #endif
mbedAustin 11:cada08fc8a70 184
mbedAustin 11:cada08fc8a70 185 // </h>
mbedAustin 11:cada08fc8a70 186
mbedAustin 11:cada08fc8a70 187 //------------- <<< end of configuration section >>> -----------------------
mbedAustin 11:cada08fc8a70 188
mbedAustin 11:cada08fc8a70 189 // Standard library system mutexes
mbedAustin 11:cada08fc8a70 190 // ===============================
mbedAustin 11:cada08fc8a70 191 // Define max. number system mutexes that are used to protect
mbedAustin 11:cada08fc8a70 192 // the arm standard runtime library. For microlib they are not used.
mbedAustin 11:cada08fc8a70 193 #ifndef OS_MUTEXCNT
mbedAustin 11:cada08fc8a70 194 #define OS_MUTEXCNT 12
mbedAustin 11:cada08fc8a70 195 #endif
mbedAustin 11:cada08fc8a70 196
mbedAustin 11:cada08fc8a70 197 /*----------------------------------------------------------------------------
mbedAustin 11:cada08fc8a70 198 * RTX User configuration part END
mbedAustin 11:cada08fc8a70 199 *---------------------------------------------------------------------------*/
mbedAustin 11:cada08fc8a70 200
mbedAustin 11:cada08fc8a70 201 #define OS_TRV ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
mbedAustin 11:cada08fc8a70 202
mbedAustin 11:cada08fc8a70 203
mbedAustin 11:cada08fc8a70 204 /*----------------------------------------------------------------------------
mbedAustin 11:cada08fc8a70 205 * OS Idle daemon
mbedAustin 11:cada08fc8a70 206 *---------------------------------------------------------------------------*/
mbedAustin 11:cada08fc8a70 207 void os_idle_demon (void) {
mbedAustin 11:cada08fc8a70 208 /* The idle demon is a system thread, running when no other thread is */
mbedAustin 11:cada08fc8a70 209 /* ready to run. */
mbedAustin 11:cada08fc8a70 210
mbedAustin 11:cada08fc8a70 211 /* Sleep: ideally, we should put the chip to sleep.
mbedAustin 11:cada08fc8a70 212 Unfortunately, this usually requires disconnecting the interface chip (debugger).
mbedAustin 11:cada08fc8a70 213 This can be done, but it would break the local file system.
mbedAustin 11:cada08fc8a70 214 */
mbedAustin 11:cada08fc8a70 215 for (;;) {
mbedAustin 11:cada08fc8a70 216 // sleep();
mbedAustin 11:cada08fc8a70 217 }
mbedAustin 11:cada08fc8a70 218 }
mbedAustin 11:cada08fc8a70 219
mbedAustin 11:cada08fc8a70 220 /*----------------------------------------------------------------------------
mbedAustin 11:cada08fc8a70 221 * RTX Errors
mbedAustin 11:cada08fc8a70 222 *---------------------------------------------------------------------------*/
mbedAustin 11:cada08fc8a70 223 extern void mbed_die(void);
mbedAustin 11:cada08fc8a70 224
mbedAustin 11:cada08fc8a70 225 void os_error (uint32_t err_code) {
mbedAustin 11:cada08fc8a70 226 /* This function is called when a runtime error is detected. Parameter */
mbedAustin 11:cada08fc8a70 227 /* 'err_code' holds the runtime error code (defined in RTX_Conf.h). */
mbedAustin 11:cada08fc8a70 228 mbed_die();
mbedAustin 11:cada08fc8a70 229 }
mbedAustin 11:cada08fc8a70 230
mbedAustin 11:cada08fc8a70 231 void sysThreadError(osStatus status) {
mbedAustin 11:cada08fc8a70 232 if (status != osOK) {
mbedAustin 11:cada08fc8a70 233 mbed_die();
mbedAustin 11:cada08fc8a70 234 }
mbedAustin 11:cada08fc8a70 235 }
mbedAustin 11:cada08fc8a70 236
mbedAustin 11:cada08fc8a70 237 /*----------------------------------------------------------------------------
mbedAustin 11:cada08fc8a70 238 * RTX Configuration Functions
mbedAustin 11:cada08fc8a70 239 *---------------------------------------------------------------------------*/
mbedAustin 11:cada08fc8a70 240
mbedAustin 11:cada08fc8a70 241 #include "RTX_CM_lib.h"
mbedAustin 11:cada08fc8a70 242
mbedAustin 11:cada08fc8a70 243 /*----------------------------------------------------------------------------
mbedAustin 11:cada08fc8a70 244 * end of file
mbedAustin 11:cada08fc8a70 245 *---------------------------------------------------------------------------*/
mbedAustin 11:cada08fc8a70 246