summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author(no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-07-30 12:57:08 +0000
committer(no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-07-30 12:57:08 +0000
commit78c6dcc4aece268a15e15b654a71de436b5b2eb1 (patch)
treec5c1580cde81cea9a1f4442dd057523e944a140d
parent3221ecd80929d9f29ada6633c64c58e84c97d0fd (diff)
add new WUPA and ANTICOL modes
git-svn-id: https://svn.openpcd.org:2342/trunk@69 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
-rw-r--r--openpcd/firmware/src/main_reqa.c70
1 files changed, 63 insertions, 7 deletions
diff --git a/openpcd/firmware/src/main_reqa.c b/openpcd/firmware/src/main_reqa.c
index cd1f162..e03fffa 100644
--- a/openpcd/firmware/src/main_reqa.c
+++ b/openpcd/firmware/src/main_reqa.c
@@ -27,26 +27,82 @@ void _init_func(void)
rc632_iso14443a_init(RAH);
}
+#define MODE_REQA 0x01
+#define MODE_WUPA 0x02
+#define MODE_ANTICOL 0x03
+
+static volatile int mode = MODE_REQA;
+
int _main_dbgu(char key)
{
- return -EINVAL;
+ switch (key) {
+ case 'r':
+ mode = MODE_REQA;
+ break;
+ case 'w':
+ mode = MODE_WUPA;
+ break;
+ case 'a':
+ mode = MODE_ANTICOL;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
}
void _main_func(void)
{
+ int status;
struct iso14443a_atqa atqa;
+ struct rfid_layer2_handle l2h;
+ volatile int i;
memset(&atqa, 0, sizeof(atqa));
+ /* fake layer2 handle initialization */
+ memset(&l2h, 0, sizeof(l2h));
+ l2h.l2 = &rfid_layer2_iso14443a;
+ l2h.priv.iso14443a.state = ISO14443A_STATE_NONE;
+ l2h.priv.iso14443a.level = ISO14443A_LEVEL_NONE;
+
trigger_pulse();
+ /* FIXME: why does this not work without reset or power-cycle? */
+ rc632_turn_off_rf();
+ //rc632_reset();
+ rc632_turn_on_rf();
+ rc632_iso14443a_init(RAH);
+ for (i = 0; i < 0xfffff; i++) {}
+ //rc632_dump();
+ switch (mode) {
+ case MODE_REQA:
+ status = rc632_iso14443a_transceive_sf(RAH, ISO14443A_SF_CMD_REQA, &atqa);
+ if (status < 0)
+ DEBUGPCRF("error during transceive_sf REQA");
+ else
+ DEBUGPCRF("received ATQA: %s", hexdump((char *)&atqa, sizeof(atqa)));
+ break;
+ case MODE_WUPA:
+ status = rc632_iso14443a_transceive_sf(RAH, ISO14443A_SF_CMD_WUPA, &atqa);
+ if (status < 0)
+ DEBUGPCRF("error during transceive_sf WUPA");
+ else
+ DEBUGPCRF("received WUPA: %s", hexdump((char *)&atqa, sizeof(atqa)));
+ break;
+ case MODE_ANTICOL:
+ status = iso14443a_anticol(&l2h);
+ if (status < 0)
+ DEBUGPCR("error during anticol");
+ else
+ DEBUGPCR("Anticol OK");
+ break;
+ }
- if (rc632_iso14443a_transceive_sf(RAH, ISO14443A_SF_CMD_WUPA, &atqa) < 0) {
- DEBUGPCRF("error during transceive_sf");
+ if (status < 0)
led_switch(1, 0);
- } else {
- DEBUGPCRF("received ATQA: %s\n", hexdump((char *)&atqa, sizeof(atqa)));
+ else
led_switch(1, 1);
- }
-
+
led_toggle(2);
}
personal git repositories of Harald Welte. Your mileage may vary