NRF com

Dependencies:   mbed nRF24L01P

Committer:
vmihalcut
Date:
Mon May 27 06:06:31 2013 +0000
Revision:
0:fdfe93cb9255
NRF24L01 receiver

Who changed what in which revision?

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