summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-07-30 22:31:00 +0200
committerHarald Welte <laforge@gnumonks.org>2011-07-30 22:31:00 +0200
commit3e504477a9227b984e2cc8e63913b4d228068040 (patch)
treebd7d3d385ecd100732c35197410dbf45668ebb03
parent832cc89602395af45ea0a39ebcd34f3f612608d7 (diff)
ccid project: actually power the card
-rw-r--r--usb-device-ccid-project/main.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/usb-device-ccid-project/main.c b/usb-device-ccid-project/main.c
index f4d8fdc..ab1874a 100644
--- a/usb-device-ccid-project/main.c
+++ b/usb-device-ccid-project/main.c
@@ -141,6 +141,13 @@ unsigned char USBState = STATE_IDLE;
static const Pin pinsISO7816[] = {PINS_ISO7816};
static const Pin pinIso7816RstMC = PIN_ISO7816_RSTMC;
+static const Pin pinsPower[] = {
+ /* low = off */
+ {1 << 5, AT91C_BASE_PIOA, AT91C_ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT},
+ /* high = off */
+ {1 << 26, AT91C_BASE_PIOA, AT91C_ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT},
+};
+
//------------------------------------------------------------------------------
// Optional smartcard detection
//------------------------------------------------------------------------------
@@ -155,16 +162,20 @@ static const Pin pinSmartCard = PIN_SMARTCARD_CONNECT;
//------------------------------------------------------------------------------
static void ISR_PioSmartCard(const Pin *pPin)
{
+ printf("-H- ISR_PioSmartCard\n\r");
// Check all pending interrupts
if ((pinSmartCard.pio->PIO_ISR & pinSmartCard.mask) != 0) {
+ printf("-H- SmartCard.mask\n\r");
// Check current level on pin
if (PIO_Get(&pinSmartCard) == 0) {
+ printf("-H- Insert\n\r");
CCID_Insertion();
}
else {
+ printf("-H- Removal\n\r");
CCID_Removal();
}
}
@@ -529,6 +540,11 @@ int main( void )
// Configure ISO7816 driver
PIO_Configure(pinsISO7816, PIO_LISTSIZE(&pinsISO7816));
+ PIO_Configure(pinsPower, PIO_LISTSIZE(&pinsPower));
+
+ /* power up the card */
+ PIO_Set(&pinsPower[0]);
+
ISO7816_Init( pinIso7816RstMC );
// USB audio driver initialization
@@ -545,13 +561,13 @@ int main( void )
if( USBState == STATE_SUSPEND ) {
TRACE_DEBUG("suspend !\n\r");
- //LowPowerMode();
+ LowPowerMode();
USBState = STATE_IDLE;
}
if( USBState == STATE_RESUME ) {
// Return in normal MODE
TRACE_DEBUG("resume !\n\r");
- //NormalPowerMode();
+ NormalPowerMode();
USBState = STATE_IDLE;
}
CCID_SmartCardRequest();
personal git repositories of Harald Welte. Your mileage may vary