blob: df23ce47b961fdfa83d3d1d9e72e0e1dd30db934 [file] [log] [blame]
Harald Welte9d3e3822015-11-09 00:50:54 +01001#pragma once
2
3#include <stdint.h>
4
5struct card_handle;
6
7enum card_io {
8 CARD_IO_VCC,
9 CARD_IO_RST,
10 CARD_IO_CLK,
11};
12
13struct card_handle *card_emu_init(uint8_t slot_num, uint8_t tc_chan, uint8_t uart_chan);
14
15/* process a single byte received from the reader */
16void card_emu_process_rx_byte(struct card_handle *ch, uint8_t byte);
17
Harald Welte855ba9e2016-02-24 21:00:46 +010018/* transmit a single byte to the reader */
19int card_emu_tx_byte(struct card_handle *ch);
Harald Welte9d3e3822015-11-09 00:50:54 +010020
21/* hardware driver informs us that a card I/O signal has changed */
22void card_emu_io_statechg(struct card_handle *ch, enum card_io io, int active);
23
24/* User sets a new ATR to be returned during next card reset */
25int card_emu_set_atr(struct card_handle *ch, const uint8_t *atr, uint8_t len);
26
Harald Welte54cb3d02016-02-29 14:12:40 +010027struct llist_head *card_emu_get_uart_tx_queue(struct card_handle *ch);
28struct llist_head *card_emu_get_usb_tx_queue(struct card_handle *ch);
Harald Welteacae4122016-03-02 10:27:58 +010029void card_emu_have_new_uart_tx(struct card_handle *ch);
Harald Welteff160652016-03-19 21:59:06 +010030void card_emu_report_status(struct card_handle *ch);
Harald Welte9d3e3822015-11-09 00:50:54 +010031
32#define ENABLE_TX 0x01
33#define ENABLE_RX 0x02
34
35int card_emu_uart_update_fidi(uint8_t uart_chan, unsigned int fidi);
36int card_emu_uart_tx(uint8_t uart_chan, uint8_t byte);
37void card_emu_uart_enable(uint8_t uart_chan, uint8_t rxtx);
Harald Weltec58bba02016-03-20 14:57:53 +010038void card_emu_uart_wait_tx_idle(uint8_t uart_chan);