cardem: use TC_ETU to trigger ATR sending

this changes how ATR is handled.
the ATR is also printed when set (as important debug information).
the test is also updated to correspond to the new mechanism (
simulating the timeout before sending the ATR)

Change-Id: I69df797e2feadffa9f5f977cb71b69386cee7cd0
This commit is contained in:
Kévin Redon
2018-07-29 00:18:12 +02:00
parent d8ebd6ab77
commit ebe672e926
4 changed files with 104 additions and 30 deletions

View File

@@ -1,6 +1,7 @@
/* card emulation mode
*
* (C) 2015-2017 by Harald Welte <laforge@gnumonks.org>
* (C) 2018 by sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -98,15 +99,11 @@ struct cardem_inst cardem_inst[] = {
static Usart *get_usart_by_chan(uint8_t uart_chan)
{
switch (uart_chan) {
case 0:
return USART1;
#ifdef CARDEMU_SECOND_UART
case 1:
return USART0;
#endif
if (uart_chan < ARRAY_SIZE(cardem_inst)) {
return cardem_inst[uart_chan].usart_info.base;
} else {
return NULL;
}
return NULL;
}
/***********************************************************************
@@ -244,6 +241,20 @@ int card_emu_uart_update_fidi(uint8_t uart_chan, unsigned int fidi)
return 0;
}
/* call-back from card_emu.c to force a USART interrupt */
void card_emu_uart_interrupt(uint8_t uart_chan)
{
Usart *usart = get_usart_by_chan(uart_chan);
if (!usart) {
return;
}
if (USART0 == usart) {
NVIC_SetPendingIRQ(USART0_IRQn);
} else if (USART1 == usart) {
NVIC_SetPendingIRQ(USART1_IRQn);
}
}
/***********************************************************************
* ADC for VCC voltage detection
***********************************************************************/