Skip to content

Commit

Permalink
Implement interrupts and noInterrupts
Browse files Browse the repository at this point in the history
- Using irq_lock and irq_unlock zephyr apis.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
  • Loading branch information
Ayush1325 committed Aug 16, 2024
1 parent 3538c54 commit fd926ed
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cores/arduino/zephyrCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,3 +464,18 @@ void disableInterrupt(pin_size_t pinNumber) {
pcb->handlers[BIT(arduino_pins[pinNumber].pin)].enabled = false;
}
}

static unsigned int irq_key = UINT_MAX;

void interrupts(void) {
if (irq_key != UINT_MAX) {
irq_unlock(irq_key);
irq_key = UINT_MAX;
}
}

void noInterrupts(void) {
if (irq_key == UINT_MAX) {
irq_key = irq_lock();
}
}

0 comments on commit fd926ed

Please sign in to comment.