Compatibility with 24 bit flash pointers on AVR with more than 64KiB of Flash (ATMEGA1280, ATMEGA2560 etc) #113
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi
This patch is here to make the driver compatible with AVR MPU with more than 64KiB flash memory, i.e. ATMega2056 (Arduino Mega). The original driver is not compatible and crashes when it is placed over 64KiB boundary. Also, when the Arduino's internal table port_to_input_PGM was over the 64KiB, macros PIN_TO_BASEREG and similar does not work because of Arduino's bug - macro portInputRegister and similar does not work.
I've simplified the interrupt handler, now it uses 16 bytes ram lookup table instead of calculated jump. So now is more compact and there is not problem when the routine is placed over 64KiB boundary. The calculated jump had only 16 bit pointer to the destination.
Also I've fixed the initialize, macros PIN_TO_BASEREG and PIN_TO_BITMASK are now compatible with lookup table over the 64KiB boundary.
The init function also resets the RAMPZ register if it exists, so future calls of pgm_read_near will point to the first page of flash.