improve eeprom reading routine

git-svn-id: https://svn.openpcd.org:2342/trunk@149 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
This commit is contained in:
(no author) 2006-09-09 09:39:55 +00:00
parent f17643b5f4
commit 83f2dd8a29
1 changed files with 18 additions and 10 deletions

View File

@ -371,16 +371,17 @@ rc632_transceive(struct rfid_asic_handle *handle,
return rc632_fifo_read(handle, *rx_len, rx_buf);
}
static int
rc632_read_eeprom(struct rfid_asic_handle *handle)
int
rc632_read_eeprom(struct rfid_asic_handle *handle, u_int16_t addr, u_int8_t len,
u_int8_t *recvbuf)
{
u_int8_t recvbuf[60];
u_int8_t sndbuf[3];
u_int8_t err;
int ret;
sndbuf[0] = 0x00;
sndbuf[1] = 0x00;
sndbuf[2] = 0x3c;
sndbuf[0] = (addr & 0xff);
sndbuf[1] = addr >> 8;
sndbuf[2] = len;
ret = rc632_fifo_write(handle, 3, sndbuf, 0x03);
if (ret < 0)
@ -390,14 +391,21 @@ rc632_read_eeprom(struct rfid_asic_handle *handle)
if (ret < 0)
return ret;
usleep(20000);
/* usleep(20000); */
ret = rc632_fifo_read(handle, sizeof(recvbuf), recvbuf);
ret = rc632_reg_read(handle, RC632_REG_ERROR_FLAG, &err);
if (err & RC632_ERR_FLAG_ACCESS_ERR)
return -EPERM;
ret = rc632_reg_read(handle, RC632_REG_FIFO_DATA, &err);
if (err < len)
len = err;
ret = rc632_fifo_read(handle, len, recvbuf);
if (ret < 0)
return ret;
// FIXME: do something with eeprom contents
return ret;
return len;
}
static int