1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-06 05:21:22 +03:00

Merge pull request #200 from Makuna/esp8266

true noInterrupts() interrupts() support
This commit is contained in:
Ivan Grokhotkov 2015-05-08 08:28:10 +03:00
commit 7e15659c29
3 changed files with 22 additions and 2 deletions

View File

@ -124,8 +124,17 @@ void timer1_write(uint32_t ticks); //maximum ticks 8388607
void ets_intr_lock();
void ets_intr_unlock();
#define interrupts() ets_intr_unlock();
#define noInterrupts() ets_intr_lock();
// level (0-15),
// 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")
extern uint32_t interruptsState;
#define interrupts() xt_enable_interrupts(interruptsState)
#define noInterrupts() xt_disable_interrupts(interruptsState, 15)
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )

View File

@ -95,8 +95,16 @@ class EspClass {
FlashMode_t getFlashChipMode(void);
uint32_t getFlashChipSizeByChipId(void);
inline uint32_t getCycleCount(void);
};
uint32_t EspClass::getCycleCount(void)
{
uint32_t ccount;
__asm__ __volatile__("rsr %0,ccount":"=a" (ccount));
return ccount;
}
extern EspClass ESP;
#endif //ESP_H

View File

@ -139,6 +139,9 @@ extern void __detachInterrupt(uint8_t pin) {
}
}
// stored state for the noInterrupts/interrupts methods
uint32_t interruptsState = 0;
void initPins() {
//Disable UART interrupts
system_set_os_print(0);