]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c
1 /*----------------------------------------------------------------------------
3 *----------------------------------------------------------------------------
5 * Purpose: Configuration of CMSIS RTX Kernel for Cortex-M
7 *----------------------------------------------------------------------------
9 * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
10 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * - Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * - Neither the name of ARM nor the names of its contributors may be used
19 * to endorse or promote products derived from this software without
20 * specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *---------------------------------------------------------------------------*/
38 /*----------------------------------------------------------------------------
39 * RTX User configuration part BEGIN
40 *---------------------------------------------------------------------------*/
42 //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
44 // <h>Thread Configuration
45 // =======================
47 // <o>Number of concurrent running threads <0-250>
48 // <i> Defines max. number of threads that will run at the same time.
49 // counting "main", but not counting "osTimerThread"
52 # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_LPC4330) || defined(TARGET_LPC4337) || defined(TARGET_LPC1347) || defined(TARGET_K64F) || defined(TARGET_STM32F401RE)\
53 || defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68) \
54 || defined(TARGET_STM32F411RE) || defined(TARGET_STM32F405RG) || defined(TARGET_K22F) || defined(TARGET_STM32F429ZI) || defined(TARGET_STM32F401VC) || defined(TARGET_MAX32610) || defined(TARGET_MAX32600) || defined(TARGET_TEENSY3_1)
55 # define OS_TASKCNT 14
56 # elif defined(TARGET_LPC11U24) || defined(TARGET_STM32F303RE) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) \
57 || defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_KL05Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8) \
58 || defined(TARGET_STM32F103RB) || defined(TARGET_LPC824) || defined(TARGET_STM32F302R8) || defined(TARGET_STM32F334R8) || defined(TARGET_STM32F334C8) \
59 || defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC)
62 # error "no target defined"
66 // <o>Scheduler (+ interrupts) stack size [bytes] <64-4096:8><#/4>
67 #ifndef OS_SCHEDULERSTKSIZE
68 # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_LPC4330) || defined(TARGET_LPC4337) || defined(TARGET_LPC1347) || defined(TARGET_K64F) || defined(TARGET_STM32F401RE)\
69 || defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68) \
70 || defined(TARGET_STM32F411RE) || defined(TARGET_STM32F405RG) || defined(TARGET_K22F) || defined(TARGET_STM32F429ZI) || defined(TARGET_STM32F401VC) || defined(TARGET_MAX32610) || defined(TARGET_MAX32600) || defined(TARGET_TEENSY3_1)
71 # define OS_SCHEDULERSTKSIZE 256
72 # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) \
73 || defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_KL05Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8) \
74 || defined(TARGET_STM32F103RB) || defined(TARGET_LPC824) || defined(TARGET_STM32F302R8) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC)
75 # define OS_SCHEDULERSTKSIZE 128
76 # elif defined(TARGET_STM32F334R8) || defined(TARGET_STM32F303RE) || defined(TARGET_STM32F334C8) || defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
77 # define OS_SCHEDULERSTKSIZE 112
79 # error "no target defined"
83 // <o>Idle stack size [bytes] <64-4096:8><#/4>
84 // <i> Defines default stack size for the Idle thread.
85 #ifndef OS_IDLESTKSIZE
86 #define OS_IDLESTKSIZE 128
89 // <o>Timer Thread stack size [bytes] <64-4096:8><#/4>
90 // <i> Defines stack size for Timer thread.
93 #define OS_TIMERSTKSZ WORDS_STACK_SIZE
96 // <q>Check for stack overflow
97 // <i> Includes the stack checking code for stack overflow.
98 // <i> Note that additional code reduces the Kernel performance.
100 #define OS_STKCHECK 1
103 // <o>Processor mode for thread execution
104 // <0=> Unprivileged mode
105 // <1=> Privileged mode
106 // <i> Default: Privileged mode
112 // <h>SysTick Timer Configuration
113 // ==============================
115 // <o>Timer clock value [Hz] <1-1000000000>
116 // <i> Defines the timer clock value.
117 // <i> Default: 6000000 (6MHz)
119 # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
120 # define OS_CLOCK 96000000
122 # elif defined(TARGET_LPC1347) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_STM32F334R8) || defined(TARGET_STM32F334C8) || defined(TARGET_STM32F303RE) || defined(TARGET_TEENSY3_1)
123 # define OS_CLOCK 72000000
125 # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) || defined(TARGET_KL25Z) \
126 || defined(TARGET_KL05Z) || defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F051R8) || defined(TARGET_LPC11U68) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC)
127 # define OS_CLOCK 48000000
129 # elif defined(TARGET_LPC812)
130 # define OS_CLOCK 36000000
132 # elif defined(TARGET_LPC824)
133 # define OS_CLOCK 30000000
135 # elif defined(TARGET_STM32F100RB)
136 # define OS_CLOCK 24000000
138 # elif defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_K64F) || defined(TARGET_K22F)
139 # define OS_CLOCK 120000000
141 # elif defined(TARGET_LPC4330)
142 # define OS_CLOCK 204000000
144 # elif defined(TARGET_LPC4337)
145 # define OS_CLOCK 204000000
147 # elif defined(TARGET_STM32F407) || defined(TARGET_F407VG)
148 # define OS_CLOCK 168000000
150 # elif defined(TARGET_STM32F401RE)
151 # define OS_CLOCK 84000000
153 # elif defined(TARGET_STM32F411RE)
154 # define OS_CLOCK 100000000
156 #elif defined(TARGET_STM32F103RB)
157 # define OS_CLOCK 72000000
159 #elif defined(TARGET_STM32F429ZI)
160 # define OS_CLOCK 168000000
162 #elif defined(TARGET_STM32F302R8)
163 # define OS_CLOCK 64000000
165 #elif defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
166 # define OS_CLOCK 32000000
168 #elif defined(TARGET_STM32F401VC)
169 # define OS_CLOCK 84000000
171 #elif defined(TARGET_MAX32610) || defined(TARGET_MAX32600)
172 # define OS_CLOCK 24000000
175 # error "no target defined"
179 // <o>Timer tick value [us] <1-1000000>
180 // <i> Defines the timer tick value.
181 // <i> Default: 1000 (1ms)
188 // <h>System Configuration
189 // =======================
191 // <e>Round-Robin Thread switching
192 // ===============================
194 // <i> Enables Round-Robin Thread switching.
199 // <o>Round-Robin Timeout [ticks] <1-1000>
200 // <i> Defines how long a thread will execute before a thread switch.
203 #define OS_ROBINTOUT 5
210 // <i> Enables user Timers
215 // <o>Timer Thread Priority
221 // <6=> Realtime (highest)
222 // <i> Defines priority for Timer Thread
225 #define OS_TIMERPRIO 5
228 // <o>Timer Callback Queue size <1-32>
229 // <i> Number of concurrent active timer callback functions.
231 #ifndef OS_TIMERCBQSZ
232 #define OS_TIMERCBQS 4
237 // <o>ISR FIFO Queue size<4=> 4 entries <8=> 8 entries
238 // <12=> 12 entries <16=> 16 entries
239 // <24=> 24 entries <32=> 32 entries
240 // <48=> 48 entries <64=> 64 entries
242 // <i> ISR functions store requests to this buffer,
243 // <i> when they are called from the interrupt handler.
244 // <i> Default: 16 entries
251 //------------- <<< end of configuration section >>> -----------------------
253 // Standard library system mutexes
254 // ===============================
255 // Define max. number system mutexes that are used to protect
256 // the arm standard runtime library. For microlib they are not used.
258 #define OS_MUTEXCNT 12
261 /*----------------------------------------------------------------------------
262 * RTX User configuration part END
263 *---------------------------------------------------------------------------*/
265 #define OS_TRV ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
268 /*----------------------------------------------------------------------------
270 *---------------------------------------------------------------------------*/
271 void os_idle_demon (void) {
272 /* The idle demon is a system thread, running when no other thread is */
275 /* Sleep: ideally, we should put the chip to sleep.
276 Unfortunately, this usually requires disconnecting the interface chip (debugger).
277 This can be done, but it would break the local file system.
284 /*----------------------------------------------------------------------------
286 *---------------------------------------------------------------------------*/
287 extern void mbed_die(void);
289 void os_error (uint32_t err_code
) {
290 /* This function is called when a runtime error is detected. Parameter */
291 /* 'err_code' holds the runtime error code (defined in RTX_Conf.h). */
295 void sysThreadError(osStatus status
) {
296 if (status
!= osOK
) {
301 /*----------------------------------------------------------------------------
302 * RTX Configuration Functions
303 *---------------------------------------------------------------------------*/
305 #include "RTX_CM_lib.h"
307 /*----------------------------------------------------------------------------
309 *---------------------------------------------------------------------------*/