24 #include "system_clock.h"
31 extern int PWM_IN_EXTI_MAXPERIOD;
32 extern int PWM_IN_EXTI_MINPERIOD;
33 extern int PWM_IN_MAXPERIOD;
34 extern int PWM_IN_MINPERIOD;
36 extern const uint32_t extiLines[];
38 #if defined(KODUINO_ISRS_INLINE)
39 static inline void wirishExternalInterruptHandler(uint8_t i)
__attribute__((always_inline, unused));
41 static inline void wirishExternalInterruptHandler(uint8_t i);
43 static inline void wirishExternalInterruptHandler(uint8_t i) {
44 EXTI_ClearITPendingBit(extiLines[i]);
46 EXTIChannel *S = &EXTI_MAP[i];
51 volatile int currentMs =
millis();
52 volatile int currentSubMs = SysTick->LOAD - SysTick->VAL;
53 volatile int delta = (currentMs - S->risingEdgeMs) * SysTick->LOAD + currentSubMs - S->risingEdgeSubMs;
57 S->risingEdgeMs = currentMs;
58 S->risingEdgeSubMs = currentSubMs;
60 if (delta > PWM_IN_EXTI_MAXPERIOD)
61 S->period = delta - SysTick->LOAD;
62 else if (delta < PWM_IN_EXTI_MINPERIOD)
63 S->period = delta + SysTick->LOAD;
66 S->pulsewidth = delta;
70 ISRType handler = S->handler;
82 void attachInterruptWithPriority(uint8_t pinName, ISRType ISR, InterruptTrigger mode, uint8_t priority);
94 void attachInterrupt(uint8_t pinName, ISRType ISR, InterruptTrigger mode);
133 #endif // __cplusplus
void noInterrupts()
Disable external interrupts.
Definition: exti.c:173
static uint8_t digitalRead(uint8_t pin) __attribute__((always_inline
Read a digital pin.
Definition: gpio.h:57
static uint32_t millis() __attribute__((always_inline
Definition: system_clock.h:50
void detachInterrupt(uint8_t pinName)
Disable an interrupt.
Definition: exti.c:155
void interrupts()
Enable external interrupts.
Definition: exti.c:179
void attachInterrupt(uint8_t pinName, ISRType ISR, InterruptTrigger mode)
Enable an interrupt with default priority.
Definition: exti.c:151