include ../stm32f4/Makefile-raw.defs
+aoschemelib=$(shell pkg-config --variable=aoschemelib ao-scheme)
+
+include $(aoschemelib)/Makefile-scheme
+
+IDVENDOR=0xfffe
+IDPRODUCT=0xfffa
+PRODUCT=stm32f4-disco
+SERIAL=1
+
+INC = \
+ ao.h \
+ ao_arch.h \
+ ao_arch_funcs.h \
+ ao_boot.h \
+ ao_pins.h \
+ ao_task.h \
+ ao_product.h \
+ $(SCHEME_HDRS) \
+ ao_scheme_const.h \
+ stm32f4.h \
+ Makefile
+
ALTOS_SRC = \
ao_interrupt.c \
+ ao_romconfig.c \
ao_panic.c \
ao_timer.c \
- ao_led.c \
ao_task.c \
- ao_stdio.c
+ ao_stdio.c \
+ ao_product.o \
+ ao_cmd.c \
+ ao_exti_stm32f4.c \
+ ao_usart_stm32f4.c \
+ ao_led.c \
+ ao_impure.c \
+ $(SCHEME_SRCS)
-CFLAGS = $(STM32F4_CFLAGS)
+CFLAGS = $(STM32F4_CFLAGS) -I$(aoschemelib)
PROG=stm32f4-disco-$(VERSION)
ELF=$(PROG).elf
$(ELF): Makefile $(OBJ)
$(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJ) -Wl,-M=$(MAP) $(LIBS)
+$(OBJ): $(INC)
+
+ao_product.h: ao-make-product.5c ../Version Makefile
+ $(call quiet,NICKLE,$<) $< -m altusmetrum.org -V $(IDVENDOR) -s $(SERIAL) -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
+
+SCHEME_SCHEME=\
+ ao_scheme_basic_syntax.scheme \
+ ao_scheme_list.scheme \
+ ao_scheme_advanced_syntax.scheme \
+ ao_scheme_vector.scheme \
+ ao_scheme_string.scheme \
+ ao_scheme_char.scheme \
+ ao_scheme_number.scheme
+
+ao_scheme_const.h: ao-scheme-make-const-big $(SCHEME_SCHEME)
+ $^ -o $@ -d POSIX,PORT,SAVE
+
distclean: clean
clean:
*/
#include <ao.h>
+#include <ao_scheme.h>
-static struct ao_task red_task;
-static struct ao_task green_task;
-
-static void
-red(void)
-{
- for (;;) {
- ao_led_toggle(LED_RED);
- ao_delay(AO_MS_TO_TICKS(500));
- }
+static void scheme_cmd() {
+ ao_scheme_read_eval_print(stdin, stdout, false);
}
-static void
-green(void)
+static const struct ao_cmds scheme_cmds[] = {
+ { scheme_cmd, "l\0Run scheme interpreter" },
+ { 0, 0 }
+};
+
+int
+_ao_scheme_getc(void)
{
- for (;;) {
- ao_led_toggle(LED_GREEN);
- ao_delay(AO_MS_TO_TICKS(450));
+ static uint8_t at_eol;
+ int c;
+
+ if (at_eol) {
+ ao_cmd_readline(ao_scheme_read_list ? "- " : "> ");
+ at_eol = 0;
}
+ c = (unsigned char) ao_cmd_lex();
+ if (c == '\n')
+ at_eol = 1;
+ return c;
}
void main(void)
ao_clock_init();
ao_timer_init();
ao_led_init();
+ ao_usart_init();
ao_task_init();
-
- ao_add_task(&red_task, red, "red");
- ao_add_task(&green_task, green, "green");
+ ao_cmd_init();
+ ao_cmd_register(scheme_cmds);
ao_start_scheduler();
}
#define LED_0_PORT (&stm_gpioc)
#define LED_0_PIN 5
-#define LED_GREEN (1 << 0)
+#define LED_GREEN AO_LED_0
#define LED_1_PORT (&stm_gpioe)
#define LED_1_PIN 3
-#define LED_RED (1 << 1)
+#define LED_RED AO_LED_0
+
+#define AO_LED_PANIC LED_RED
+
+/* USART */
+
+#define HAS_SERIAL_6 1
+#define SERIAL_6_RX_PORT (&stm_gpiog)
+#define SERIAL_6_RX_PIN 9
+
+#define SERIAL_6_TX_PORT (&stm_gpiog)
+#define SERIAL_6_TX_PIN 14
+
+#define USE_SERIAL_6_STDIN 1
+#define DELAY_SERIAL_6_STDIN 0
+#define USE_SERIAL_6_FLOW 0
+#define USE_SERIAL_6_SW_FLOW 0
#endif /* _AO_PINS_H_ */
--- /dev/null
+/*
+ * Copyright © 2016 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef _AO_SCHEME_OS_H_
+#define _AO_SCHEME_OS_H_
+
+#include "ao.h"
+#include "ao_scheme.h"
+
+#define AO_SCHEME_POOL 131072
+#define AO_SCHEME_TOKEN_MAX 64
+
+#define AO_SCHEME_BIG
+
+#ifndef __BYTE_ORDER
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+extern int _ao_scheme_getc(void);
+
+#define ao_scheme_getc(f) ({ (void) (f); _ao_scheme_getc(); })
+#undef putc
+#define putc(c, f) ({ (void) (f); ao_putchar(c); })
+#define fputs(s, f) ({ (void) (f); ao_put_string(s); })
+#define fiprintf(f, ...) ({ (void) (f); iprintf(__VA_ARGS__); })
+
+static inline void
+ao_scheme_abort(void)
+{
+ ao_panic(1);
+}
+
+#ifdef LEDS_AVAILABLE
+static inline void
+ao_scheme_os_led(int led)
+{
+ ao_led_set(led);
+}
+#endif
+
+#define AO_SCHEME_JIFFIES_PER_SECOND AO_HERTZ
+
+static inline void
+ao_scheme_os_delay(int delay)
+{
+ ao_delay(delay);
+}
+
+static inline int
+ao_scheme_os_jiffy(void)
+{
+ return ao_tick_count;
+}
+#endif