Maintain legacy RTOS behavior before mbed-5
Fork of mbed-rtos by
rtx/TARGET_CORTEX_A/RTX_Conf_CA.c@59:28712e303960, 2015-01-06 (annotated)
- Committer:
- mbed_official
- Date:
- Tue Jan 06 16:16:03 2015 +0000
- Revision:
- 59:28712e303960
- Parent:
- 49:77c8e4604045
- Child:
- 61:9387d4c49609
Synchronized with git revision 245a60b29caabb42eabdd19658eeac7c3f68313b
Full URL: https://github.com/mbedmicro/mbed/commit/245a60b29caabb42eabdd19658eeac7c3f68313b/
NUCLEO_F072RB/F091RC - adding target to rtos lib and exporter for coide and gcc_arm
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 48:e9a2c7cb57a4 | 1 | /*---------------------------------------------------------------------------- |
mbed_official | 48:e9a2c7cb57a4 | 2 | * RL-ARM - RTX |
mbed_official | 48:e9a2c7cb57a4 | 3 | *---------------------------------------------------------------------------- |
mbed_official | 48:e9a2c7cb57a4 | 4 | * Name: RTX_Conf_CM.C |
mbed_official | 48:e9a2c7cb57a4 | 5 | * Purpose: Configuration of CMSIS RTX Kernel |
mbed_official | 48:e9a2c7cb57a4 | 6 | * Rev.: V4.60 |
mbed_official | 48:e9a2c7cb57a4 | 7 | *---------------------------------------------------------------------------- |
mbed_official | 48:e9a2c7cb57a4 | 8 | * |
mbed_official | 48:e9a2c7cb57a4 | 9 | * Copyright (c) 1999-2009 KEIL, 2009-2013 ARM Germany GmbH |
mbed_official | 48:e9a2c7cb57a4 | 10 | * All rights reserved. |
mbed_official | 48:e9a2c7cb57a4 | 11 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 48:e9a2c7cb57a4 | 12 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 48:e9a2c7cb57a4 | 13 | * - Redistributions of source code must retain the above copyright |
mbed_official | 48:e9a2c7cb57a4 | 14 | * notice, this list of conditions and the following disclaimer. |
mbed_official | 48:e9a2c7cb57a4 | 15 | * - Redistributions in binary form must reproduce the above copyright |
mbed_official | 48:e9a2c7cb57a4 | 16 | * notice, this list of conditions and the following disclaimer in the |
mbed_official | 48:e9a2c7cb57a4 | 17 | * documentation and/or other materials provided with the distribution. |
mbed_official | 48:e9a2c7cb57a4 | 18 | * - Neither the name of ARM nor the names of its contributors may be used |
mbed_official | 48:e9a2c7cb57a4 | 19 | * to endorse or promote products derived from this software without |
mbed_official | 48:e9a2c7cb57a4 | 20 | * specific prior written permission. |
mbed_official | 48:e9a2c7cb57a4 | 21 | * |
mbed_official | 48:e9a2c7cb57a4 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 48:e9a2c7cb57a4 | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 48:e9a2c7cb57a4 | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
mbed_official | 48:e9a2c7cb57a4 | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
mbed_official | 48:e9a2c7cb57a4 | 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
mbed_official | 48:e9a2c7cb57a4 | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
mbed_official | 48:e9a2c7cb57a4 | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
mbed_official | 48:e9a2c7cb57a4 | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
mbed_official | 48:e9a2c7cb57a4 | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
mbed_official | 48:e9a2c7cb57a4 | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
mbed_official | 48:e9a2c7cb57a4 | 32 | * POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 48:e9a2c7cb57a4 | 33 | *---------------------------------------------------------------------------*/ |
mbed_official | 48:e9a2c7cb57a4 | 34 | |
mbed_official | 48:e9a2c7cb57a4 | 35 | #include "cmsis_os.h" |
mbed_official | 48:e9a2c7cb57a4 | 36 | |
mbed_official | 48:e9a2c7cb57a4 | 37 | /*---------------------------------------------------------------------------- |
mbed_official | 48:e9a2c7cb57a4 | 38 | * RTX User configuration part BEGIN |
mbed_official | 48:e9a2c7cb57a4 | 39 | *---------------------------------------------------------------------------*/ |
mbed_official | 48:e9a2c7cb57a4 | 40 | |
mbed_official | 48:e9a2c7cb57a4 | 41 | //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- |
mbed_official | 48:e9a2c7cb57a4 | 42 | // |
mbed_official | 48:e9a2c7cb57a4 | 43 | // <h>Thread Configuration |
mbed_official | 48:e9a2c7cb57a4 | 44 | // ======================= |
mbed_official | 48:e9a2c7cb57a4 | 45 | // |
mbed_official | 48:e9a2c7cb57a4 | 46 | // <o>Number of concurrent running threads <0-250> |
mbed_official | 48:e9a2c7cb57a4 | 47 | // <i> Defines max. number of threads that will run at the same time. |
mbed_official | 48:e9a2c7cb57a4 | 48 | // <i> Default: 6 |
mbed_official | 48:e9a2c7cb57a4 | 49 | #ifndef OS_TASKCNT |
mbed_official | 48:e9a2c7cb57a4 | 50 | #define OS_TASKCNT 25 |
mbed_official | 48:e9a2c7cb57a4 | 51 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 52 | |
mbed_official | 48:e9a2c7cb57a4 | 53 | // <o>Default Thread stack size [bytes] <64-4096:8><#/4> |
mbed_official | 48:e9a2c7cb57a4 | 54 | // <i> Defines default stack size for threads with osThreadDef stacksz = 0 |
mbed_official | 48:e9a2c7cb57a4 | 55 | // <i> Default: 200 |
mbed_official | 48:e9a2c7cb57a4 | 56 | #ifndef OS_STKSIZE |
mbed_official | 48:e9a2c7cb57a4 | 57 | #define OS_STKSIZE 200 |
mbed_official | 48:e9a2c7cb57a4 | 58 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 59 | |
mbed_official | 48:e9a2c7cb57a4 | 60 | // <o>Main Thread stack size [bytes] <64-4096:8><#/4> |
mbed_official | 48:e9a2c7cb57a4 | 61 | // <i> Defines stack size for main thread. |
mbed_official | 48:e9a2c7cb57a4 | 62 | // <i> Default: 200 |
mbed_official | 48:e9a2c7cb57a4 | 63 | #ifndef OS_MAINSTKSIZE |
mbed_official | 48:e9a2c7cb57a4 | 64 | #define OS_MAINSTKSIZE 512 |
mbed_official | 48:e9a2c7cb57a4 | 65 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 66 | |
mbed_official | 48:e9a2c7cb57a4 | 67 | // <o>Number of threads with user-provided stack size <0-250> |
mbed_official | 48:e9a2c7cb57a4 | 68 | // <i> Defines the number of threads with user-provided stack size. |
mbed_official | 48:e9a2c7cb57a4 | 69 | // <i> Default: 0 |
mbed_official | 48:e9a2c7cb57a4 | 70 | #ifndef OS_PRIVCNT |
mbed_official | 48:e9a2c7cb57a4 | 71 | #define OS_PRIVCNT 8 |
mbed_official | 48:e9a2c7cb57a4 | 72 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 73 | |
mbed_official | 48:e9a2c7cb57a4 | 74 | // <o>Total stack size [bytes] for threads with user-provided stack size <0-4096:8><#/4> |
mbed_official | 48:e9a2c7cb57a4 | 75 | // <i> Defines the combined stack size for threads with user-provided stack size. |
mbed_official | 48:e9a2c7cb57a4 | 76 | // <i> Default: 0 |
mbed_official | 48:e9a2c7cb57a4 | 77 | #ifndef OS_PRIVSTKSIZE |
mbed_official | 48:e9a2c7cb57a4 | 78 | #define OS_PRIVSTKSIZE 4096 |
mbed_official | 48:e9a2c7cb57a4 | 79 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 80 | |
mbed_official | 48:e9a2c7cb57a4 | 81 | // <q>Check for stack overflow |
mbed_official | 48:e9a2c7cb57a4 | 82 | // <i> Includes the stack checking code for stack overflow. |
mbed_official | 48:e9a2c7cb57a4 | 83 | // <i> Note that additional code reduces the Kernel performance. |
mbed_official | 48:e9a2c7cb57a4 | 84 | #ifndef OS_STKCHECK |
mbed_official | 48:e9a2c7cb57a4 | 85 | #define OS_STKCHECK 1 |
mbed_official | 48:e9a2c7cb57a4 | 86 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 87 | |
mbed_official | 48:e9a2c7cb57a4 | 88 | // <o>Processor mode for thread execution |
mbed_official | 48:e9a2c7cb57a4 | 89 | // <0=> Unprivileged mode |
mbed_official | 48:e9a2c7cb57a4 | 90 | // <1=> Privileged mode |
mbed_official | 48:e9a2c7cb57a4 | 91 | // <i> Default: Privileged mode |
mbed_official | 48:e9a2c7cb57a4 | 92 | #ifndef OS_RUNPRIV |
mbed_official | 59:28712e303960 | 93 | #define OS_RUNPRIV 1 |
mbed_official | 48:e9a2c7cb57a4 | 94 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 95 | |
mbed_official | 48:e9a2c7cb57a4 | 96 | // </h> |
mbed_official | 48:e9a2c7cb57a4 | 97 | |
mbed_official | 48:e9a2c7cb57a4 | 98 | // <h>RTX Kernel Timer Tick Configuration |
mbed_official | 48:e9a2c7cb57a4 | 99 | // ====================================== |
mbed_official | 48:e9a2c7cb57a4 | 100 | // <q> Use Cortex-M SysTick timer as RTX Kernel Timer |
mbed_official | 48:e9a2c7cb57a4 | 101 | // <i> Use the Cortex-M SysTick timer as a time-base for RTX. |
mbed_official | 48:e9a2c7cb57a4 | 102 | #ifndef OS_SYSTICK |
mbed_official | 48:e9a2c7cb57a4 | 103 | #define OS_SYSTICK 0 |
mbed_official | 48:e9a2c7cb57a4 | 104 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 105 | // |
mbed_official | 48:e9a2c7cb57a4 | 106 | // <o>Timer clock value [Hz] <1-1000000000> |
mbed_official | 48:e9a2c7cb57a4 | 107 | // <i> Defines the timer clock value. |
mbed_official | 48:e9a2c7cb57a4 | 108 | // <i> Default: 12000000 (12MHz) |
mbed_official | 48:e9a2c7cb57a4 | 109 | #ifndef OS_CLOCK |
mbed_official | 59:28712e303960 | 110 | # if defined(TARGET_RZ_A1H) |
mbed_official | 48:e9a2c7cb57a4 | 111 | #define OS_CLOCK 12000000 |
mbed_official | 59:28712e303960 | 112 | # else |
mbed_official | 59:28712e303960 | 113 | # error "no target defined" |
mbed_official | 59:28712e303960 | 114 | # endif |
mbed_official | 48:e9a2c7cb57a4 | 115 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 116 | |
mbed_official | 48:e9a2c7cb57a4 | 117 | // <o>Timer tick value [us] <1-1000000> |
mbed_official | 48:e9a2c7cb57a4 | 118 | // <i> Defines the timer tick value. |
mbed_official | 48:e9a2c7cb57a4 | 119 | // <i> Default: 1000 (1ms) |
mbed_official | 48:e9a2c7cb57a4 | 120 | #ifndef OS_TICK |
mbed_official | 48:e9a2c7cb57a4 | 121 | #define OS_TICK 1000 |
mbed_official | 48:e9a2c7cb57a4 | 122 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 123 | |
mbed_official | 48:e9a2c7cb57a4 | 124 | // </h> |
mbed_official | 48:e9a2c7cb57a4 | 125 | |
mbed_official | 48:e9a2c7cb57a4 | 126 | // <h>System Configuration |
mbed_official | 48:e9a2c7cb57a4 | 127 | // ======================= |
mbed_official | 48:e9a2c7cb57a4 | 128 | // |
mbed_official | 48:e9a2c7cb57a4 | 129 | // <e>Round-Robin Thread switching |
mbed_official | 48:e9a2c7cb57a4 | 130 | // =============================== |
mbed_official | 48:e9a2c7cb57a4 | 131 | // |
mbed_official | 48:e9a2c7cb57a4 | 132 | // <i> Enables Round-Robin Thread switching. |
mbed_official | 48:e9a2c7cb57a4 | 133 | #ifndef OS_ROBIN |
mbed_official | 48:e9a2c7cb57a4 | 134 | #define OS_ROBIN 1 |
mbed_official | 48:e9a2c7cb57a4 | 135 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 136 | |
mbed_official | 48:e9a2c7cb57a4 | 137 | // <o>Round-Robin Timeout [ticks] <1-1000> |
mbed_official | 48:e9a2c7cb57a4 | 138 | // <i> Defines how long a thread will execute before a thread switch. |
mbed_official | 48:e9a2c7cb57a4 | 139 | // <i> Default: 5 |
mbed_official | 48:e9a2c7cb57a4 | 140 | #ifndef OS_ROBINTOUT |
mbed_official | 48:e9a2c7cb57a4 | 141 | #define OS_ROBINTOUT 5 |
mbed_official | 48:e9a2c7cb57a4 | 142 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 143 | |
mbed_official | 48:e9a2c7cb57a4 | 144 | // </e> |
mbed_official | 48:e9a2c7cb57a4 | 145 | |
mbed_official | 48:e9a2c7cb57a4 | 146 | // <e>User Timers |
mbed_official | 48:e9a2c7cb57a4 | 147 | // ============== |
mbed_official | 48:e9a2c7cb57a4 | 148 | // <i> Enables user Timers |
mbed_official | 48:e9a2c7cb57a4 | 149 | #ifndef OS_TIMERS |
mbed_official | 48:e9a2c7cb57a4 | 150 | #define OS_TIMERS 1 |
mbed_official | 48:e9a2c7cb57a4 | 151 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 152 | |
mbed_official | 48:e9a2c7cb57a4 | 153 | // <o>Timer Thread Priority |
mbed_official | 48:e9a2c7cb57a4 | 154 | // <1=> Low |
mbed_official | 48:e9a2c7cb57a4 | 155 | // <2=> Below Normal <3=> Normal <4=> Above Normal |
mbed_official | 48:e9a2c7cb57a4 | 156 | // <5=> High |
mbed_official | 48:e9a2c7cb57a4 | 157 | // <6=> Realtime (highest) |
mbed_official | 48:e9a2c7cb57a4 | 158 | // <i> Defines priority for Timer Thread |
mbed_official | 48:e9a2c7cb57a4 | 159 | // <i> Default: High |
mbed_official | 48:e9a2c7cb57a4 | 160 | #ifndef OS_TIMERPRIO |
mbed_official | 48:e9a2c7cb57a4 | 161 | #define OS_TIMERPRIO 5 |
mbed_official | 48:e9a2c7cb57a4 | 162 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 163 | |
mbed_official | 48:e9a2c7cb57a4 | 164 | // <o>Timer Thread stack size [bytes] <64-4096:8><#/4> |
mbed_official | 48:e9a2c7cb57a4 | 165 | // <i> Defines stack size for Timer thread. |
mbed_official | 48:e9a2c7cb57a4 | 166 | // <i> Default: 200 |
mbed_official | 48:e9a2c7cb57a4 | 167 | #ifndef OS_TIMERSTKSZ |
mbed_official | 59:28712e303960 | 168 | #define OS_TIMERSTKSZ WORDS_STACK_SIZE |
mbed_official | 48:e9a2c7cb57a4 | 169 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 170 | |
mbed_official | 48:e9a2c7cb57a4 | 171 | // <o>Timer Callback Queue size <1-32> |
mbed_official | 48:e9a2c7cb57a4 | 172 | // <i> Number of concurrent active timer callback functions. |
mbed_official | 48:e9a2c7cb57a4 | 173 | // <i> Default: 4 |
mbed_official | 48:e9a2c7cb57a4 | 174 | #ifndef OS_TIMERCBQS |
mbed_official | 48:e9a2c7cb57a4 | 175 | #define OS_TIMERCBQS 4 |
mbed_official | 48:e9a2c7cb57a4 | 176 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 177 | |
mbed_official | 48:e9a2c7cb57a4 | 178 | // </e> |
mbed_official | 48:e9a2c7cb57a4 | 179 | |
mbed_official | 48:e9a2c7cb57a4 | 180 | // <o>ISR FIFO Queue size<4=> 4 entries <8=> 8 entries |
mbed_official | 48:e9a2c7cb57a4 | 181 | // <12=> 12 entries <16=> 16 entries |
mbed_official | 48:e9a2c7cb57a4 | 182 | // <24=> 24 entries <32=> 32 entries |
mbed_official | 48:e9a2c7cb57a4 | 183 | // <48=> 48 entries <64=> 64 entries |
mbed_official | 48:e9a2c7cb57a4 | 184 | // <96=> 96 entries |
mbed_official | 48:e9a2c7cb57a4 | 185 | // <i> ISR functions store requests to this buffer, |
mbed_official | 48:e9a2c7cb57a4 | 186 | // <i> when they are called from the interrupt handler. |
mbed_official | 48:e9a2c7cb57a4 | 187 | // <i> Default: 16 entries |
mbed_official | 48:e9a2c7cb57a4 | 188 | #ifndef OS_FIFOSZ |
mbed_official | 48:e9a2c7cb57a4 | 189 | #define OS_FIFOSZ 16 |
mbed_official | 48:e9a2c7cb57a4 | 190 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 191 | |
mbed_official | 48:e9a2c7cb57a4 | 192 | // </h> |
mbed_official | 48:e9a2c7cb57a4 | 193 | |
mbed_official | 48:e9a2c7cb57a4 | 194 | //------------- <<< end of configuration section >>> ----------------------- |
mbed_official | 48:e9a2c7cb57a4 | 195 | |
mbed_official | 48:e9a2c7cb57a4 | 196 | // Standard library system mutexes |
mbed_official | 48:e9a2c7cb57a4 | 197 | // =============================== |
mbed_official | 48:e9a2c7cb57a4 | 198 | // Define max. number system mutexes that are used to protect |
mbed_official | 48:e9a2c7cb57a4 | 199 | // the arm standard runtime library. For microlib they are not used. |
mbed_official | 48:e9a2c7cb57a4 | 200 | #ifndef OS_MUTEXCNT |
mbed_official | 59:28712e303960 | 201 | #define OS_MUTEXCNT 12 |
mbed_official | 48:e9a2c7cb57a4 | 202 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 203 | |
mbed_official | 48:e9a2c7cb57a4 | 204 | /*---------------------------------------------------------------------------- |
mbed_official | 48:e9a2c7cb57a4 | 205 | * RTX User configuration part END |
mbed_official | 48:e9a2c7cb57a4 | 206 | *---------------------------------------------------------------------------*/ |
mbed_official | 48:e9a2c7cb57a4 | 207 | |
mbed_official | 48:e9a2c7cb57a4 | 208 | #define OS_TRV ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1) |
mbed_official | 48:e9a2c7cb57a4 | 209 | |
mbed_official | 48:e9a2c7cb57a4 | 210 | |
mbed_official | 48:e9a2c7cb57a4 | 211 | /*---------------------------------------------------------------------------- |
mbed_official | 48:e9a2c7cb57a4 | 212 | * Global Functions |
mbed_official | 48:e9a2c7cb57a4 | 213 | *---------------------------------------------------------------------------*/ |
mbed_official | 48:e9a2c7cb57a4 | 214 | |
mbed_official | 48:e9a2c7cb57a4 | 215 | /*--------------------------- os_idle_demon ---------------------------------*/ |
mbed_official | 48:e9a2c7cb57a4 | 216 | |
mbed_official | 48:e9a2c7cb57a4 | 217 | void os_idle_demon (void) { |
mbed_official | 48:e9a2c7cb57a4 | 218 | /* The idle demon is a system thread, running when no other thread is */ |
mbed_official | 48:e9a2c7cb57a4 | 219 | /* ready to run. */ |
mbed_official | 48:e9a2c7cb57a4 | 220 | |
mbed_official | 48:e9a2c7cb57a4 | 221 | for (;;) { |
mbed_official | 48:e9a2c7cb57a4 | 222 | /* HERE: include optional user code to be executed when no thread runs.*/ |
mbed_official | 48:e9a2c7cb57a4 | 223 | } |
mbed_official | 48:e9a2c7cb57a4 | 224 | } |
mbed_official | 48:e9a2c7cb57a4 | 225 | |
mbed_official | 48:e9a2c7cb57a4 | 226 | #if (OS_SYSTICK == 0) // Functions for alternative timer as RTX kernel timer |
mbed_official | 48:e9a2c7cb57a4 | 227 | |
mbed_official | 48:e9a2c7cb57a4 | 228 | /*--------------------------- os_tick_init ----------------------------------*/ |
mbed_official | 48:e9a2c7cb57a4 | 229 | #ifdef TARGET_RZ_A1H |
mbed_official | 48:e9a2c7cb57a4 | 230 | #define OSTM0 (0xFCFEC000uL) /* OSTM0 */ |
mbed_official | 48:e9a2c7cb57a4 | 231 | #define OSTM1 (0xFCFEC400uL) /* OSTM1 */ |
mbed_official | 48:e9a2c7cb57a4 | 232 | #define CPG (0xFCFE0410uL) /* CPG */ |
mbed_official | 48:e9a2c7cb57a4 | 233 | |
mbed_official | 48:e9a2c7cb57a4 | 234 | #define CPGSTBCR5 (*((volatile unsigned char*)(CPG + 0x00000018uL))) |
mbed_official | 48:e9a2c7cb57a4 | 235 | |
mbed_official | 48:e9a2c7cb57a4 | 236 | #define OSTM0CMP (*((volatile unsigned long*)(OSTM0 + 0x00000000uL))) |
mbed_official | 48:e9a2c7cb57a4 | 237 | #define OSTM0CNT (*((volatile unsigned long*)(OSTM0 + 0x00000004uL))) |
mbed_official | 48:e9a2c7cb57a4 | 238 | #define OSTM0TE (*((volatile unsigned char*)(OSTM0 + 0x00000010uL))) |
mbed_official | 48:e9a2c7cb57a4 | 239 | #define OSTM0TS (*((volatile unsigned char*)(OSTM0 + 0x00000014uL))) |
mbed_official | 48:e9a2c7cb57a4 | 240 | #define OSTM0TT (*((volatile unsigned char*)(OSTM0 + 0x00000018uL))) |
mbed_official | 48:e9a2c7cb57a4 | 241 | #define OSTM0CTL (*((volatile unsigned char*)(OSTM0 + 0x00000020uL))) |
mbed_official | 48:e9a2c7cb57a4 | 242 | |
mbed_official | 48:e9a2c7cb57a4 | 243 | #define OSTM1CMP (*((volatile unsigned long*)(OSTM1 + 0x00000000uL))) |
mbed_official | 48:e9a2c7cb57a4 | 244 | #define OSTM1CNT (*((volatile unsigned long*)(OSTM1 + 0x00000004uL))) |
mbed_official | 48:e9a2c7cb57a4 | 245 | #define OSTM1TE (*((volatile unsigned char*)(OSTM1 + 0x00000010uL))) |
mbed_official | 48:e9a2c7cb57a4 | 246 | #define OSTM1TS (*((volatile unsigned char*)(OSTM1 + 0x00000014uL))) |
mbed_official | 48:e9a2c7cb57a4 | 247 | #define OSTM1TT (*((volatile unsigned char*)(OSTM1 + 0x00000018uL))) |
mbed_official | 48:e9a2c7cb57a4 | 248 | #define OSTM1CTL (*((volatile unsigned char*)(OSTM1 + 0x00000020uL))) |
mbed_official | 48:e9a2c7cb57a4 | 249 | |
mbed_official | 48:e9a2c7cb57a4 | 250 | #define CPG_STBCR5_BIT_MSTP51 (0x02u) /* OSTM0 */ |
mbed_official | 48:e9a2c7cb57a4 | 251 | #define CM1_RENESAS_RZ_A1_P0_CLK ( 32000000u) |
mbed_official | 48:e9a2c7cb57a4 | 252 | #define CM0_RENESAS_RZ_A1_P0_CLK ( 33333333u) |
mbed_official | 48:e9a2c7cb57a4 | 253 | |
mbed_official | 48:e9a2c7cb57a4 | 254 | typedef enum |
mbed_official | 48:e9a2c7cb57a4 | 255 | { |
mbed_official | 48:e9a2c7cb57a4 | 256 | IRQ_SGI0 = 0, |
mbed_official | 48:e9a2c7cb57a4 | 257 | IRQ_OSTMI0TINT = 134 |
mbed_official | 48:e9a2c7cb57a4 | 258 | } IRQn_Type; |
mbed_official | 48:e9a2c7cb57a4 | 259 | |
mbed_official | 48:e9a2c7cb57a4 | 260 | typedef void(*IRQHandler)(); |
mbed_official | 48:e9a2c7cb57a4 | 261 | |
mbed_official | 48:e9a2c7cb57a4 | 262 | extern void PendSV_Handler(uint32_t); |
mbed_official | 48:e9a2c7cb57a4 | 263 | extern void OS_Tick_Handler(uint32_t); |
mbed_official | 48:e9a2c7cb57a4 | 264 | extern uint32_t InterruptHandlerRegister (IRQn_Type irq, IRQHandler handler); |
mbed_official | 48:e9a2c7cb57a4 | 265 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 266 | |
mbed_official | 48:e9a2c7cb57a4 | 267 | // Initialize alternative hardware timer as RTX kernel timer |
mbed_official | 48:e9a2c7cb57a4 | 268 | // Return: IRQ number of the alternative hardware timer |
mbed_official | 48:e9a2c7cb57a4 | 269 | int os_tick_init (void) { |
mbed_official | 48:e9a2c7cb57a4 | 270 | #ifdef TARGET_RZ_A1H |
mbed_official | 48:e9a2c7cb57a4 | 271 | CPGSTBCR5 &= ~(CPG_STBCR5_BIT_MSTP51); /* enable OSTM0 clock */ |
mbed_official | 48:e9a2c7cb57a4 | 272 | |
mbed_official | 48:e9a2c7cb57a4 | 273 | OSTM0TT = 0x1; /* Stop the counter and clears the OSTM0TE bit. */ |
mbed_official | 48:e9a2c7cb57a4 | 274 | OSTM0CTL = 0x1; /* Interval timer mode. Interrupt enabled */ |
mbed_official | 48:e9a2c7cb57a4 | 275 | |
mbed_official | 48:e9a2c7cb57a4 | 276 | OSTM0CMP = (uint32_t)(((double)CM0_RENESAS_RZ_A1_P0_CLK*(double)OS_TICK)/1E6); |
mbed_official | 48:e9a2c7cb57a4 | 277 | |
mbed_official | 48:e9a2c7cb57a4 | 278 | OSTM0TS = 0x1; /* Start the counter and sets the OSTM0TE bit. */ |
mbed_official | 48:e9a2c7cb57a4 | 279 | |
mbed_official | 48:e9a2c7cb57a4 | 280 | InterruptHandlerRegister(IRQ_SGI0 , (IRQHandler)PendSV_Handler); |
mbed_official | 48:e9a2c7cb57a4 | 281 | InterruptHandlerRegister(IRQ_OSTMI0TINT, (IRQHandler)OS_Tick_Handler); |
mbed_official | 48:e9a2c7cb57a4 | 282 | |
mbed_official | 48:e9a2c7cb57a4 | 283 | |
mbed_official | 48:e9a2c7cb57a4 | 284 | return IRQ_OSTMI0TINT; /* Return IRQ number of timer (0..239) */ |
mbed_official | 48:e9a2c7cb57a4 | 285 | /* RTX will set and configure the interrupt */ |
mbed_official | 48:e9a2c7cb57a4 | 286 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 287 | } |
mbed_official | 48:e9a2c7cb57a4 | 288 | |
mbed_official | 48:e9a2c7cb57a4 | 289 | /*--------------------------- os_tick_irqack --------------------------------*/ |
mbed_official | 48:e9a2c7cb57a4 | 290 | |
mbed_official | 48:e9a2c7cb57a4 | 291 | // Acknowledge alternative hardware timer interrupt |
mbed_official | 48:e9a2c7cb57a4 | 292 | void os_tick_irqack (void) { |
mbed_official | 48:e9a2c7cb57a4 | 293 | /* ... */ |
mbed_official | 48:e9a2c7cb57a4 | 294 | } |
mbed_official | 48:e9a2c7cb57a4 | 295 | |
mbed_official | 48:e9a2c7cb57a4 | 296 | #endif // (OS_SYSTICK == 0) |
mbed_official | 48:e9a2c7cb57a4 | 297 | |
mbed_official | 48:e9a2c7cb57a4 | 298 | /*--------------------------- os_error --------------------------------------*/ |
mbed_official | 48:e9a2c7cb57a4 | 299 | extern void mbed_die(void); |
mbed_official | 48:e9a2c7cb57a4 | 300 | |
mbed_official | 48:e9a2c7cb57a4 | 301 | void os_error (uint32_t err_code) { |
mbed_official | 48:e9a2c7cb57a4 | 302 | /* This function is called when a runtime error is detected. Parameter */ |
mbed_official | 48:e9a2c7cb57a4 | 303 | /* 'err_code' holds the runtime error code (defined in RTL.H). */ |
mbed_official | 48:e9a2c7cb57a4 | 304 | mbed_die(); |
mbed_official | 48:e9a2c7cb57a4 | 305 | |
mbed_official | 48:e9a2c7cb57a4 | 306 | /* HERE: include optional code to be executed on runtime error. */ |
mbed_official | 48:e9a2c7cb57a4 | 307 | for (;;); |
mbed_official | 48:e9a2c7cb57a4 | 308 | } |
mbed_official | 48:e9a2c7cb57a4 | 309 | |
mbed_official | 48:e9a2c7cb57a4 | 310 | |
mbed_official | 48:e9a2c7cb57a4 | 311 | /*---------------------------------------------------------------------------- |
mbed_official | 48:e9a2c7cb57a4 | 312 | * RTX Configuration Functions |
mbed_official | 48:e9a2c7cb57a4 | 313 | *---------------------------------------------------------------------------*/ |
mbed_official | 48:e9a2c7cb57a4 | 314 | |
mbed_official | 48:e9a2c7cb57a4 | 315 | #include "RTX_CM_lib.h" |
mbed_official | 48:e9a2c7cb57a4 | 316 | |
mbed_official | 48:e9a2c7cb57a4 | 317 | /*---------------------------------------------------------------------------- |
mbed_official | 48:e9a2c7cb57a4 | 318 | * end of file |
mbed_official | 48:e9a2c7cb57a4 | 319 | *---------------------------------------------------------------------------*/ |