Clone of mbed rtos 2 for easy accessibility.
Fork of mbed-rtos by
rtx/TARGET_CORTEX_M/RTX_Conf_CM.c@118:6635230e06ba, 2016-07-25 (annotated)
- Committer:
- Kojto
- Date:
- Mon Jul 25 14:12:24 2016 +0100
- Revision:
- 118:6635230e06ba
- Parent:
- 113:d9366c711a75
- Child:
- 119:19af2d39a542
RTOS rev118
Compatible with the mbed library v122
Changes:
- warnings about duplicated CM symbols fix
- init sequence update - allows init array to be run prior kernel start
- RTOS with OS_TIMERS=0 fix for thread id
- Thread ctor is deprecated, use start() method
- main stack fix for IAR (set via linker script)
- add TCB context pointer
- provide thread safety for toolchains (std lib locks)
- add MBED_RTOS_SINGLE_THREAD macro (sets TSKCNT to 1 and TIMERS to 0)
- nrf51, nucleo l423kc, nucleo f767zi, nucleo f446ze, efm32 support addition
- add OSObserver function
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 49:77c8e4604045 | 1 | /*---------------------------------------------------------------------------- |
mbed_official | 112:53ace74b190c | 2 | * CMSIS-RTOS - RTX |
mbed_official | 49:77c8e4604045 | 3 | *---------------------------------------------------------------------------- |
mbed_official | 49:77c8e4604045 | 4 | * Name: RTX_Conf_CM.C |
mbed_official | 49:77c8e4604045 | 5 | * Purpose: Configuration of CMSIS RTX Kernel for Cortex-M |
mbed_official | 112:53ace74b190c | 6 | * Rev.: V4.70.1 |
mbed_official | 49:77c8e4604045 | 7 | *---------------------------------------------------------------------------- |
mbed_official | 49:77c8e4604045 | 8 | * |
mbed_official | 112:53ace74b190c | 9 | * Copyright (c) 1999-2009 KEIL, 2009-2015 ARM Germany GmbH |
mbed_official | 49:77c8e4604045 | 10 | * All rights reserved. |
mbed_official | 49:77c8e4604045 | 11 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 49:77c8e4604045 | 12 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 49:77c8e4604045 | 13 | * - Redistributions of source code must retain the above copyright |
mbed_official | 49:77c8e4604045 | 14 | * notice, this list of conditions and the following disclaimer. |
mbed_official | 49:77c8e4604045 | 15 | * - Redistributions in binary form must reproduce the above copyright |
mbed_official | 49:77c8e4604045 | 16 | * notice, this list of conditions and the following disclaimer in the |
mbed_official | 49:77c8e4604045 | 17 | * documentation and/or other materials provided with the distribution. |
mbed_official | 49:77c8e4604045 | 18 | * - Neither the name of ARM nor the names of its contributors may be used |
mbed_official | 49:77c8e4604045 | 19 | * to endorse or promote products derived from this software without |
mbed_official | 49:77c8e4604045 | 20 | * specific prior written permission. |
mbed_official | 49:77c8e4604045 | 21 | * |
mbed_official | 49:77c8e4604045 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 49:77c8e4604045 | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 49:77c8e4604045 | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
mbed_official | 49:77c8e4604045 | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
mbed_official | 49:77c8e4604045 | 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
mbed_official | 49:77c8e4604045 | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
mbed_official | 49:77c8e4604045 | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
mbed_official | 49:77c8e4604045 | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
mbed_official | 49:77c8e4604045 | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
mbed_official | 49:77c8e4604045 | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
mbed_official | 49:77c8e4604045 | 32 | * POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 49:77c8e4604045 | 33 | *---------------------------------------------------------------------------*/ |
mbed_official | 49:77c8e4604045 | 34 | |
mbed_official | 49:77c8e4604045 | 35 | #include "cmsis_os.h" |
mbed_official | 49:77c8e4604045 | 36 | |
mbed_official | 49:77c8e4604045 | 37 | |
mbed_official | 49:77c8e4604045 | 38 | /*---------------------------------------------------------------------------- |
mbed_official | 49:77c8e4604045 | 39 | * RTX User configuration part BEGIN |
mbed_official | 49:77c8e4604045 | 40 | *---------------------------------------------------------------------------*/ |
mbed_official | 49:77c8e4604045 | 41 | |
mbed_official | 49:77c8e4604045 | 42 | //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- |
mbed_official | 49:77c8e4604045 | 43 | // |
mbed_official | 49:77c8e4604045 | 44 | // <h>Thread Configuration |
mbed_official | 49:77c8e4604045 | 45 | // ======================= |
mbed_official | 49:77c8e4604045 | 46 | // |
mbed_official | 112:53ace74b190c | 47 | // <o>Number of concurrent running user threads <1-250> |
mbed_official | 112:53ace74b190c | 48 | // <i> Defines max. number of user threads that will run at the same time. |
mbed_official | 49:77c8e4604045 | 49 | // <i> Default: 6 |
mbed_official | 49:77c8e4604045 | 50 | #ifndef OS_TASKCNT |
mbed_official | 64:ab4200083b07 | 51 | # 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)\ |
mbed_official | 97:6c35e082773a | 52 | || defined(TARGET_STM32F410RB) || defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68) \ |
mbed_official | 79:c586ffeebfb4 | 53 | || 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) \ |
Kojto | 118:6635230e06ba | 54 | || defined(TARGET_STM32L152RE) || defined(TARGET_STM32F446RE) || defined(TARGET_STM32F446VE) || defined(TARGET_STM32F446ZE) || defined(TARGET_STM32L432KC) || defined(TARGET_STM32L476VG) || defined(TARGET_STM32L476RG) || defined(TARGET_STM32F469NI) || defined(TARGET_STM32F746NG) || defined(TARGET_STM32F746ZG) || defined(TARGET_STM32L152RC) \ |
Kojto | 118:6635230e06ba | 55 | || defined(TARGET_EFM32GG_STK3700) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32PG_STK3401) || defined(TARGET_STM32F767ZI) |
mbed_official | 49:77c8e4604045 | 56 | # define OS_TASKCNT 14 |
mbed_official | 95:12552ef4e980 | 57 | # elif defined(TARGET_LPC11U24) || defined(TARGET_STM32F303RE) || defined(TARGET_STM32F303K8) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) \ |
mbed_official | 111:162b12aea5f2 | 58 | || defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_KL26Z) || defined(TARGET_KL27Z) || defined(TARGET_KL05Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8) \ |
mbed_official | 59:28712e303960 | 59 | || defined(TARGET_STM32F103RB) || defined(TARGET_LPC824) || defined(TARGET_STM32F302R8) || defined(TARGET_STM32F334R8) || defined(TARGET_STM32F334C8) \ |
mbed_official | 108:ac4f3830f9ff | 60 | || defined(TARGET_STM32L031K6) || defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8) || defined(TARGET_STM32L073RZ) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC) || defined(TARGET_NZ32_SC151) \ |
Kojto | 118:6635230e06ba | 61 | || defined(TARGET_SSCI824) || defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB) \ |
Kojto | 118:6635230e06ba | 62 | || defined(TARGET_EFM32HG_STK3400) || defined(TARGET_MCU_NRF51822) || defined(TARGET_BEETLE) |
mbed_official | 49:77c8e4604045 | 63 | # define OS_TASKCNT 6 |
mbed_official | 49:77c8e4604045 | 64 | # else |
mbed_official | 49:77c8e4604045 | 65 | # error "no target defined" |
mbed_official | 49:77c8e4604045 | 66 | # endif |
mbed_official | 49:77c8e4604045 | 67 | #endif |
mbed_official | 49:77c8e4604045 | 68 | |
mbed_official | 112:53ace74b190c | 69 | #ifdef __MBED_CMSIS_RTOS_CM |
mbed_official | 112:53ace74b190c | 70 | // <o>Idle stack size [bytes] <64-4096:8><#/4> |
mbed_official | 112:53ace74b190c | 71 | // <i> Defines default stack size for the Idle thread. |
mbed_official | 112:53ace74b190c | 72 | #ifndef OS_IDLESTKSIZE |
mbed_official | 112:53ace74b190c | 73 | #define OS_IDLESTKSIZE 128 |
mbed_official | 112:53ace74b190c | 74 | #endif |
mbed_official | 112:53ace74b190c | 75 | #else // __MBED_CMSIS_RTOS_CM |
mbed_official | 112:53ace74b190c | 76 | // <o>Default Thread stack size [bytes] <64-4096:8><#/4> |
mbed_official | 112:53ace74b190c | 77 | // <i> Defines default stack size for threads with osThreadDef stacksz = 0 |
mbed_official | 112:53ace74b190c | 78 | // <i> Default: 200 |
mbed_official | 112:53ace74b190c | 79 | #ifndef OS_STKSIZE |
mbed_official | 112:53ace74b190c | 80 | #define OS_STKSIZE 200 |
mbed_official | 112:53ace74b190c | 81 | #endif |
mbed_official | 112:53ace74b190c | 82 | #endif // __MBED_CMSIS_RTOS_CM |
mbed_official | 112:53ace74b190c | 83 | |
mbed_official | 112:53ace74b190c | 84 | // <o>Main Thread stack size [bytes] <64-32768:8><#/4> |
mbed_official | 112:53ace74b190c | 85 | #ifndef OS_MAINSTKSIZE |
mbed_official | 64:ab4200083b07 | 86 | # 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)\ |
mbed_official | 97:6c35e082773a | 87 | || defined(TARGET_STM32F410RB) || defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68) \ |
mbed_official | 79:c586ffeebfb4 | 88 | || 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) \ |
Kojto | 118:6635230e06ba | 89 | || defined(TARGET_STM32L152RE) || defined(TARGET_STM32F446RE) || defined(TARGET_STM32F446VE) || defined(TARGET_STM32F446ZE) || defined(TARGET_STM32L432KC) || defined(TARGET_STM32L476VG) || defined(TARGET_STM32L476RG) || defined(TARGET_STM32F469NI) || defined(TARGET_STM32F746NG) || defined(TARGET_STM32F746ZG) || defined(TARGET_STM32L152RC) \ |
Kojto | 118:6635230e06ba | 90 | ||defined(TARGET_EFM32GG_STK3700) || defined(TARGET_STM32F767ZI) |
mbed_official | 112:53ace74b190c | 91 | # define OS_MAINSTKSIZE 256 |
mbed_official | 49:77c8e4604045 | 92 | # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) \ |
mbed_official | 111:162b12aea5f2 | 93 | || defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_KL26Z) || defined(TARGET_KL27Z) || defined(TARGET_KL05Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8) \ |
mbed_official | 104:07314541bd12 | 94 | || defined(TARGET_STM32F103RB) || defined(TARGET_LPC824) || defined(TARGET_STM32F302R8) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC) || defined(TARGET_NZ32_SC151) \ |
Kojto | 118:6635230e06ba | 95 | || defined(TARGET_SSCI824) || defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB) \ |
Kojto | 118:6635230e06ba | 96 | || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32PG_STK3401) |
mbed_official | 112:53ace74b190c | 97 | # define OS_MAINSTKSIZE 128 |
Kojto | 118:6635230e06ba | 98 | # elif defined(TARGET_STM32F334R8) || defined(TARGET_STM32F303RE) || defined(TARGET_STM32F303K8) || defined(TARGET_STM32F334C8) \ |
Kojto | 118:6635230e06ba | 99 | || defined(TARGET_STM32L031K6) || defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8) || defined(TARGET_STM32L073RZ) \ |
Kojto | 118:6635230e06ba | 100 | || defined(TARGET_EFM32HG_STK3400) || defined(TARGET_BEETLE) |
mbed_official | 112:53ace74b190c | 101 | # define OS_MAINSTKSIZE 112 |
Kojto | 118:6635230e06ba | 102 | # elif defined(TARGET_MCU_NRF51822) |
Kojto | 118:6635230e06ba | 103 | # define OS_MAINSTKSIZE 512 |
mbed_official | 49:77c8e4604045 | 104 | # else |
mbed_official | 49:77c8e4604045 | 105 | # error "no target defined" |
mbed_official | 49:77c8e4604045 | 106 | # endif |
mbed_official | 49:77c8e4604045 | 107 | #endif |
mbed_official | 49:77c8e4604045 | 108 | |
mbed_official | 112:53ace74b190c | 109 | #ifndef __MBED_CMSIS_RTOS_CM |
mbed_official | 112:53ace74b190c | 110 | // <o>Number of threads with user-provided stack size <0-250> |
mbed_official | 112:53ace74b190c | 111 | // <i> Defines the number of threads with user-provided stack size. |
mbed_official | 112:53ace74b190c | 112 | // <i> Default: 0 |
mbed_official | 112:53ace74b190c | 113 | #ifndef OS_PRIVCNT |
mbed_official | 112:53ace74b190c | 114 | #define OS_PRIVCNT 0 |
mbed_official | 49:77c8e4604045 | 115 | #endif |
Kojto | 118:6635230e06ba | 116 | |
mbed_official | 112:53ace74b190c | 117 | // <o>Total stack size [bytes] for threads with user-provided stack size <0-1048576:8><#/4> |
mbed_official | 112:53ace74b190c | 118 | // <i> Defines the combined stack size for threads with user-provided stack size. |
mbed_official | 112:53ace74b190c | 119 | // <i> Default: 0 |
mbed_official | 112:53ace74b190c | 120 | #ifndef OS_PRIVSTKSIZE |
mbed_official | 112:53ace74b190c | 121 | #define OS_PRIVSTKSIZE 0 // this stack size value is in words |
mbed_official | 112:53ace74b190c | 122 | #endif |
mbed_official | 112:53ace74b190c | 123 | #endif // __MBED_CMSIS_RTOS_CM |
mbed_official | 49:77c8e4604045 | 124 | |
mbed_official | 112:53ace74b190c | 125 | // <q>Stack overflow checking |
mbed_official | 112:53ace74b190c | 126 | // <i> Enable stack overflow checks at thread switch. |
mbed_official | 112:53ace74b190c | 127 | // <i> Enabling this option increases slightly the execution time of a thread switch. |
mbed_official | 49:77c8e4604045 | 128 | #ifndef OS_STKCHECK |
mbed_official | 49:77c8e4604045 | 129 | #define OS_STKCHECK 1 |
mbed_official | 49:77c8e4604045 | 130 | #endif |
Kojto | 118:6635230e06ba | 131 | |
mbed_official | 112:53ace74b190c | 132 | // <q>Stack usage watermark |
mbed_official | 112:53ace74b190c | 133 | // <i> Initialize thread stack with watermark pattern for analyzing stack usage (current/maximum) in System and Thread Viewer. |
mbed_official | 112:53ace74b190c | 134 | // <i> Enabling this option increases significantly the execution time of osThreadCreate. |
mbed_official | 112:53ace74b190c | 135 | #ifndef OS_STKINIT |
mbed_official | 112:53ace74b190c | 136 | #define OS_STKINIT 0 |
mbed_official | 112:53ace74b190c | 137 | #endif |
Kojto | 118:6635230e06ba | 138 | |
Kojto | 118:6635230e06ba | 139 | // <o>Processor mode for thread execution |
Kojto | 118:6635230e06ba | 140 | // <0=> Unprivileged mode |
mbed_official | 112:53ace74b190c | 141 | // <1=> Privileged mode |
mbed_official | 112:53ace74b190c | 142 | // <i> Default: Privileged mode |
mbed_official | 49:77c8e4604045 | 143 | #ifndef OS_RUNPRIV |
mbed_official | 49:77c8e4604045 | 144 | #define OS_RUNPRIV 1 |
mbed_official | 49:77c8e4604045 | 145 | #endif |
mbed_official | 49:77c8e4604045 | 146 | |
mbed_official | 49:77c8e4604045 | 147 | // </h> |
Kojto | 118:6635230e06ba | 148 | |
mbed_official | 112:53ace74b190c | 149 | // <h>RTX Kernel Timer Tick Configuration |
mbed_official | 112:53ace74b190c | 150 | // ====================================== |
mbed_official | 112:53ace74b190c | 151 | // <q> Use Cortex-M SysTick timer as RTX Kernel Timer |
Kojto | 118:6635230e06ba | 152 | // <i> Cortex-M processors provide in most cases a SysTick timer that can be used as |
mbed_official | 112:53ace74b190c | 153 | // <i> as time-base for RTX. |
mbed_official | 112:53ace74b190c | 154 | #ifndef OS_SYSTICK |
Kojto | 118:6635230e06ba | 155 | # if defined(TARGET_MCU_NRF51822) |
Kojto | 118:6635230e06ba | 156 | # define OS_SYSTICK 0 |
Kojto | 118:6635230e06ba | 157 | # else |
Kojto | 118:6635230e06ba | 158 | # define OS_SYSTICK 1 |
Kojto | 118:6635230e06ba | 159 | # endif |
mbed_official | 112:53ace74b190c | 160 | #endif |
mbed_official | 49:77c8e4604045 | 161 | // |
mbed_official | 112:53ace74b190c | 162 | // <o>RTOS Kernel Timer input clock frequency [Hz] <1-1000000000> |
Kojto | 118:6635230e06ba | 163 | // <i> Defines the input frequency of the RTOS Kernel Timer. |
Kojto | 118:6635230e06ba | 164 | // <i> When the Cortex-M SysTick timer is used, the input clock |
mbed_official | 112:53ace74b190c | 165 | // <i> is on most systems identical with the core clock. |
mbed_official | 49:77c8e4604045 | 166 | #ifndef OS_CLOCK |
mbed_official | 102:f62a48e9da94 | 167 | # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_TEENSY3_1) |
mbed_official | 49:77c8e4604045 | 168 | # define OS_CLOCK 96000000 |
mbed_official | 49:77c8e4604045 | 169 | |
mbed_official | 102:f62a48e9da94 | 170 | # elif defined(TARGET_LPC1347) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_STM32F334R8) || defined(TARGET_STM32F334C8) || defined(TARGET_STM32F303RE) |
mbed_official | 49:77c8e4604045 | 171 | # define OS_CLOCK 72000000 |
mbed_official | 49:77c8e4604045 | 172 | |
mbed_official | 95:12552ef4e980 | 173 | # elif defined(TARGET_STM32F303K8) |
mbed_official | 95:12552ef4e980 | 174 | # define OS_CLOCK 64000000 |
mbed_official | 95:12552ef4e980 | 175 | |
mbed_official | 59:28712e303960 | 176 | # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) || defined(TARGET_KL25Z) \ |
mbed_official | 111:162b12aea5f2 | 177 | || defined(TARGET_KL26Z) || defined(TARGET_KL27Z) || defined(TARGET_KL05Z) || defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F051R8) || defined(TARGET_LPC11U68) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC) |
mbed_official | 49:77c8e4604045 | 178 | # define OS_CLOCK 48000000 |
mbed_official | 49:77c8e4604045 | 179 | |
mbed_official | 49:77c8e4604045 | 180 | # elif defined(TARGET_LPC812) |
mbed_official | 49:77c8e4604045 | 181 | # define OS_CLOCK 36000000 |
mbed_official | 49:77c8e4604045 | 182 | |
mbed_official | 81:e45e4ac7c3c8 | 183 | # elif defined(TARGET_LPC824) || defined(TARGET_SSCI824) |
mbed_official | 49:77c8e4604045 | 184 | # define OS_CLOCK 30000000 |
mbed_official | 49:77c8e4604045 | 185 | |
Kojto | 118:6635230e06ba | 186 | # elif defined(TARGET_STM32F100RB) || defined(TARGET_BEETLE) |
mbed_official | 49:77c8e4604045 | 187 | # define OS_CLOCK 24000000 |
mbed_official | 49:77c8e4604045 | 188 | |
mbed_official | 64:ab4200083b07 | 189 | # elif defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_K64F) || defined(TARGET_K22F) |
mbed_official | 49:77c8e4604045 | 190 | # define OS_CLOCK 120000000 |
mbed_official | 49:77c8e4604045 | 191 | |
mbed_official | 63:5448826aa700 | 192 | # elif defined(TARGET_LPC4330) |
mbed_official | 63:5448826aa700 | 193 | # define OS_CLOCK 204000000 |
mbed_official | 63:5448826aa700 | 194 | |
mbed_official | 49:77c8e4604045 | 195 | # elif defined(TARGET_LPC4337) |
mbed_official | 49:77c8e4604045 | 196 | # define OS_CLOCK 204000000 |
mbed_official | 49:77c8e4604045 | 197 | |
mbed_official | 49:77c8e4604045 | 198 | # elif defined(TARGET_STM32F407) || defined(TARGET_F407VG) |
mbed_official | 49:77c8e4604045 | 199 | # define OS_CLOCK 168000000 |
mbed_official | 49:77c8e4604045 | 200 | |
mbed_official | 49:77c8e4604045 | 201 | # elif defined(TARGET_STM32F401RE) |
mbed_official | 49:77c8e4604045 | 202 | # define OS_CLOCK 84000000 |
mbed_official | 49:77c8e4604045 | 203 | |
mbed_official | 49:77c8e4604045 | 204 | # elif defined(TARGET_STM32F411RE) |
mbed_official | 49:77c8e4604045 | 205 | # define OS_CLOCK 100000000 |
mbed_official | 49:77c8e4604045 | 206 | |
mbed_official | 97:6c35e082773a | 207 | # elif defined(TARGET_STM32F410RB) |
mbed_official | 97:6c35e082773a | 208 | # define OS_CLOCK 100000000 |
mbed_official | 97:6c35e082773a | 209 | |
mbed_official | 78:2db19f47c2ba | 210 | #elif defined(TARGET_STM32F103RB) |
mbed_official | 49:77c8e4604045 | 211 | # define OS_CLOCK 72000000 |
mbed_official | 49:77c8e4604045 | 212 | |
mbed_official | 57:430de2831ec7 | 213 | #elif defined(TARGET_STM32F429ZI) |
mbed_official | 58:13a25134ac60 | 214 | # define OS_CLOCK 168000000 |
mbed_official | 57:430de2831ec7 | 215 | |
mbed_official | 59:28712e303960 | 216 | #elif defined(TARGET_STM32F302R8) |
mbed_official | 75:557d5b275f31 | 217 | # define OS_CLOCK 72000000 |
mbed_official | 59:28712e303960 | 218 | |
mbed_official | 108:ac4f3830f9ff | 219 | #elif defined(TARGET_STM32L031K6) || defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8) || defined(TARGET_STM32L073RZ) |
mbed_official | 59:28712e303960 | 220 | # define OS_CLOCK 32000000 |
mbed_official | 59:28712e303960 | 221 | |
mbed_official | 60:f4d3d8971bc3 | 222 | #elif defined(TARGET_STM32F401VC) |
mbed_official | 60:f4d3d8971bc3 | 223 | # define OS_CLOCK 84000000 |
mbed_official | 60:f4d3d8971bc3 | 224 | |
Kojto | 118:6635230e06ba | 225 | # elif defined(TARGET_STM32F746NG) || defined(TARGET_STM32F746ZG) || defined(TARGET_STM32F767ZI) |
mbed_official | 98:c825593ece39 | 226 | # define OS_CLOCK 216000000 |
mbed_official | 98:c825593ece39 | 227 | |
mbed_official | 73:34292fba723c | 228 | #elif defined(TARGET_MAX32610) || defined(TARGET_MAX32600) |
mbed_official | 71:570e569a5b59 | 229 | # define OS_CLOCK 24000000 |
mbed_official | 71:570e569a5b59 | 230 | |
mbed_official | 104:07314541bd12 | 231 | #elif defined(TARGET_NZ32_SC151) |
mbed_official | 78:2db19f47c2ba | 232 | # define OS_CLOCK 32000000 |
mbed_official | 78:2db19f47c2ba | 233 | |
mbed_official | 78:2db19f47c2ba | 234 | #elif defined(TARGET_STM32L152RE) |
mbed_official | 78:2db19f47c2ba | 235 | # define OS_CLOCK 24000000 |
mbed_official | 78:2db19f47c2ba | 236 | |
Kojto | 118:6635230e06ba | 237 | #elif defined(TARGET_STM32F446RE) || defined(TARGET_STM32F446ZE) || defined(TARGET_STM32F446VE) |
mbed_official | 79:c586ffeebfb4 | 238 | # define OS_CLOCK 180000000 |
mbed_official | 79:c586ffeebfb4 | 239 | |
mbed_official | 87:e695cd34556b | 240 | #elif defined(TARGET_STM32F030R8) |
mbed_official | 87:e695cd34556b | 241 | # define OS_CLOCK 48000000 |
mbed_official | 87:e695cd34556b | 242 | |
mbed_official | 87:e695cd34556b | 243 | #elif defined(TARGET_STM32F070RB) |
mbed_official | 87:e695cd34556b | 244 | # define OS_CLOCK 48000000 |
mbed_official | 79:c586ffeebfb4 | 245 | |
Kojto | 118:6635230e06ba | 246 | #elif defined(TARGET_STM32L432KC) || defined(TARGET_STM32L476VG) || defined(TARGET_STM32L476RG) |
mbed_official | 91:9d001ed5feec | 247 | # define OS_CLOCK 80000000 |
mbed_official | 91:9d001ed5feec | 248 | |
mbed_official | 96:6d90423c236e | 249 | #elif defined(TARGET_STM32F469NI) |
mbed_official | 96:6d90423c236e | 250 | # define OS_CLOCK 168000000 |
mbed_official | 96:6d90423c236e | 251 | |
mbed_official | 99:79d2f32f753f | 252 | #elif defined(TARGET_STM32L152RC) |
mbed_official | 99:79d2f32f753f | 253 | # define OS_CLOCK 24000000 |
mbed_official | 99:79d2f32f753f | 254 | |
Kojto | 118:6635230e06ba | 255 | #elif defined(TARGET_EFM32) |
Kojto | 118:6635230e06ba | 256 | # include "clocking.h" |
Kojto | 118:6635230e06ba | 257 | # define OS_CLOCK REFERENCE_FREQUENCY |
Kojto | 118:6635230e06ba | 258 | |
Kojto | 118:6635230e06ba | 259 | #elif defined(TARGET_MCU_NRF51822) |
Kojto | 118:6635230e06ba | 260 | # define OS_CLOCK 32768 |
Kojto | 118:6635230e06ba | 261 | |
mbed_official | 49:77c8e4604045 | 262 | # else |
mbed_official | 49:77c8e4604045 | 263 | # error "no target defined" |
mbed_official | 49:77c8e4604045 | 264 | # endif |
mbed_official | 49:77c8e4604045 | 265 | #endif |
Kojto | 118:6635230e06ba | 266 | |
mbed_official | 112:53ace74b190c | 267 | // <o>RTX Timer tick interval value [us] <1-1000000> |
mbed_official | 112:53ace74b190c | 268 | // <i> The RTX Timer tick interval value is used to calculate timeout values. |
mbed_official | 112:53ace74b190c | 269 | // <i> When the Cortex-M SysTick timer is enabled, the value also configures the SysTick timer. |
mbed_official | 49:77c8e4604045 | 270 | // <i> Default: 1000 (1ms) |
mbed_official | 49:77c8e4604045 | 271 | #ifndef OS_TICK |
mbed_official | 49:77c8e4604045 | 272 | #define OS_TICK 1000 |
mbed_official | 49:77c8e4604045 | 273 | #endif |
mbed_official | 49:77c8e4604045 | 274 | |
mbed_official | 49:77c8e4604045 | 275 | // </h> |
mbed_official | 49:77c8e4604045 | 276 | |
mbed_official | 49:77c8e4604045 | 277 | // <h>System Configuration |
mbed_official | 49:77c8e4604045 | 278 | // ======================= |
mbed_official | 49:77c8e4604045 | 279 | // |
mbed_official | 49:77c8e4604045 | 280 | // <e>Round-Robin Thread switching |
mbed_official | 49:77c8e4604045 | 281 | // =============================== |
mbed_official | 49:77c8e4604045 | 282 | // |
mbed_official | 49:77c8e4604045 | 283 | // <i> Enables Round-Robin Thread switching. |
mbed_official | 49:77c8e4604045 | 284 | #ifndef OS_ROBIN |
mbed_official | 49:77c8e4604045 | 285 | #define OS_ROBIN 1 |
mbed_official | 49:77c8e4604045 | 286 | #endif |
mbed_official | 49:77c8e4604045 | 287 | |
mbed_official | 49:77c8e4604045 | 288 | // <o>Round-Robin Timeout [ticks] <1-1000> |
mbed_official | 49:77c8e4604045 | 289 | // <i> Defines how long a thread will execute before a thread switch. |
mbed_official | 49:77c8e4604045 | 290 | // <i> Default: 5 |
mbed_official | 49:77c8e4604045 | 291 | #ifndef OS_ROBINTOUT |
mbed_official | 49:77c8e4604045 | 292 | #define OS_ROBINTOUT 5 |
mbed_official | 49:77c8e4604045 | 293 | #endif |
mbed_official | 49:77c8e4604045 | 294 | |
mbed_official | 49:77c8e4604045 | 295 | // </e> |
mbed_official | 49:77c8e4604045 | 296 | |
mbed_official | 49:77c8e4604045 | 297 | // <e>User Timers |
mbed_official | 49:77c8e4604045 | 298 | // ============== |
mbed_official | 49:77c8e4604045 | 299 | // <i> Enables user Timers |
mbed_official | 49:77c8e4604045 | 300 | #ifndef OS_TIMERS |
mbed_official | 49:77c8e4604045 | 301 | #define OS_TIMERS 1 |
mbed_official | 49:77c8e4604045 | 302 | #endif |
mbed_official | 49:77c8e4604045 | 303 | |
mbed_official | 49:77c8e4604045 | 304 | // <o>Timer Thread Priority |
mbed_official | 49:77c8e4604045 | 305 | // <1=> Low |
mbed_official | 112:53ace74b190c | 306 | // <2=> Below Normal <3=> Normal <4=> Above Normal |
mbed_official | 49:77c8e4604045 | 307 | // <5=> High |
mbed_official | 49:77c8e4604045 | 308 | // <6=> Realtime (highest) |
mbed_official | 49:77c8e4604045 | 309 | // <i> Defines priority for Timer Thread |
mbed_official | 49:77c8e4604045 | 310 | // <i> Default: High |
mbed_official | 49:77c8e4604045 | 311 | #ifndef OS_TIMERPRIO |
mbed_official | 49:77c8e4604045 | 312 | #define OS_TIMERPRIO 5 |
mbed_official | 49:77c8e4604045 | 313 | #endif |
Kojto | 118:6635230e06ba | 314 | |
mbed_official | 112:53ace74b190c | 315 | // <o>Timer Thread stack size [bytes] <64-4096:8><#/4> |
mbed_official | 112:53ace74b190c | 316 | // <i> Defines stack size for Timer thread. |
mbed_official | 112:53ace74b190c | 317 | // <i> Default: 200 |
mbed_official | 112:53ace74b190c | 318 | #ifndef OS_TIMERSTKSZ |
mbed_official | 112:53ace74b190c | 319 | #define OS_TIMERSTKSZ 200 |
mbed_official | 112:53ace74b190c | 320 | #endif |
Kojto | 118:6635230e06ba | 321 | |
mbed_official | 49:77c8e4604045 | 322 | // <o>Timer Callback Queue size <1-32> |
mbed_official | 49:77c8e4604045 | 323 | // <i> Number of concurrent active timer callback functions. |
mbed_official | 49:77c8e4604045 | 324 | // <i> Default: 4 |
mbed_official | 112:53ace74b190c | 325 | #ifndef OS_TIMERCBQS |
mbed_official | 49:77c8e4604045 | 326 | #define OS_TIMERCBQS 4 |
mbed_official | 49:77c8e4604045 | 327 | #endif |
mbed_official | 49:77c8e4604045 | 328 | |
mbed_official | 49:77c8e4604045 | 329 | // </e> |
mbed_official | 49:77c8e4604045 | 330 | |
mbed_official | 49:77c8e4604045 | 331 | // <o>ISR FIFO Queue size<4=> 4 entries <8=> 8 entries |
mbed_official | 49:77c8e4604045 | 332 | // <12=> 12 entries <16=> 16 entries |
mbed_official | 49:77c8e4604045 | 333 | // <24=> 24 entries <32=> 32 entries |
mbed_official | 49:77c8e4604045 | 334 | // <48=> 48 entries <64=> 64 entries |
mbed_official | 49:77c8e4604045 | 335 | // <96=> 96 entries |
mbed_official | 49:77c8e4604045 | 336 | // <i> ISR functions store requests to this buffer, |
mbed_official | 49:77c8e4604045 | 337 | // <i> when they are called from the interrupt handler. |
mbed_official | 49:77c8e4604045 | 338 | // <i> Default: 16 entries |
mbed_official | 49:77c8e4604045 | 339 | #ifndef OS_FIFOSZ |
mbed_official | 49:77c8e4604045 | 340 | #define OS_FIFOSZ 16 |
mbed_official | 49:77c8e4604045 | 341 | #endif |
mbed_official | 49:77c8e4604045 | 342 | |
mbed_official | 49:77c8e4604045 | 343 | // </h> |
mbed_official | 49:77c8e4604045 | 344 | |
mbed_official | 49:77c8e4604045 | 345 | //------------- <<< end of configuration section >>> ----------------------- |
mbed_official | 49:77c8e4604045 | 346 | |
mbed_official | 49:77c8e4604045 | 347 | // Standard library system mutexes |
mbed_official | 49:77c8e4604045 | 348 | // =============================== |
mbed_official | 49:77c8e4604045 | 349 | // Define max. number system mutexes that are used to protect |
mbed_official | 49:77c8e4604045 | 350 | // the arm standard runtime library. For microlib they are not used. |
mbed_official | 49:77c8e4604045 | 351 | #ifndef OS_MUTEXCNT |
mbed_official | 49:77c8e4604045 | 352 | #define OS_MUTEXCNT 12 |
mbed_official | 49:77c8e4604045 | 353 | #endif |
mbed_official | 49:77c8e4604045 | 354 | |
mbed_official | 49:77c8e4604045 | 355 | /*---------------------------------------------------------------------------- |
mbed_official | 49:77c8e4604045 | 356 | * RTX User configuration part END |
mbed_official | 49:77c8e4604045 | 357 | *---------------------------------------------------------------------------*/ |
mbed_official | 49:77c8e4604045 | 358 | |
mbed_official | 49:77c8e4604045 | 359 | #define OS_TRV ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1) |
mbed_official | 49:77c8e4604045 | 360 | |
mbed_official | 49:77c8e4604045 | 361 | |
mbed_official | 49:77c8e4604045 | 362 | /*---------------------------------------------------------------------------- |
mbed_official | 49:77c8e4604045 | 363 | * OS Idle daemon |
mbed_official | 49:77c8e4604045 | 364 | *---------------------------------------------------------------------------*/ |
mbed_official | 107:bdd541595fc5 | 365 | extern void rtos_idle_loop(void); |
mbed_official | 49:77c8e4604045 | 366 | |
mbed_official | 107:bdd541595fc5 | 367 | void os_idle_demon (void) { |
mbed_official | 107:bdd541595fc5 | 368 | /* The idle demon is a system thread, running when no other thread is */ |
mbed_official | 107:bdd541595fc5 | 369 | /* ready to run. */ |
mbed_official | 107:bdd541595fc5 | 370 | rtos_idle_loop(); |
mbed_official | 49:77c8e4604045 | 371 | } |
mbed_official | 49:77c8e4604045 | 372 | |
mbed_official | 49:77c8e4604045 | 373 | /*---------------------------------------------------------------------------- |
mbed_official | 49:77c8e4604045 | 374 | * RTX Errors |
mbed_official | 49:77c8e4604045 | 375 | *---------------------------------------------------------------------------*/ |
mbed_official | 112:53ace74b190c | 376 | extern void error(const char* format, ...); |
mbed_official | 112:53ace74b190c | 377 | extern osThreadId svcThreadGetId (void); |
mbed_official | 112:53ace74b190c | 378 | |
mbed_official | 49:77c8e4604045 | 379 | void os_error (uint32_t err_code) { |
mbed_official | 49:77c8e4604045 | 380 | /* This function is called when a runtime error is detected. Parameter */ |
mbed_official | 112:53ace74b190c | 381 | /* 'err_code' holds the runtime error code (defined in RTX_Config.h). */ |
mbed_official | 112:53ace74b190c | 382 | osThreadId err_task = svcThreadGetId(); |
mbed_official | 113:d9366c711a75 | 383 | error("RTX error code: 0x%08X, task ID: 0x%08X\n", err_code, err_task); |
mbed_official | 49:77c8e4604045 | 384 | } |
mbed_official | 49:77c8e4604045 | 385 | |
mbed_official | 49:77c8e4604045 | 386 | void sysThreadError(osStatus status) { |
mbed_official | 49:77c8e4604045 | 387 | if (status != osOK) { |
mbed_official | 113:d9366c711a75 | 388 | osThreadId err_task = svcThreadGetId(); |
mbed_official | 113:d9366c711a75 | 389 | error("CMSIS-RTOS error status: 0x%08X, task ID: 0x%08X\n", status, err_task); |
mbed_official | 49:77c8e4604045 | 390 | } |
mbed_official | 49:77c8e4604045 | 391 | } |
mbed_official | 49:77c8e4604045 | 392 | |
mbed_official | 49:77c8e4604045 | 393 | /*---------------------------------------------------------------------------- |
mbed_official | 49:77c8e4604045 | 394 | * RTX Configuration Functions |
mbed_official | 49:77c8e4604045 | 395 | *---------------------------------------------------------------------------*/ |
mbed_official | 49:77c8e4604045 | 396 | |
mbed_official | 49:77c8e4604045 | 397 | #include "RTX_CM_lib.h" |
mbed_official | 49:77c8e4604045 | 398 | |
mbed_official | 49:77c8e4604045 | 399 | /*---------------------------------------------------------------------------- |
mbed_official | 49:77c8e4604045 | 400 | * end of file |
mbed_official | 49:77c8e4604045 | 401 | *---------------------------------------------------------------------------*/ |