PIO[ABCD] handlers improvement using ATSAM3X8E CLZ instruction #3983
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.
This is a small improvement to WInterrupts.c for the DUE which allows a faster interrupt dispatching associated to generic I/O pins.
Basically I have modified the code of the interrupt handler functions PIOA_Handler(), PIOB_Handler(), PIOC_Handler() and PIOD_handler() in the original WInterrupts.c. The improvement consists mainly in taking advantage of ATSAM3XE assembler instruction CLZ. With this instruction it is possible to calculate the number of leading zeros in a 32 bit value in just one machine instruction. CLZ is available in C/C++ using CMSIS function __CLZ(). This change can improve the dispatching of interrupts a lot, specially when you have a sparse number of active interrupts associated with a few i/O pins.