skeleton for lab1

Dependencies:   AvailableMemory mbed-rtos mbed

Fork of helloaabbc by 32314 mbed

Committer:
y7jin
Date:
Thu Apr 03 22:56:32 2014 +0000
Revision:
0:1c8f2727e9f5
hello

Who changed what in which revision?

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