|
| 1 | +/*---------------------------------------------------------------------------- |
| 2 | + * RL-ARM - RTX |
| 3 | + *---------------------------------------------------------------------------- |
| 4 | + * Name: RTX_CONFIG.C |
| 5 | + * Purpose: Configuration of RTX Kernel for Cortex-M |
| 6 | + * Rev.: V4.70 |
| 7 | + *---------------------------------------------------------------------------- |
| 8 | + * This code is part of the RealView Run-Time Library. |
| 9 | + * Copyright (c) 2004-2013 KEIL - An ARM Company. All rights reserved. |
| 10 | + *---------------------------------------------------------------------------*/ |
| 11 | + |
| 12 | +#include <RTL.h> |
| 13 | + |
| 14 | +/*---------------------------------------------------------------------------- |
| 15 | + * RTX User configuration part BEGIN |
| 16 | + *---------------------------------------------------------------------------*/ |
| 17 | + |
| 18 | +//-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- |
| 19 | +// |
| 20 | +// <h>Task Configuration |
| 21 | +// ===================== |
| 22 | +// |
| 23 | +// <o>Number of concurrent running tasks <0-250> |
| 24 | +// <i> Define max. number of tasks that will run at the same time. |
| 25 | +// <i> Default: 6 |
| 26 | +#ifndef OS_TASKCNT |
| 27 | + #define OS_TASKCNT 10 |
| 28 | +#endif |
| 29 | + |
| 30 | +// <o>Number of tasks with user-provided stack <0-250> |
| 31 | +// <i> Define the number of tasks that will use a bigger stack. |
| 32 | +// <i> The memory space for the stack is provided by the user. |
| 33 | +// <i> Default: 0 |
| 34 | +#ifndef OS_PRIVCNT |
| 35 | + #define OS_PRIVCNT 0 |
| 36 | +#endif |
| 37 | + |
| 38 | +// <o>Task stack size [bytes] <20-4096:8><#/4> |
| 39 | +// <i> Set the stack size for tasks which is assigned by the system. |
| 40 | +// <i> Default: 512 |
| 41 | +#ifndef OS_STKSIZE |
| 42 | + #define OS_STKSIZE 64 |
| 43 | +#endif |
| 44 | + |
| 45 | +// <q>Check for the stack overflow |
| 46 | +// =============================== |
| 47 | +// <i> Include the stack checking code for a stack overflow. |
| 48 | +// <i> Note that additional code reduces the Kernel performance. |
| 49 | +#ifndef OS_STKCHECK |
| 50 | + #define OS_STKCHECK 1 |
| 51 | +#endif |
| 52 | + |
| 53 | +// <q>Run in privileged mode |
| 54 | +// ========================= |
| 55 | +// <i> Run all Tasks in privileged mode. |
| 56 | +// <i> Default: Unprivileged |
| 57 | +#ifndef OS_RUNPRIV |
| 58 | + #define OS_RUNPRIV 0 |
| 59 | +#endif |
| 60 | + |
| 61 | +// </h> |
| 62 | +// <h>Tick Timer Configuration |
| 63 | +// ============================= |
| 64 | +// <o>Hardware timer <0=> Core SysTick <1=> Peripheral Timer |
| 65 | +// <i> Define the on-chip timer used as a time-base for RTX. |
| 66 | +// <i> Default: Core SysTick |
| 67 | +#ifndef OS_TIMER |
| 68 | + #define OS_TIMER 0 |
| 69 | +#endif |
| 70 | + |
| 71 | +// <o>Timer clock value [Hz] <1-1000000000> |
| 72 | +// <i> Set the timer clock value for selected timer. |
| 73 | +// <i> Default: 6000000 (6MHz) |
| 74 | +#ifndef OS_CLOCK |
| 75 | + #define OS_CLOCK 16000000 |
| 76 | +#endif |
| 77 | + |
| 78 | +// <o>Timer tick value [us] <1-1000000> |
| 79 | +// <i> Set the timer tick value for selected timer. |
| 80 | +// <i> Default: 10000 (10ms) |
| 81 | +#ifndef OS_TICK |
| 82 | + #define OS_TICK 200 |
| 83 | +#endif |
| 84 | + |
| 85 | +// </h> |
| 86 | + |
| 87 | +// <h>System Configuration |
| 88 | +// ======================= |
| 89 | +// <e>Round-Robin Task switching |
| 90 | +// ============================= |
| 91 | +// <i> Enable Round-Robin Task switching. |
| 92 | +#ifndef OS_ROBIN |
| 93 | + #define OS_ROBIN 0 |
| 94 | +#endif |
| 95 | + |
| 96 | +// <o>Round-Robin Timeout [ticks] <1-1000> |
| 97 | +// <i> Define how long a task will execute before a task switch. |
| 98 | +// <i> Default: 5 |
| 99 | +#ifndef OS_ROBINTOUT |
| 100 | + #define OS_ROBINTOUT 5 |
| 101 | +#endif |
| 102 | + |
| 103 | +// </e> |
| 104 | + |
| 105 | +// <o>Number of user timers <0-250> |
| 106 | +// <i> Define max. number of user timers that will run at the same time. |
| 107 | +// <i> Default: 0 (User timers disabled) |
| 108 | +#ifndef OS_TIMERCNT |
| 109 | + #define OS_TIMERCNT 0 |
| 110 | +#endif |
| 111 | + |
| 112 | +// <o>ISR FIFO Queue size<4=> 4 entries <8=> 8 entries |
| 113 | +// <12=> 12 entries <16=> 16 entries |
| 114 | +// <24=> 24 entries <32=> 32 entries |
| 115 | +// <48=> 48 entries <64=> 64 entries |
| 116 | +// <96=> 96 entries |
| 117 | +// <i> ISR functions store requests to this buffer, |
| 118 | +// <i> when they are called from the iterrupt handler. |
| 119 | +// <i> Default: 16 entries |
| 120 | +#ifndef OS_FIFOSZ |
| 121 | + #define OS_FIFOSZ 16 |
| 122 | +#endif |
| 123 | + |
| 124 | +// </h> |
| 125 | + |
| 126 | +//------------- <<< end of configuration section >>> ----------------------- |
| 127 | + |
| 128 | +// Standard library system mutexes |
| 129 | +// =============================== |
| 130 | +// Define max. number system mutexes that are used to protect |
| 131 | +// the arm standard runtime library. For microlib they are not used. |
| 132 | +#ifndef OS_MUTEXCNT |
| 133 | + #define OS_MUTEXCNT 8 |
| 134 | +#endif |
| 135 | + |
| 136 | +/*---------------------------------------------------------------------------- |
| 137 | + * RTX User configuration part END |
| 138 | + *---------------------------------------------------------------------------*/ |
| 139 | + |
| 140 | +#define OS_TRV ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1) |
| 141 | + |
| 142 | +/*---------------------------------------------------------------------------- |
| 143 | + * Global Functions |
| 144 | + *---------------------------------------------------------------------------*/ |
| 145 | + |
| 146 | +/*--------------------------- os_idle_demon ---------------------------------*/ |
| 147 | + |
| 148 | +__task void os_idle_demon (void) { |
| 149 | + /* The idle demon is a system task, running when no other task is ready */ |
| 150 | + /* to run. The 'os_xxx' function calls are not allowed from this task. */ |
| 151 | + |
| 152 | + for (;;) { |
| 153 | + /* HERE: include optional user code to be executed when no task runs.*/ |
| 154 | + } |
| 155 | +} |
| 156 | + |
| 157 | +/*--------------------------- os_tick_init ----------------------------------*/ |
| 158 | + |
| 159 | +#if (OS_TIMER != 0) |
| 160 | +int os_tick_init (void) { |
| 161 | + /* Initialize hardware timer as system tick timer. */ |
| 162 | + /* ... */ |
| 163 | + return (-1); /* Return IRQ number of timer (0..239) */ |
| 164 | +} |
| 165 | +#endif |
| 166 | + |
| 167 | +/*--------------------------- os_tick_irqack --------------------------------*/ |
| 168 | + |
| 169 | +#if (OS_TIMER != 0) |
| 170 | +void os_tick_irqack (void) { |
| 171 | + /* Acknowledge timer interrupt. */ |
| 172 | + /* ... */ |
| 173 | +} |
| 174 | +#endif |
| 175 | + |
| 176 | +/*--------------------------- os_tmr_call -----------------------------------*/ |
| 177 | + |
| 178 | +void os_tmr_call (U16 info) { |
| 179 | + /* This function is called when the user timer has expired. Parameter */ |
| 180 | + /* 'info' holds the value, defined when the timer was created. */ |
| 181 | + while(1){} |
| 182 | + /* HERE: include optional user code to be executed on timeout. */ |
| 183 | +} |
| 184 | + |
| 185 | + |
| 186 | +/*--------------------------- os_error --------------------------------------*/ |
| 187 | + |
| 188 | +void os_error (U32 err_code) { |
| 189 | + /* This function is called when a runtime error is detected. Parameter */ |
| 190 | + /* 'err_code' holds the runtime error code (defined in RTL.H). */ |
| 191 | + |
| 192 | + /* HERE: include optional code to be executed on runtime error. */ |
| 193 | + for (;;); |
| 194 | +} |
| 195 | + |
| 196 | + |
| 197 | +/*---------------------------------------------------------------------------- |
| 198 | + * RTX Configuration Functions |
| 199 | + *---------------------------------------------------------------------------*/ |
| 200 | + |
| 201 | +#include <RTX_lib.c> |
| 202 | + |
| 203 | +/*---------------------------------------------------------------------------- |
| 204 | + * end of file |
| 205 | + *---------------------------------------------------------------------------*/ |
0 commit comments