Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 29a3fd8

Browse files
Fix digitalRead for controllers with big flash
1 parent 42fa4a1 commit 29a3fd8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎cores/arduino/Arduino.h‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,22 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
175175
//
176176
// These perform slightly better as macros compared to inline functions
177177
//
178+
#define analogInPinToBit(P) (P)
179+
#if (FLASHEND > 0xFFFF)
180+
#define digitalPinToPort(P) ( pgm_read_byte_far( pgm_get_far_address( digital_pin_to_port_PGM ) + (P) ) )
181+
#define digitalPinToBitMask(P) ( pgm_read_byte_far( pgm_get_far_address( digital_pin_to_bit_mask_PGM ) + (P) ) )
182+
#define digitalPinToTimer(P) ( pgm_read_byte_far( pgm_get_far_address( digital_pin_to_timer_PGM ) + (P) ) )
183+
#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word_far( pgm_get_far_address( port_to_output_PGM ) + (P))) )
184+
#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word_far( pgm_get_far_address( port_to_input_PGM ) + (P))) )
185+
#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word_far( pgm_get_far_address( port_to_mode_PGM ) + (P))) )
186+
#else
178187
#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
179188
#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
180189
#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
181-
#define analogInPinToBit(P) (P)
182190
#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
183191
#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
184192
#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
193+
#endif
185194

186195
#define NOT_A_PIN 0
187196
#define NOT_A_PORT 0

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /