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