- separate 'STATIC' (non-dyamic-allocation) from 'FIRMWARE' (no host drivers)
[librfid] / src / ccid / rfid_reader_cm5121_ccid_direct.c
1 /* CM5121 backend for 'internal' CCID driver */
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <stdio.h>
5
6 #include <librfid/rfid.h>
7
8 #ifndef LIBRFID_FIRMWARE
9
10 #include <librfid/rfid_asic.h>
11
12 #include "ccid-driver.h"
13
14 /* this is the sole function required by rfid_reader_cm5121.c */
15 int 
16 PC_to_RDR_Escape(void *handle, 
17                  const unsigned char *tx_buf, unsigned int tx_len,
18                  unsigned char *rx_buf, unsigned int *rx_len)
19 {
20         int rc;
21         ccid_driver_t ch = handle;
22         size_t maxrxlen = *rx_len;
23
24         rc = ccid_transceive_escape (ch, tx_buf, tx_len,
25                                      rx_buf, maxrxlen, rx_len);
26
27         return rc;
28 }
29
30 int cm5121_source_init(struct rfid_asic_transport_handle *rath)
31 {
32         int rc;
33
34         rc = ccid_open_reader(&rath->data, NULL);
35         if (rc) {
36                 fprintf (stderr, "failed to open CCID reader: %#x\n", rc);
37                 return -1;
38         }
39         return 0;
40 }
41
42 #endif /* LIBRFID_FIRMWARE */