1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-18 07:52:14 +01:00

Merge pull request #3983 from antodom/pio_handlers

PIO[ABCD] handlers improvement using ATSAM3X8E CLZ instruction
This commit is contained in:
Arturo Guadalupi 2016-01-05 15:07:36 +01:00
commit 1ad17fb372

View File

@ -134,47 +134,47 @@ extern "C" {
#endif #endif
void PIOA_Handler(void) { void PIOA_Handler(void) {
uint32_t isr = PIOA->PIO_ISR; uint32_t isr = PIOA->PIO_ISR;
uint32_t i; uint8_t leading_zeros;
for (i=0; i<32; i++, isr>>=1) { while((leading_zeros=__CLZ(isr))<32)
if ((isr & 0x1) == 0) {
continue; uint8_t pin=32-leading_zeros-1;
if (callbacksPioA[i]) if(callbacksPioA[pin]) callbacksPioA[pin]();
callbacksPioA[i](); isr=isr&(~(1<<pin));
} }
} }
void PIOB_Handler(void) { void PIOB_Handler(void) {
uint32_t isr = PIOB->PIO_ISR; uint32_t isr = PIOB->PIO_ISR;
uint32_t i; uint8_t leading_zeros;
for (i=0; i<32; i++, isr>>=1) { while((leading_zeros=__CLZ(isr))<32)
if ((isr & 0x1) == 0) {
continue; uint8_t pin=32-leading_zeros-1;
if (callbacksPioB[i]) if(callbacksPioB[pin]) callbacksPioB[pin]();
callbacksPioB[i](); isr=isr&(~(1<<pin));
} }
} }
void PIOC_Handler(void) { void PIOC_Handler(void) {
uint32_t isr = PIOC->PIO_ISR; uint32_t isr = PIOC->PIO_ISR;
uint32_t i; uint8_t leading_zeros;
for (i=0; i<32; i++, isr>>=1) { while((leading_zeros=__CLZ(isr))<32)
if ((isr & 0x1) == 0) {
continue; uint8_t pin=32-leading_zeros-1;
if (callbacksPioC[i]) if(callbacksPioC[pin]) callbacksPioC[pin]();
callbacksPioC[i](); isr=isr&(~(1<<pin));
} }
} }
void PIOD_Handler(void) { void PIOD_Handler(void) {
uint32_t isr = PIOD->PIO_ISR; uint32_t isr = PIOD->PIO_ISR;
uint32_t i; uint8_t leading_zeros;
for (i=0; i<32; i++, isr>>=1) { while((leading_zeros=__CLZ(isr))<32)
if ((isr & 0x1) == 0) {
continue; uint8_t pin=32-leading_zeros-1;
if (callbacksPioD[i]) if(callbacksPioD[pin]) callbacksPioD[pin]();
callbacksPioD[i](); isr=isr&(~(1<<pin));
} }
} }
#ifdef __cplusplus #ifdef __cplusplus