summaryrefslogtreecommitdiff
path: root/src/stm32f4-disco
diff options
context:
space:
mode:
Diffstat (limited to 'src/stm32f4-disco')
-rw-r--r--src/stm32f4-disco/.gitignore3
-rw-r--r--src/stm32f4-disco/Makefile81
-rw-r--r--src/stm32f4-disco/ao_disco.c56
-rw-r--r--src/stm32f4-disco/ao_pins.h79
-rw-r--r--src/stm32f4-disco/ao_scheme_os.h70
5 files changed, 289 insertions, 0 deletions
diff --git a/src/stm32f4-disco/.gitignore b/src/stm32f4-disco/.gitignore
new file mode 100644
index 00000000..deb5083f
--- /dev/null
+++ b/src/stm32f4-disco/.gitignore
@@ -0,0 +1,3 @@
+stm32f4-disco-*.elf
+stm32f4-disco-*.ihx
+stm32f4-disco-*.map
diff --git a/src/stm32f4-disco/Makefile b/src/stm32f4-disco/Makefile
new file mode 100644
index 00000000..de30316c
--- /dev/null
+++ b/src/stm32f4-disco/Makefile
@@ -0,0 +1,81 @@
+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_task.c \
+ ao_stdio.c \
+ ao_product.c \
+ ao_cmd.c \
+ ao_exti_stm32f4.c \
+ ao_usart_stm32f4.c \
+ ao_usb_gen.c \
+ ao_usb_stm32f4.c \
+ ao_led.c \
+ ao_impure.c \
+ $(SCHEME_SRCS)
+
+CFLAGS = $(STM32F4_CFLAGS) -I$(aoschemelib)
+
+PROG=stm32f4-disco-$(VERSION)
+ELF=$(PROG).elf
+IHX=$(PROG).ihx
+
+SRC=$(ALTOS_SRC) ao_disco.c
+OBJ=$(SRC:.c=.o)
+MAP=$(PROG).map
+
+all: $(ELF) $(IHX)
+
+$(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:
+ rm -f *.o *.elf *.ihx *.map
+
+install:
+
+uninstall:
diff --git a/src/stm32f4-disco/ao_disco.c b/src/stm32f4-disco/ao_disco.c
new file mode 100644
index 00000000..ab3c0340
--- /dev/null
+++ b/src/stm32f4-disco/ao_disco.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2018 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, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+
+#include <ao.h>
+#include <ao_scheme.h>
+#include <ao_usb.h>
+
+static void scheme_cmd() {
+ ao_scheme_read_eval_print(stdin, stdout, false);
+}
+
+static const struct ao_cmds scheme_cmds[] = {
+ { scheme_cmd, "l\0Run scheme interpreter" },
+ { 0, 0 }
+};
+
+int
+_ao_scheme_getc(void)
+{
+ 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_task_init();
+
+ ao_led_init();
+ ao_usart_init();
+ ao_usb_init();
+ ao_cmd_init();
+ ao_cmd_register(scheme_cmds);
+ ao_start_scheduler();
+}
diff --git a/src/stm32f4-disco/ao_pins.h b/src/stm32f4-disco/ao_pins.h
new file mode 100644
index 00000000..6a18d59d
--- /dev/null
+++ b/src/stm32f4-disco/ao_pins.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2018 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, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+#ifndef _AO_PINS_H_
+#define _AO_PINS_H_
+
+/* Clock tree configuration */
+#define AO_HSE 8000000 /* fed from st/link processor */
+#define AO_HSE_BYPASS 1 /* no xtal, directly fed */
+
+#define AO_PLL_M 8 /* down to 1MHz */
+
+#define AO_PLL1_R 2 /* down to 96MHz */
+#define AO_PLL1_N 192 /* up to 192MHz */
+#define AO_PLL1_P 2 /* down to 96MHz */
+#define AO_PLL1_Q 4 /* down to 48MHz for USB and SDIO */
+
+#define AO_AHB_PRESCALER 1
+#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1
+
+#define AO_APB1_PRESCALER 2
+#define AO_RCC_CFGR_PPRE1_DIV STM_RCC_CFGR_PPRE1_DIV_2
+
+#define AO_APB2_PRESCALER 1
+#define AO_RCC_CFGR_PPRE2_DIV STM_RCC_CFGR_PPRE2_DIV_1
+
+#define DEBUG_THE_CLOCK 1
+
+#define HAS_BEEP 0
+
+#define B_USER_PORT (&stm_gpioa)
+#define B_USER_PIN 0
+
+/* LEDs */
+
+#define HAS_LED 1
+
+#define LED_0_PORT (&stm_gpioc)
+#define LED_0_PIN 5
+#define LED_GREEN AO_LED_0
+
+#define LED_1_PORT (&stm_gpioe)
+#define LED_1_PIN 3
+#define LED_RED AO_LED_0
+
+#define AO_LED_PANIC LED_RED
+
+#define AO_CMD_LEN 128
+
+/* 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
+
+/* USB */
+
+#define HAS_USB 1
+#define USE_USB_STDIO 0
+
+#endif /* _AO_PINS_H_ */
diff --git a/src/stm32f4-disco/ao_scheme_os.h b/src/stm32f4-disco/ao_scheme_os.h
new file mode 100644
index 00000000..b1eac30b
--- /dev/null
+++ b/src/stm32f4-disco/ao_scheme_os.h
@@ -0,0 +1,70 @@
+/*
+ * 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