Skip to content

Commit 45a61af

Browse files
committed
Add portInputRegister API
Very legacy but still in use (by DHT library, for example). Need to test if digitalPinToPort works correctly too with legacy libraries declaing special sections guarded by #ifdef __AVR__
1 parent 9334ca2 commit 45a61af

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cores/arduino/Arduino.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ extern const uint8_t PROGMEM digital_pin_to_interrupt[];
124124
#define analogPinToBitMask(pin) ( (pin < NUM_ANALOG_INPUTS) ? (1 << analogPinToBitPosition(pin)) : NOT_A_PIN )
125125
#define digitalPinToTimer(pin) ( (pin < NUM_TOTAL_PINS) ? pgm_read_byte(digital_pin_to_timer + pin) : NOT_ON_TIMER )
126126

127+
#define portInputRegister(port) ( &(((PORT_t*)(&PORTA + port))->IN) )
128+
127129
#define portToPortStruct(port) ( (port < NUM_TOTAL_PORTS) ? ((PORT_t *)&PORTA + port) : NULL)
128130
#define digitalPinToPortStruct(pin) ( (pin < NUM_TOTAL_PINS) ? ((PORT_t *)&PORTA + digitalPinToPort(pin)) : NULL)
129131
#define getPINnCTRLregister(port, bit_pos) ( ((port != NULL) && (bit_pos < NOT_A_PIN)) ? ((uint8_t *)&(port->PIN0CTRL) + bit_pos) : NULL )

0 commit comments

Comments
 (0)