Fork of official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

Dependents:   Final_Coffee_Roaster

Fork of mbed-rtos by mbed official

Committer:
mbed_official
Date:
Thu Sep 25 17:30:10 2014 +0100
Revision:
42:079b9616ee6c
Parent:
41:631c0f1008c3
Child:
43:aaa1b2c7c64c
Synchronized with git revision 68d4685136b9024b691aa474b0a3833b9b3035dc

Full URL: https://github.com/mbedmicro/mbed/commit/68d4685136b9024b691aa474b0a3833b9b3035dc/

[RTOS] NUCLEO_F103RB - definitions to support the target

Who changed what in which revision?

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