File tree 2 files changed +33
-26
lines changed
hardware/esp8266com/esp8266/cores/esp8266
2 files changed +33
-26
lines changed Original file line number Diff line number Diff line change @@ -160,27 +160,6 @@ void ets_intr_unlock();
160
160
#define interrupts () xt_rsil(0)
161
161
#define noInterrupts () xt_rsil(15)
162
162
163
- // this auto class wraps up xt_rsil so your code can be simplier, but can only be
164
- // used in an ino or cpp files. A normal use pattern is like
165
- //
166
- // {
167
- // {
168
- // InterruptLock(1); // this routine will allow level 2 and above
169
- // // do work within interrupt lock here
170
- // }
171
- // do work outside of interrupt lock here outside its scope
172
- // }
173
- //
174
- #define InterruptLock (intrLevel ) \
175
- class _AutoDisableIntr { \
176
- public: \
177
- _AutoDisableIntr () { _savedPS = xt_rsil (intrLevel); } \
178
- ~_AutoDisableIntr () { xt_wsr_ps (_savedPS); } \
179
- private: \
180
- uint32_t _savedPS; \
181
- }; \
182
- _AutoDisableIntr _autoDisableIntr
183
-
184
163
185
164
#define clockCyclesPerMicrosecond () ( F_CPU / 1000000L )
186
165
#define clockCyclesToMicroseconds (a ) ( (a) / clockCyclesPerMicrosecond() )
Original file line number Diff line number Diff line change @@ -8,23 +8,51 @@ extern "C" {
8
8
#include " ets_sys.h"
9
9
}
10
10
11
-
12
- #define xt_disable_interrupts (state, level ) __asm__ __volatile__ (" rsil %0," __STRINGIFY(level) : "=a" (state))
13
- #define xt_enable_interrupts (state ) __asm__ __volatile__ (" wsr %0,ps; isync" :: " a" (state) : "memory")
11
+ // these auto classes wrap up xt_rsil so your code can be simplier, but can only be
12
+ // used in an ino or cpp files.
13
+
14
+ // InterruptLock is used when you want to completely disable locks
15
+ // {
16
+ // {
17
+ // InterruptLock lock;
18
+ // // do work within interrupt lock here
19
+ // }
20
+ // do work outside of interrupt lock here outside its scope
21
+ // }
22
+ //
14
23
15
24
class InterruptLock {
16
25
public:
17
26
InterruptLock () {
18
- xt_disable_interrupts ( _state, 15 );
27
+ _state = = xt_rsil ( 15 );
19
28
}
20
29
21
30
~InterruptLock () {
22
- xt_enable_interrupts (_state);
31
+ xt_wsr_ps (_state);
23
32
}
24
33
25
34
protected:
26
35
uint32_t _state;
27
36
};
28
37
38
+ // AutoInterruptLock is when you need to set a specific level, A normal use pattern is like
39
+ //
40
+ // {
41
+ // {
42
+ // AutoInterruptLock(1); // this routine will allow level 2 and above
43
+ // // do work within interrupt lock here
44
+ // }
45
+ // do work outside of interrupt lock here outside its scope
46
+ // }
47
+ //
48
+ #define AutoInterruptLock (intrLevel ) \
49
+ class _AutoDisableIntr { \
50
+ public: \
51
+ _AutoDisableIntr () { _savedPS = xt_rsil (intrLevel); } \
52
+ ~_AutoDisableIntr () { xt_wsr_ps (_savedPS); } \
53
+ private: \
54
+ uint32_t _savedPS; \
55
+ }; \
56
+ _AutoDisableIntr _autoDisableIntr
29
57
30
58
#endif // INTERRUPTS_H
You can’t perform that action at this time.
0 commit comments