ede7c05f3b6e53a99cc508dcc13146741edd92e6
[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
18 static void scheme_cmd() {
19         ao_scheme_read_eval_print(stdin, stdout, false);
20 }
21
22 static const struct ao_cmds scheme_cmds[] = {
23         { scheme_cmd,   "l\0Run scheme interpreter" },
24         { 0, 0 }
25 };
26
27 int
28 _ao_scheme_getc(void)
29 {
30         static uint8_t  at_eol;
31         int c;
32
33         if (at_eol) {
34                 ao_cmd_readline(ao_scheme_read_list ? "- " : "> ");
35                 at_eol = 0;
36         }
37         c = (unsigned char) ao_cmd_lex();
38         if (c == '\n')
39                 at_eol = 1;
40         return c;
41 }
42
43 void main(void)
44 {
45         ao_clock_init();
46         ao_timer_init();
47         ao_led_init();
48         ao_usart_init();
49         ao_task_init();
50         ao_cmd_init();
51         ao_cmd_register(scheme_cmds);
52         ao_start_scheduler();
53 }