Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / src / stm32f4-disco / ao_disco.c
1 /*
2  * Copyright © 2018 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, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  */
14
15 #include <ao.h>
16 #include <ao_scheme.h>
17 #include <ao_usb.h>
18
19 static void scheme_cmd() {
20         ao_scheme_read_eval_print(stdin, stdout, false);
21 }
22
23 static const struct ao_cmds scheme_cmds[] = {
24         { scheme_cmd,   "l\0Run scheme interpreter" },
25         { 0, 0 }
26 };
27
28 int
29 _ao_scheme_getc(void)
30 {
31         static uint8_t  at_eol;
32         int c;
33
34         if (at_eol) {
35                 ao_cmd_readline(ao_scheme_read_list ? "- " : "> ");
36                 at_eol = 0;
37         }
38         c = (unsigned char) ao_cmd_lex();
39         if (c == '\n')
40                 at_eol = 1;
41         return c;
42 }
43
44 void main(void)
45 {
46         ao_clock_init();
47         ao_timer_init();
48         ao_task_init();
49
50         ao_led_init();
51         ao_usart_init();
52         ao_usb_init();
53         ao_cmd_init();
54         ao_cmd_register(scheme_cmds);
55         ao_start_scheduler();
56 }