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