Lab Checkoff

Dependencies:   SDFileSystem TextLCD mbed-rtos mbed wave_player FATFileSystem

Committer:
doubster
Date:
Wed Nov 13 20:00:28 2013 +0000
Revision:
0:67dbd54e60d4
Lab Checkoff

Who changed what in which revision?

UserRevisionLine numberNew contents of line
doubster 0:67dbd54e60d4 1 /*----------------------------------------------------------------------------
doubster 0:67dbd54e60d4 2 * RL-ARM - RTX
doubster 0:67dbd54e60d4 3 *----------------------------------------------------------------------------
doubster 0:67dbd54e60d4 4 * Name: RT_TIME.C
doubster 0:67dbd54e60d4 5 * Purpose: Delay and interval wait functions
doubster 0:67dbd54e60d4 6 * Rev.: V4.60
doubster 0:67dbd54e60d4 7 *----------------------------------------------------------------------------
doubster 0:67dbd54e60d4 8 *
doubster 0:67dbd54e60d4 9 * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
doubster 0:67dbd54e60d4 10 * All rights reserved.
doubster 0:67dbd54e60d4 11 * Redistribution and use in source and binary forms, with or without
doubster 0:67dbd54e60d4 12 * modification, are permitted provided that the following conditions are met:
doubster 0:67dbd54e60d4 13 * - Redistributions of source code must retain the above copyright
doubster 0:67dbd54e60d4 14 * notice, this list of conditions and the following disclaimer.
doubster 0:67dbd54e60d4 15 * - Redistributions in binary form must reproduce the above copyright
doubster 0:67dbd54e60d4 16 * notice, this list of conditions and the following disclaimer in the
doubster 0:67dbd54e60d4 17 * documentation and/or other materials provided with the distribution.
doubster 0:67dbd54e60d4 18 * - Neither the name of ARM nor the names of its contributors may be used
doubster 0:67dbd54e60d4 19 * to endorse or promote products derived from this software without
doubster 0:67dbd54e60d4 20 * specific prior written permission.
doubster 0:67dbd54e60d4 21 *
doubster 0:67dbd54e60d4 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
doubster 0:67dbd54e60d4 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
doubster 0:67dbd54e60d4 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
doubster 0:67dbd54e60d4 25 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
doubster 0:67dbd54e60d4 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
doubster 0:67dbd54e60d4 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
doubster 0:67dbd54e60d4 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
doubster 0:67dbd54e60d4 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
doubster 0:67dbd54e60d4 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
doubster 0:67dbd54e60d4 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
doubster 0:67dbd54e60d4 32 * POSSIBILITY OF SUCH DAMAGE.
doubster 0:67dbd54e60d4 33 *---------------------------------------------------------------------------*/
doubster 0:67dbd54e60d4 34
doubster 0:67dbd54e60d4 35 #include "rt_TypeDef.h"
doubster 0:67dbd54e60d4 36 #include "RTX_Config.h"
doubster 0:67dbd54e60d4 37 #include "rt_Task.h"
doubster 0:67dbd54e60d4 38 #include "rt_Time.h"
doubster 0:67dbd54e60d4 39
doubster 0:67dbd54e60d4 40 /*----------------------------------------------------------------------------
doubster 0:67dbd54e60d4 41 * Global Variables
doubster 0:67dbd54e60d4 42 *---------------------------------------------------------------------------*/
doubster 0:67dbd54e60d4 43
doubster 0:67dbd54e60d4 44 /* Free running system tick counter */
doubster 0:67dbd54e60d4 45 U32 os_time;
doubster 0:67dbd54e60d4 46
doubster 0:67dbd54e60d4 47
doubster 0:67dbd54e60d4 48 /*----------------------------------------------------------------------------
doubster 0:67dbd54e60d4 49 * Functions
doubster 0:67dbd54e60d4 50 *---------------------------------------------------------------------------*/
doubster 0:67dbd54e60d4 51
doubster 0:67dbd54e60d4 52
doubster 0:67dbd54e60d4 53 /*--------------------------- rt_time_get -----------------------------------*/
doubster 0:67dbd54e60d4 54
doubster 0:67dbd54e60d4 55 U32 rt_time_get (void) {
doubster 0:67dbd54e60d4 56 /* Get system time tick */
doubster 0:67dbd54e60d4 57 return (os_time);
doubster 0:67dbd54e60d4 58 }
doubster 0:67dbd54e60d4 59
doubster 0:67dbd54e60d4 60
doubster 0:67dbd54e60d4 61 /*--------------------------- rt_dly_wait -----------------------------------*/
doubster 0:67dbd54e60d4 62
doubster 0:67dbd54e60d4 63 void rt_dly_wait (U16 delay_time) {
doubster 0:67dbd54e60d4 64 /* Delay task by "delay_time" */
doubster 0:67dbd54e60d4 65 rt_block (delay_time, WAIT_DLY);
doubster 0:67dbd54e60d4 66 }
doubster 0:67dbd54e60d4 67
doubster 0:67dbd54e60d4 68
doubster 0:67dbd54e60d4 69 /*--------------------------- rt_itv_set ------------------------------------*/
doubster 0:67dbd54e60d4 70
doubster 0:67dbd54e60d4 71 void rt_itv_set (U16 interval_time) {
doubster 0:67dbd54e60d4 72 /* Set interval length and define start of first interval */
doubster 0:67dbd54e60d4 73 os_tsk.run->interval_time = interval_time;
doubster 0:67dbd54e60d4 74 os_tsk.run->delta_time = interval_time + (U16)os_time;
doubster 0:67dbd54e60d4 75 }
doubster 0:67dbd54e60d4 76
doubster 0:67dbd54e60d4 77
doubster 0:67dbd54e60d4 78 /*--------------------------- rt_itv_wait -----------------------------------*/
doubster 0:67dbd54e60d4 79
doubster 0:67dbd54e60d4 80 void rt_itv_wait (void) {
doubster 0:67dbd54e60d4 81 /* Wait for interval end and define start of next one */
doubster 0:67dbd54e60d4 82 U16 delta;
doubster 0:67dbd54e60d4 83
doubster 0:67dbd54e60d4 84 delta = os_tsk.run->delta_time - (U16)os_time;
doubster 0:67dbd54e60d4 85 os_tsk.run->delta_time += os_tsk.run->interval_time;
doubster 0:67dbd54e60d4 86 if ((delta & 0x8000) == 0) {
doubster 0:67dbd54e60d4 87 rt_block (delta, WAIT_ITV);
doubster 0:67dbd54e60d4 88 }
doubster 0:67dbd54e60d4 89 }
doubster 0:67dbd54e60d4 90
doubster 0:67dbd54e60d4 91 /*----------------------------------------------------------------------------
doubster 0:67dbd54e60d4 92 * end of file
doubster 0:67dbd54e60d4 93 *---------------------------------------------------------------------------*/
doubster 0:67dbd54e60d4 94
doubster 0:67dbd54e60d4 95