projects
/
librfid
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* Add spidev reader driver
[librfid]
/
src
/
rfid_asic_rc632.c
diff --git
a/src/rfid_asic_rc632.c
b/src/rfid_asic_rc632.c
index
0d6824c
..
0ba4dc5
100644
(file)
--- a/
src/rfid_asic_rc632.c
+++ b/
src/rfid_asic_rc632.c
@@
-16,7
+16,7
@@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 5
9 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ * Foundation, Inc., 5
1 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA
*/
#include <unistd.h>
*/
#include <unistd.h>
@@
-35,8
+35,10
@@
#include "rfid_iso14443_common.h"
#include "rc632.h"
#include "rfid_iso14443_common.h"
#include "rc632.h"
-//#include "rc632_14443a.h"
+#ifdef __MINGW32__
+#include "usleep.h"
+#endif/*__MINGW32__*/
#define RC632_TMO_AUTH1 140
#define RC632_TMO_AUTH1 140
@@
-608,7
+610,7
@@
rc632_open(struct rfid_asic_transport_handle *th)
return NULL;
memset(h, 0, sizeof(*h));
return NULL;
memset(h, 0, sizeof(*h));
- h->asic = &rc632;
+ h->asic =
(void*)
&rc632;
h->rath = th;
h->fc = h->asic->fc;
/* FIXME: this is only cm5121 specific, since the latency
h->rath = th;
h->fc = h->asic->fc;
/* FIXME: this is only cm5121 specific, since the latency
@@
-875,7
+877,7
@@
rc632_iso14443a_transceive_acf(struct rfid_asic_handle *handle,
int ret;
u_int8_t rx_buf[64];
u_int8_t rx_len = sizeof(rx_buf);
int ret;
u_int8_t rx_buf[64];
u_int8_t rx_len = sizeof(rx_buf);
- u_int8_t rx_align = 0, tx_last_bits, tx_bytes;
+ u_int8_t rx_align = 0, tx_last_bits, tx_bytes
, tx_bytes_total
;
u_int8_t boc;
u_int8_t error_flag;
*bit_of_col = ISO14443A_BITOFCOL_NONE;
u_int8_t boc;
u_int8_t error_flag;
*bit_of_col = ISO14443A_BITOFCOL_NONE;
@@
-899,14
+901,14
@@
rc632_iso14443a_transceive_acf(struct rfid_asic_handle *handle,
if (ret < 0)
return ret;
if (ret < 0)
return ret;
- tx_last_bits = acf->nvb & 0x0
f
; /* lower nibble indicates bits */
- tx_bytes =
acf->nvb >> 4
;
+ tx_last_bits = acf->nvb & 0x0
7
; /* lower nibble indicates bits */
+ tx_bytes =
( acf->nvb >> 4 ) & 0x07
;
if (tx_last_bits) {
if (tx_last_bits) {
- tx_bytes
++
;
- rx_align =
(tx_last_bits+1) % 8;
/* rx frame complements tx */
+ tx_bytes
_total = tx_bytes+1
;
+ rx_align =
tx_last_bits & 0x07;
/* rx frame complements tx */
}
}
-
- //rx_align = 8 - tx_last_bits;/* rx frame complements tx */
+ else
+ tx_bytes_total = tx_bytes;
/* set RxAlign and TxLastBits*/
ret = rc632_reg_write(handle, RC632_REG_BIT_FRAMING,
/* set RxAlign and TxLastBits*/
ret = rc632_reg_write(handle, RC632_REG_BIT_FRAMING,
@@
-914,7
+916,7
@@
rc632_iso14443a_transceive_acf(struct rfid_asic_handle *handle,
if (ret < 0)
return ret;
if (ret < 0)
return ret;
- ret = rc632_transceive(handle, (u_int8_t *)acf, tx_bytes,
+ ret = rc632_transceive(handle, (u_int8_t *)acf, tx_bytes
_total
,
rx_buf, &rx_len, 0x32, 0);
if (ret < 0)
return ret;
rx_buf, &rx_len, 0x32, 0);
if (ret < 0)
return ret;
@@
-923,8
+925,10
@@
rc632_iso14443a_transceive_acf(struct rfid_asic_handle *handle,
acf->uid_bits[tx_bytes-2] = (
(acf->uid_bits[tx_bytes-2] & (0xff >> (8-tx_last_bits)))
| rx_buf[0]);
acf->uid_bits[tx_bytes-2] = (
(acf->uid_bits[tx_bytes-2] & (0xff >> (8-tx_last_bits)))
| rx_buf[0]);
+
/* copy the rest */
/* copy the rest */
- memcpy(&acf->uid_bits[tx_bytes+1-2], &rx_buf[1], rx_len-1);
+ if(rx_len)
+ memcpy(&acf->uid_bits[tx_bytes-1], &rx_buf[1], rx_len-1);
/* determine whether there was a collission */
ret = rc632_reg_read(handle, RC632_REG_ERROR_FLAG, &error_flag);
/* determine whether there was a collission */
ret = rc632_reg_read(handle, RC632_REG_ERROR_FLAG, &error_flag);