summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author(no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-09-09 09:39:55 +0000
committer(no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-09-09 09:39:55 +0000
commit83f2dd8a29c7b77990d272a5d7843b33fe26f319 (patch)
treeb47e47628b807da4bf17013b2023514dafc69e05
parentf17643b5f4284edeeb6b2aaa83bcd56bfc17deaf (diff)
improve eeprom reading routine
git-svn-id: https://svn.openpcd.org:2342/trunk@149 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
-rw-r--r--openpcd/firmware/src/pcd/rc632_highlevel.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/openpcd/firmware/src/pcd/rc632_highlevel.c b/openpcd/firmware/src/pcd/rc632_highlevel.c
index 8cb1b86..b1186ab 100644
--- a/openpcd/firmware/src/pcd/rc632_highlevel.c
+++ b/openpcd/firmware/src/pcd/rc632_highlevel.c
@@ -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
personal git repositories of Harald Welte. Your mileage may vary