mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-16 21:28:33 +03:00
card_emu: Use USART timeout for waiting time
Instead of using the timer/counter peripheral to handle the waiting time and corresponding timeout, the USART peripheral internal timeout mechanism is used. This is particularly important for the SIMtrace board since there (contrary to other boards) the I/O signal is not wired to a TIO pin of the timer/counter block, and hence Rx/Tx data cannot reset that timer/counter. As a result of this migration, cardem is now supported not only on owhw + qmod, but also on the simtrace board. The guts of this change have been lifted out of Change-Id Ibcb2c8cace9137695adf5fb3de43566f7cfb93b5 by Kevin Redon, which was unfortunately touching various different topics at the same time and hence was split up. Some improvements are the introduction of the ENABLE_TX_TIMER_ONLY mode, which avoids the USART interrupt handler getting hammered with TXRDY between release of RST and start of the ATR. Change-Id: Ibcb2c8cace9137695adf5fb3de43566f7cfb93b5 Related: OS#1704
This commit is contained in:
@@ -50,6 +50,9 @@ void card_emu_uart_enable(uint8_t uart_chan, uint8_t rxtx)
|
||||
case ENABLE_TX:
|
||||
rts = "TX";
|
||||
break;
|
||||
case ENABLE_TX_TIMER_ONLY:
|
||||
rts = "TX-TIMER-ONLY";
|
||||
break;
|
||||
case ENABLE_RX:
|
||||
rts = "RX";
|
||||
break;
|
||||
@@ -66,29 +69,14 @@ void card_emu_uart_interrupt(uint8_t uart_chan)
|
||||
printf("uart_interrupt(uart_chan=%u)\n", uart_chan);
|
||||
}
|
||||
|
||||
void tc_etu_set_wtime(uint8_t tc_chan, uint16_t wtime)
|
||||
void card_emu_uart_update_wt(uint8_t uart_chan, uint32_t wt)
|
||||
{
|
||||
printf("tc_etu_set_wtime(tc_chan=%u, wtime=%u)\n", tc_chan, wtime);
|
||||
printf("%s(uart_chan=%u, wtime=%u)\n", __func__, uart_chan, wt);
|
||||
}
|
||||
|
||||
void tc_etu_set_etu(uint8_t tc_chan, uint16_t etu)
|
||||
void card_emu_uart_reset_wt(uint8_t uart_chan)
|
||||
{
|
||||
printf("tc_etu_set_etu(tc_chan=%u, etu=%u)\n", tc_chan, etu);
|
||||
}
|
||||
|
||||
void tc_etu_init(uint8_t chan_nr, void *handle)
|
||||
{
|
||||
printf("tc_etu_init(tc_chan=%u)\n", chan_nr);
|
||||
}
|
||||
|
||||
void tc_etu_enable(uint8_t chan_nr)
|
||||
{
|
||||
printf("tc_etu_enable(tc_chan=%u)\n", chan_nr);
|
||||
}
|
||||
|
||||
void tc_etu_disable(uint8_t chan_nr)
|
||||
{
|
||||
printf("tc_etu_disable(tc_chan=%u)\n", chan_nr);
|
||||
printf("%s(uart_chan=%u\n", __func__, uart_chan);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +124,7 @@ static void io_start_card(struct card_handle *ch)
|
||||
/* release from reset and verify th ATR */
|
||||
card_emu_io_statechg(ch, CARD_IO_RST, 0);
|
||||
/* simulate waiting time before ATR expired */
|
||||
tc_etu_wtime_expired(ch);
|
||||
card_emu_wtime_expired(ch);
|
||||
verify_atr(ch);
|
||||
}
|
||||
|
||||
@@ -408,7 +396,7 @@ int main(int argc, char **argv)
|
||||
struct card_handle *ch;
|
||||
unsigned int i;
|
||||
|
||||
ch = card_emu_init(0, 23, 42, PHONE_DATAIN, PHONE_INT, false, true, false);
|
||||
ch = card_emu_init(0, 42, PHONE_DATAIN, PHONE_INT, false, true, false);
|
||||
assert(ch);
|
||||
|
||||
usb_buf_init();
|
||||
|
||||
Reference in New Issue
Block a user