mbed os with nrf51 internal bandgap enabled to read battery level
Dependents: BLE_file_test BLE_Blink ExternalEncoder
rtos/rtx/TARGET_ARM7/rt_Time.c@0:f269e3021894, 2016-10-23 (annotated)
- Committer:
- elessair
- Date:
- Sun Oct 23 15:10:02 2016 +0000
- Revision:
- 0:f269e3021894
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | /*---------------------------------------------------------------------------- |
elessair | 0:f269e3021894 | 2 | * RL-ARM - RTX |
elessair | 0:f269e3021894 | 3 | *---------------------------------------------------------------------------- |
elessair | 0:f269e3021894 | 4 | * Name: RT_TIME.C |
elessair | 0:f269e3021894 | 5 | * Purpose: Delay and interval wait functions |
elessair | 0:f269e3021894 | 6 | * Rev.: V4.60 |
elessair | 0:f269e3021894 | 7 | *---------------------------------------------------------------------------- |
elessair | 0:f269e3021894 | 8 | * |
elessair | 0:f269e3021894 | 9 | * Copyright (c) 1999-2009 KEIL, 2009-2015 ARM Germany GmbH |
elessair | 0:f269e3021894 | 10 | * All rights reserved. |
elessair | 0:f269e3021894 | 11 | * Redistribution and use in source and binary forms, with or without |
elessair | 0:f269e3021894 | 12 | * modification, are permitted provided that the following conditions are met: |
elessair | 0:f269e3021894 | 13 | * - Redistributions of source code must retain the above copyright |
elessair | 0:f269e3021894 | 14 | * notice, this list of conditions and the following disclaimer. |
elessair | 0:f269e3021894 | 15 | * - Redistributions in binary form must reproduce the above copyright |
elessair | 0:f269e3021894 | 16 | * notice, this list of conditions and the following disclaimer in the |
elessair | 0:f269e3021894 | 17 | * documentation and/or other materials provided with the distribution. |
elessair | 0:f269e3021894 | 18 | * - Neither the name of ARM nor the names of its contributors may be used |
elessair | 0:f269e3021894 | 19 | * to endorse or promote products derived from this software without |
elessair | 0:f269e3021894 | 20 | * specific prior written permission. |
elessair | 0:f269e3021894 | 21 | * |
elessair | 0:f269e3021894 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
elessair | 0:f269e3021894 | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
elessair | 0:f269e3021894 | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
elessair | 0:f269e3021894 | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
elessair | 0:f269e3021894 | 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
elessair | 0:f269e3021894 | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
elessair | 0:f269e3021894 | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
elessair | 0:f269e3021894 | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
elessair | 0:f269e3021894 | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
elessair | 0:f269e3021894 | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
elessair | 0:f269e3021894 | 32 | * POSSIBILITY OF SUCH DAMAGE. |
elessair | 0:f269e3021894 | 33 | *---------------------------------------------------------------------------*/ |
elessair | 0:f269e3021894 | 34 | |
elessair | 0:f269e3021894 | 35 | #include "rt_TypeDef.h" |
elessair | 0:f269e3021894 | 36 | #include "RTX_Conf.h" |
elessair | 0:f269e3021894 | 37 | #include "rt_Task.h" |
elessair | 0:f269e3021894 | 38 | #include "rt_Time.h" |
elessair | 0:f269e3021894 | 39 | |
elessair | 0:f269e3021894 | 40 | /*---------------------------------------------------------------------------- |
elessair | 0:f269e3021894 | 41 | * Global Variables |
elessair | 0:f269e3021894 | 42 | *---------------------------------------------------------------------------*/ |
elessair | 0:f269e3021894 | 43 | |
elessair | 0:f269e3021894 | 44 | /* Free running system tick counter */ |
elessair | 0:f269e3021894 | 45 | U32 os_time; |
elessair | 0:f269e3021894 | 46 | |
elessair | 0:f269e3021894 | 47 | |
elessair | 0:f269e3021894 | 48 | /*---------------------------------------------------------------------------- |
elessair | 0:f269e3021894 | 49 | * Functions |
elessair | 0:f269e3021894 | 50 | *---------------------------------------------------------------------------*/ |
elessair | 0:f269e3021894 | 51 | |
elessair | 0:f269e3021894 | 52 | |
elessair | 0:f269e3021894 | 53 | /*--------------------------- rt_time_get -----------------------------------*/ |
elessair | 0:f269e3021894 | 54 | |
elessair | 0:f269e3021894 | 55 | U32 rt_time_get (void) { |
elessair | 0:f269e3021894 | 56 | /* Get system time tick */ |
elessair | 0:f269e3021894 | 57 | return (os_time); |
elessair | 0:f269e3021894 | 58 | } |
elessair | 0:f269e3021894 | 59 | |
elessair | 0:f269e3021894 | 60 | |
elessair | 0:f269e3021894 | 61 | /*--------------------------- rt_dly_wait -----------------------------------*/ |
elessair | 0:f269e3021894 | 62 | |
elessair | 0:f269e3021894 | 63 | void rt_dly_wait (U16 delay_time) { |
elessair | 0:f269e3021894 | 64 | /* Delay task by "delay_time" */ |
elessair | 0:f269e3021894 | 65 | rt_block (delay_time, WAIT_DLY); |
elessair | 0:f269e3021894 | 66 | } |
elessair | 0:f269e3021894 | 67 | |
elessair | 0:f269e3021894 | 68 | |
elessair | 0:f269e3021894 | 69 | /*--------------------------- rt_itv_set ------------------------------------*/ |
elessair | 0:f269e3021894 | 70 | |
elessair | 0:f269e3021894 | 71 | void rt_itv_set (U16 interval_time) { |
elessair | 0:f269e3021894 | 72 | /* Set interval length and define start of first interval */ |
elessair | 0:f269e3021894 | 73 | os_tsk.run->interval_time = interval_time; |
elessair | 0:f269e3021894 | 74 | os_tsk.run->delta_time = interval_time + (U16)os_time; |
elessair | 0:f269e3021894 | 75 | } |
elessair | 0:f269e3021894 | 76 | |
elessair | 0:f269e3021894 | 77 | |
elessair | 0:f269e3021894 | 78 | /*--------------------------- rt_itv_wait -----------------------------------*/ |
elessair | 0:f269e3021894 | 79 | |
elessair | 0:f269e3021894 | 80 | void rt_itv_wait (void) { |
elessair | 0:f269e3021894 | 81 | /* Wait for interval end and define start of next one */ |
elessair | 0:f269e3021894 | 82 | U16 delta; |
elessair | 0:f269e3021894 | 83 | |
elessair | 0:f269e3021894 | 84 | delta = os_tsk.run->delta_time - (U16)os_time; |
elessair | 0:f269e3021894 | 85 | os_tsk.run->delta_time += os_tsk.run->interval_time; |
elessair | 0:f269e3021894 | 86 | if ((delta & 0x8000) == 0) { |
elessair | 0:f269e3021894 | 87 | rt_block (delta, WAIT_ITV); |
elessair | 0:f269e3021894 | 88 | } |
elessair | 0:f269e3021894 | 89 | } |
elessair | 0:f269e3021894 | 90 | |
elessair | 0:f269e3021894 | 91 | /*---------------------------------------------------------------------------- |
elessair | 0:f269e3021894 | 92 | * end of file |
elessair | 0:f269e3021894 | 93 | *---------------------------------------------------------------------------*/ |
elessair | 0:f269e3021894 | 94 |