1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

Timer0 and Servo library support

This exposes the Timer0
This provides a Servo library support compatible with Arduino Servo
library but only supports the two timers the esp8266 has available
This commit is contained in:
Makuna
2015-05-29 13:30:15 -07:00
parent bca0997046
commit 3c3bc0f523
9 changed files with 727 additions and 7 deletions

View File

@ -43,6 +43,7 @@ typedef void (*int_handler_t)(void*);
#define ETS_GPIO_INUM 4
#define ETS_UART_INUM 5
#define ETS_UART1_INUM 5
#define ETS_CCOMPARE0_INUM 6
#define ETS_FRC_TIMER1_INUM 9 /* use edge*/
#define ETS_INTR_LOCK() \
@ -51,6 +52,23 @@ typedef void (*int_handler_t)(void*);
#define ETS_INTR_UNLOCK() \
ets_intr_unlock()
inline uint32_t ETS_INTR_ENABLED(void)
{
uint32_t enabled;
__asm__ __volatile__("esync; rsr %0,intenable":"=a" (enabled));
return enabled;
}
inline uint32_t ETS_INTR_PENDING(void)
{
uint32_t pending;
__asm__ __volatile__("esync; rsr %0,interrupt":"=a" (pending));
return pending;
}
#define ETS_CCOMPARE0_INTR_ATTACH(func, arg) \
ets_isr_attach(ETS_CCOMPARE0_INUM, (int_handler_t)(func), (void *)(arg))
#define ETS_FRC_TIMER1_INTR_ATTACH(func, arg) \
ets_isr_attach(ETS_FRC_TIMER1_INUM, (int_handler_t)(func), (void *)(arg))
@ -78,6 +96,12 @@ typedef void (*int_handler_t)(void*);
#define ETS_UART_INTR_DISABLE() \
ETS_INTR_DISABLE(ETS_UART_INUM)
#define ETS_CCOMPARE0_ENABLE() \
ETS_INTR_ENABLE(ETS_CCOMPARE0_INUM)
#define ETS_CCOMPARE0_DISABLE() \
ETS_INTR_DISABLE(ETS_CCOMPARE0_INUM)
#define ETS_FRC1_INTR_ENABLE() \
ETS_INTR_ENABLE(ETS_FRC_TIMER1_INUM)