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