Versie 0.2 Het versturen via de NRF werkt nog niet helemaal omdat er per 4 bytes verstuurd moet worden. Wordt gefixt d.m.v. dynamic stuff!

Dependencies:   BufferedSerial

Dependents:   rtos_basic rtos_basic

Fork of mbed-rtos by mbed official

Committer:
Reynier
Date:
Fri Apr 29 15:22:56 2016 +0000
Revision:
108:e3b1083b1577
Parent:
80:2dab120a94c2
versie 0.2; Het versturen via NRF werkt nog niet helemaal omdat er per 4 bytes verstuurd moeten worden. Wordt nog gefixt d.m.v. dynamic stuff!

Who changed what in which revision?

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