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