diff --git a/include/arm11/hardware/timer.h b/include/arm11/hardware/timer.h index 45ad588..f850726 100644 --- a/include/arm11/hardware/timer.h +++ b/include/arm11/hardware/timer.h @@ -57,9 +57,11 @@ u32 TIMER_getTicks(void); /** - * @brief Stops the timer. + * @brief Stops the timer and returns the current number of ticks. + * + * @return The number of ticks. */ -void TIMER_stop(void); +u32 TIMER_stop(void); /** * @brief Halts the CPU for the specified number of ticks. diff --git a/include/arm9/hardware/timer.h b/include/arm9/hardware/timer.h index 27aec3f..fbb32ef 100644 --- a/include/arm9/hardware/timer.h +++ b/include/arm9/hardware/timer.h @@ -78,11 +78,13 @@ u16 TIMER_getTicks(Timer timer); /** - * @brief Stops a timer. + * @brief Stops a timer and returns the current number of ticks. * * @param[in] timer The timer to stop. + * + * @return The number of ticks. */ -void TIMER_stop(Timer timer); +u16 TIMER_stop(Timer timer); /** * @brief Halts the CPU for the specified number of milliseconds. diff --git a/source/arm11/hardware/timer.c b/source/arm11/hardware/timer.c index b5a5445..a31e69b 100644 --- a/source/arm11/hardware/timer.c +++ b/source/arm11/hardware/timer.c @@ -54,10 +54,12 @@ return REG_TIMER_COUNTER; } -void TIMER_stop(void) +u32 TIMER_stop(void) { REG_TIMER_CNT = 0; REG_TIMER_INT_STAT = 1; + + return REG_TIMER_COUNTER; } void TIMER_sleepTicks(u32 ticks) diff --git a/source/arm9/hardware/timer.c b/source/arm9/hardware/timer.c index 918b0a7..2f140fd 100644 --- a/source/arm9/hardware/timer.c +++ b/source/arm9/hardware/timer.c @@ -67,9 +67,11 @@ return REG_TIMER_VAL(timer); } -void TIMER_stop(Timer timer) +u16 TIMER_stop(Timer timer) { REG_TIMER_CNT(timer) = 0; + + return REG_TIMER_VAL(timer); } void TIMER_sleep(u32 ms)