aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/libcommon/source/mode_cardemu.c
diff options
context:
space:
mode:
authorKévin Redon <kredon@sysmocom.de>2018-07-29 00:18:12 +0200
committerKévin Redon <kredon@sysmocom.de>2018-07-30 15:02:35 +0200
commitebe672e92666f3e05cb7dacb04868fe168a19889 (patch)
tree3563f6f4f3d23f6008b670c2991127ba864409c5 /firmware/libcommon/source/mode_cardemu.c
parentd8ebd6ab77fc422232e679a36887f40a56c24e53 (diff)
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
Diffstat (limited to 'firmware/libcommon/source/mode_cardemu.c')
-rw-r--r--firmware/libcommon/source/mode_cardemu.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/firmware/libcommon/source/mode_cardemu.c b/firmware/libcommon/source/mode_cardemu.c
index 57d541b..76b3a01 100644
--- a/firmware/libcommon/source/mode_cardemu.c
+++ b/firmware/libcommon/source/mode_cardemu.c
@@ -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
***********************************************************************/