Committer:
PA
Date:
Thu Jun 21 14:04:44 2012 +0000
Revision:
0:7ae810ca8a42

        

Who changed what in which revision?

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