Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.
Upstream: https://github.com/ARMmbed/DAPLink
source/rtos/rt_Time.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_Time.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_Task.h" |
Pawel Zarembski |
0:01f31e923fe2 | 25 | #include "rt_Time.h" |
Pawel Zarembski |
0:01f31e923fe2 | 26 | |
Pawel Zarembski |
0:01f31e923fe2 | 27 | /*---------------------------------------------------------------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 28 | * Global Variables |
Pawel Zarembski |
0:01f31e923fe2 | 29 | *---------------------------------------------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 30 | |
Pawel Zarembski |
0:01f31e923fe2 | 31 | /* Free running system tick counter */ |
Pawel Zarembski |
0:01f31e923fe2 | 32 | U32 os_time; |
Pawel Zarembski |
0:01f31e923fe2 | 33 | |
Pawel Zarembski |
0:01f31e923fe2 | 34 | |
Pawel Zarembski |
0:01f31e923fe2 | 35 | /*---------------------------------------------------------------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 36 | * Functions |
Pawel Zarembski |
0:01f31e923fe2 | 37 | *---------------------------------------------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 38 | |
Pawel Zarembski |
0:01f31e923fe2 | 39 | |
Pawel Zarembski |
0:01f31e923fe2 | 40 | /*--------------------------- rt_time_get -----------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 41 | |
Pawel Zarembski |
0:01f31e923fe2 | 42 | U32 rt_time_get (void) { |
Pawel Zarembski |
0:01f31e923fe2 | 43 | /* Get system time tick */ |
Pawel Zarembski |
0:01f31e923fe2 | 44 | return (os_time); |
Pawel Zarembski |
0:01f31e923fe2 | 45 | } |
Pawel Zarembski |
0:01f31e923fe2 | 46 | |
Pawel Zarembski |
0:01f31e923fe2 | 47 | |
Pawel Zarembski |
0:01f31e923fe2 | 48 | /*--------------------------- rt_dly_wait -----------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 49 | |
Pawel Zarembski |
0:01f31e923fe2 | 50 | void rt_dly_wait (U16 delay_time) { |
Pawel Zarembski |
0:01f31e923fe2 | 51 | /* Delay task by "delay_time" */ |
Pawel Zarembski |
0:01f31e923fe2 | 52 | rt_block (delay_time, WAIT_DLY); |
Pawel Zarembski |
0:01f31e923fe2 | 53 | } |
Pawel Zarembski |
0:01f31e923fe2 | 54 | |
Pawel Zarembski |
0:01f31e923fe2 | 55 | |
Pawel Zarembski |
0:01f31e923fe2 | 56 | /*--------------------------- rt_itv_set ------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 57 | |
Pawel Zarembski |
0:01f31e923fe2 | 58 | void rt_itv_set (U16 interval_time) { |
Pawel Zarembski |
0:01f31e923fe2 | 59 | /* Set interval length and define start of first interval */ |
Pawel Zarembski |
0:01f31e923fe2 | 60 | os_tsk.run->interval_time = interval_time; |
Pawel Zarembski |
0:01f31e923fe2 | 61 | os_tsk.run->delta_time = interval_time + (U16)os_time; |
Pawel Zarembski |
0:01f31e923fe2 | 62 | } |
Pawel Zarembski |
0:01f31e923fe2 | 63 | |
Pawel Zarembski |
0:01f31e923fe2 | 64 | |
Pawel Zarembski |
0:01f31e923fe2 | 65 | /*--------------------------- rt_itv_wait -----------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 66 | |
Pawel Zarembski |
0:01f31e923fe2 | 67 | void rt_itv_wait (void) { |
Pawel Zarembski |
0:01f31e923fe2 | 68 | /* Wait for interval end and define start of next one */ |
Pawel Zarembski |
0:01f31e923fe2 | 69 | U16 delta; |
Pawel Zarembski |
0:01f31e923fe2 | 70 | |
Pawel Zarembski |
0:01f31e923fe2 | 71 | delta = os_tsk.run->delta_time - (U16)os_time; |
Pawel Zarembski |
0:01f31e923fe2 | 72 | os_tsk.run->delta_time += os_tsk.run->interval_time; |
Pawel Zarembski |
0:01f31e923fe2 | 73 | if ((delta & 0x8000) == 0) { |
Pawel Zarembski |
0:01f31e923fe2 | 74 | rt_block (delta, WAIT_ITV); |
Pawel Zarembski |
0:01f31e923fe2 | 75 | } |
Pawel Zarembski |
0:01f31e923fe2 | 76 | } |
Pawel Zarembski |
0:01f31e923fe2 | 77 | |
Pawel Zarembski |
0:01f31e923fe2 | 78 | /*---------------------------------------------------------------------------- |
Pawel Zarembski |
0:01f31e923fe2 | 79 | * end of file |
Pawel Zarembski |
0:01f31e923fe2 | 80 | *---------------------------------------------------------------------------*/ |
Pawel Zarembski |
0:01f31e923fe2 | 81 |