Yes

Dependents:   Asservissement_Gyro

Committer:
braichi13
Date:
Sun May 08 14:39:47 2022 +0000
Revision:
0:77205fc699b9
Programme du Gyropode

Who changed what in which revision?

UserRevisionLine numberNew contents of line
braichi13 0:77205fc699b9 1 /*----------------------------------------------------------------------------
braichi13 0:77205fc699b9 2 * RL-ARM - RTX
braichi13 0:77205fc699b9 3 *----------------------------------------------------------------------------
braichi13 0:77205fc699b9 4 * Name: RT_ROBIN.C
braichi13 0:77205fc699b9 5 * Purpose: Round Robin Task switching
braichi13 0:77205fc699b9 6 * Rev.: V4.60
braichi13 0:77205fc699b9 7 *----------------------------------------------------------------------------
braichi13 0:77205fc699b9 8 *
braichi13 0:77205fc699b9 9 * Copyright (c) 1999-2009 KEIL, 2009-2015 ARM Germany GmbH
braichi13 0:77205fc699b9 10 * All rights reserved.
braichi13 0:77205fc699b9 11 * Redistribution and use in source and binary forms, with or without
braichi13 0:77205fc699b9 12 * modification, are permitted provided that the following conditions are met:
braichi13 0:77205fc699b9 13 * - Redistributions of source code must retain the above copyright
braichi13 0:77205fc699b9 14 * notice, this list of conditions and the following disclaimer.
braichi13 0:77205fc699b9 15 * - Redistributions in binary form must reproduce the above copyright
braichi13 0:77205fc699b9 16 * notice, this list of conditions and the following disclaimer in the
braichi13 0:77205fc699b9 17 * documentation and/or other materials provided with the distribution.
braichi13 0:77205fc699b9 18 * - Neither the name of ARM nor the names of its contributors may be used
braichi13 0:77205fc699b9 19 * to endorse or promote products derived from this software without
braichi13 0:77205fc699b9 20 * specific prior written permission.
braichi13 0:77205fc699b9 21 *
braichi13 0:77205fc699b9 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
braichi13 0:77205fc699b9 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
braichi13 0:77205fc699b9 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
braichi13 0:77205fc699b9 25 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
braichi13 0:77205fc699b9 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
braichi13 0:77205fc699b9 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
braichi13 0:77205fc699b9 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
braichi13 0:77205fc699b9 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
braichi13 0:77205fc699b9 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
braichi13 0:77205fc699b9 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
braichi13 0:77205fc699b9 32 * POSSIBILITY OF SUCH DAMAGE.
braichi13 0:77205fc699b9 33 *---------------------------------------------------------------------------*/
braichi13 0:77205fc699b9 34
braichi13 0:77205fc699b9 35 #include "rt_TypeDef.h"
braichi13 0:77205fc699b9 36 #include "RTX_Conf.h"
braichi13 0:77205fc699b9 37 #include "rt_List.h"
braichi13 0:77205fc699b9 38 #include "rt_Task.h"
braichi13 0:77205fc699b9 39 #include "rt_Time.h"
braichi13 0:77205fc699b9 40 #include "rt_Robin.h"
braichi13 0:77205fc699b9 41 #include "rt_HAL_CM.h"
braichi13 0:77205fc699b9 42
braichi13 0:77205fc699b9 43 /*----------------------------------------------------------------------------
braichi13 0:77205fc699b9 44 * Global Variables
braichi13 0:77205fc699b9 45 *---------------------------------------------------------------------------*/
braichi13 0:77205fc699b9 46
braichi13 0:77205fc699b9 47 struct OS_ROBIN os_robin;
braichi13 0:77205fc699b9 48
braichi13 0:77205fc699b9 49
braichi13 0:77205fc699b9 50 /*----------------------------------------------------------------------------
braichi13 0:77205fc699b9 51 * Global Functions
braichi13 0:77205fc699b9 52 *---------------------------------------------------------------------------*/
braichi13 0:77205fc699b9 53
braichi13 0:77205fc699b9 54 /*--------------------------- rt_init_robin ---------------------------------*/
braichi13 0:77205fc699b9 55
braichi13 0:77205fc699b9 56 __weak void rt_init_robin (void) {
braichi13 0:77205fc699b9 57 /* Initialize Round Robin variables. */
braichi13 0:77205fc699b9 58 os_robin.task = NULL;
braichi13 0:77205fc699b9 59 os_robin.tout = (U16)os_rrobin;
braichi13 0:77205fc699b9 60 }
braichi13 0:77205fc699b9 61
braichi13 0:77205fc699b9 62 /*--------------------------- rt_chk_robin ----------------------------------*/
braichi13 0:77205fc699b9 63
braichi13 0:77205fc699b9 64 __weak void rt_chk_robin (void) {
braichi13 0:77205fc699b9 65 /* Check if Round Robin timeout expired and switch to the next ready task.*/
braichi13 0:77205fc699b9 66 P_TCB p_new;
braichi13 0:77205fc699b9 67
braichi13 0:77205fc699b9 68 if (os_robin.task != os_rdy.p_lnk) {
braichi13 0:77205fc699b9 69 /* New task was suspended, reset Round Robin timeout. */
braichi13 0:77205fc699b9 70 os_robin.task = os_rdy.p_lnk;
braichi13 0:77205fc699b9 71 os_robin.time = (U16)os_time + os_robin.tout - 1;
braichi13 0:77205fc699b9 72 }
braichi13 0:77205fc699b9 73 if (os_robin.time == (U16)os_time) {
braichi13 0:77205fc699b9 74 /* Round Robin timeout has expired, swap Robin tasks. */
braichi13 0:77205fc699b9 75 os_robin.task = NULL;
braichi13 0:77205fc699b9 76 p_new = rt_get_first (&os_rdy);
braichi13 0:77205fc699b9 77 rt_put_prio ((P_XCB)&os_rdy, p_new);
braichi13 0:77205fc699b9 78 }
braichi13 0:77205fc699b9 79 }
braichi13 0:77205fc699b9 80
braichi13 0:77205fc699b9 81 /*----------------------------------------------------------------------------
braichi13 0:77205fc699b9 82 * end of file
braichi13 0:77205fc699b9 83 *---------------------------------------------------------------------------*/
braichi13 0:77205fc699b9 84