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