TEste

Dependencies:  

Dependents:   EtherTest2 Andar_Linha_Reta_Robo_Claw_v1

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RTX_Conf_CM.c Source File

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.20
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 
00037 
00038 /*----------------------------------------------------------------------------
00039  *      RTX User configuration part BEGIN
00040  *---------------------------------------------------------------------------*/
00041 
00042 //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
00043 //
00044 // <h>Thread Configuration
00045 // =======================
00046 //
00047 //   <o>Number of concurrent running threads <0-250>
00048 //   <i> Defines max. number of threads that will run at the same time.
00049 //       counting "main", but not counting "osTimerThread"
00050 //   <i> Default: 6
00051 #ifndef OS_TASKCNT
00052 #  if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
00053 #    define OS_TASKCNT         7
00054 #  elif defined(TARGET_LPC11U24)
00055 #    define OS_TASKCNT         3
00056 #  endif
00057 #endif
00058 
00059 //   <o>Number of threads with user-provided stack size <0-250>
00060 //   The stack of "main" and "osTimerThread" are calculated separately
00061 //   <i> Defines the number of threads with user-provided stack size.
00062 //   <i> Default: 0
00063 #ifndef OS_PRIVCNT
00064  #define OS_PRIVCNT         (OS_TASKCNT - 1)
00065 #endif
00066 
00067 //   <o>Default Thread stack size [bytes] <64-4096:8><#/4>
00068 //   <i> Defines default stack size for threads.
00069 //   <i> Default: 200
00070 #ifndef OS_STKSIZE
00071  #define OS_STKSIZE         WORDS_STACK_SIZE
00072 #endif
00073 
00074 //   <o>Main Thread stack size [bytes] <64-4096:8><#/4>
00075 //   <i> Defines stack size for main thread.
00076 //   <i> Default: 200
00077 #ifndef OS_MAINSTKSIZE
00078   #define OS_MAINSTKSIZE     WORDS_STACK_SIZE
00079 #endif
00080 
00081 // <q>Check for stack overflow
00082 // ===========================
00083 // <i> Includes the stack checking code for stack overflow.
00084 // <i> Note that additional code reduces the Kernel performance.
00085 #ifndef OS_STKCHECK
00086  #define OS_STKCHECK    1
00087 #endif
00088 
00089 // <q>Run in privileged mode
00090 // =========================
00091 // <i> Runs all Threads in privileged mode.
00092 // <i> Default: Unprivileged
00093 #ifndef OS_RUNPRIV
00094  #define OS_RUNPRIV     1
00095 #endif
00096 
00097 // </h>
00098 // <h>SysTick Timer Configuration
00099 // ==============================
00100 //
00101 //   <o>Timer clock value [Hz] <1-1000000000>
00102 //   <i> Defines the timer clock value.
00103 //   <i> Default: 6000000  (6MHz)
00104 #ifndef OS_CLOCK
00105 #  if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
00106 #    define OS_CLOCK       96000000
00107 #  elif defined(TARGET_LPC11U24)
00108 #    define OS_CLOCK       48000000
00109 #  endif
00110 #endif
00111 
00112 //   <o>Timer tick value [us] <1-1000000>
00113 //   <i> Defines the timer tick value.
00114 //   <i> Default: 1000  (1ms)
00115 #ifndef OS_TICK
00116  #define OS_TICK        1000
00117 #endif
00118 
00119 // </h>
00120 
00121 // <h>System Configuration
00122 // =======================
00123 //
00124 // <e>Round-Robin Thread switching
00125 // ===============================
00126 //
00127 // <i> Enables Round-Robin Thread switching.
00128 #ifndef OS_ROBIN
00129  #define OS_ROBIN       1
00130 #endif
00131 
00132 //   <o>Round-Robin Timeout [ticks] <1-1000>
00133 //   <i> Defines how long a thread will execute before a thread switch.
00134 //   <i> Default: 5
00135 #ifndef OS_ROBINTOUT
00136  #define OS_ROBINTOUT   5
00137 #endif
00138 
00139 // </e>
00140 
00141 // <e>User Timers
00142 // ==============
00143 //   <i> Enables user Timers
00144 #ifndef OS_TIMERS
00145  #define OS_TIMERS      1
00146 #endif
00147 
00148 //   <o>Timer Thread Priority
00149 //                        <1=> Low
00150 //                        <2=> Below Normal
00151 //                        <3=> Normal
00152 //                        <4=> Above Normal
00153 //                        <5=> High
00154 //                        <6=> Realtime
00155 //   <i> Defines priority for Timer Thread
00156 //   <i> Default: High
00157 #ifndef OS_TIMERPRIO
00158  #define OS_TIMERPRIO   5
00159 #endif
00160 
00161 //   <o>Timer Thread stack size [bytes] <64-4096:8><#/4>
00162 //   <i> Defines stack size for Timer thread.
00163 //   <i> Default: 200
00164 #ifndef OS_TIMERSTKSZ
00165  #define OS_TIMERSTKSZ  WORDS_STACK_SIZE
00166 #endif
00167 
00168 //   <o>Timer Callback Queue size <1-32>
00169 //   <i> Defines number of concurrent callbacks that will be queued.
00170 //   <i> Default: 4
00171 #ifndef OS_TIMERCBQSZ
00172  #define OS_TIMERCBQS   4
00173 #endif
00174 
00175 // </e>
00176 
00177 //   <o>ISR FIFO Queue size<4=>   4 entries  <8=>   8 entries
00178 //                         <12=> 12 entries  <16=> 16 entries
00179 //                         <24=> 24 entries  <32=> 32 entries
00180 //                         <48=> 48 entries  <64=> 64 entries
00181 //                         <96=> 96 entries
00182 //   <i> ISR functions store requests to this buffer,
00183 //   <i> when they are called from the iterrupt handler.
00184 //   <i> Default: 16 entries
00185 #ifndef OS_FIFOSZ
00186  #define OS_FIFOSZ      16
00187 #endif
00188 
00189 // </h>
00190 
00191 //------------- <<< end of configuration section >>> -----------------------
00192 
00193 // Standard library system mutexes
00194 // ===============================
00195 //  Define max. number system mutexes that are used to protect 
00196 //  the arm standard runtime library. For microlib they are not used.
00197 #ifndef OS_MUTEXCNT
00198  #define OS_MUTEXCNT    8
00199 #endif
00200 
00201 /*----------------------------------------------------------------------------
00202  *      RTX User configuration part END
00203  *---------------------------------------------------------------------------*/
00204 
00205 #define OS_TRV          ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
00206 
00207 
00208 /*----------------------------------------------------------------------------
00209  *      OS Idle daemon
00210  *---------------------------------------------------------------------------*/
00211 void os_idle_demon (void) {
00212   /* The idle demon is a system thread, running when no other thread is      */
00213   /* ready to run.                                                           */
00214   
00215   /* Sleep: ideally, we should put the chip to sleep.
00216      Unfortunately, this usually requires disconnecting the interface chip (debugger).
00217      This can be done, but it would break the local file system.
00218   */
00219   for (;;) {
00220       // sleep();
00221   }
00222 }
00223 
00224 /*----------------------------------------------------------------------------
00225  *      RTX Errors
00226  *---------------------------------------------------------------------------*/
00227 extern void mbed_die(void);
00228 
00229 void os_error (uint32_t err_code) {
00230     /* This function is called when a runtime error is detected. Parameter     */
00231     /* 'err_code' holds the runtime error code (defined in RTX_Config.h).      */
00232     mbed_die();
00233 }
00234 
00235 void sysThreadError(osStatus status) {
00236     if (status != osOK) {
00237         mbed_die();
00238     }
00239 }
00240 
00241 /*----------------------------------------------------------------------------
00242  *      RTX Configuration Functions
00243  *---------------------------------------------------------------------------*/
00244 
00245 #include "RTX_CM_lib.h"
00246 
00247 /*----------------------------------------------------------------------------
00248  * end of file
00249  *---------------------------------------------------------------------------*/