.

Dependencies:   mbed-rtos

Dependents:   Glove

Fork of mbed-rtos by mbed official

Committer:
jboettcher
Date:
Wed Dec 07 05:05:18 2016 +0000
Revision:
124:62fd81674a5d
Parent:
123:58563e6cba1e
.

Who changed what in which revision?

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