Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

Dependents:   denki-yohou_b TestY201 Network-RTOS NTPClient_HelloWorld ... more

Deprecated

This is the mbed 2 rtos library. mbed OS 5 integrates the mbed library with mbed-rtos. With this, we have provided thread safety for all mbed APIs. If you'd like to learn about using mbed OS 5, please see the docs.

Committer:
<>
Date:
Thu Sep 01 15:13:42 2016 +0100
Revision:
121:3da5f554d8bf
Parent:
92:bc9729798a19
RTOS rev121

Compatible with the mbed library v125

Changes:
- K64F: Revert to hardcoded stack pointer in RTX.
- Adding NCS36510 support.
- Add MAX32620 target support.
- Fix implicit declaration of function 'atexit'.

Who changed what in which revision?

UserRevisionLine numberNew 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: RT_TIME.C
mbed_official 48:e9a2c7cb57a4 5 * Purpose: Delay and interval wait functions
mbed_official 92:bc9729798a19 6 * Rev.: V4.70
mbed_official 48:e9a2c7cb57a4 7 *----------------------------------------------------------------------------
mbed_official 48:e9a2c7cb57a4 8 *
mbed_official 92:bc9729798a19 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 68:d3d0e710b443 18 * - Neither the name of ARM nor the names of its contributors may be used
mbed_official 68:d3d0e710b443 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 68:d3d0e710b443 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 68:d3d0e710b443 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 68:d3d0e710b443 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
mbed_official 68:d3d0e710b443 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
mbed_official 68:d3d0e710b443 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
mbed_official 68:d3d0e710b443 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 "rt_TypeDef.h"
mbed_official 48:e9a2c7cb57a4 36 #include "RTX_Config.h"
mbed_official 48:e9a2c7cb57a4 37 #include "rt_Task.h"
mbed_official 48:e9a2c7cb57a4 38 #include "rt_Time.h"
mbed_official 48:e9a2c7cb57a4 39
mbed_official 48:e9a2c7cb57a4 40 /*----------------------------------------------------------------------------
mbed_official 48:e9a2c7cb57a4 41 * Global Variables
mbed_official 48:e9a2c7cb57a4 42 *---------------------------------------------------------------------------*/
mbed_official 48:e9a2c7cb57a4 43
mbed_official 48:e9a2c7cb57a4 44 /* Free running system tick counter */
mbed_official 48:e9a2c7cb57a4 45 U32 os_time;
mbed_official 48:e9a2c7cb57a4 46
mbed_official 48:e9a2c7cb57a4 47
mbed_official 48:e9a2c7cb57a4 48 /*----------------------------------------------------------------------------
mbed_official 48:e9a2c7cb57a4 49 * Functions
mbed_official 48:e9a2c7cb57a4 50 *---------------------------------------------------------------------------*/
mbed_official 48:e9a2c7cb57a4 51
mbed_official 48:e9a2c7cb57a4 52
mbed_official 48:e9a2c7cb57a4 53 /*--------------------------- rt_time_get -----------------------------------*/
mbed_official 48:e9a2c7cb57a4 54
mbed_official 48:e9a2c7cb57a4 55 U32 rt_time_get (void) {
mbed_official 48:e9a2c7cb57a4 56 /* Get system time tick */
mbed_official 48:e9a2c7cb57a4 57 return (os_time);
mbed_official 48:e9a2c7cb57a4 58 }
mbed_official 48:e9a2c7cb57a4 59
mbed_official 48:e9a2c7cb57a4 60
mbed_official 48:e9a2c7cb57a4 61 /*--------------------------- rt_dly_wait -----------------------------------*/
mbed_official 48:e9a2c7cb57a4 62
mbed_official 48:e9a2c7cb57a4 63 void rt_dly_wait (U16 delay_time) {
mbed_official 48:e9a2c7cb57a4 64 /* Delay task by "delay_time" */
mbed_official 48:e9a2c7cb57a4 65 rt_block (delay_time, WAIT_DLY);
mbed_official 48:e9a2c7cb57a4 66 }
mbed_official 48:e9a2c7cb57a4 67
mbed_official 48:e9a2c7cb57a4 68
mbed_official 48:e9a2c7cb57a4 69 /*--------------------------- rt_itv_set ------------------------------------*/
mbed_official 48:e9a2c7cb57a4 70
mbed_official 48:e9a2c7cb57a4 71 void rt_itv_set (U16 interval_time) {
mbed_official 48:e9a2c7cb57a4 72 /* Set interval length and define start of first interval */
mbed_official 48:e9a2c7cb57a4 73 os_tsk.run->interval_time = interval_time;
mbed_official 48:e9a2c7cb57a4 74 os_tsk.run->delta_time = interval_time + (U16)os_time;
mbed_official 48:e9a2c7cb57a4 75 }
mbed_official 48:e9a2c7cb57a4 76
mbed_official 48:e9a2c7cb57a4 77
mbed_official 48:e9a2c7cb57a4 78 /*--------------------------- rt_itv_wait -----------------------------------*/
mbed_official 48:e9a2c7cb57a4 79
mbed_official 48:e9a2c7cb57a4 80 void rt_itv_wait (void) {
mbed_official 48:e9a2c7cb57a4 81 /* Wait for interval end and define start of next one */
mbed_official 48:e9a2c7cb57a4 82 U16 delta;
mbed_official 48:e9a2c7cb57a4 83
mbed_official 48:e9a2c7cb57a4 84 delta = os_tsk.run->delta_time - (U16)os_time;
mbed_official 48:e9a2c7cb57a4 85 os_tsk.run->delta_time += os_tsk.run->interval_time;
mbed_official 48:e9a2c7cb57a4 86 if ((delta & 0x8000) == 0) {
mbed_official 48:e9a2c7cb57a4 87 rt_block (delta, WAIT_ITV);
mbed_official 48:e9a2c7cb57a4 88 }
mbed_official 48:e9a2c7cb57a4 89 }
mbed_official 48:e9a2c7cb57a4 90
mbed_official 48:e9a2c7cb57a4 91 /*----------------------------------------------------------------------------
mbed_official 48:e9a2c7cb57a4 92 * end of file
mbed_official 48:e9a2c7cb57a4 93 *---------------------------------------------------------------------------*/
mbed_official 48:e9a2c7cb57a4 94