Counter

Dependencies:   EthernetInterface NTPClient SDFileSystem TextLCD WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip FATFileSystem

Committer:
Tuxitheone
Date:
Mon Feb 29 18:59:15 2016 +0000
Revision:
0:ecaf3e593122
TankCounter

Who changed what in which revision?

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