From b5d695174313663b46cf56549c59d5c08811b8aa Mon Sep 17 00:00:00 2001 From: ficeto Date: Mon, 11 May 2015 14:17:13 +0300 Subject: [PATCH] fix PWM and Timer1 --- cores/esp8266/core_esp8266_timer.c | 23 +++++++++++++++-------- cores/esp8266/core_esp8266_wiring.c | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cores/esp8266/core_esp8266_timer.c b/cores/esp8266/core_esp8266_timer.c index 54ec65692..9edee3671 100644 --- a/cores/esp8266/core_esp8266_timer.c +++ b/cores/esp8266/core_esp8266_timer.c @@ -30,32 +30,39 @@ void timer1_isr_handler(void *para){ 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; ETS_FRC1_INTR_ENABLE(); } -void timer1_detachInterrupt() { +extern void __timer1_detachInterrupt() { timer1_user_cb = 0; TEIE &= ~TEIE1;//edge int 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); T1I = 0; } -void timer1_write(uint32_t ticks){ +extern void __timer1_write(uint32_t ticks){ T1L = ((ticks) & 0x7FFFFF); if((T1C & (1 << TCIT)) == 0) TEIE |= TEIE1;//edge int enable } -void timer1_disable(){ +extern void __timer1_disable(){ T1C = 0; T1I = 0; } -void timer1_isr_init(){ - ETS_FRC_TIMER1_INTR_ATTACH(timer1_isr_handler, NULL); -} \ No newline at end of file +extern void timer1_isr_init(void) __attribute__ ((weak, alias("__timer1_isr_init"))); +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"))); \ No newline at end of file diff --git a/cores/esp8266/core_esp8266_wiring.c b/cores/esp8266/core_esp8266_wiring.c index b16acc242..0170b4bcf 100644 --- a/cores/esp8266/core_esp8266_wiring.c +++ b/cores/esp8266/core_esp8266_wiring.c @@ -75,6 +75,7 @@ void delayMicroseconds(unsigned int us) { void init() { initPins(); + timer1_isr_init(); os_timer_setfn(µs_overflow_timer, (os_timer_func_t*) µs_overflow_tick, 0); os_timer_arm(µs_overflow_timer, 60000, REPEAT); }