Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5855ec0

Browse files
committed
Fixed macros with right registers
1 parent ee1f39a commit 5855ec0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

cores/arduino/Arduino.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,13 @@ bool isDoubleBondedActive(uint8_t pin);
125125
#define analogPinToBitMask(pin) ( (pin < NUM_ANALOG_INPUTS) ? (1 << analogPinToBitPosition(pin)) : NOT_A_PIN )
126126
#define digitalPinToTimer(pin) ( (pin < NUM_TOTAL_PINS) ? pgm_read_byte(digital_pin_to_timer + pin) : NOT_ON_TIMER )
127127

128-
#define portInputRegister(port) ( &(((PORT_t*)(&PORTA + port))->IN) )
129-
130128
#define portToPortStruct(port) ( (port < NUM_TOTAL_PORTS) ? ((PORT_t *)&PORTA + port) : NULL)
131129
#define digitalPinToPortStruct(pin) ( (pin < NUM_TOTAL_PINS) ? ((PORT_t *)&PORTA + digitalPinToPort(pin)) : NULL)
132-
#define getPINnCTRLregister(port, bit_pos) ( ((port != NULL) && (bit_pos < NOT_A_PIN)) ? ((uint8_t *)&(port->PIN0CTRL) + bit_pos) : NULL )
130+
#define getPINnCTRLregister(port, bit_pos) ( ((port != NULL) && (bit_pos < NOT_A_PIN)) ? ((volatile uint8_t *)&(port->PIN0CTRL) + bit_pos) : NULL )
133131
#define digitalPinToInterrupt(p) ( digitalPinToPort(p) * 8 + digitalPinToBitPosition(p) )
134132

135133
#define portOutputRegister(P) ( (volatile uint8_t *)( &portToPortStruct(P)->OUT ) )
134+
#define portInputRegister(P) ( (volatile uint8_t *)( &portToPortStruct(P)->IN ) )
136135

137136
#ifdef __cplusplus
138137
} // extern "C"

0 commit comments

Comments
 (0)