mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
fix PWM and Timer1
This commit is contained in:
parent
1f657fab73
commit
b5d6951743
@ -30,32 +30,39 @@ void timer1_isr_handler(void *para){
|
|||||||
if(timer1_user_cb) timer1_user_cb();
|
if(timer1_user_cb) timer1_user_cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer1_attachInterrupt(void (*userFunc)(void)) {
|
extern void __timer1_isr_init(){
|
||||||
|
ETS_FRC_TIMER1_INTR_ATTACH(timer1_isr_handler, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void __timer1_attachInterrupt(void (*userFunc)(void)) {
|
||||||
timer1_user_cb = userFunc;
|
timer1_user_cb = userFunc;
|
||||||
ETS_FRC1_INTR_ENABLE();
|
ETS_FRC1_INTR_ENABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer1_detachInterrupt() {
|
extern void __timer1_detachInterrupt() {
|
||||||
timer1_user_cb = 0;
|
timer1_user_cb = 0;
|
||||||
TEIE &= ~TEIE1;//edge int disable
|
TEIE &= ~TEIE1;//edge int disable
|
||||||
ETS_FRC1_INTR_DISABLE();
|
ETS_FRC1_INTR_DISABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer1_enable(uint8_t divider, uint8_t int_type, uint8_t reload){
|
extern void __timer1_enable(uint8_t divider, uint8_t int_type, uint8_t reload){
|
||||||
T1C = (1 << TCTE) | ((divider & 3) << TCPD) | ((int_type & 1) << TCIT) | ((reload & 1) << TCAR);
|
T1C = (1 << TCTE) | ((divider & 3) << TCPD) | ((int_type & 1) << TCIT) | ((reload & 1) << TCAR);
|
||||||
T1I = 0;
|
T1I = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer1_write(uint32_t ticks){
|
extern void __timer1_write(uint32_t ticks){
|
||||||
T1L = ((ticks) & 0x7FFFFF);
|
T1L = ((ticks) & 0x7FFFFF);
|
||||||
if((T1C & (1 << TCIT)) == 0) TEIE |= TEIE1;//edge int enable
|
if((T1C & (1 << TCIT)) == 0) TEIE |= TEIE1;//edge int enable
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer1_disable(){
|
extern void __timer1_disable(){
|
||||||
T1C = 0;
|
T1C = 0;
|
||||||
T1I = 0;
|
T1I = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer1_isr_init(){
|
extern void timer1_isr_init(void) __attribute__ ((weak, alias("__timer1_isr_init")));
|
||||||
ETS_FRC_TIMER1_INTR_ATTACH(timer1_isr_handler, NULL);
|
extern void timer1_detachInterrupt(void) __attribute__ ((weak, alias("__timer1_detachInterrupt")));
|
||||||
}
|
extern void timer1_disable(void) __attribute__ ((weak, alias("__timer1_disable")));
|
||||||
|
extern void timer1_attachInterrupt(void (*userFunc)(void)) __attribute__ ((weak, alias("__timer1_attachInterrupt")));
|
||||||
|
extern void timer1_write(uint32_t ticks) __attribute__ ((weak, alias("__timer1_write")));
|
||||||
|
extern void timer1_enable(uint8_t divider, uint8_t int_type, uint8_t reload) __attribute__ ((weak, alias("__timer1_enable")));
|
@ -75,6 +75,7 @@ void delayMicroseconds(unsigned int us) {
|
|||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
initPins();
|
initPins();
|
||||||
|
timer1_isr_init();
|
||||||
os_timer_setfn(µs_overflow_timer, (os_timer_func_t*) µs_overflow_tick, 0);
|
os_timer_setfn(µs_overflow_timer, (os_timer_func_t*) µs_overflow_tick, 0);
|
||||||
os_timer_arm(µs_overflow_timer, 60000, REPEAT);
|
os_timer_arm(µs_overflow_timer, 60000, REPEAT);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user