summaryrefslogtreecommitdiff
path: root/firmware/include/openpcd.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/include/openpcd.h')
-rw-r--r--firmware/include/openpcd.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/firmware/include/openpcd.h b/firmware/include/openpcd.h
new file mode 100644
index 0000000..e6ccebe
--- /dev/null
+++ b/firmware/include/openpcd.h
@@ -0,0 +1,85 @@
+#ifndef _OPENPCD_PROTO_H
+#define _OPENPCD_PROTO_H
+
+/* This header file describes the USB protocol of the OpenPCD RFID reader */
+
+#include <sys/types.h>
+
+struct openpcd_hdr {
+ u_int8_t cmd; /* command. high nibble: class, low nibble: cmd */
+ u_int8_t flags;
+ u_int8_t reg; /* register */
+ u_int8_t val; /* value (in case of write *) */
+ u_int8_t data[0];
+} __attribute__ ((packed));
+
+#define OPENPC_FLAG_RESPOND 0x01 /* Response requested */
+
+enum openpcd_cmd_class {
+ /* PCD (reader) side */
+ OPENPCD_CMD_CLS_RC632 = 0x1,
+ OPENPCD_CMD_CLS_LED = 0x2,
+ OPENPCD_CMD_CLS_SSC = 0x3,
+ OPENPCD_CMD_CLS_PWM = 0x4,
+ OPENPCD_CMD_CLS_ADC = 0x5,
+ /* PICC (transponder) side */
+ OPENPCD_CMD_CLS_PICC = 0xe,
+
+ OPENPCD_CMD_CLS_USBTEST = 0xf,
+};
+
+#define OPENPCD_REG_MAX 0x3f
+
+#define OPENPCD_CMD_CLS(x) (x >> 4)
+#define OPENPCD_CMD(x) (x & 0xf)
+
+#define OPENPCD_CLS2CMD(x) (x << 4)
+
+/* CMD_CLS_RC632 */
+#define OPENPCD_CMD_WRITE_REG (0x1|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_RC632))
+#define OPENPCD_CMD_WRITE_FIFO (0x2|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_RC632))
+#define OPENPCD_CMD_WRITE_VFIFO (0x3|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_RC632))
+#define OPENPCD_CMD_REG_BITS_CLEAR (0x4|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_RC632))
+#define OPENPCD_CMD_REG_BITS_SET (0x5|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_RC632))
+#define OPENPCD_CMD_READ_REG (0x6|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_RC632))
+#define OPENPCD_CMD_READ_FIFO (0x7|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_RC632))
+#define OPENPCD_CMD_READ_VFIFO (0x8|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_RC632))
+#define OPENPCD_CMD_DUMP_REGS (0x9|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_RC632))
+#define OPENPCD_CMD_IRQ (0xa|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_RC632))
+
+/* CMD_CLS_LED */
+#define OPENPCD_CMD_SET_LED (0x1|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_LED))
+
+/* CMD_CLS_SSC */
+#define OPENPCD_CMD_SSC_READ (0x1|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_SSC))
+#define OPENPCD_CMD_SSC_WRITE (0x2|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_SSC))
+
+/* CMD_CLS_PWM */
+#define OPENPCD_CMD_PWM_ENABLE (0x1|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_PWM))
+#define OPENPCD_CMD_PWM_DUTY_SET (0x2|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_PWM))
+#define OPENPCD_CMD_PWM_DUTY_GET (0x3|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_PWM))
+#define OPENPCD_CMD_PWM_FREQ_SET (0x4|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_PWM))
+#define OPENPCD_CMD_PWM_FREQ_GET (0x5|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_PWM))
+
+/* CMD_CLS_PICC */
+#define OPENPCD_CMD_PICC_REG_WRITE (0x1|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_PICC))
+#define OPENPCD_CMD_PICC_REG_READ (0x2|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_PICC))
+
+/* CMD_CLS_ADC */
+#define OPENPCD_CMD_ADC_READ (0x1|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_ADC))
+
+/* CMD_CLS_USBTEST */
+#define OPENPCD_CMD_USBTEST_IN (0x1|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_USBTEST))
+#define OPENPCD_CMD_USBTEST_OUT (0x2|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_USBTEST))
+
+/* FIXME */
+#define OPENPCD_CMD_PIO_IRQ (0x3|OPENPCD_CLS2CMD(OPENPCD_CMD_CLS_USBTEST))
+
+
+#define OPENPCD_VENDOR_ID 0x2342
+#define OPENPCD_PRODUCT_ID 0x0001
+#define OPENPCD_OUT_EP 0x01
+#define OPENPCD_IN_EP 0x82
+#define OPENPCD_IRQ_EP 0x83
+
+#endif
personal git repositories of Harald Welte. Your mileage may vary