25 #include "user_config.h"
33 static ETSTimer task_1ms;
40 os_timer_disarm(&task_1ms);
49 os_timer_arm(&task_1ms, 1, 1);
57 os_timer_disarm(&task_1ms);
60 #endif // ifdef ESP8266
68 #define HAVE_HIRES_TIMER
71 #define TIMER1_PRESCALE 1L
74 #define TIMER1_COUNTS_PER_TIC (F_CPU/TIMER1_PRESCALE/SYSTEM_TASK_HZ)
77 #define TIMER1_COUNTER_RES (SYSTEM_TASK_TIC_NS/TIMER1_COUNTS_PER_TIC)
79 #if TIMER1_COUNTS_PER_TIC >= 65535L
80 #error TIMER1_COUNTS_PER_TIC too big -- increase TIMER1 Prescale
83 #define TIMER1_PRE_1 (1 << CS10)
84 #define TIMER1_PRE_8 (1 << CS11)
85 #define TIMER1_PRE_64 ((1 << CS11) | ( 1 << CS10))
86 #define TIMER1_PRE_256 (1 << CS12)
88 #define TIMER1_PRE_1024 ((1 << CS12) | ( 1 << CS10))
125 TCCR1B=(1<<WGM12) | TIMER1_PRE_1;
127 OCR1A=(TIMER1_COUNTS_PER_TIC-1);
128 TIMSK1 |= (1<<OCIE1A);
137 ISR(TIMER1_COMPA_vect)
143 #ifdef HAVE_HIRES_TIMER
156 uint16_t count1,count2;
158 uint8_t pendingf = 0;
171 if( TIFR1 & (1<<OCF1A) )
179 offset = TIMER1_COUNTS_PER_TIC;
184 offset = TIMER1_COUNTS_PER_TIC;
191 offset *= TIMER1_COUNTER_RES;
195 if (ts->
tv_nsec >= 1000000000L)
202 #endif // ifdef HAVE_HIRES_TIMER