Donatien Garnier / Mbed 2 deprecated CPPSocketsTest

Dependencies:   mbed EthernetInterface

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