- move some initialization of proto handle from _tcl to core
[librfid] / rfid_reader_cm5121.c
index a916c82..11e4ee9 100644 (file)
 #define SENDBUF_LEN    40
 #define RECVBUF_LEN    40
 
+#if 0
+#ifdef DEBUGP
+#undef DEBUGP
+#define DEBUGP(x, ...)
+#define DEBUGPC(x, ...)
+#endif
+#endif
+
 static
 int Write1ByteToReg(struct rfid_asic_transport_handle *rath,
                    unsigned char reg, unsigned char value)
@@ -85,10 +93,10 @@ static int Read1ByteFromReg(struct rfid_asic_transport_handle *rath,
        sndbuf[5] = 0x00;
        sndbuf[6] = reg;
 
-       DEBUGP("reg=0x%02x, val=%02x: ", reg, *value);
        if (PC_to_RDR_Escape(rath->data, sndbuf, 7, recvbuf, 
                             &retlen) == 0) {
                *value = recvbuf[1];
+               DEBUGP("reg=0x%02x, val=%02x: ", reg, *value);
                DEBUGPC("OK\n");
                return 0;
        }
@@ -174,7 +182,7 @@ static int TestFIFO(struct rc632_handle *handle)
 static int cm5121_transcieve(struct rfid_reader_handle *rh,
                             const unsigned char *tx_data, unsigned int tx_len,
                             unsigned char *rx_data, unsigned int *rx_len,
-                            unsigned int timeout, unsigned int flags)
+                            u_int64_t timeout, unsigned int flags)
 {
        return rh->ah->asic->priv.rc632.fn.transcieve(rh->ah, tx_data,
                                                           tx_len, rx_data,
@@ -186,13 +194,14 @@ static int cm5121_transcieve_sf(struct rfid_reader_handle *rh,
                               unsigned char cmd, struct iso14443a_atqa *atqa)
 {
        return rh->ah->asic->priv.rc632.fn.iso14443a.transcieve_sf(rh->ah,
-                                                                       cmd,
-                                               (unsigned char *) atqa);
+                                                                  cmd,
+                                                                  atqa);
 }
 
 static int
-cm5121_transcieve_acf(struct rfid_reader_handle *rh, struct iso14443a_anticol_cmd *cmd,
-                                             unsigned int *bit_of_col)
+cm5121_transcieve_acf(struct rfid_reader_handle *rh,
+                     struct iso14443a_anticol_cmd *cmd,
+                     unsigned int *bit_of_col)
 {
        return rh->ah->asic->priv.rc632.fn.iso14443a.transcieve_acf(rh->ah,
                                                         cmd, bit_of_col);
@@ -210,6 +219,12 @@ cm5121_14443b_init(struct rfid_reader_handle *rh)
        return rh->ah->asic->priv.rc632.fn.iso14443b.init(rh->ah);
 }
 
+static int
+cm5121_15693_init(struct rfid_reader_handle *rh)
+{
+       return rh->ah->asic->priv.rc632.fn.iso15693.init(rh->ah);
+}
+
 
 struct rfid_asic_transport cm5121_ccid = {
        .name = "CM5121 OpenCT",
@@ -230,7 +245,7 @@ static int cm5121_enable_rc632(struct rfid_asic_transport_handle *rath)
        unsigned int rx_len = sizeof(rx_buf);
 
        PC_to_RDR_Escape(rath->data, tx_buf, 1, rx_buf, &rx_len);
-       printf("received %d bytes from 01 command\n", rx_len);
+       printf("received %u bytes from 01 command\n", rx_len);
 
        return 0;
 }
@@ -292,6 +307,8 @@ struct rfid_reader rfid_reader_cm5121 = {
                .init = &cm5121_14443a_init,
                .transcieve_sf = &cm5121_transcieve_sf,
                .transcieve_acf = &cm5121_transcieve_acf,
+               .speed = RFID_READER_SPEED_106K | RFID_READER_SPEED_212K |
+                        RFID_READER_SPEED_424K | RFID_READER_SPEED_848K,
        },
        .iso14443b = {
                .init = &cm5121_14443b_init,