summaryrefslogtreecommitdiff
path: root/src/nucleao-32
diff options
context:
space:
mode:
Diffstat (limited to 'src/nucleao-32')
-rw-r--r--src/nucleao-32/.gitignore2
-rw-r--r--src/nucleao-32/Makefile93
-rw-r--r--src/nucleao-32/ao_nucleo.c48
-rw-r--r--src/nucleao-32/ao_pins.h65
-rw-r--r--src/nucleao-32/flash-loader/.gitignore2
-rw-r--r--src/nucleao-32/flash-loader/Makefile8
-rw-r--r--src/nucleao-32/flash-loader/ao_pins.h37
7 files changed, 255 insertions, 0 deletions
diff --git a/src/nucleao-32/.gitignore b/src/nucleao-32/.gitignore
new file mode 100644
index 00000000..cb8f78e5
--- /dev/null
+++ b/src/nucleao-32/.gitignore
@@ -0,0 +1,2 @@
+ao_product.h
+nucleo-32*
diff --git a/src/nucleao-32/Makefile b/src/nucleao-32/Makefile
new file mode 100644
index 00000000..69049982
--- /dev/null
+++ b/src/nucleao-32/Makefile
@@ -0,0 +1,93 @@
+#
+# AltOS build
+#
+#
+
+include ../stmf0/Makefile.defs
+
+INC = \
+ ao.h \
+ ao_arch.h \
+ ao_arch_funcs.h \
+ ao_boot.h \
+ ao_pins.h \
+ ao_product.h \
+ ao_task.h \
+ ao_lisp.h \
+ ao_lisp_const.h \
+ stm32f0.h \
+ Makefile
+
+ALTOS_SRC = \
+ ao_boot_chain.c \
+ ao_interrupt.c \
+ ao_product.c \
+ ao_romconfig.c \
+ ao_cmd.c \
+ ao_config.c \
+ ao_task.c \
+ ao_led.c \
+ ao_beep_stm.c \
+ ao_dma_stm.c \
+ ao_stdio.c \
+ ao_panic.c \
+ ao_timer.c \
+ ao_mutex.c \
+ ao_usb_stm.c \
+ ao_serial_stm.c \
+ ao_flash_stm.c \
+ ao_lisp_atom.c \
+ ao_lisp_builtin.c \
+ ao_lisp_cons.c \
+ ao_lisp_error.c \
+ ao_lisp_eval.c \
+ ao_lisp_frame.c \
+ ao_lisp_int.c \
+ ao_lisp_lambda.c \
+ ao_lisp_lex.c \
+ ao_lisp_mem.c \
+ ao_lisp_poly.c \
+ ao_lisp_read.c \
+ ao_lisp_rep.c \
+ ao_lisp_save.c \
+ ao_lisp_stack.c \
+ ao_lisp_string.c \
+ ao_lisp_os_save.c
+
+PRODUCT=Nucleo-32
+PRODUCT_DEF=-DNUCLEO
+IDPRODUCT=0x000a
+
+CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS) -Os -g
+
+LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stmf0 -Wl,-Tload.ld
+
+PROGNAME=nucleo-32
+PROG=$(PROGNAME)-$(VERSION).elf
+HEX=$(PROGNAME)-$(VERSION).ihx
+
+SRC=$(ALTOS_SRC) ao_nucleo.c
+OBJ=$(SRC:.c=.o)
+
+all: $(PROG) $(HEX)
+
+$(PROG): Makefile $(OBJ) altos.ld
+ $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
+
+$(OBJ): $(INC)
+
+ao_product.h: ao-make-product.5c ../Version
+ $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
+
+load: $(PROG)
+ stm-load $(PROG)
+
+distclean: clean
+
+clean:
+ rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx
+ rm -f ao_product.h
+
+install:
+
+uninstall:
diff --git a/src/nucleao-32/ao_nucleo.c b/src/nucleao-32/ao_nucleo.c
new file mode 100644
index 00000000..6b4cbaae
--- /dev/null
+++ b/src/nucleao-32/ao_nucleo.c
@@ -0,0 +1,48 @@
+/*
+ * 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, 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_lisp.h>
+#include <ao_beep.h>
+
+static void lisp_cmd() {
+ ao_lisp_read_eval_print();
+}
+
+static void beep() {
+ ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200));
+}
+
+static const struct ao_cmds blink_cmds[] = {
+ { lisp_cmd, "l\0Run lisp interpreter" },
+ { beep, "b\0Beep" },
+ { 0, 0 }
+};
+
+void main(void)
+{
+ ao_led_init(LEDS_AVAILABLE);
+ ao_clock_init();
+ ao_task_init();
+ ao_timer_init();
+ ao_dma_init();
+ ao_usb_init();
+ ao_serial_init();
+ ao_beep_init();
+ ao_cmd_init();
+ ao_cmd_register(blink_cmds);
+ ao_start_scheduler();
+}
+
+
diff --git a/src/nucleao-32/ao_pins.h b/src/nucleao-32/ao_pins.h
new file mode 100644
index 00000000..cee4616f
--- /dev/null
+++ b/src/nucleao-32/ao_pins.h
@@ -0,0 +1,65 @@
+/*
+ * 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; 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.
+ *
+ * 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_PINS_H_
+#define _AO_PINS_H_
+
+#define LED_PORT_ENABLE STM_RCC_AHBENR_IOPBEN
+#define LED_PORT (&stm_gpiob)
+#define LED_PIN_GREEN 3
+#define AO_LED_GREEN (1 << LED_PIN_GREEN)
+#define AO_LED_PANIC AO_LED_GREEN
+#define AO_CMD_LEN 128
+#define AO_LISP_POOL_TOTAL 3072
+#define AO_LISP_SAVE 1
+#define AO_STACK_SIZE 1024
+
+#define LEDS_AVAILABLE (AO_LED_GREEN)
+
+#define AO_POWER_MANAGEMENT 0
+
+/* 48MHz clock based on USB */
+#define AO_HSI48 1
+
+/* HCLK = 48MHz */
+#define AO_AHB_PRESCALER 1
+#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1
+
+/* APB = 48MHz */
+#define AO_APB_PRESCALER 1
+#define AO_RCC_CFGR_PPRE_DIV STM_RCC_CFGR_PPRE_DIV_1
+
+#define HAS_USB 1
+#define AO_USB_DIRECTIO 0
+#define AO_PA11_PA12_RMP 0
+#define HAS_BEEP 1
+
+#define BEEPER_TIMER 2
+#define BEEPER_CHANNEL 4
+#define BEEPER_PORT (&stm_gpioa)
+#define BEEPER_PIN 3
+
+#define IS_FLASH_LOADER 0
+
+#define HAS_SERIAL_2 1
+#define SERIAL_2_PA2_PA15 1
+#define USE_SERIAL_2_FLOW 0
+#define USE_SERIAL_2_STDIN 1
+#define DELAY_SERIAL_2_STDIN 0
+
+#endif /* _AO_PINS_H_ */
diff --git a/src/nucleao-32/flash-loader/.gitignore b/src/nucleao-32/flash-loader/.gitignore
new file mode 100644
index 00000000..cb8f78e5
--- /dev/null
+++ b/src/nucleao-32/flash-loader/.gitignore
@@ -0,0 +1,2 @@
+ao_product.h
+nucleo-32*
diff --git a/src/nucleao-32/flash-loader/Makefile b/src/nucleao-32/flash-loader/Makefile
new file mode 100644
index 00000000..2392e998
--- /dev/null
+++ b/src/nucleao-32/flash-loader/Makefile
@@ -0,0 +1,8 @@
+#
+# AltOS flash loader build
+#
+#
+
+TOPDIR=../..
+HARDWARE=nucleo-32
+include $(TOPDIR)/stmf0/Makefile-flash.defs
diff --git a/src/nucleao-32/flash-loader/ao_pins.h b/src/nucleao-32/flash-loader/ao_pins.h
new file mode 100644
index 00000000..8bdbdb1a
--- /dev/null
+++ b/src/nucleao-32/flash-loader/ao_pins.h
@@ -0,0 +1,37 @@
+/*
+ * 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; 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.
+ *
+ * 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_PINS_H_
+#define _AO_PINS_H_
+
+#include <ao_flash_stm_pins.h>
+
+/* Pin D3, which is PB0 */
+
+#define AO_BOOT_PIN 1
+#define AO_BOOT_APPLICATION_GPIO stm_gpiob
+#define AO_BOOT_APPLICATION_PIN 0
+#define AO_BOOT_APPLICATION_VALUE 1
+#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP
+
+/* USB */
+#define HAS_USB 1
+#define AO_USB_DIRECTIO 0
+#define AO_PA11_PA12_RMP 0
+
+#endif /* _AO_PINS_H_ */