mbed client lightswitch demo

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by Austin Blackstone

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

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