I messed up the merge, so pushing it over to another repo so I don't lose it. Will tidy up and remove later
Dependencies: BufferedSerial FatFileSystemCpp mbed
rt_Time.c
00001 /*---------------------------------------------------------------------------- 00002 * RL-ARM - RTX 00003 *---------------------------------------------------------------------------- 00004 * Name: RT_TIME.C 00005 * Purpose: Delay and interval wait functions 00006 * Rev.: V4.60 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 "rt_TypeDef.h" 00036 #include "RTX_Conf.h" 00037 #include "rt_Task.h" 00038 #include "rt_Time.h" 00039 00040 /*---------------------------------------------------------------------------- 00041 * Global Variables 00042 *---------------------------------------------------------------------------*/ 00043 00044 /* Free running system tick counter */ 00045 U32 os_time; 00046 00047 00048 /*---------------------------------------------------------------------------- 00049 * Functions 00050 *---------------------------------------------------------------------------*/ 00051 00052 00053 /*--------------------------- rt_time_get -----------------------------------*/ 00054 00055 U32 rt_time_get (void) { 00056 /* Get system time tick */ 00057 return (os_time); 00058 } 00059 00060 00061 /*--------------------------- rt_dly_wait -----------------------------------*/ 00062 00063 void rt_dly_wait (U16 delay_time) { 00064 /* Delay task by "delay_time" */ 00065 rt_block (delay_time, WAIT_DLY); 00066 } 00067 00068 00069 /*--------------------------- rt_itv_set ------------------------------------*/ 00070 00071 void rt_itv_set (U16 interval_time) { 00072 /* Set interval length and define start of first interval */ 00073 os_tsk.run->interval_time = interval_time; 00074 os_tsk.run->delta_time = interval_time + (U16)os_time; 00075 } 00076 00077 00078 /*--------------------------- rt_itv_wait -----------------------------------*/ 00079 00080 void rt_itv_wait (void) { 00081 /* Wait for interval end and define start of next one */ 00082 U16 delta; 00083 00084 delta = os_tsk.run->delta_time - (U16)os_time; 00085 os_tsk.run->delta_time += os_tsk.run->interval_time; 00086 if ((delta & 0x8000) == 0) { 00087 rt_block (delta, WAIT_ITV); 00088 } 00089 } 00090 00091 /*---------------------------------------------------------------------------- 00092 * end of file 00093 *---------------------------------------------------------------------------*/ 00094
Generated on Thu Dec 15 2022 06:07:05 by 1.7.2