@@ -96,24 +96,12 @@ ISR(TIMER1_COMPA_vect,ISR_NOBLOCK)
9696IRAM_ATTR ISR (TIMER1_COMPA_vect)
9797#endif
9898{
99- #ifdef HAL_TIMER1_INT_CLEAR
100- HAL_TIMER1_INT_CLEAR;
101- #endif
102- #ifdef ESP32
103- portENTER_CRITICAL_ISR (&siderealTimerMux);
99+ #ifdef HAL_TIMER1_PREFIX
100+ HAL_TIMER1_PREFIX;
104101#endif
105102
106103 // run 1/3 of the time at 3x the rate, unless a goto is happening
107- if (trackingState!=TrackingMoveTo) {
108- cnt++;
109- if (cnt%3 !=0 ) {
110- #ifdef ESP32
111- portEXIT_CRITICAL_ISR (&siderealTimerMux);
112- #endif
113- return ;
114- }
115- cnt=0 ;
116- }
104+ if (trackingState!=TrackingMoveTo) { cnt++; if (cnt%3 !=0 ) goto done; cnt=0 ; }
117105 lst++;
118106
119107 // handle buzzer
@@ -123,9 +111,10 @@ IRAM_ATTR ISR(TIMER1_COMPA_vect)
123111 timerSuper ();
124112#endif
125113
126- #ifdef ESP32
127- portEXIT_CRITICAL_ISR (&siderealTimerMux);
128- #endif
114+ done: {}
115+ #ifdef HAL_TIMER1_SUFFIX
116+ HAL_TIMER1_SUFFIX;
117+ #endif
129118}
130119
131120void timerSuper () {
@@ -248,22 +237,11 @@ void timerSuper() {
248237
249238IRAM_ATTR ISR (TIMER3_COMPA_vect)
250239{
251- #ifdef HAL_TIMER3_INT_CLEAR
252- HAL_TIMER3_INT_CLEAR;
253- #endif
254- #ifdef ESP32
255- portENTER_CRITICAL_ISR (&motorTimerMux);
240+ #ifdef HAL_TIMER3_PREFIX
241+ HAL_TIMER3_PREFIX;
256242#endif
257243
258- if (!fastAxis1) {
259- t3cnt++;
260- if (t3cnt%t3rep!=0 ) {
261- #ifdef ESP32
262- portEXIT_CRITICAL_ISR (&motorTimerMux);
263- #endif
264- return ;
265- }
266- }
244+ if (!fastAxis1) { t3cnt++; if (t3cnt%t3rep!=0 ) goto done; }
267245
268246 StepPinAxis1_LOW;
269247
@@ -325,29 +303,19 @@ IRAM_ATTR ISR(TIMER3_COMPA_vect)
325303 }
326304#endif
327305
328- #ifdef ESP32
329- portEXIT_CRITICAL_ISR (&motorTimerMux);
306+ done: {}
307+ #ifdef HAL_TIMER3_SUFFIX
308+ HAL_TIMER3_SUFFIX;
330309#endif
331310}
332311
333312IRAM_ATTR ISR (TIMER4_COMPA_vect)
334313{
335- #ifdef HAL_TIMER4_INT_CLEAR
336- HAL_TIMER4_INT_CLEAR;
337- #endif
338- #ifdef ESP32
339- portENTER_CRITICAL_ISR (&motorTimerMux);
314+ #ifdef HAL_TIMER4_PREFIX
315+ HAL_TIMER4_PREFIX;
340316#endif
341317
342- if (!fastAxis2) {
343- t4cnt++;
344- if (t4cnt%t4rep!=0 ) {
345- #ifdef ESP32
346- portEXIT_CRITICAL_ISR (&motorTimerMux);
347- #endif
348- return ;
349- }
350- }
318+ if (!fastAxis2) { t4cnt++; if (t4cnt%t4rep!=0 ) goto done; }
351319
352320 StepPinAxis2_LOW;
353321
@@ -409,8 +377,9 @@ IRAM_ATTR ISR(TIMER4_COMPA_vect)
409377 }
410378#endif
411379
412- #ifdef ESP32
413- portEXIT_CRITICAL_ISR (&motorTimerMux);
380+ done: {}
381+ #ifdef HAL_TIMER4_SUFFIX
382+ HAL_TIMER4_SUFFIX;
414383#endif
415384}
416385
@@ -453,4 +422,3 @@ void clockSync() {
453422 PPSlastMicroS=t;
454423}
455424#endif
456-
0 commit comments