Anasse Abdoul / Mbed 2 deprecated Test_MPU6050

Dependencies:   mbed

Committer:
anasse
Date:
Thu Mar 31 07:43:50 2022 +0000
Revision:
0:a59a3d743804
vers0

Who changed what in which revision?

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