Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.
Upstream: https://github.com/ARMmbed/DAPLink
source/rtos/rt_Robin.c@0:01f31e923fe2, 2020-04-07 (annotated)
- Committer:
- Pawel Zarembski
- Date:
- Tue Apr 07 12:55:42 2020 +0200
- Revision:
- 0:01f31e923fe2
hani: DAPLink with reset workaround
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pawel Zarembski |
0:01f31e923fe2 | 1 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 2 | * @file rt_Robin.c |
Pawel Zarembski |
0:01f31e923fe2 | 3 | * @brief |
Pawel Zarembski |
0:01f31e923fe2 | 4 | * |
Pawel Zarembski |
0:01f31e923fe2 | 5 | * DAPLink Interface Firmware |
Pawel Zarembski |
0:01f31e923fe2 | 6 | * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved |
Pawel Zarembski |
0:01f31e923fe2 | 7 | * SPDX-License-Identifier: Apache-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 8 | * |
Pawel Zarembski |
0:01f31e923fe2 | 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Pawel Zarembski |
0:01f31e923fe2 | 10 | * not use this file except in compliance with the License. |
Pawel Zarembski |
0:01f31e923fe2 | 11 | * You may obtain a copy of the License at |
Pawel Zarembski |
0:01f31e923fe2 | 12 | * |
Pawel Zarembski |
0:01f31e923fe2 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 14 | * |
Pawel Zarembski |
0:01f31e923fe2 | 15 | * Unless required by applicable law or agreed to in writing, software |
Pawel Zarembski |
0:01f31e923fe2 | 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Pawel Zarembski |
0:01f31e923fe2 | 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Pawel Zarembski |
0:01f31e923fe2 | 18 | * See the License for the specific language governing permissions and |
Pawel Zarembski |
0:01f31e923fe2 | 19 | * limitations under the License. |
Pawel Zarembski |
0:01f31e923fe2 | 20 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 21 | |
Pawel Zarembski |
0:01f31e923fe2 | 22 | #include "rt_TypeDef.h" |
Pawel Zarembski |
0:01f31e923fe2 | 23 | #include "RTX_Config.h" |
Pawel Zarembski |
0:01f31e923fe2 | 24 | #include "rt_List.h" |
Pawel Zarembski |
0:01f31e923fe2 | 25 | #include "rt_Task.h" |
Pawel Zarembski |
0:01f31e923fe2 | 26 | #include "rt_Time.h" |
Pawel Zarembski |
0:01f31e923fe2 | 27 | #include "rt_Robin.h" |
Pawel Zarembski |
0:01f31e923fe2 | 28 | |
Pawel Zarembski |
0:01f31e923fe2 | 29 | /*---------------------------------------------------------------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 30 | * Global Variables |
Pawel Zarembski |
0:01f31e923fe2 | 31 | *---------------------------------------------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 32 | |
Pawel Zarembski |
0:01f31e923fe2 | 33 | struct OS_ROBIN os_robin; |
Pawel Zarembski |
0:01f31e923fe2 | 34 | |
Pawel Zarembski |
0:01f31e923fe2 | 35 | |
Pawel Zarembski |
0:01f31e923fe2 | 36 | /*---------------------------------------------------------------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 37 | * Global Functions |
Pawel Zarembski |
0:01f31e923fe2 | 38 | *---------------------------------------------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 39 | |
Pawel Zarembski |
0:01f31e923fe2 | 40 | /*--------------------------- rt_init_robin ---------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 41 | |
Pawel Zarembski |
0:01f31e923fe2 | 42 | __weak void rt_init_robin (void) { |
Pawel Zarembski |
0:01f31e923fe2 | 43 | /* Initialize Round Robin variables. */ |
Pawel Zarembski |
0:01f31e923fe2 | 44 | os_robin.task = NULL; |
Pawel Zarembski |
0:01f31e923fe2 | 45 | os_robin.tout = (U16)os_rrobin; |
Pawel Zarembski |
0:01f31e923fe2 | 46 | } |
Pawel Zarembski |
0:01f31e923fe2 | 47 | |
Pawel Zarembski |
0:01f31e923fe2 | 48 | /*--------------------------- rt_chk_robin ----------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 49 | |
Pawel Zarembski |
0:01f31e923fe2 | 50 | __weak void rt_chk_robin (void) { |
Pawel Zarembski |
0:01f31e923fe2 | 51 | /* Check if Round Robin timeout expired and switch to the next ready task.*/ |
Pawel Zarembski |
0:01f31e923fe2 | 52 | P_TCB p_new; |
Pawel Zarembski |
0:01f31e923fe2 | 53 | |
Pawel Zarembski |
0:01f31e923fe2 | 54 | if (os_robin.task != os_rdy.p_lnk) { |
Pawel Zarembski |
0:01f31e923fe2 | 55 | /* New task was suspended, reset Round Robin timeout. */ |
Pawel Zarembski |
0:01f31e923fe2 | 56 | os_robin.task = os_rdy.p_lnk; |
Pawel Zarembski |
0:01f31e923fe2 | 57 | os_robin.time = (U16)os_time + os_robin.tout - 1; |
Pawel Zarembski |
0:01f31e923fe2 | 58 | } |
Pawel Zarembski |
0:01f31e923fe2 | 59 | if (os_robin.time == (U16)os_time) { |
Pawel Zarembski |
0:01f31e923fe2 | 60 | /* Round Robin timeout has expired, swap Robin tasks. */ |
Pawel Zarembski |
0:01f31e923fe2 | 61 | os_robin.task = NULL; |
Pawel Zarembski |
0:01f31e923fe2 | 62 | p_new = rt_get_first (&os_rdy); |
Pawel Zarembski |
0:01f31e923fe2 | 63 | rt_put_prio ((P_XCB)&os_rdy, p_new); |
Pawel Zarembski |
0:01f31e923fe2 | 64 | } |
Pawel Zarembski |
0:01f31e923fe2 | 65 | } |
Pawel Zarembski |
0:01f31e923fe2 | 66 | |
Pawel Zarembski |
0:01f31e923fe2 | 67 | /*---------------------------------------------------------------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 68 | * end of file |
Pawel Zarembski |
0:01f31e923fe2 | 69 | *---------------------------------------------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 70 |