1
|
/* main_reqa - OpenPCD firmware for generating an endless loop of
|
2
|
* ISO 14443-A REQA packets.
|
3
|
* (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
|
4
|
*
|
5
|
* This program is free software; you can redistribute it and/or modify
|
6
|
* it under the terms of the GNU General Public License as published by
|
7
|
* the Free Software Foundation; either version 2 of the License, or
|
8
|
* (at your option) any later version.
|
9
|
*
|
10
|
* This program is distributed in the hope that it will be useful,
|
11
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
* GNU General Public License for more details.
|
14
|
*
|
15
|
* You should have received a copy of the GNU General Public License
|
16
|
* along with this program; if not, write to the Free Software
|
17
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
*
|
19
|
*/
|
20
|
|
21
|
|
22
|
/* If a response is received from the PICC, LED2 (green) will be switched
|
23
|
* on. If no valid response has been received within the timeout of the
|
24
|
* receiver, LED1 (Red) will be toggled.
|
25
|
*
|
26
|
*/
|
27
|
|
28
|
#include <errno.h>
|
29
|
#include <string.h>
|
30
|
#include <librfid/rfid_layer2_iso14443a.h>
|
31
|
#include "rc632.h"
|
32
|
#include <os/dbgu.h>
|
33
|
#include <os/led.h>
|
34
|
#include <os/trigger.h>
|
35
|
#include <os/pcd_enumerate.h>
|
36
|
#include <os/main.h>
|
37
|
#include <pcd/rc632_highlevel.h>
|
38
|
|
39
|
#include <librfid/rfid_reader.h>
|
40
|
#include <librfid/rfid_layer2.h>
|
41
|
#include <librfid/rfid_protocol.h>
|
42
|
|
43
|
#define RAH NULL
|
44
|
|
45
|
static struct rfid_reader_handle *rh;
|
46
|
static struct rfid_layer2_handle *l2h;
|
47
|
|
48
|
void _init_func(void)
|
49
|
{
|
50
|
trigger_init();
|
51
|
rc632_init();
|
52
|
DEBUGPCRF("turning on RF");
|
53
|
rc632_turn_on_rf(RAH);
|
54
|
/* FIXME: do we need this? */
|
55
|
DEBUGPCRF("initializing 14443A operation");
|
56
|
rh = rfid_reader_open(NULL, RFID_READER_OPENPCD);
|
57
|
l2h = rfid_layer2_init(rh, RFID_LAYER2_ISO14443A);
|
58
|
|
59
|
/* Switch to 848kBps (1subcp / bit) */
|
60
|
//opcd_rc632_clear_bits(RAH, RC632_REG_RX_CONTROL1, RC632_RXCTRL1_SUBCP_MASK);
|
61
|
}
|
62
|
|
63
|
int _main_dbgu(char key)
|
64
|
{
|
65
|
static char ana_out_sel;
|
66
|
int ret = -EINVAL;
|
67
|
|
68
|
switch (key) {
|
69
|
case 'q':
|
70
|
ana_out_sel--;
|
71
|
ret = 1;
|
72
|
break;
|
73
|
case 'w':
|
74
|
ana_out_sel++;
|
75
|
ret = 1;
|
76
|
break;
|
77
|
case 'c':
|
78
|
rc632_turn_on_rf(RAH);
|
79
|
break;
|
80
|
case 'o':
|
81
|
rc632_turn_off_rf(RAH);
|
82
|
break;
|
83
|
}
|
84
|
|
85
|
if (ana_out_sel >= 0xd)
|
86
|
ana_out_sel = 0;
|
87
|
|
88
|
if (ret == 1) {
|
89
|
ana_out_sel &= 0x0f;
|
90
|
DEBUGPCR("switching to analog output mode 0x%x\n", ana_out_sel);
|
91
|
opcd_rc632_reg_write(RAH, RC632_REG_TEST_ANA_SELECT, ana_out_sel);
|
92
|
}
|
93
|
|
94
|
return ret;
|
95
|
}
|
96
|
|
97
|
void _main_func(void)
|
98
|
{
|
99
|
#if 1
|
100
|
struct iso14443a_atqa atqa;
|
101
|
|
102
|
memset(&atqa, 0, sizeof(atqa));
|
103
|
|
104
|
trigger_pulse();
|
105
|
|
106
|
if (iso14443a_transceive_sf(l2h, ISO14443A_SF_CMD_WUPA, &atqa) < 0) {
|
107
|
DEBUGPCRF("error during transceive_sf");
|
108
|
led_switch(1, 0);
|
109
|
} else {
|
110
|
DEBUGPCRF("received ATQA: %s\n", hexdump((char *)&atqa, sizeof(atqa)));
|
111
|
led_switch(1, 1);
|
112
|
}
|
113
|
#endif
|
114
|
led_toggle(2);
|
115
|
}
|