Skip to content

Conversation

@josefpavlik
Copy link

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.

simplified interrupt service, avoid using indirect jumg, it uses instead 16 bytes of ram to hold offset table
Also, handling far pointers during initialization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant