diff options
author | Christina Quast <chrysh.ng+github@gmail.com> | 2015-11-05 10:57:50 +0100 |
---|---|---|
committer | Christina Quast <chrysh.ng+github@gmail.com> | 2015-11-05 10:57:50 +0100 |
commit | 442dc27bc916e204e3458b97ea7185f4648141ca (patch) | |
tree | 34510886fc53391cf501e2a2883e12231b0f712f | |
parent | 89690c98ddda1d98760d3d05e6bdd6ba2b16c157 (diff) |
Remove check for PIO_ISR interrue
At first I thought I had to check the interrupt source when my interrupt
handler was called. But then, the smart card insertion pin was never
marked as the interrupt source in the PIO_ISR.
It turns out, the ISR register is cleared on read, which is done by the
atmel lib function PioInterruptHandler.
-rw-r--r-- | firmware/src_simtrace/ccid.c | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/firmware/src_simtrace/ccid.c b/firmware/src_simtrace/ccid.c index 2c70eea..45efaa0 100644 --- a/firmware/src_simtrace/ccid.c +++ b/firmware/src_simtrace/ccid.c @@ -2,6 +2,7 @@ * ATMEL Microcontroller Software Support * ---------------------------------------------------------------------------- * Copyright (c) 2009, Atmel Corporation + * Copyright (c) 2014, Christina Quast * * All rights reserved. * @@ -74,33 +75,21 @@ static const Pin pinSmartCard = SMARTCARD_CONNECT_PIN; */ static void ISR_PioSmartCard( const Pin *pPin ) { -/* FIXME: why is pinSmartCard.pio->PIO_ISR the wrong number? - printf("+++++ Trying to check for pending interrupts (PIO ISR: 0x%X)\n\r", pinSmartCard.pio->PIO_ISR); - printf("+++++ Mask: 0x%X\n\r", pinSmartCard.mask); -Output: - +++++ Trying to check for pending interrupts (PIO ISR: 0x400)) = 1<<10 - +++++ Mask: 0x100 = 1<<8 -*/ - // PA10 is DTXD, which is the debug uart transmit pin - - printf("Interrupt!!\n\r"); - /* Check all pending interrupts */ - // FIXME: this if condition is not always true... -// if ( (pinSmartCard.pio->PIO_ISR & pinSmartCard.mask) != 0 ) + /* Check current level on pin */ + /* The interrupt is already erased on read from the PIO_ISR (PIO Interrupt + * Status Register) by the calling higher level interrupt handler + */ + if ( PIO_Get( &pinSmartCard ) == 0 ) { - /* Check current level on pin */ - if ( PIO_Get( &pinSmartCard ) == 0 ) - { - sim_inserted = 1; - printf( "-I- Smartcard inserted\n\r" ) ; - CCID_Insertion(); - } - else - { - sim_inserted = 0; - printf( "-I- Smartcard removed\n\r" ) ; - CCID_Removal(); - } + sim_inserted = 1; + printf( "-I- Smartcard inserted\n\r" ) ; + CCID_Insertion(); + } + else + { + sim_inserted = 0; + printf( "-I- Smartcard removed\n\r" ) ; + CCID_Removal(); } } |