Lab Checkoff

Dependencies:   SDFileSystem TextLCD mbed-rtos mbed wave_player FATFileSystem

Committer:
doubster
Date:
Wed Nov 13 20:00:28 2013 +0000
Revision:
0:67dbd54e60d4
Lab Checkoff

Who changed what in which revision?

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