File tree 3 files changed +8
-22
lines changed
3 files changed +8
-22
lines changed Original file line number Diff line number Diff line change @@ -114,8 +114,8 @@ void timer1_write(uint32_t ticks); //maximum ticks 8388607
114
114
// it is auto-disabled when the compare value matches CCOUNT
115
115
// it is auto-enabled when the compare value changes
116
116
#define timer0_interrupted () (ETS_INTR_PENDING() & (_BV(ETS_COMPARE0_INUM)))
117
- #define timer0_read () (ESP.getCycleCompare0( ))
118
- #define timer0_write (ticks ) (ESP.setCycleCompare0(ticks) )
117
+ #define timer0_read () ((__extension__({uint32_t count;__asm__ __volatile__("esync; rsr %0,ccompare0":"=a" (count));count;}) ))
118
+ #define timer0_write (count ) __asm__ __volatile__("wsr %0,ccompare0; esync"::"a" (count) : "memory" )
119
119
120
120
void timer0_isr_init (void );
121
121
void timer0_attachInterrupt (void (* userFunc )(void ));
Original file line number Diff line number Diff line change @@ -99,8 +99,6 @@ class EspClass {
99
99
uint32_t getFlashChipSizeByChipId (void );
100
100
101
101
inline uint32_t getCycleCount (void );
102
- inline uint32_t getCycleCompare0 (void );
103
- inline void setCycleCompare0 (uint32_t count);
104
102
};
105
103
106
104
uint32_t EspClass::getCycleCount (void )
@@ -110,20 +108,6 @@ uint32_t EspClass::getCycleCount(void)
110
108
return ccount;
111
109
}
112
110
113
- // this returns a value in the range of (0 - 2^32)
114
- uint32_t EspClass::getCycleCompare0 (void )
115
- {
116
- uint32_t count;
117
- __asm__ __volatile__ (" esync; rsr %0,ccompare0" :" =a" (count));
118
- return count;
119
- }
120
-
121
- // this takes a value in the range of (0 - 2^32)
122
- void EspClass::setCycleCompare0 (uint32_t count)
123
- {
124
- __asm__ __volatile__ (" wsr %0,ccompare0; esync" ::" a" (count) : " memory" );
125
- }
126
-
127
111
extern EspClass ESP;
128
112
129
113
#endif // ESP_H
Original file line number Diff line number Diff line change 22
22
#include "pins_arduino.h"
23
23
#include "c_types.h"
24
24
25
- void (* timer1_user_cb )(void );
25
+ typedef void (* _timercallback )(void );
26
+
27
+ static volatile _timercallback timer1_user_cb = NULL ;
26
28
27
29
void timer1_isr_handler (void * para ){
28
30
if ((T1C & ((1 << TCAR ) | (1 << TCIT ))) == 0 ) TEIE &= ~TEIE1 ;//edge int disable
@@ -60,7 +62,7 @@ void timer1_disable(){
60
62
T1I = 0 ;
61
63
}
62
64
63
- void ( * timer0_user_cb )( void ) ;
65
+ static volatile _timercallback timer0_user_cb = NULL ;
64
66
65
67
void timer0_isr_handler (void * para ){
66
68
if (timer0_user_cb ) {
@@ -73,11 +75,11 @@ void timer0_isr_init(){
73
75
}
74
76
75
77
void timer0_attachInterrupt (void (* userFunc )(void )) {
76
- timer1_user_cb = userFunc ;
78
+ timer0_user_cb = userFunc ;
77
79
ETS_CCOMPARE0_ENABLE ();
78
80
}
79
81
80
82
void timer0_detachInterrupt () {
81
- timer1_user_cb = NULL ;
83
+ timer0_user_cb = NULL ;
82
84
ETS_CCOMPARE0_DISABLE ();
83
85
}
You can’t perform that action at this time.
0 commit comments