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 <[email protected]>
  • Loading branch information
Ayush1325 committed Aug 18, 2024
1 parent 3538c54 commit 675628e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cores/arduino/zephyrCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,22 @@ size_t analog_pin_index(pin_size_t pinNumber) {

#endif //CONFIG_ADC

static unsigned int irq_key;
static bool interrupts_disabled = false;

void interrupts(void) {
if (interrupts_disabled) {
irq_unlock(irq_key);
interrupts_disabled = false;
}
}

void noInterrupts(void) {
if (!interrupts_disabled) {
irq_key = irq_lock();
interrupts_disabled = true;
}
}
}

void yield(void) {
Expand Down

0 comments on commit 675628e

Please sign in to comment.