mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-25 20:02:37 +03:00
Fixed timer bug and cleaned up
Decided to not expose compare timer in ESP object to minimize the exposure surface Fixed incorrect timer callback being used and initialized timer callbacks
This commit is contained in:
parent
95da465eb7
commit
63f91292ce
@ -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() (ESP.getCycleCompare0())
|
||||
#define timer0_write(ticks) (ESP.setCycleCompare0(ticks))
|
||||
#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")
|
||||
|
||||
void timer0_isr_init(void);
|
||||
void timer0_attachInterrupt(void(*userFunc)(void));
|
||||
|
@ -99,8 +99,6 @@ 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)
|
||||
@ -110,20 +108,6 @@ 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,7 +22,9 @@
|
||||
#include "pins_arduino.h"
|
||||
#include "c_types.h"
|
||||
|
||||
void (*timer1_user_cb)(void);
|
||||
typedef void(*_timercallback)(void);
|
||||
|
||||
static volatile _timercallback timer1_user_cb = NULL;
|
||||
|
||||
void timer1_isr_handler(void *para){
|
||||
if((T1C & ((1 << TCAR) | (1 << TCIT))) == 0) TEIE &= ~TEIE1;//edge int disable
|
||||
@ -60,7 +62,7 @@ void timer1_disable(){
|
||||
T1I = 0;
|
||||
}
|
||||
|
||||
void(*timer0_user_cb)(void);
|
||||
static volatile _timercallback timer0_user_cb = NULL;
|
||||
|
||||
void timer0_isr_handler(void *para){
|
||||
if (timer0_user_cb) {
|
||||
@ -73,11 +75,11 @@ void timer0_isr_init(){
|
||||
}
|
||||
|
||||
void timer0_attachInterrupt(void(*userFunc)(void)) {
|
||||
timer1_user_cb = userFunc;
|
||||
timer0_user_cb = userFunc;
|
||||
ETS_CCOMPARE0_ENABLE();
|
||||
}
|
||||
|
||||
void timer0_detachInterrupt() {
|
||||
timer1_user_cb = NULL;
|
||||
timer0_user_cb = NULL;
|
||||
ETS_CCOMPARE0_DISABLE();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user