mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
Revert "Fixed timer bug and cleaned up"
This reverts commit cff57490feae778b68740e0ef878d4521ae4eb2b.
This commit is contained in:
parent
63f91292ce
commit
4ad7f3bf07
@ -114,8 +114,8 @@ void timer1_write(uint32_t ticks); //maximum ticks 8388607
|
||||
// it is auto-disabled when the compare value matches CCOUNT
|
||||
// it is auto-enabled when the compare value changes
|
||||
#define timer0_interrupted() (ETS_INTR_PENDING() & (_BV(ETS_COMPARE0_INUM)))
|
||||
#define timer0_read() ((__extension__({uint32_t count;__asm__ __volatile__("esync; rsr %0,ccompare0":"=a" (count));count;})))
|
||||
#define timer0_write(count) __asm__ __volatile__("wsr %0,ccompare0; esync"::"a" (count) : "memory")
|
||||
#define timer0_read() (ESP.getCycleCompare0())
|
||||
#define timer0_write(ticks) (ESP.setCycleCompare0(ticks))
|
||||
|
||||
void timer0_isr_init(void);
|
||||
void timer0_attachInterrupt(void(*userFunc)(void));
|
||||
|
@ -99,6 +99,8 @@ class EspClass {
|
||||
uint32_t getFlashChipSizeByChipId(void);
|
||||
|
||||
inline uint32_t getCycleCount(void);
|
||||
inline uint32_t getCycleCompare0(void);
|
||||
inline void setCycleCompare0(uint32_t count);
|
||||
};
|
||||
|
||||
uint32_t EspClass::getCycleCount(void)
|
||||
@ -108,6 +110,20 @@ uint32_t EspClass::getCycleCount(void)
|
||||
return ccount;
|
||||
}
|
||||
|
||||
// this returns a value in the range of (0 - 2^32)
|
||||
uint32_t EspClass::getCycleCompare0(void)
|
||||
{
|
||||
uint32_t count;
|
||||
__asm__ __volatile__("esync; rsr %0,ccompare0":"=a" (count));
|
||||
return count;
|
||||
}
|
||||
|
||||
// this takes a value in the range of (0 - 2^32)
|
||||
void EspClass::setCycleCompare0(uint32_t count)
|
||||
{
|
||||
__asm__ __volatile__("wsr %0,ccompare0; esync"::"a" (count) : "memory");
|
||||
}
|
||||
|
||||
extern EspClass ESP;
|
||||
|
||||
#endif //ESP_H
|
||||
|
@ -22,9 +22,7 @@
|
||||
#include "pins_arduino.h"
|
||||
#include "c_types.h"
|
||||
|
||||
typedef void(*_timercallback)(void);
|
||||
|
||||
static volatile _timercallback timer1_user_cb = NULL;
|
||||
void (*timer1_user_cb)(void);
|
||||
|
||||
void timer1_isr_handler(void *para){
|
||||
if((T1C & ((1 << TCAR) | (1 << TCIT))) == 0) TEIE &= ~TEIE1;//edge int disable
|
||||
@ -62,7 +60,7 @@ void timer1_disable(){
|
||||
T1I = 0;
|
||||
}
|
||||
|
||||
static volatile _timercallback timer0_user_cb = NULL;
|
||||
void(*timer0_user_cb)(void);
|
||||
|
||||
void timer0_isr_handler(void *para){
|
||||
if (timer0_user_cb) {
|
||||
@ -75,11 +73,11 @@ void timer0_isr_init(){
|
||||
}
|
||||
|
||||
void timer0_attachInterrupt(void(*userFunc)(void)) {
|
||||
timer0_user_cb = userFunc;
|
||||
timer1_user_cb = userFunc;
|
||||
ETS_CCOMPARE0_ENABLE();
|
||||
}
|
||||
|
||||
void timer0_detachInterrupt() {
|
||||
timer0_user_cb = NULL;
|
||||
timer1_user_cb = NULL;
|
||||
ETS_CCOMPARE0_DISABLE();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user