Skip to content

Commit

Permalink
Arduino.h: Add digitalPinToInterrupt
Browse files Browse the repository at this point in the history
- This does not seem to be present in ArduinoCoreAPI but defined for all
  Arduino boards (and microblocks has started using it).
- Also present in arduino docs.

Signed-off-by: Ayush Singh <[email protected]>
  • Loading branch information
Ayush1325 authored and DhruvaG2000 committed Sep 15, 2024
1 parent f6e9483 commit dc24cf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ enum analogPins { DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user),
void interrupts(void);
void noInterrupts(void);

int digitalPinToInterrupt(pin_size_t pin);

#include <variant.h>
#ifdef __cplusplus
#include <zephyrPrint.h>
Expand Down
7 changes: 7 additions & 0 deletions cores/arduino/zephyrCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,10 @@ void noInterrupts(void) {
interrupts_disabled = true;
}
}

int digitalPinToInterrupt(pin_size_t pin) {
struct gpio_port_callback *pcb =
find_gpio_port_callback(arduino_pins[pin].port);

return (pcb) ? pin : -1;
}

0 comments on commit dc24cf0

Please sign in to comment.