Arrow / Mbed OS DAPLink Reset
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rt_Robin.c Source File

rt_Robin.c

Go to the documentation of this file.
00001 /**
00002  * @file    rt_Robin.c
00003  * @brief   
00004  *
00005  * DAPLink Interface Firmware
00006  * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
00007  * SPDX-License-Identifier: Apache-2.0
00008  *
00009  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00010  * not use this file except in compliance with the License.
00011  * You may obtain a copy of the License at
00012  *
00013  * http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  * Unless required by applicable law or agreed to in writing, software
00016  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00017  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00022 #include "rt_TypeDef.h"
00023 #include "RTX_Config.h"
00024 #include "rt_List.h"
00025 #include "rt_Task.h"
00026 #include "rt_Time.h"
00027 #include "rt_Robin.h"
00028 
00029 /*----------------------------------------------------------------------------
00030  *      Global Variables
00031  *---------------------------------------------------------------------------*/
00032 
00033 struct OS_ROBIN os_robin;
00034 
00035 
00036 /*----------------------------------------------------------------------------
00037  *      Global Functions
00038  *---------------------------------------------------------------------------*/
00039 
00040 /*--------------------------- rt_init_robin ---------------------------------*/
00041 
00042 __weak void rt_init_robin (void) {
00043   /* Initialize Round Robin variables. */
00044   os_robin.task = NULL;
00045   os_robin.tout = (U16)os_rrobin;
00046 }
00047 
00048 /*--------------------------- rt_chk_robin ----------------------------------*/
00049 
00050 __weak void rt_chk_robin (void) {
00051   /* Check if Round Robin timeout expired and switch to the next ready task.*/
00052   P_TCB p_new;
00053 
00054   if (os_robin.task != os_rdy.p_lnk) {
00055     /* New task was suspended, reset Round Robin timeout. */
00056     os_robin.task = os_rdy.p_lnk;
00057     os_robin.time = (U16)os_time + os_robin.tout - 1;
00058   }
00059   if (os_robin.time == (U16)os_time) {
00060     /* Round Robin timeout has expired, swap Robin tasks. */
00061     os_robin.task = NULL;
00062     p_new = rt_get_first (&os_rdy);
00063     rt_put_prio ((P_XCB)&os_rdy, p_new);
00064   }
00065 }
00066 
00067 /*----------------------------------------------------------------------------
00068  * end of file
00069  *---------------------------------------------------------------------------*/
00070