mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-17 13:48:32 +03:00
cardem: use USART timeout for waiting time
the reset/ATR handling has been heavily updated/fixed. 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 the clock signal is not connected to the timer counter. thus this change adds card emulation support for SIMtrace boards. Fi and Di have been properly rename to F and D since the "i" stands only for an "indicated" value, not the actual value. this does not change the USB protocol (the variable have just been renamed). additional variables store more information about the card capabilities NOTE: it has only be tested for the SIMtrace board Change-Id: Ibcb2c8cace9137695adf5fb3de43566f7cfb93b5
This commit is contained in:
@@ -48,10 +48,41 @@ struct llist_head *card_emu_get_uart_tx_queue(struct card_handle *ch);
|
||||
void card_emu_have_new_uart_tx(struct card_handle *ch);
|
||||
void card_emu_report_status(struct card_handle *ch);
|
||||
|
||||
/*! call when the waiting time has half-expired
|
||||
* param[in] ch card for which the waiting time half expired
|
||||
*/
|
||||
void card_emu_wt_halfed(struct card_handle *ch);
|
||||
/*! call when the waiting time has expired
|
||||
* param[in] ch card for which the waiting time expired
|
||||
*/
|
||||
void card_emu_wt_expired(struct card_handle *ch);
|
||||
|
||||
#define ENABLE_TX 0x01
|
||||
#define ENABLE_RX 0x02
|
||||
|
||||
int card_emu_uart_update_fidi(uint8_t uart_chan, unsigned int fidi);
|
||||
// the following functions are callbacks implement in mode_cardemu.c
|
||||
|
||||
/*! update F and D on USART peripheral
|
||||
* @param[in] usart USART peripheral to configure
|
||||
* @param[in] f clock rate conversion integer F value
|
||||
* @param[in] d baud rate adjustment factor D value
|
||||
* @note this should happen after reset and protocol select (through PPS or implicit)
|
||||
*/
|
||||
void card_emu_uart_update_fd(uint8_t uart_chan, uint16_t f, uint8_t d);
|
||||
/*! update WT on USART peripheral
|
||||
* @param[in] usart USART peripheral to configure
|
||||
* @param[in] wt inactivity Waiting Time before card_emu_wt_expired is called (0 to disable)
|
||||
*/
|
||||
void card_emu_uart_update_wt(uint8_t uart_chan, uint32_t wt);
|
||||
/*! reset waiting timeout count down on USART peripheral
|
||||
* @param[in] usart USART peripheral to configure
|
||||
*/
|
||||
void card_emu_uart_reset_wt(uint8_t uart_chan);
|
||||
/*! set I/O line high
|
||||
* @param[in] usart USART peripheral to configure
|
||||
* @param[in] set if I/O line should be set high (true), or cleared low (false)
|
||||
*/
|
||||
void card_emu_uart_io_set(uint8_t uart_chan, bool set);
|
||||
int card_emu_uart_tx(uint8_t uart_chan, uint8_t byte);
|
||||
void card_emu_uart_enable(uint8_t uart_chan, uint8_t rxtx);
|
||||
void card_emu_uart_wait_tx_idle(uint8_t uart_chan);
|
||||
|
||||
@@ -228,11 +228,10 @@ struct cardemu_usb_msg_status {
|
||||
uint32_t flags;
|
||||
/* phone-applied target voltage in mV */
|
||||
uint16_t voltage_mv;
|
||||
/* Fi/Di related information */
|
||||
uint8_t fi;
|
||||
uint8_t di;
|
||||
uint8_t wi;
|
||||
uint32_t waiting_time;
|
||||
uint8_t f; /*!< index of F and f_max values as encoded in ISO/IEC 7816-3:2006(E) Table 7 */
|
||||
uint8_t d; /*!< index of D value as encoded in ISO/IEC 7816-3:2006(E) Table 8 */
|
||||
uint8_t wi; /*!< Waiting Integer as defined in ISO/IEC 7816-3:2006(E) Section 10.2 */
|
||||
uint32_t wt; /*!< Waiting Time in ETU as defined in ISO/IEC 7816-3:2006(E) Section 8.1 */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* CEMU_USB_MSGT_DO_PTS */
|
||||
|
||||
Reference in New Issue
Block a user