diff --git a/bacnet-stack/ports/atmega168/timer.c b/bacnet-stack/ports/atmega168/timer.c index 40c60b12..5a7b0d7e 100644 --- a/bacnet-stack/ports/atmega168/timer.c +++ b/bacnet-stack/ports/atmega168/timer.c @@ -88,12 +88,10 @@ uint16_t Timer_Silence( void) { uint16_t timer; - uint8_t sreg; - sreg = SREG; - __disable_interrupt(); + BIT_CLEAR(TIMSK0, TOIE0); timer = SilenceTime; - SREG = sreg; + BIT_SET(TIMSK0, TOIE0); return timer; } @@ -102,10 +100,7 @@ uint16_t Timer_Silence( void Timer_Silence_Reset( void) { - uint8_t sreg; - - sreg = SREG; - __disable_interrupt(); + BIT_CLEAR(TIMSK0, TOIE0); SilenceTime = 0; - SREG = sreg; + BIT_SET(TIMSK0, TOIE0); } diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/timer2.c b/bacnet-stack/ports/bdk-atxx4-mstp/timer2.c index 13b2e613..d497ec1e 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/timer2.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/timer2.c @@ -57,6 +57,7 @@ /* counter for the the timer which wraps every 49.7 days */ static volatile uint32_t Millisecond_Counter; +static volatile uint8_t Millisecond_Counter_Byte; /* forward prototype */ ISR(TIMER2_OVF_vect); @@ -70,6 +71,7 @@ static inline void timer_interrupt_handler(void) /* Set the counter for the next interrupt */ TCNT2 = TIMER2_COUNT; Millisecond_Counter++; + Millisecond_Counter_Byte++; } /************************************************************************* @@ -102,6 +104,17 @@ uint32_t timer_milliseconds( return timer_value; } +/************************************************************************* +* Description: returns the current millisecond count +* Returns: none +* Notes: This method only disables the timer overflow interrupt. +*************************************************************************/ +uint8_t timer_milliseconds_byte( + void) +{ + return Millisecond_Counter; +} + /************************************************************************* * Description: Initialization for Timer * Returns: none