File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,27 +160,6 @@ void ets_intr_unlock();
160160#define interrupts () xt_rsil(0)
161161#define noInterrupts () xt_rsil(15)
162162
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-
184163
185164#define clockCyclesPerMicrosecond () ( F_CPU / 1000000L )
186165#define clockCyclesToMicroseconds (a ) ( (a) / clockCyclesPerMicrosecond() )
Original file line number Diff line number Diff line change @@ -8,23 +8,51 @@ extern "C" {
88#include " ets_sys.h"
99}
1010
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+ //
1423
1524class InterruptLock {
1625public:
1726 InterruptLock () {
18- xt_disable_interrupts ( _state, 15 );
27+ _state = = xt_rsil ( 15 );
1928 }
2029
2130 ~InterruptLock () {
22- xt_enable_interrupts (_state);
31+ xt_wsr_ps (_state);
2332 }
2433
2534protected:
2635 uint32_t _state;
2736};
2837
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
2957
3058#endif // INTERRUPTS_H
You can’t perform that action at this time.
0 commit comments