Skip to content

Commit

Permalink
correct sync use
Browse files Browse the repository at this point in the history
rsil doesn't require a sync,
isync  needed for processor state register
esync needed to get special register
  • Loading branch information
Makuna authored and igrr committed Jun 26, 2015
1 parent 87abcf3 commit 28a5a4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cores/esp8266/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ void ets_intr_unlock();
// level 15 will disable ALL interrupts,
// level 0 will disable most software interrupts
//
#define xt_disable_interrupts(state, level) __asm__ __volatile__("rsil %0," __STRINGIFY(level) "; esync; isync; dsync" : "=a" (state))
#define xt_enable_interrupts(state) __asm__ __volatile__("wsr %0,ps; esync" :: "a" (state) : "memory")
#define xt_disable_interrupts(state, level) __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state))
#define xt_enable_interrupts(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")

extern uint32_t interruptsState;

#define interrupts() xt_enable_interrupts(interruptsState)
#define noInterrupts() __asm__ __volatile__("rsil %0,15; esync; isync; dsync" : "=a" (interruptsState))
#define noInterrupts() __asm__ __volatile__("rsil %0,15" : "=a" (interruptsState))

#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
Expand Down
2 changes: 1 addition & 1 deletion cores/esp8266/Esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class EspClass {
uint32_t EspClass::getCycleCount()
{
uint32_t ccount;
__asm__ __volatile__("rsr %0,ccount":"=a" (ccount));
__asm__ __volatile__("esync; rsr %0,ccount":"=a" (ccount));
return ccount;
}

Expand Down

0 comments on commit 28a5a4c

Please sign in to comment.