Added byte sized timer that can be used inside an 8-bit microcontroller ISR for up to 255mS of elapsed timing.

This commit is contained in:
skarg
2010-12-10 23:16:02 +00:00
parent f5829ea483
commit 75249e0330
2 changed files with 26 additions and 2 deletions
+20
View File
@@ -303,6 +303,26 @@ void timer_interval_restart(
} }
} }
/*************************************************************************
* Description: Return the elapsed time
* Returns: number of milliseconds elapsed
* Notes: only up to 255ms elapsed
**************************************************************************/
uint8_t timer_milliseconds_delta(uint8_t start)
{
return (timer_milliseconds_byte() - start);
}
/*************************************************************************
* Description: Mark the start of a delta timer
* Returns: mark timer starting tick
* Notes: only up to 255ms elapsed
**************************************************************************/
uint8_t timer_milliseconds_mark(void)
{
return timer_milliseconds_byte();
}
#ifdef TEST #ifdef TEST
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
+6 -2
View File
@@ -48,8 +48,8 @@ extern "C" {
void); void);
uint32_t timer_milliseconds( uint32_t timer_milliseconds(
void); void);
uint32_t timer_milliseconds_set( uint8_t timer_milliseconds_byte(
uint32_t value); void);
/* these functions are in the generic timer.c module */ /* these functions are in the generic timer.c module */
@@ -103,6 +103,10 @@ extern "C" {
void timer_interval_restart( void timer_interval_restart(
struct itimer *t); struct itimer *t);
/* special for 8-bit microcontrollers - limited to 255ms */
uint8_t timer_milliseconds_delta(uint8_t start);
uint8_t timer_milliseconds_mark(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */