Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard. Patched to work with NUCLEO L152 board
Fork of mbed-rtos by
RTX_Conf_CM.c
00001 /*---------------------------------------------------------------------------- 00002 * RL-ARM - RTX 00003 *---------------------------------------------------------------------------- 00004 * Name: RTX_Conf_CM.C 00005 * Purpose: Configuration of CMSIS RTX Kernel for Cortex-M 00006 * Rev.: V4.60 00007 *---------------------------------------------------------------------------- 00008 * 00009 * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH 00010 * All rights reserved. 00011 * Redistribution and use in source and binary forms, with or without 00012 * modification, are permitted provided that the following conditions are met: 00013 * - Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * - Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in the 00017 * documentation and/or other materials provided with the distribution. 00018 * - Neither the name of ARM nor the names of its contributors may be used 00019 * to endorse or promote products derived from this software without 00020 * specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00025 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 00026 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00027 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00028 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00029 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00030 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00031 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 *---------------------------------------------------------------------------*/ 00034 00035 #include "cmsis_os.h" 00036 #include "stm32l1xx_rcc.h" 00037 00038 00039 /*---------------------------------------------------------------------------- 00040 * RTX User configuration part BEGIN 00041 *---------------------------------------------------------------------------*/ 00042 00043 //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- 00044 // 00045 // <h>Thread Configuration 00046 // ======================= 00047 // 00048 // <o>Number of concurrent running threads <0-250> 00049 // <i> Defines max. number of threads that will run at the same time. 00050 // counting "main", but not counting "osTimerThread" 00051 // <i> Default: 6 00052 #ifndef OS_TASKCNT 00053 # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC4337) || defined(TARGET_LPC1347) || defined(TARGET_K64F) || defined(TARGET_STM32F401RE)\ 00054 || defined(TARGET_KL46Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68) || defined(TARGET_NRF51822) || defined(TARGET_STM32F411RE) || defined(TARGET_NUCLEO_L152RE) 00055 # define OS_TASKCNT 14 00056 # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) \ 00057 || defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_KL05Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8) 00058 # define OS_TASKCNT 6 00059 # else 00060 # error "no target defined" 00061 # endif 00062 #endif 00063 00064 // <o>Scheduler (+ interrupts) stack size [bytes] <64-4096:8><#/4> 00065 #ifndef OS_SCHEDULERSTKSIZE 00066 # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC4337) || defined(TARGET_LPC1347) || defined(TARGET_K64F) || defined(TARGET_STM32F401RE)\ 00067 || defined(TARGET_KL46Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68) || defined(TARGET_NRF51822) || defined(TARGET_STM32F411RE) || defined(TARGET_NUCLEO_L152RE) 00068 # define OS_SCHEDULERSTKSIZE 256 00069 # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) \ 00070 || defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_KL05Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8) 00071 # define OS_SCHEDULERSTKSIZE 128 00072 # else 00073 # error "no target defined" 00074 # endif 00075 #endif 00076 00077 // <o>Idle stack size [bytes] <64-4096:8><#/4> 00078 // <i> Defines default stack size for the Idle thread. 00079 #ifndef OS_IDLESTKSIZE 00080 #define OS_IDLESTKSIZE 128 00081 #endif 00082 00083 // <o>Timer Thread stack size [bytes] <64-4096:8><#/4> 00084 // <i> Defines stack size for Timer thread. 00085 // <i> Default: 200 00086 #ifndef OS_TIMERSTKSZ 00087 #define OS_TIMERSTKSZ WORDS_STACK_SIZE 00088 #endif 00089 00090 // <q>Check for stack overflow 00091 // <i> Includes the stack checking code for stack overflow. 00092 // <i> Note that additional code reduces the Kernel performance. 00093 #ifndef OS_STKCHECK 00094 #define OS_STKCHECK 1 00095 #endif 00096 00097 // <o>Processor mode for thread execution 00098 // <0=> Unprivileged mode 00099 // <1=> Privileged mode 00100 // <i> Default: Privileged mode 00101 #ifndef OS_RUNPRIV 00102 #define OS_RUNPRIV 1 00103 #endif 00104 00105 // </h> 00106 // <h>SysTick Timer Configuration 00107 // ============================== 00108 // 00109 // <o>Timer clock value [Hz] <1-1000000000> 00110 // <i> Defines the timer clock value. 00111 // <i> Default: 6000000 (6MHz) 00112 #ifndef OS_CLOCK 00113 # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) 00114 # define OS_CLOCK 96000000 00115 00116 # elif defined(TARGET_LPC1347) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) 00117 # define OS_CLOCK 72000000 00118 00119 # 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) 00120 # define OS_CLOCK 48000000 00121 00122 # elif defined(TARGET_LPC812) 00123 # define OS_CLOCK 36000000 00124 00125 # elif defined(TARGET_STM32F100RB) 00126 # define OS_CLOCK 24000000 00127 00128 # elif defined(TARGET_LPC4088) || defined(TARGET_K64F) 00129 # define OS_CLOCK 120000000 00130 00131 # elif defined(TARGET_LPC4337) 00132 # define OS_CLOCK 204000000 00133 00134 # elif defined(TARGET_STM32F407) || defined(TARGET_F407VG) 00135 # define OS_CLOCK 168000000 00136 00137 # elif defined(TARGET_NRF51822) 00138 # define OS_CLOCK 16000000 00139 00140 # elif defined(TARGET_STM32F401RE) 00141 # define OS_CLOCK 84000000 00142 00143 # elif defined(TARGET_STM32F411RE) 00144 # define OS_CLOCK 100000000 00145 00146 # elif defined(TARGET_NUCLEO_L152RE) 00147 # define OS_CLOCK 32000000 00148 00149 # else 00150 # error "no target defined" 00151 # endif 00152 #endif 00153 00154 // <o>Timer tick value [us] <1-1000000> 00155 // <i> Defines the timer tick value. 00156 // <i> Default: 1000 (1ms) 00157 #ifndef OS_TICK 00158 #define OS_TICK 1000 00159 #endif 00160 00161 // </h> 00162 00163 // <h>System Configuration 00164 // ======================= 00165 // 00166 // <e>Round-Robin Thread switching 00167 // =============================== 00168 // 00169 // <i> Enables Round-Robin Thread switching. 00170 #ifndef OS_ROBIN 00171 #define OS_ROBIN 1 00172 #endif 00173 00174 // <o>Round-Robin Timeout [ticks] <1-1000> 00175 // <i> Defines how long a thread will execute before a thread switch. 00176 // <i> Default: 5 00177 #ifndef OS_ROBINTOUT 00178 #define OS_ROBINTOUT 5 00179 #endif 00180 00181 // </e> 00182 00183 // <e>User Timers 00184 // ============== 00185 // <i> Enables user Timers 00186 #ifndef OS_TIMERS 00187 #define OS_TIMERS 1 00188 #endif 00189 00190 // <o>Timer Thread Priority 00191 // <1=> Low 00192 // <2=> Below Normal 00193 // <3=> Normal 00194 // <4=> Above Normal 00195 // <5=> High 00196 // <6=> Realtime (highest) 00197 // <i> Defines priority for Timer Thread 00198 // <i> Default: High 00199 #ifndef OS_TIMERPRIO 00200 #define OS_TIMERPRIO 5 00201 #endif 00202 00203 // <o>Timer Callback Queue size <1-32> 00204 // <i> Number of concurrent active timer callback functions. 00205 // <i> Default: 4 00206 #ifndef OS_TIMERCBQSZ 00207 #define OS_TIMERCBQS 4 00208 #endif 00209 00210 // </e> 00211 00212 // <o>ISR FIFO Queue size<4=> 4 entries <8=> 8 entries 00213 // <12=> 12 entries <16=> 16 entries 00214 // <24=> 24 entries <32=> 32 entries 00215 // <48=> 48 entries <64=> 64 entries 00216 // <96=> 96 entries 00217 // <i> ISR functions store requests to this buffer, 00218 // <i> when they are called from the interrupt handler. 00219 // <i> Default: 16 entries 00220 #ifndef OS_FIFOSZ 00221 #define OS_FIFOSZ 16 00222 #endif 00223 00224 // </h> 00225 00226 //------------- <<< end of configuration section >>> ----------------------- 00227 00228 // Standard library system mutexes 00229 // =============================== 00230 // Define max. number system mutexes that are used to protect 00231 // the arm standard runtime library. For microlib they are not used. 00232 #ifndef OS_MUTEXCNT 00233 #define OS_MUTEXCNT 12 00234 #endif 00235 00236 /*---------------------------------------------------------------------------- 00237 * RTX User configuration part END 00238 *---------------------------------------------------------------------------*/ 00239 00240 #define OS_TRV ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1) 00241 00242 00243 /*---------------------------------------------------------------------------- 00244 * OS Idle daemon 00245 *---------------------------------------------------------------------------*/ 00246 void os_idle_demon (void) { 00247 /* The idle demon is a system thread, running when no other thread is */ 00248 /* ready to run. */ 00249 00250 /* Sleep: ideally, we should put the chip to sleep. 00251 Unfortunately, this usually requires disconnecting the interface chip (debugger). 00252 This can be done, but it would break the local file system. 00253 */ 00254 for (;;) { 00255 RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); 00256 // Request to enter SLEEP mode with regulator ON 00257 PWR_EnterSleepMode(PWR_Regulator_ON, PWR_SLEEPEntry_WFI); //sleep(); 00258 } 00259 } 00260 00261 /*---------------------------------------------------------------------------- 00262 * RTX Errors 00263 *---------------------------------------------------------------------------*/ 00264 extern void mbed_die(void); 00265 00266 void os_error (uint32_t err_code) { 00267 /* This function is called when a runtime error is detected. Parameter */ 00268 /* 'err_code' holds the runtime error code (defined in RTX_Conf.h). */ 00269 mbed_die(); 00270 } 00271 00272 void sysThreadError(osStatus status) { 00273 if (status != osOK) { 00274 mbed_die(); 00275 } 00276 } 00277 00278 /*---------------------------------------------------------------------------- 00279 * RTX Configuration Functions 00280 *---------------------------------------------------------------------------*/ 00281 00282 #include "RTX_CM_lib.h" 00283 00284 /*---------------------------------------------------------------------------- 00285 * end of file 00286 *---------------------------------------------------------------------------*/ 00287
Generated on Thu Jul 14 2022 02:41:33 by
![doxygen](doxygen.png)