xLAB - acutators / led-mrf-osc_full_Latest_2

Dependencies:   addressable_leds

Dependents:   led-mrf-osc_full

Committer:
Jing_Qiu
Date:
Sat Mar 21 02:42:59 2015 +0000
Revision:
1:d4c1d8dc8ced
Parent:
0:284274252007
revised

Who changed what in which revision?

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