Mouse code for the MacroRat
mbed-dev/targets/TARGET_ARM_SSG/TARGET_BEETLE/device/apb_timer.c@18:6a4db94011d3, 2017-05-14 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sun May 14 23:18:57 2017 +0000
- Revision:
- 18:6a4db94011d3
Publishing again
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /* mbed Microcontroller Library |
sahilmgandhi | 18:6a4db94011d3 | 2 | * Copyright (c) 2016 ARM Limited |
sahilmgandhi | 18:6a4db94011d3 | 3 | * |
sahilmgandhi | 18:6a4db94011d3 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
sahilmgandhi | 18:6a4db94011d3 | 5 | * you may not use this file except in compliance with the License. |
sahilmgandhi | 18:6a4db94011d3 | 6 | * You may obtain a copy of the License at |
sahilmgandhi | 18:6a4db94011d3 | 7 | * |
sahilmgandhi | 18:6a4db94011d3 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
sahilmgandhi | 18:6a4db94011d3 | 9 | * |
sahilmgandhi | 18:6a4db94011d3 | 10 | * Unless required by applicable law or agreed to in writing, software |
sahilmgandhi | 18:6a4db94011d3 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
sahilmgandhi | 18:6a4db94011d3 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
sahilmgandhi | 18:6a4db94011d3 | 13 | * See the License for the specific language governing permissions and |
sahilmgandhi | 18:6a4db94011d3 | 14 | * limitations under the License. |
sahilmgandhi | 18:6a4db94011d3 | 15 | */ |
sahilmgandhi | 18:6a4db94011d3 | 16 | #include "cmsis.h" |
sahilmgandhi | 18:6a4db94011d3 | 17 | #include "apb_timer.h" |
sahilmgandhi | 18:6a4db94011d3 | 18 | |
sahilmgandhi | 18:6a4db94011d3 | 19 | /* Timer Private Data */ |
sahilmgandhi | 18:6a4db94011d3 | 20 | typedef struct { |
sahilmgandhi | 18:6a4db94011d3 | 21 | /* Timer Definition */ |
sahilmgandhi | 18:6a4db94011d3 | 22 | CMSDK_TIMER_TypeDef *timerN; |
sahilmgandhi | 18:6a4db94011d3 | 23 | /* Timer IRQn */ |
sahilmgandhi | 18:6a4db94011d3 | 24 | uint32_t timerIRQn; |
sahilmgandhi | 18:6a4db94011d3 | 25 | /* Timer Reload Value */ |
sahilmgandhi | 18:6a4db94011d3 | 26 | uint32_t timerReload; |
sahilmgandhi | 18:6a4db94011d3 | 27 | /* Timer state */ |
sahilmgandhi | 18:6a4db94011d3 | 28 | uint32_t state; |
sahilmgandhi | 18:6a4db94011d3 | 29 | } apb_timer_t; |
sahilmgandhi | 18:6a4db94011d3 | 30 | |
sahilmgandhi | 18:6a4db94011d3 | 31 | /* Timer state definitions */ |
sahilmgandhi | 18:6a4db94011d3 | 32 | #define TIMER_INITIALIZED (1) |
sahilmgandhi | 18:6a4db94011d3 | 33 | #define TIMER_ENABLED (1 << 1) |
sahilmgandhi | 18:6a4db94011d3 | 34 | |
sahilmgandhi | 18:6a4db94011d3 | 35 | /* |
sahilmgandhi | 18:6a4db94011d3 | 36 | * This Timer is written for MBED OS and keeps count |
sahilmgandhi | 18:6a4db94011d3 | 37 | * of the ticks. All the elaboration logic is demanded |
sahilmgandhi | 18:6a4db94011d3 | 38 | * to the upper layers. |
sahilmgandhi | 18:6a4db94011d3 | 39 | */ |
sahilmgandhi | 18:6a4db94011d3 | 40 | #define TIMER_MAX_VALUE 0xFFFFFFFF |
sahilmgandhi | 18:6a4db94011d3 | 41 | #define TIMER_TICKS_US (SystemCoreClock/1000000) |
sahilmgandhi | 18:6a4db94011d3 | 42 | |
sahilmgandhi | 18:6a4db94011d3 | 43 | /* Timers Array */ |
sahilmgandhi | 18:6a4db94011d3 | 44 | static apb_timer_t Timers[NUM_TIMERS]; |
sahilmgandhi | 18:6a4db94011d3 | 45 | |
sahilmgandhi | 18:6a4db94011d3 | 46 | void Timer_Index_Init(uint32_t timer, uint32_t reload, |
sahilmgandhi | 18:6a4db94011d3 | 47 | CMSDK_TIMER_TypeDef *TimerN, uint32_t IRQn) |
sahilmgandhi | 18:6a4db94011d3 | 48 | { |
sahilmgandhi | 18:6a4db94011d3 | 49 | Timers[timer].timerN = TimerN; |
sahilmgandhi | 18:6a4db94011d3 | 50 | Timers[timer].timerIRQn = IRQn; |
sahilmgandhi | 18:6a4db94011d3 | 51 | Timers[timer].timerReload = reload; |
sahilmgandhi | 18:6a4db94011d3 | 52 | Timers[timer].state = TIMER_INITIALIZED; |
sahilmgandhi | 18:6a4db94011d3 | 53 | } |
sahilmgandhi | 18:6a4db94011d3 | 54 | |
sahilmgandhi | 18:6a4db94011d3 | 55 | /* |
sahilmgandhi | 18:6a4db94011d3 | 56 | * Timer_Initialize(): Initializes an hardware timer |
sahilmgandhi | 18:6a4db94011d3 | 57 | * timer: timer to be Initialized |
sahilmgandhi | 18:6a4db94011d3 | 58 | * time_us: timer reload value in us - 0 to reload to timer max value |
sahilmgandhi | 18:6a4db94011d3 | 59 | * time_us = tick_value / TIMER_TICKS_US |
sahilmgandhi | 18:6a4db94011d3 | 60 | */ |
sahilmgandhi | 18:6a4db94011d3 | 61 | #define TIMER_INIT(index, reload) Timer_Index_Init(index, reload, CMSDK_TIMER##index, TIMER##index##_IRQn) |
sahilmgandhi | 18:6a4db94011d3 | 62 | void Timer_Initialize(uint32_t timer, uint32_t time_us) |
sahilmgandhi | 18:6a4db94011d3 | 63 | { |
sahilmgandhi | 18:6a4db94011d3 | 64 | uint32_t reload = 0; |
sahilmgandhi | 18:6a4db94011d3 | 65 | |
sahilmgandhi | 18:6a4db94011d3 | 66 | if (timer < NUM_TIMERS) |
sahilmgandhi | 18:6a4db94011d3 | 67 | { |
sahilmgandhi | 18:6a4db94011d3 | 68 | if (time_us == 0) |
sahilmgandhi | 18:6a4db94011d3 | 69 | reload = TIMER_MAX_VALUE; |
sahilmgandhi | 18:6a4db94011d3 | 70 | else |
sahilmgandhi | 18:6a4db94011d3 | 71 | reload = (time_us) * TIMER_TICKS_US; |
sahilmgandhi | 18:6a4db94011d3 | 72 | |
sahilmgandhi | 18:6a4db94011d3 | 73 | switch(timer) { |
sahilmgandhi | 18:6a4db94011d3 | 74 | case 0: TIMER_INIT(0, reload); |
sahilmgandhi | 18:6a4db94011d3 | 75 | break; |
sahilmgandhi | 18:6a4db94011d3 | 76 | case 1: TIMER_INIT(1, reload); |
sahilmgandhi | 18:6a4db94011d3 | 77 | break; |
sahilmgandhi | 18:6a4db94011d3 | 78 | default: break; |
sahilmgandhi | 18:6a4db94011d3 | 79 | } |
sahilmgandhi | 18:6a4db94011d3 | 80 | } |
sahilmgandhi | 18:6a4db94011d3 | 81 | } |
sahilmgandhi | 18:6a4db94011d3 | 82 | |
sahilmgandhi | 18:6a4db94011d3 | 83 | /* |
sahilmgandhi | 18:6a4db94011d3 | 84 | * Timer_Enable(): Enables a hardware timer |
sahilmgandhi | 18:6a4db94011d3 | 85 | * timer: timer to be enabled |
sahilmgandhi | 18:6a4db94011d3 | 86 | */ |
sahilmgandhi | 18:6a4db94011d3 | 87 | void Timer_Enable(uint32_t timer) |
sahilmgandhi | 18:6a4db94011d3 | 88 | { |
sahilmgandhi | 18:6a4db94011d3 | 89 | /* The timer has to be contained in a valid range */ |
sahilmgandhi | 18:6a4db94011d3 | 90 | if (timer < NUM_TIMERS) { |
sahilmgandhi | 18:6a4db94011d3 | 91 | /* Timer has to be already initialized */ |
sahilmgandhi | 18:6a4db94011d3 | 92 | if (Timers[timer].state == TIMER_INITIALIZED) { |
sahilmgandhi | 18:6a4db94011d3 | 93 | /* Disable Timer */ |
sahilmgandhi | 18:6a4db94011d3 | 94 | (Timers[timer].timerN)->CTRL = 0x0; |
sahilmgandhi | 18:6a4db94011d3 | 95 | /* Reload Value */ |
sahilmgandhi | 18:6a4db94011d3 | 96 | (Timers[timer].timerN)->RELOAD = Timers[timer].timerReload; |
sahilmgandhi | 18:6a4db94011d3 | 97 | /* Enable Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 98 | (Timers[timer].timerN)->CTRL = CMSDK_TIMER_CTRL_IRQEN_Msk; |
sahilmgandhi | 18:6a4db94011d3 | 99 | /* Enable Counter */ |
sahilmgandhi | 18:6a4db94011d3 | 100 | (Timers[timer].timerN)->CTRL |= CMSDK_TIMER_CTRL_EN_Msk; |
sahilmgandhi | 18:6a4db94011d3 | 101 | /* Change timer state */ |
sahilmgandhi | 18:6a4db94011d3 | 102 | Timers[timer].state |= TIMER_ENABLED; |
sahilmgandhi | 18:6a4db94011d3 | 103 | } |
sahilmgandhi | 18:6a4db94011d3 | 104 | } |
sahilmgandhi | 18:6a4db94011d3 | 105 | } |
sahilmgandhi | 18:6a4db94011d3 | 106 | |
sahilmgandhi | 18:6a4db94011d3 | 107 | /* |
sahilmgandhi | 18:6a4db94011d3 | 108 | * Timer_Disable(): Disables a hardware timer |
sahilmgandhi | 18:6a4db94011d3 | 109 | * timer: timer to be disabled |
sahilmgandhi | 18:6a4db94011d3 | 110 | */ |
sahilmgandhi | 18:6a4db94011d3 | 111 | void Timer_Disable(uint32_t timer) |
sahilmgandhi | 18:6a4db94011d3 | 112 | { |
sahilmgandhi | 18:6a4db94011d3 | 113 | /* The timer has to be contained in a valid range */ |
sahilmgandhi | 18:6a4db94011d3 | 114 | if (timer < NUM_TIMERS) { |
sahilmgandhi | 18:6a4db94011d3 | 115 | /* Timer has to be already initialized and enabled */ |
sahilmgandhi | 18:6a4db94011d3 | 116 | if (Timers[timer].state == (TIMER_INITIALIZED | TIMER_ENABLED)) { |
sahilmgandhi | 18:6a4db94011d3 | 117 | /* Disable Timer */ |
sahilmgandhi | 18:6a4db94011d3 | 118 | (Timers[timer].timerN)->CTRL = 0x0; |
sahilmgandhi | 18:6a4db94011d3 | 119 | /* Change timer state */ |
sahilmgandhi | 18:6a4db94011d3 | 120 | Timers[timer].state = TIMER_INITIALIZED; |
sahilmgandhi | 18:6a4db94011d3 | 121 | } |
sahilmgandhi | 18:6a4db94011d3 | 122 | } |
sahilmgandhi | 18:6a4db94011d3 | 123 | } |
sahilmgandhi | 18:6a4db94011d3 | 124 | |
sahilmgandhi | 18:6a4db94011d3 | 125 | /* |
sahilmgandhi | 18:6a4db94011d3 | 126 | * Timer_isEnabled(): verifies if a timer is enabled |
sahilmgandhi | 18:6a4db94011d3 | 127 | * timer: timer to be verified |
sahilmgandhi | 18:6a4db94011d3 | 128 | * @return: 0 disabled - 1 enabled |
sahilmgandhi | 18:6a4db94011d3 | 129 | */ |
sahilmgandhi | 18:6a4db94011d3 | 130 | uint32_t Timer_isEnabled(uint32_t timer) |
sahilmgandhi | 18:6a4db94011d3 | 131 | { |
sahilmgandhi | 18:6a4db94011d3 | 132 | /* The timer has to be contained in a valid range */ |
sahilmgandhi | 18:6a4db94011d3 | 133 | if (timer < NUM_TIMERS) { |
sahilmgandhi | 18:6a4db94011d3 | 134 | /* Timer has to be already initialized and enabled */ |
sahilmgandhi | 18:6a4db94011d3 | 135 | if (Timers[timer].state == (TIMER_INITIALIZED | TIMER_ENABLED)) |
sahilmgandhi | 18:6a4db94011d3 | 136 | return 1; |
sahilmgandhi | 18:6a4db94011d3 | 137 | } else { |
sahilmgandhi | 18:6a4db94011d3 | 138 | return 0; |
sahilmgandhi | 18:6a4db94011d3 | 139 | } |
sahilmgandhi | 18:6a4db94011d3 | 140 | return 0; |
sahilmgandhi | 18:6a4db94011d3 | 141 | } |
sahilmgandhi | 18:6a4db94011d3 | 142 | |
sahilmgandhi | 18:6a4db94011d3 | 143 | /* |
sahilmgandhi | 18:6a4db94011d3 | 144 | * Timer_Read(): provides timer VALUE |
sahilmgandhi | 18:6a4db94011d3 | 145 | * timer: timer to be read |
sahilmgandhi | 18:6a4db94011d3 | 146 | * @return: timer VALUE us |
sahilmgandhi | 18:6a4db94011d3 | 147 | */ |
sahilmgandhi | 18:6a4db94011d3 | 148 | uint32_t Timer_Read(uint32_t timer) |
sahilmgandhi | 18:6a4db94011d3 | 149 | { |
sahilmgandhi | 18:6a4db94011d3 | 150 | uint32_t return_value = 0; |
sahilmgandhi | 18:6a4db94011d3 | 151 | /* Verify if the Timer is enabled */ |
sahilmgandhi | 18:6a4db94011d3 | 152 | if (Timer_isEnabled(timer) == 1) { |
sahilmgandhi | 18:6a4db94011d3 | 153 | return_value = (Timers[timer].timerReload |
sahilmgandhi | 18:6a4db94011d3 | 154 | - (Timers[timer].timerN)->VALUE) |
sahilmgandhi | 18:6a4db94011d3 | 155 | / TIMER_TICKS_US; |
sahilmgandhi | 18:6a4db94011d3 | 156 | } |
sahilmgandhi | 18:6a4db94011d3 | 157 | |
sahilmgandhi | 18:6a4db94011d3 | 158 | return return_value; |
sahilmgandhi | 18:6a4db94011d3 | 159 | } |
sahilmgandhi | 18:6a4db94011d3 | 160 | |
sahilmgandhi | 18:6a4db94011d3 | 161 | /* |
sahilmgandhi | 18:6a4db94011d3 | 162 | * Timer_SetInterrupt(): sets timer Interrupt |
sahilmgandhi | 18:6a4db94011d3 | 163 | * timer: timer on which interrupt is set |
sahilmgandhi | 18:6a4db94011d3 | 164 | * time_us: reloading time in us |
sahilmgandhi | 18:6a4db94011d3 | 165 | */ |
sahilmgandhi | 18:6a4db94011d3 | 166 | void Timer_SetInterrupt(uint32_t timer, uint32_t time_us) |
sahilmgandhi | 18:6a4db94011d3 | 167 | { |
sahilmgandhi | 18:6a4db94011d3 | 168 | uint32_t load_time_us = 0; |
sahilmgandhi | 18:6a4db94011d3 | 169 | /* Verify if the Timer is enabled */ |
sahilmgandhi | 18:6a4db94011d3 | 170 | if (Timer_isEnabled(timer) == 1) { |
sahilmgandhi | 18:6a4db94011d3 | 171 | /* Disable Timer */ |
sahilmgandhi | 18:6a4db94011d3 | 172 | Timer_Disable(timer); |
sahilmgandhi | 18:6a4db94011d3 | 173 | /* Enable Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 174 | (Timers[timer].timerN)->CTRL = CMSDK_TIMER_CTRL_IRQEN_Msk; |
sahilmgandhi | 18:6a4db94011d3 | 175 | |
sahilmgandhi | 18:6a4db94011d3 | 176 | /* Check time us condition */ |
sahilmgandhi | 18:6a4db94011d3 | 177 | if(time_us == TIMER_DEFAULT_RELOAD) |
sahilmgandhi | 18:6a4db94011d3 | 178 | load_time_us = TIMER_MAX_VALUE; |
sahilmgandhi | 18:6a4db94011d3 | 179 | else |
sahilmgandhi | 18:6a4db94011d3 | 180 | load_time_us = time_us * TIMER_TICKS_US; |
sahilmgandhi | 18:6a4db94011d3 | 181 | |
sahilmgandhi | 18:6a4db94011d3 | 182 | /* Initialize Timer Value */ |
sahilmgandhi | 18:6a4db94011d3 | 183 | Timers[timer].timerReload = load_time_us; |
sahilmgandhi | 18:6a4db94011d3 | 184 | (Timers[timer].timerN)->RELOAD = Timers[timer].timerReload; |
sahilmgandhi | 18:6a4db94011d3 | 185 | (Timers[timer].timerN)->VALUE = Timers[timer].timerReload; |
sahilmgandhi | 18:6a4db94011d3 | 186 | /* Enable Counter */ |
sahilmgandhi | 18:6a4db94011d3 | 187 | (Timers[timer].timerN)->CTRL |= CMSDK_TIMER_CTRL_EN_Msk; |
sahilmgandhi | 18:6a4db94011d3 | 188 | /* Change timer state */ |
sahilmgandhi | 18:6a4db94011d3 | 189 | Timers[timer].state |= TIMER_ENABLED; |
sahilmgandhi | 18:6a4db94011d3 | 190 | } |
sahilmgandhi | 18:6a4db94011d3 | 191 | } |
sahilmgandhi | 18:6a4db94011d3 | 192 | |
sahilmgandhi | 18:6a4db94011d3 | 193 | /* |
sahilmgandhi | 18:6a4db94011d3 | 194 | * Timer_DisableInterrupt(): disables timer interrupt |
sahilmgandhi | 18:6a4db94011d3 | 195 | * timer: timer on which interrupt is disabled |
sahilmgandhi | 18:6a4db94011d3 | 196 | */ |
sahilmgandhi | 18:6a4db94011d3 | 197 | void Timer_DisableInterrupt(uint32_t timer) |
sahilmgandhi | 18:6a4db94011d3 | 198 | { |
sahilmgandhi | 18:6a4db94011d3 | 199 | /* Verify if the Timer is enabled */ |
sahilmgandhi | 18:6a4db94011d3 | 200 | if (Timer_isEnabled(timer) == 1) { |
sahilmgandhi | 18:6a4db94011d3 | 201 | /* Disable Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 202 | (Timers[timer].timerN)->CTRL &= CMSDK_TIMER_CTRL_EN_Msk; |
sahilmgandhi | 18:6a4db94011d3 | 203 | } |
sahilmgandhi | 18:6a4db94011d3 | 204 | } |
sahilmgandhi | 18:6a4db94011d3 | 205 | |
sahilmgandhi | 18:6a4db94011d3 | 206 | /* |
sahilmgandhi | 18:6a4db94011d3 | 207 | * Timer_ClearInterrupt(): clear timer interrupt |
sahilmgandhi | 18:6a4db94011d3 | 208 | * timer: timer on which interrupt needs to be cleared |
sahilmgandhi | 18:6a4db94011d3 | 209 | */ |
sahilmgandhi | 18:6a4db94011d3 | 210 | void Timer_ClearInterrupt(uint32_t timer) |
sahilmgandhi | 18:6a4db94011d3 | 211 | { |
sahilmgandhi | 18:6a4db94011d3 | 212 | /* Verify if the Timer is enabled */ |
sahilmgandhi | 18:6a4db94011d3 | 213 | if (Timer_isEnabled(timer) == 1) { |
sahilmgandhi | 18:6a4db94011d3 | 214 | /* Clear Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 215 | (Timers[timer].timerN)->INTCLEAR = CMSDK_TIMER_INTCLEAR_Msk; |
sahilmgandhi | 18:6a4db94011d3 | 216 | } |
sahilmgandhi | 18:6a4db94011d3 | 217 | } |
sahilmgandhi | 18:6a4db94011d3 | 218 | |
sahilmgandhi | 18:6a4db94011d3 | 219 | /* |
sahilmgandhi | 18:6a4db94011d3 | 220 | * Timer_GetIRQn(): returns IRQn of a Timer |
sahilmgandhi | 18:6a4db94011d3 | 221 | * timer: timer on which IRQn is defined - 0 if it is not defined |
sahilmgandhi | 18:6a4db94011d3 | 222 | */ |
sahilmgandhi | 18:6a4db94011d3 | 223 | uint32_t Timer_GetIRQn(uint32_t timer) |
sahilmgandhi | 18:6a4db94011d3 | 224 | { |
sahilmgandhi | 18:6a4db94011d3 | 225 | /* Verify if the Timer is enabled */ |
sahilmgandhi | 18:6a4db94011d3 | 226 | if (Timer_isEnabled(timer) == 1) { |
sahilmgandhi | 18:6a4db94011d3 | 227 | return Timers[timer].timerIRQn; |
sahilmgandhi | 18:6a4db94011d3 | 228 | } |
sahilmgandhi | 18:6a4db94011d3 | 229 | return 0; |
sahilmgandhi | 18:6a4db94011d3 | 230 | } |
sahilmgandhi | 18:6a4db94011d3 | 231 | |
sahilmgandhi | 18:6a4db94011d3 | 232 | /* |
sahilmgandhi | 18:6a4db94011d3 | 233 | * Timer_GetTicksUS(): returns the number of Ticks per us |
sahilmgandhi | 18:6a4db94011d3 | 234 | * timer: timer associated with the Ticks per us |
sahilmgandhi | 18:6a4db94011d3 | 235 | * @return: Ticks per us - 0 if the timer is disables |
sahilmgandhi | 18:6a4db94011d3 | 236 | */ |
sahilmgandhi | 18:6a4db94011d3 | 237 | uint32_t Timer_GetTicksUS(uint32_t timer) |
sahilmgandhi | 18:6a4db94011d3 | 238 | { |
sahilmgandhi | 18:6a4db94011d3 | 239 | /* Verify if the Timer is enabled */ |
sahilmgandhi | 18:6a4db94011d3 | 240 | if (Timer_isEnabled(timer) == 1) { |
sahilmgandhi | 18:6a4db94011d3 | 241 | return TIMER_TICKS_US; |
sahilmgandhi | 18:6a4db94011d3 | 242 | } |
sahilmgandhi | 18:6a4db94011d3 | 243 | return 0; |
sahilmgandhi | 18:6a4db94011d3 | 244 | } |
sahilmgandhi | 18:6a4db94011d3 | 245 | |
sahilmgandhi | 18:6a4db94011d3 | 246 | /* |
sahilmgandhi | 18:6a4db94011d3 | 247 | * Timer_GetReloadValue(): returns the load value of the selected |
sahilmgandhi | 18:6a4db94011d3 | 248 | * timer. |
sahilmgandhi | 18:6a4db94011d3 | 249 | * timer: timer associated with the Ticks per us |
sahilmgandhi | 18:6a4db94011d3 | 250 | * @return: reload value of the selected singletimer |
sahilmgandhi | 18:6a4db94011d3 | 251 | */ |
sahilmgandhi | 18:6a4db94011d3 | 252 | uint32_t Timer_GetReloadValue(uint32_t timer) |
sahilmgandhi | 18:6a4db94011d3 | 253 | { |
sahilmgandhi | 18:6a4db94011d3 | 254 | /* Verify if the Timer is enabled */ |
sahilmgandhi | 18:6a4db94011d3 | 255 | if (Timer_isEnabled(timer) == 1) { |
sahilmgandhi | 18:6a4db94011d3 | 256 | if (timer == TIMER1) |
sahilmgandhi | 18:6a4db94011d3 | 257 | return Timers[timer].timerReload / TIMER_TICKS_US; |
sahilmgandhi | 18:6a4db94011d3 | 258 | else |
sahilmgandhi | 18:6a4db94011d3 | 259 | return Timers[timer].timerReload / TIMER_TICKS_US; |
sahilmgandhi | 18:6a4db94011d3 | 260 | } |
sahilmgandhi | 18:6a4db94011d3 | 261 | return 0; |
sahilmgandhi | 18:6a4db94011d3 | 262 | } |