Skip to content

Commit dc24cf0

Browse files
Ayush1325DhruvaG2000
authored andcommitted
Arduino.h: Add digitalPinToInterrupt
- 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]>
1 parent f6e9483 commit dc24cf0

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cores/arduino/Arduino.h

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ enum analogPins { DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user),
100100
void interrupts(void);
101101
void noInterrupts(void);
102102

103+
int digitalPinToInterrupt(pin_size_t pin);
104+
103105
#include <variant.h>
104106
#ifdef __cplusplus
105107
#include <zephyrPrint.h>

cores/arduino/zephyrCommon.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -480,3 +480,10 @@ void noInterrupts(void) {
480480
interrupts_disabled = true;
481481
}
482482
}
483+
484+
int digitalPinToInterrupt(pin_size_t pin) {
485+
struct gpio_port_callback *pcb =
486+
find_gpio_port_callback(arduino_pins[pin].port);
487+
488+
return (pcb) ? pin : -1;
489+
}

0 commit comments

Comments
 (0)