Skip to content

Commit b382d4b

Browse files
committed
Implement interrupts and noInterrupts
- Using irq_lock and irq_unlock zephyr apis. Signed-off-by: Ayush Singh <[email protected]>
1 parent 3538c54 commit b382d4b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cores/arduino/zephyrCommon.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,20 @@ size_t analog_pin_index(pin_size_t pinNumber) {
175175

176176
#endif //CONFIG_ADC
177177

178+
static unsigned int irq_key = UINT_MAX;
179+
180+
void interrupts(void) {
181+
if (irq_key != UINT_MAX) {
182+
irq_unlock(irq_key);
183+
irq_key = UINT_MAX;
184+
}
185+
}
186+
187+
void noInterrupts(void) {
188+
if (irq_key == UINT_MAX) {
189+
irq_key = irq_lock();
190+
}
191+
}
178192
}
179193

180194
void yield(void) {
@@ -464,3 +478,4 @@ void disableInterrupt(pin_size_t pinNumber) {
464478
pcb->handlers[BIT(arduino_pins[pinNumber].pin)].enabled = false;
465479
}
466480
}
481+

0 commit comments

Comments
 (0)