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_ROBIN.C
anasse 0:a59a3d743804 5 * Purpose: Round Robin Task switching
anasse 0:a59a3d743804 6 * Rev.: V4.70
anasse 0:a59a3d743804 7 *----------------------------------------------------------------------------
anasse 0:a59a3d743804 8 *
anasse 0:a59a3d743804 9 * Copyright (c) 1999-2009 KEIL, 2009-2013 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_Config.h"
anasse 0:a59a3d743804 37 #include "rt_List.h"
anasse 0:a59a3d743804 38 #include "rt_Task.h"
anasse 0:a59a3d743804 39 #include "rt_Time.h"
anasse 0:a59a3d743804 40 #include "rt_Robin.h"
anasse 0:a59a3d743804 41 #ifdef __CORTEX_A9
anasse 0:a59a3d743804 42 #include "rt_HAL_CA.h"
anasse 0:a59a3d743804 43 #else
anasse 0:a59a3d743804 44 #include "rt_HAL_CM.h"
anasse 0:a59a3d743804 45 #endif
anasse 0:a59a3d743804 46
anasse 0:a59a3d743804 47 /*----------------------------------------------------------------------------
anasse 0:a59a3d743804 48 * Global Variables
anasse 0:a59a3d743804 49 *---------------------------------------------------------------------------*/
anasse 0:a59a3d743804 50
anasse 0:a59a3d743804 51 struct OS_ROBIN os_robin;
anasse 0:a59a3d743804 52
anasse 0:a59a3d743804 53
anasse 0:a59a3d743804 54 /*----------------------------------------------------------------------------
anasse 0:a59a3d743804 55 * Global Functions
anasse 0:a59a3d743804 56 *---------------------------------------------------------------------------*/
anasse 0:a59a3d743804 57
anasse 0:a59a3d743804 58 /*--------------------------- rt_init_robin ---------------------------------*/
anasse 0:a59a3d743804 59
anasse 0:a59a3d743804 60 __weak void rt_init_robin (void) {
anasse 0:a59a3d743804 61 /* Initialize Round Robin variables. */
anasse 0:a59a3d743804 62 os_robin.task = NULL;
anasse 0:a59a3d743804 63 os_robin.tout = (U16)os_rrobin;
anasse 0:a59a3d743804 64 }
anasse 0:a59a3d743804 65
anasse 0:a59a3d743804 66 /*--------------------------- rt_chk_robin ----------------------------------*/
anasse 0:a59a3d743804 67
anasse 0:a59a3d743804 68 __weak void rt_chk_robin (void) {
anasse 0:a59a3d743804 69 /* Check if Round Robin timeout expired and switch to the next ready task.*/
anasse 0:a59a3d743804 70 P_TCB p_new;
anasse 0:a59a3d743804 71
anasse 0:a59a3d743804 72 if (os_robin.task != os_rdy.p_lnk) {
anasse 0:a59a3d743804 73 /* New task was suspended, reset Round Robin timeout. */
anasse 0:a59a3d743804 74 os_robin.task = os_rdy.p_lnk;
anasse 0:a59a3d743804 75 os_robin.time = (U16)os_time + os_robin.tout - 1;
anasse 0:a59a3d743804 76 }
anasse 0:a59a3d743804 77 if (os_robin.time == (U16)os_time) {
anasse 0:a59a3d743804 78 /* Round Robin timeout has expired, swap Robin tasks. */
anasse 0:a59a3d743804 79 os_robin.task = NULL;
anasse 0:a59a3d743804 80 p_new = rt_get_first (&os_rdy);
anasse 0:a59a3d743804 81 rt_put_prio ((P_XCB)&os_rdy, p_new);
anasse 0:a59a3d743804 82 }
anasse 0:a59a3d743804 83 }
anasse 0:a59a3d743804 84
anasse 0:a59a3d743804 85 /*----------------------------------------------------------------------------
anasse 0:a59a3d743804 86 * end of file
anasse 0:a59a3d743804 87 *---------------------------------------------------------------------------*/
anasse 0:a59a3d743804 88