Port to C027 (using AppShield and Ethernet)

Dependencies:   C12832 EthernetInterface LM75B MMA7660 MQTT mbed-rtos mbed

Fork of IBMIoTClientEthernetExample by IBM Watson IoT

Committer:
samdanbury
Date:
Wed Aug 20 12:45:14 2014 +0000
Revision:
6:37b6d0d56190
Code completely changed to improve the structure, flow and memory usage of the application

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samdanbury 6:37b6d0d56190 1 /*----------------------------------------------------------------------------
samdanbury 6:37b6d0d56190 2 * RL-ARM - RTX
samdanbury 6:37b6d0d56190 3 *----------------------------------------------------------------------------
samdanbury 6:37b6d0d56190 4 * Name: RTX_Conf_CM.C
samdanbury 6:37b6d0d56190 5 * Purpose: Configuration of CMSIS RTX Kernel for Cortex-M
samdanbury 6:37b6d0d56190 6 * Rev.: V4.60
samdanbury 6:37b6d0d56190 7 *----------------------------------------------------------------------------
samdanbury 6:37b6d0d56190 8 *
samdanbury 6:37b6d0d56190 9 * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
samdanbury 6:37b6d0d56190 10 * All rights reserved.
samdanbury 6:37b6d0d56190 11 * Redistribution and use in source and binary forms, with or without
samdanbury 6:37b6d0d56190 12 * modification, are permitted provided that the following conditions are met:
samdanbury 6:37b6d0d56190 13 * - Redistributions of source code must retain the above copyright
samdanbury 6:37b6d0d56190 14 * notice, this list of conditions and the following disclaimer.
samdanbury 6:37b6d0d56190 15 * - Redistributions in binary form must reproduce the above copyright
samdanbury 6:37b6d0d56190 16 * notice, this list of conditions and the following disclaimer in the
samdanbury 6:37b6d0d56190 17 * documentation and/or other materials provided with the distribution.
samdanbury 6:37b6d0d56190 18 * - Neither the name of ARM nor the names of its contributors may be used
samdanbury 6:37b6d0d56190 19 * to endorse or promote products derived from this software without
samdanbury 6:37b6d0d56190 20 * specific prior written permission.
samdanbury 6:37b6d0d56190 21 *
samdanbury 6:37b6d0d56190 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
samdanbury 6:37b6d0d56190 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
samdanbury 6:37b6d0d56190 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
samdanbury 6:37b6d0d56190 25 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
samdanbury 6:37b6d0d56190 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
samdanbury 6:37b6d0d56190 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
samdanbury 6:37b6d0d56190 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
samdanbury 6:37b6d0d56190 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
samdanbury 6:37b6d0d56190 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
samdanbury 6:37b6d0d56190 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
samdanbury 6:37b6d0d56190 32 * POSSIBILITY OF SUCH DAMAGE.
samdanbury 6:37b6d0d56190 33 *---------------------------------------------------------------------------*/
samdanbury 6:37b6d0d56190 34
samdanbury 6:37b6d0d56190 35 #include "cmsis_os.h"
samdanbury 6:37b6d0d56190 36
samdanbury 6:37b6d0d56190 37
samdanbury 6:37b6d0d56190 38 /*----------------------------------------------------------------------------
samdanbury 6:37b6d0d56190 39 * RTX User configuration part BEGIN
samdanbury 6:37b6d0d56190 40 *---------------------------------------------------------------------------*/
samdanbury 6:37b6d0d56190 41
samdanbury 6:37b6d0d56190 42 //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
samdanbury 6:37b6d0d56190 43 //
samdanbury 6:37b6d0d56190 44 // <h>Thread Configuration
samdanbury 6:37b6d0d56190 45 // =======================
samdanbury 6:37b6d0d56190 46 //
samdanbury 6:37b6d0d56190 47 // <o>Number of concurrent running threads <0-250>
samdanbury 6:37b6d0d56190 48 // <i> Defines max. number of threads that will run at the same time.
samdanbury 6:37b6d0d56190 49 // counting "main", but not counting "osTimerThread"
samdanbury 6:37b6d0d56190 50 // <i> Default: 6
samdanbury 6:37b6d0d56190 51 #ifndef OS_TASKCNT
samdanbury 6:37b6d0d56190 52 # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC1347) || defined(TARGET_K64F) \
samdanbury 6:37b6d0d56190 53 || defined(TARGET_KL46Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68)
samdanbury 6:37b6d0d56190 54 # define OS_TASKCNT 14
samdanbury 6:37b6d0d56190 55 # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPC1114) \
samdanbury 6:37b6d0d56190 56 || defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8)
samdanbury 6:37b6d0d56190 57 # define OS_TASKCNT 6
samdanbury 6:37b6d0d56190 58 # else
samdanbury 6:37b6d0d56190 59 # error "no target defined"
samdanbury 6:37b6d0d56190 60 # endif
samdanbury 6:37b6d0d56190 61 #endif
samdanbury 6:37b6d0d56190 62
samdanbury 6:37b6d0d56190 63 // <o>Scheduler (+ interrupts) stack size [bytes] <64-4096:8><#/4>
samdanbury 6:37b6d0d56190 64 #ifndef OS_SCHEDULERSTKSIZE
samdanbury 6:37b6d0d56190 65 # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC1347) || defined(TARGET_K64F) \
samdanbury 6:37b6d0d56190 66 || defined(TARGET_KL46Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68)
samdanbury 6:37b6d0d56190 67 # define OS_SCHEDULERSTKSIZE 256
samdanbury 6:37b6d0d56190 68 # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPC1114) \
samdanbury 6:37b6d0d56190 69 || defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8)
samdanbury 6:37b6d0d56190 70 # define OS_SCHEDULERSTKSIZE 128
samdanbury 6:37b6d0d56190 71 # else
samdanbury 6:37b6d0d56190 72 # error "no target defined"
samdanbury 6:37b6d0d56190 73 # endif
samdanbury 6:37b6d0d56190 74 #endif
samdanbury 6:37b6d0d56190 75
samdanbury 6:37b6d0d56190 76 // <o>Idle stack size [bytes] <64-4096:8><#/4>
samdanbury 6:37b6d0d56190 77 // <i> Defines default stack size for the Idle thread.
samdanbury 6:37b6d0d56190 78 #ifndef OS_IDLESTKSIZE
samdanbury 6:37b6d0d56190 79 #define OS_IDLESTKSIZE 128
samdanbury 6:37b6d0d56190 80 #endif
samdanbury 6:37b6d0d56190 81
samdanbury 6:37b6d0d56190 82 // <o>Timer Thread stack size [bytes] <64-4096:8><#/4>
samdanbury 6:37b6d0d56190 83 // <i> Defines stack size for Timer thread.
samdanbury 6:37b6d0d56190 84 // <i> Default: 200
samdanbury 6:37b6d0d56190 85 #ifndef OS_TIMERSTKSZ
samdanbury 6:37b6d0d56190 86 #define OS_TIMERSTKSZ WORDS_STACK_SIZE
samdanbury 6:37b6d0d56190 87 #endif
samdanbury 6:37b6d0d56190 88
samdanbury 6:37b6d0d56190 89 // <q>Check for stack overflow
samdanbury 6:37b6d0d56190 90 // <i> Includes the stack checking code for stack overflow.
samdanbury 6:37b6d0d56190 91 // <i> Note that additional code reduces the Kernel performance.
samdanbury 6:37b6d0d56190 92 #ifndef OS_STKCHECK
samdanbury 6:37b6d0d56190 93 #define OS_STKCHECK 1
samdanbury 6:37b6d0d56190 94 #endif
samdanbury 6:37b6d0d56190 95
samdanbury 6:37b6d0d56190 96 // <o>Processor mode for thread execution
samdanbury 6:37b6d0d56190 97 // <0=> Unprivileged mode
samdanbury 6:37b6d0d56190 98 // <1=> Privileged mode
samdanbury 6:37b6d0d56190 99 // <i> Default: Privileged mode
samdanbury 6:37b6d0d56190 100 #ifndef OS_RUNPRIV
samdanbury 6:37b6d0d56190 101 #define OS_RUNPRIV 1
samdanbury 6:37b6d0d56190 102 #endif
samdanbury 6:37b6d0d56190 103
samdanbury 6:37b6d0d56190 104 // </h>
samdanbury 6:37b6d0d56190 105 // <h>SysTick Timer Configuration
samdanbury 6:37b6d0d56190 106 // ==============================
samdanbury 6:37b6d0d56190 107 //
samdanbury 6:37b6d0d56190 108 // <o>Timer clock value [Hz] <1-1000000000>
samdanbury 6:37b6d0d56190 109 // <i> Defines the timer clock value.
samdanbury 6:37b6d0d56190 110 // <i> Default: 6000000 (6MHz)
samdanbury 6:37b6d0d56190 111 #ifndef OS_CLOCK
samdanbury 6:37b6d0d56190 112 # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
samdanbury 6:37b6d0d56190 113 # define OS_CLOCK 96000000
samdanbury 6:37b6d0d56190 114
samdanbury 6:37b6d0d56190 115 # elif defined(TARGET_LPC1347) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549)
samdanbury 6:37b6d0d56190 116 # define OS_CLOCK 72000000
samdanbury 6:37b6d0d56190 117
samdanbury 6:37b6d0d56190 118 # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPC1114) || defined(TARGET_KL25Z) || defined(TARGET_KL46Z) || defined(TARGET_STM32F051R8) || defined(TARGET_LPC11U68)
samdanbury 6:37b6d0d56190 119 # define OS_CLOCK 48000000
samdanbury 6:37b6d0d56190 120
samdanbury 6:37b6d0d56190 121 # elif defined(TARGET_LPC812)
samdanbury 6:37b6d0d56190 122 # define OS_CLOCK 36000000
samdanbury 6:37b6d0d56190 123
samdanbury 6:37b6d0d56190 124 # elif defined(TARGET_STM32F100RB)
samdanbury 6:37b6d0d56190 125 # define OS_CLOCK 24000000
samdanbury 6:37b6d0d56190 126
samdanbury 6:37b6d0d56190 127 # elif defined(TARGET_LPC4088) || defined(TARGET_K64F)
samdanbury 6:37b6d0d56190 128 # define OS_CLOCK 120000000
samdanbury 6:37b6d0d56190 129
samdanbury 6:37b6d0d56190 130 # elif defined(TARGET_STM32F407) || defined(TARGET_F407VG)
samdanbury 6:37b6d0d56190 131 # define OS_CLOCK 168000000
samdanbury 6:37b6d0d56190 132
samdanbury 6:37b6d0d56190 133 # else
samdanbury 6:37b6d0d56190 134 # error "no target defined"
samdanbury 6:37b6d0d56190 135 # endif
samdanbury 6:37b6d0d56190 136 #endif
samdanbury 6:37b6d0d56190 137
samdanbury 6:37b6d0d56190 138 // <o>Timer tick value [us] <1-1000000>
samdanbury 6:37b6d0d56190 139 // <i> Defines the timer tick value.
samdanbury 6:37b6d0d56190 140 // <i> Default: 1000 (1ms)
samdanbury 6:37b6d0d56190 141 #ifndef OS_TICK
samdanbury 6:37b6d0d56190 142 #define OS_TICK 1000
samdanbury 6:37b6d0d56190 143 #endif
samdanbury 6:37b6d0d56190 144
samdanbury 6:37b6d0d56190 145 // </h>
samdanbury 6:37b6d0d56190 146
samdanbury 6:37b6d0d56190 147 // <h>System Configuration
samdanbury 6:37b6d0d56190 148 // =======================
samdanbury 6:37b6d0d56190 149 //
samdanbury 6:37b6d0d56190 150 // <e>Round-Robin Thread switching
samdanbury 6:37b6d0d56190 151 // ===============================
samdanbury 6:37b6d0d56190 152 //
samdanbury 6:37b6d0d56190 153 // <i> Enables Round-Robin Thread switching.
samdanbury 6:37b6d0d56190 154 #ifndef OS_ROBIN
samdanbury 6:37b6d0d56190 155 #define OS_ROBIN 1
samdanbury 6:37b6d0d56190 156 #endif
samdanbury 6:37b6d0d56190 157
samdanbury 6:37b6d0d56190 158 // <o>Round-Robin Timeout [ticks] <1-1000>
samdanbury 6:37b6d0d56190 159 // <i> Defines how long a thread will execute before a thread switch.
samdanbury 6:37b6d0d56190 160 // <i> Default: 5
samdanbury 6:37b6d0d56190 161 #ifndef OS_ROBINTOUT
samdanbury 6:37b6d0d56190 162 #define OS_ROBINTOUT 5
samdanbury 6:37b6d0d56190 163 #endif
samdanbury 6:37b6d0d56190 164
samdanbury 6:37b6d0d56190 165 // </e>
samdanbury 6:37b6d0d56190 166
samdanbury 6:37b6d0d56190 167 // <e>User Timers
samdanbury 6:37b6d0d56190 168 // ==============
samdanbury 6:37b6d0d56190 169 // <i> Enables user Timers
samdanbury 6:37b6d0d56190 170 #ifndef OS_TIMERS
samdanbury 6:37b6d0d56190 171 #define OS_TIMERS 1
samdanbury 6:37b6d0d56190 172 #endif
samdanbury 6:37b6d0d56190 173
samdanbury 6:37b6d0d56190 174 // <o>Timer Thread Priority
samdanbury 6:37b6d0d56190 175 // <1=> Low
samdanbury 6:37b6d0d56190 176 // <2=> Below Normal
samdanbury 6:37b6d0d56190 177 // <3=> Normal
samdanbury 6:37b6d0d56190 178 // <4=> Above Normal
samdanbury 6:37b6d0d56190 179 // <5=> High
samdanbury 6:37b6d0d56190 180 // <6=> Realtime (highest)
samdanbury 6:37b6d0d56190 181 // <i> Defines priority for Timer Thread
samdanbury 6:37b6d0d56190 182 // <i> Default: High
samdanbury 6:37b6d0d56190 183 #ifndef OS_TIMERPRIO
samdanbury 6:37b6d0d56190 184 #define OS_TIMERPRIO 5
samdanbury 6:37b6d0d56190 185 #endif
samdanbury 6:37b6d0d56190 186
samdanbury 6:37b6d0d56190 187 // <o>Timer Callback Queue size <1-32>
samdanbury 6:37b6d0d56190 188 // <i> Number of concurrent active timer callback functions.
samdanbury 6:37b6d0d56190 189 // <i> Default: 4
samdanbury 6:37b6d0d56190 190 #ifndef OS_TIMERCBQSZ
samdanbury 6:37b6d0d56190 191 #define OS_TIMERCBQS 4
samdanbury 6:37b6d0d56190 192 #endif
samdanbury 6:37b6d0d56190 193
samdanbury 6:37b6d0d56190 194 // </e>
samdanbury 6:37b6d0d56190 195
samdanbury 6:37b6d0d56190 196 // <o>ISR FIFO Queue size<4=> 4 entries <8=> 8 entries
samdanbury 6:37b6d0d56190 197 // <12=> 12 entries <16=> 16 entries
samdanbury 6:37b6d0d56190 198 // <24=> 24 entries <32=> 32 entries
samdanbury 6:37b6d0d56190 199 // <48=> 48 entries <64=> 64 entries
samdanbury 6:37b6d0d56190 200 // <96=> 96 entries
samdanbury 6:37b6d0d56190 201 // <i> ISR functions store requests to this buffer,
samdanbury 6:37b6d0d56190 202 // <i> when they are called from the interrupt handler.
samdanbury 6:37b6d0d56190 203 // <i> Default: 16 entries
samdanbury 6:37b6d0d56190 204 #ifndef OS_FIFOSZ
samdanbury 6:37b6d0d56190 205 #define OS_FIFOSZ 16
samdanbury 6:37b6d0d56190 206 #endif
samdanbury 6:37b6d0d56190 207
samdanbury 6:37b6d0d56190 208 // </h>
samdanbury 6:37b6d0d56190 209
samdanbury 6:37b6d0d56190 210 //------------- <<< end of configuration section >>> -----------------------
samdanbury 6:37b6d0d56190 211
samdanbury 6:37b6d0d56190 212 // Standard library system mutexes
samdanbury 6:37b6d0d56190 213 // ===============================
samdanbury 6:37b6d0d56190 214 // Define max. number system mutexes that are used to protect
samdanbury 6:37b6d0d56190 215 // the arm standard runtime library. For microlib they are not used.
samdanbury 6:37b6d0d56190 216 #ifndef OS_MUTEXCNT
samdanbury 6:37b6d0d56190 217 #define OS_MUTEXCNT 12
samdanbury 6:37b6d0d56190 218 #endif
samdanbury 6:37b6d0d56190 219
samdanbury 6:37b6d0d56190 220 /*----------------------------------------------------------------------------
samdanbury 6:37b6d0d56190 221 * RTX User configuration part END
samdanbury 6:37b6d0d56190 222 *---------------------------------------------------------------------------*/
samdanbury 6:37b6d0d56190 223
samdanbury 6:37b6d0d56190 224 #define OS_TRV ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
samdanbury 6:37b6d0d56190 225
samdanbury 6:37b6d0d56190 226
samdanbury 6:37b6d0d56190 227 /*----------------------------------------------------------------------------
samdanbury 6:37b6d0d56190 228 * OS Idle daemon
samdanbury 6:37b6d0d56190 229 *---------------------------------------------------------------------------*/
samdanbury 6:37b6d0d56190 230 void os_idle_demon (void) {
samdanbury 6:37b6d0d56190 231 /* The idle demon is a system thread, running when no other thread is */
samdanbury 6:37b6d0d56190 232 /* ready to run. */
samdanbury 6:37b6d0d56190 233
samdanbury 6:37b6d0d56190 234 /* Sleep: ideally, we should put the chip to sleep.
samdanbury 6:37b6d0d56190 235 Unfortunately, this usually requires disconnecting the interface chip (debugger).
samdanbury 6:37b6d0d56190 236 This can be done, but it would break the local file system.
samdanbury 6:37b6d0d56190 237 */
samdanbury 6:37b6d0d56190 238 for (;;) {
samdanbury 6:37b6d0d56190 239 // sleep();
samdanbury 6:37b6d0d56190 240 }
samdanbury 6:37b6d0d56190 241 }
samdanbury 6:37b6d0d56190 242
samdanbury 6:37b6d0d56190 243 /*----------------------------------------------------------------------------
samdanbury 6:37b6d0d56190 244 * RTX Errors
samdanbury 6:37b6d0d56190 245 *---------------------------------------------------------------------------*/
samdanbury 6:37b6d0d56190 246 extern void mbed_die(void);
samdanbury 6:37b6d0d56190 247
samdanbury 6:37b6d0d56190 248 void os_error (uint32_t err_code) {
samdanbury 6:37b6d0d56190 249 /* This function is called when a runtime error is detected. Parameter */
samdanbury 6:37b6d0d56190 250 /* 'err_code' holds the runtime error code (defined in RTX_Conf.h). */
samdanbury 6:37b6d0d56190 251 mbed_die();
samdanbury 6:37b6d0d56190 252 }
samdanbury 6:37b6d0d56190 253
samdanbury 6:37b6d0d56190 254 void sysThreadError(osStatus status) {
samdanbury 6:37b6d0d56190 255 if (status != osOK) {
samdanbury 6:37b6d0d56190 256 mbed_die();
samdanbury 6:37b6d0d56190 257 }
samdanbury 6:37b6d0d56190 258 }
samdanbury 6:37b6d0d56190 259
samdanbury 6:37b6d0d56190 260 /*----------------------------------------------------------------------------
samdanbury 6:37b6d0d56190 261 * RTX Configuration Functions
samdanbury 6:37b6d0d56190 262 *---------------------------------------------------------------------------*/
samdanbury 6:37b6d0d56190 263
samdanbury 6:37b6d0d56190 264 #include "RTX_CM_lib.h"
samdanbury 6:37b6d0d56190 265
samdanbury 6:37b6d0d56190 266 /*----------------------------------------------------------------------------
samdanbury 6:37b6d0d56190 267 * end of file
samdanbury 6:37b6d0d56190 268 *---------------------------------------------------------------------------*/