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