summaryrefslogtreecommitdiff
path: root/firmware/src/pcd
diff options
context:
space:
mode:
authorlaforge <laforge@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-10-04 17:49:08 +0000
committerlaforge <laforge@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-10-04 17:49:08 +0000
commit6a189e6160b55368f9fcbf1982aa870e7399da6e (patch)
treee475e3b2249b8d3ef2b383d5196a22433b744a9d /firmware/src/pcd
parent74ce3dc46172a6f04edd9e85a3bcd41f54a2bb7c (diff)
add feature to write full register set
git-svn-id: https://svn.openpcd.org:2342/trunk@259 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'firmware/src/pcd')
-rw-r--r--firmware/src/pcd/rc632.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/firmware/src/pcd/rc632.c b/firmware/src/pcd/rc632.c
index 8513d2a..5287300 100644
--- a/firmware/src/pcd/rc632.c
+++ b/firmware/src/pcd/rc632.c
@@ -185,6 +185,8 @@ struct rc632 {
#define RC632_F_FIFO_TX 0x0001
static struct rc632 rc632;
+#define RC632_WRITE_ADDR(x) ((x << 1) & 0x7e)
+
/* RC632 access primitives */
int rc632_reg_write(struct rfid_asic_handle *hdl,
@@ -194,7 +196,7 @@ int rc632_reg_write(struct rfid_asic_handle *hdl,
DEBUG632("[0x%02x] <= 0x%02x", addr, data);
- addr = (addr << 1) & 0x7e;
+ addr = RC632_WRITE_ADDR(addr);
spi_outbuf[0] = addr;
spi_outbuf[1] = data;
@@ -203,6 +205,32 @@ int rc632_reg_write(struct rfid_asic_handle *hdl,
return spi_transceive(spi_outbuf, 2, spi_inbuf, &rx_len);
}
+#define RC632_REGSET_START 0x10
+#define RC632_REGSET_END 0x3f
+#define RC632_REGSET_MAXSIZE (RC632_REGSET_END-RC632_REGSET_START)
+static char regset_buf[RC632_REGSET_MAXSIZE * 2];
+
+int rc632_reg_write_set(struct rfid_asic_handle *hdl,
+ u_int8_t *regs, int len)
+{
+ u_int8_t i, j = 0;
+ u_int16_t rx_len;
+
+ if (len > RC632_REGSET_MAXSIZE)
+ return -E2BIG;
+
+ for (i = RC632_REGSET_START; i <= RC632_REGSET_END; i++) {
+ /* skip bank registers */
+ if (i % 8 == 0)
+ continue;
+ regset_buf[j++] = RC632_WRITE_ADDR(i);
+ regset_buf[j++] = regs[i - RC632_REGSET_START];
+ }
+
+ rx_len = j;
+ return spi_transceive(regset_buf, j, spi_inbuf, &rx_len);
+}
+
int rc632_fifo_write(struct rfid_asic_handle *hdl,
u_int8_t len, u_int8_t *data, u_int8_t flags)
{
@@ -457,6 +485,10 @@ static int rc632_usb_in(struct req_ctx *rctx)
DEBUGP("WRITE_REG(0x%02x, 0x%02x) ", poh->reg, poh->val);
rc632_reg_write(RAH, poh->reg, poh->val);
break;
+ case OPENPCD_CMD_WRITE_REG_SET:
+ DEBUGP("WRITE_REG_SET(%s) ", hexdump(poh->data, len));
+ rc632_reg_write_set(RAH, poh->data, len);
+ break;
case OPENPCD_CMD_WRITE_FIFO:
DEBUGP("WRITE FIFO(len=%u): %s ", len,
hexdump(poh->data, len));
personal git repositories of Harald Welte. Your mileage may vary