Merge branch 'mpusb'
[fw/altos] / src / mpusb-v3.0 / ao_mpusb.c
1 /*
2  * Copyright © 2012 Keith Packard <keithp@keithp.com>
3  *
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; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 #include <ao.h>
19 #include <ao_serial.h>
20
21 static struct ao_task ao_report_task;
22
23 static void
24 ao_report(void)
25 {
26         int     c;
27         ao_up_set_speed(AO_SERIAL_SPEED_9600);
28         for (;;) {
29                 ao_arch_block_interrupts();
30                 c = _ao_up_pollchar();
31                 ao_arch_release_interrupts();
32                 if (c == AO_READ_AGAIN) {
33                         flush();
34                         c = ao_up_getchar();
35                 }
36                 putchar(c);
37         }
38 }
39
40 int
41 main(void)
42 {
43         ao_clock_init();
44
45         ao_task_init();
46
47         ao_timer_init();
48
49         ao_serial_init();
50
51         ao_dma_init();
52
53         ao_cmd_init();
54
55         ao_usb_init();
56
57         ao_add_task(&ao_report_task, ao_report, "report");
58
59         ao_start_scheduler();
60         return 0;
61 }