X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=bertos%2Fcpu%2Favr%2Fdrv%2Ftimer_avr.h;h=1288057f6d01e3e3f89f08fea6340c43944ad09c;hb=c4091308dd2d35b7a79b3b0632ade5594b6fedf4;hp=96d05082b83f978b8c27815c1d601e36385aae2c;hpb=8dabf14299bc6b3b9fc0b4dfdeba91af82aba46c;p=bertos.git diff --git a/bertos/cpu/avr/drv/timer_avr.h b/bertos/cpu/avr/drv/timer_avr.h index 96d05082..1288057f 100644 --- a/bertos/cpu/avr/drv/timer_avr.h +++ b/bertos/cpu/avr/drv/timer_avr.h @@ -43,12 +43,14 @@ #ifndef DRV_TIMER_AVR_H #define DRV_TIMER_AVR_H -#include /* CPU_FREQ */ +#include /* CPU_FREQ */ -#include "cfg/cfg_timer.h" /* CONFIG_TIMER */ -#include /* uint8_t */ -#include /* DIV_ROUND */ +#include "cfg/cfg_timer.h" /* CONFIG_TIMER */ +#include /* uint8_t */ +#include /* DIV_ROUND */ +#include +#include /** * \name Values for CONFIG_TIMER. @@ -81,6 +83,12 @@ /// Type of time expressed in ticks of the hardware high-precision timer typedef uint8_t hptime_t; + #define SIZEOF_HPTIME_T 1 + + INLINE hptime_t timer_hw_hpread(void) + { + return TCNT0; + } #elif (CONFIG_TIMER == TIMER_ON_OVERFLOW1) @@ -93,6 +101,12 @@ /// Type of time expressed in ticks of the hardware high precision timer typedef uint16_t hptime_t; + #define SIZEOF_HPTIME_T 2 + + INLINE hptime_t timer_hw_hpread(void) + { + return TCNT1; + } #elif (CONFIG_TIMER == TIMER_ON_OUTPUT_COMPARE2) @@ -107,9 +121,14 @@ /** Value for OCR register in output-compare based timers. */ #define TIMER_HW_CNT OCR_DIVISOR - /// Type of time expressed in ticks of the hardware high precision timer typedef uint8_t hptime_t; + #define SIZEOF_HPTIME_T 1 + + INLINE hptime_t timer_hw_hpread(void) + { + return TCNT2; + } #elif (CONFIG_TIMER == TIMER_ON_OVERFLOW3) @@ -122,6 +141,13 @@ /// Type of time expressed in ticks of the hardware high precision timer typedef uint16_t hptime_t; + #define SIZEOF_HPTIME_T 2 + + INLINE hptime_t timer_hw_hpread(void) + { + return TCNT3; + } + #else #error Unimplemented value for CONFIG_TIMER @@ -143,5 +169,6 @@ /** Not needed, timer IRQ handler called only for timer source */ #define timer_hw_triggered() (true) +void timer_hw_init(void); #endif /* DRV_TIMER_AVR_H */