summaryrefslogtreecommitdiff
path: root/src/stm-demo
diff options
context:
space:
mode:
Diffstat (limited to 'src/stm-demo')
-rw-r--r--src/stm-demo/Makefile2
-rw-r--r--src/stm-demo/ao_demo.c41
-rw-r--r--src/stm-demo/ao_pins.h11
-rw-r--r--src/stm-demo/flash-loader/Makefile8
-rw-r--r--src/stm-demo/flash-loader/ao_pins.h35
5 files changed, 84 insertions, 13 deletions
diff --git a/src/stm-demo/Makefile b/src/stm-demo/Makefile
index 98fcd9e5..869fb32f 100644
--- a/src/stm-demo/Makefile
+++ b/src/stm-demo/Makefile
@@ -9,6 +9,7 @@ INC = \
ao.h \
ao_arch.h \
ao_arch_funcs.h \
+ ao_boot.h \
ao_pins.h \
ao_product.h
@@ -26,7 +27,6 @@ ALTOS_SRC = \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
- ao_serial_stm.c \
ao_lcd_stm.c \
ao_lcd_font.c \
ao_mutex.c \
diff --git a/src/stm-demo/ao_demo.c b/src/stm-demo/ao_demo.c
index 58cf651b..ffc5d2d8 100644
--- a/src/stm-demo/ao_demo.c
+++ b/src/stm-demo/ao_demo.c
@@ -171,12 +171,38 @@ ao_event(void)
}
#endif
+static uint8_t ao_blinking = 0;
+
+static void
+ao_blink(void)
+{
+ for (;;) {
+ while (!ao_blinking)
+ ao_sleep(&ao_blinking);
+ while (ao_blinking) {
+ ao_led_toggle(AO_LED_BLUE|AO_LED_GREEN);
+ ao_delay(AO_MS_TO_TICKS(500));
+ }
+ }
+}
+
+static struct ao_task ao_blink_task;
+
+static void
+ao_blink_toggle(void)
+{
+ ao_blinking = !ao_blinking;
+ ao_wakeup(&ao_blinking);
+}
+
+
__code struct ao_cmds ao_demo_cmds[] = {
{ ao_dma_test, "D\0DMA test" },
{ ao_spi_write, "W\0SPI write" },
{ ao_spi_read, "R\0SPI read" },
{ ao_i2c_write, "i\0I2C write" },
{ ao_temp, "t\0Show temp" },
+ { ao_blink_toggle, "b\0Toggle LED blinking" },
/* { ao_event, "e\0Monitor event queue" }, */
{ 0, NULL }
};
@@ -188,23 +214,26 @@ main(void)
ao_task_init();
- ao_serial_init();
+ ao_led_init(LEDS_AVAILABLE);
+ ao_led_on(AO_LED_GREEN);
+ ao_led_off(AO_LED_BLUE);
ao_timer_init();
ao_dma_init();
ao_cmd_init();
// ao_lcd_stm_init();
// ao_lcd_font_init();
- ao_spi_init();
- ao_i2c_init();
- ao_exti_init();
+// ao_spi_init();
+// ao_i2c_init();
+// ao_exti_init();
// ao_quadrature_init();
// ao_button_init();
- ao_timer_set_adc_interval(100);
+// ao_timer_set_adc_interval(100);
- ao_adc_init();
+// ao_adc_init();
ao_usb_init();
+ ao_add_task(&ao_blink_task, ao_blink, "blink");
ao_cmd_register(&ao_demo_cmds[0]);
ao_start_scheduler();
diff --git a/src/stm-demo/ao_pins.h b/src/stm-demo/ao_pins.h
index 40e48a36..885b9db6 100644
--- a/src/stm-demo/ao_pins.h
+++ b/src/stm-demo/ao_pins.h
@@ -42,13 +42,13 @@
#define AO_APB2_PRESCALER 1
#define AO_RCC_CFGR_PPRE2_DIV STM_RCC_CFGR_PPRE2_DIV_1
-#define HAS_SERIAL_1 1
-#define USE_SERIAL_1_STDIN 1
+#define HAS_SERIAL_1 0
+#define USE_SERIAL_1_STDIN 0
#define SERIAL_1_PB6_PB7 1
#define SERIAL_1_PA9_PA10 0
#define HAS_SERIAL_2 0
-#define USE_SERIAL_2_STDIN 1
+#define USE_SERIAL_2_STDIN 0
#define SERIAL_2_PA2_PA3 0
#define SERIAL_2_PD5_PD6 1
@@ -70,7 +70,7 @@
#define AO_BOOT_CHAIN 1
-#define LOW_LEVEL_DEBUG 1
+#define LOW_LEVEL_DEBUG 0
#define LED_PORT_ENABLE STM_RCC_AHBENR_GPIOBEN
#define LED_PORT (&stm_gpiob)
@@ -78,8 +78,7 @@
#define LED_PIN_BLUE 6
#define AO_LED_GREEN (1 << LED_PIN_GREEN)
#define AO_LED_BLUE (1 << LED_PIN_BLUE)
-
-#define AO_LED_RED AO_LED_BLUE /* a patent lie */
+#define AO_LED_PANIC AO_LED_BLUE
#define LEDS_AVAILABLE (AO_LED_BLUE | AO_LED_GREEN)
diff --git a/src/stm-demo/flash-loader/Makefile b/src/stm-demo/flash-loader/Makefile
new file mode 100644
index 00000000..27e54278
--- /dev/null
+++ b/src/stm-demo/flash-loader/Makefile
@@ -0,0 +1,8 @@
+#
+# AltOS flash loader build
+#
+#
+
+TOPDIR=../..
+HARDWARE=stm-demo
+include $(TOPDIR)/stm/Makefile-flash.defs
diff --git a/src/stm-demo/flash-loader/ao_pins.h b/src/stm-demo/flash-loader/ao_pins.h
new file mode 100644
index 00000000..4c59101a
--- /dev/null
+++ b/src/stm-demo/flash-loader/ao_pins.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2013 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_PINS_H_
+#define _AO_PINS_H_
+
+/* Bridge SB17 on the board and use the MCO from the other chip */
+#define AO_HSE 8000000
+#define AO_HSE_BYPASS 1
+
+#include <ao_flash_stm_pins.h>
+
+/* Use the 'user switch' to force boot loader on power on */
+
+#define AO_BOOT_PIN 1
+#define AO_BOOT_APPLICATION_GPIO stm_gpioa
+#define AO_BOOT_APPLICATION_PIN 0
+#define AO_BOOT_APPLICATION_VALUE 0
+#define AO_BOOT_APPLICATION_MODE 0
+
+#endif /* _AO_PINS_H_ */