File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
hardware/digispark/cores/tiny Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 48
48
#define MILLISTIMER_OVF_vect MILLISTIMER_(OVF_vect)
49
49
50
50
51
+ #define MS_TIMER_TICK_EVERY_X_CYCLES 1
/* Shall be a within 1, 8, 64, 256 or 1024. (default = 64) If set to 1, HW PWM is around [email protected] with Digispark */
52
+
51
53
#if F_CPU >= 3000000L
54
+ #if !defined(MS_TIMER_TICK_EVERY_X_CYCLES )
52
55
#define MillisTimer_Prescale_Index MillisTimer_(Prescale_Value_64)
53
56
#define MillisTimer_Prescale_Value (64)
54
57
#define ToneTimer_Prescale_Index ToneTimer_(Prescale_Value_64)
55
58
#define ToneTimer_Prescale_Value (64)
59
+ #else
60
+ #define Prescaler_Value (Val ) PRESCALER_VALUE(Val)
61
+ #define PRESCALER_VALUE (Val ) Prescale_Value_##Val
62
+ #define MillisTimer_Prescale_Index MillisTimer_(Prescaler_Value(MS_TIMER_TICK_EVERY_X_CYCLES))
63
+ #define MillisTimer_Prescale_Value (MS_TIMER_TICK_EVERY_X_CYCLES)
64
+ #define ToneTimer_Prescale_Index ToneTimer_(Prescaler_Value(MS_TIMER_TICK_EVERY_X_CYCLES))
65
+ #define ToneTimer_Prescale_Value (MS_TIMER_TICK_EVERY_X_CYCLES)
66
+ #endif
56
67
#else
57
68
#define MillisTimer_Prescale_Index MillisTimer_(Prescale_Value_8)
58
69
#define MillisTimer_Prescale_Value (8)
@@ -140,7 +151,11 @@ unsigned long micros()
140
151
141
152
SREG = oldSREG ;
142
153
154
+ #if (MillisTimer_Prescale_Value >= clockCyclesPerMicrosecond ())
143
155
return ((m << 8 ) + t ) * (MillisTimer_Prescale_Value / clockCyclesPerMicrosecond ());
156
+ #else
157
+ return ((m << 8 ) + t ) / (clockCyclesPerMicrosecond () / MillisTimer_Prescale_Value );
158
+ #endif
144
159
}
145
160
146
161
void delay (unsigned long ms )
You can’t perform that action at this time.
0 commit comments