Initial commit
[kk_librfid.git] / firmware / src / pcd / main_dumbreader.c
blob62695f0c5a584a0b09d546dcac001ccc8c55e5fd
1 /* AT91SAM7 "dumb reader" firmware for OpenPCD
2 * (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <errno.h>
21 #include <include/lib_AT91SAM7.h>
22 #include <include/openpcd.h>
23 #include <os/dbgu.h>
24 #include "rc632.h"
25 #include "rc632_highlevel.h"
26 #include <os/led.h>
27 #include <os/pcd_enumerate.h>
28 #include <os/usb_handler.h>
29 #include "../openpcd.h"
30 #include <os/main.h>
32 #define RAH NULL
34 void _init_func(void)
36 rc632_init();
39 int _main_dbgu(char key)
41 unsigned char value;
43 switch (key) {
44 case '4':
45 AT91F_DBGU_Printk("Testing RC632 : ");
46 if (rc632_test(RAH) == 0)
47 AT91F_DBGU_Printk("SUCCESS!\n\r");
48 else
49 AT91F_DBGU_Printk("ERROR!\n\r");
51 break;
52 case '5':
53 opcd_rc632_reg_read(RAH, RC632_REG_RX_WAIT, &value);
54 DEBUGPCR("Reading RC632 Reg RxWait: 0x%02xr", value);
56 break;
57 case '6':
58 DEBUGPCR("Writing RC632 Reg RxWait: 0x55");
59 opcd_rc632_reg_write(RAH, RC632_REG_RX_WAIT, 0x55);
60 break;
61 case '7':
62 rc632_dump();
63 break;
64 case 'P':
65 rc632_power(1);
66 rc632_init();
67 break;
68 case 'p':
69 rc632_power(0);
70 break;
73 return -EINVAL;
76 void _main_func(void)
78 static int i;
80 if(i<4096)
81 i++;
82 else
84 led_toggle(1);
85 i=0;
88 /* first we try to get rid of pending to-be-sent stuff */
89 usb_out_process();
91 /* next we deal with incoming reqyests from USB EP1 (OUT) */
92 usb_in_process();
94 rc632_unthrottle();