#
#
-include ../stmf0/Makefile.defs
+include ../stm32l0/Makefile.defs
PUBLISH_DIR=$(HOME)/altusmetrumllc/Binaries
PUBLISH_HEX=$(PUBLISH_DIR)/$(HEX)
ao_microflight.c \
ao_microkalman.c
-ALTOS_SRC = \
+ALTOS_SRC_ = \
ao_micropeak.c \
ao_spi_stm.c \
ao_dma_stm.c \
ao_micropeak.h \
altitude-pa.h \
ao_product.h \
- stm32f0.h
+ stm32l0.h
+
+ALTOS_SRC = \
+ ao_interrupt.c \
+ ao_panic.c \
+ ao_micro.c \
+ ao_stdio.c \
+ ao_notask.c \
+ ao_serial_stm.c \
+ ao_timer.c \
+ ao_led.c
IDPRODUCT=0x14
PRODUCT=MicroPeak-v2.0
PRODUCT_DEF=-DMICROPEAK
-CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS)
+CFLAGS = $(PRODUCT_DEF) $(STML0_CFLAGS)
PROGNAME=micropeak-v2.0
PROG=$(PROGNAME)-$(VERSION).elf
all: $(PROG) $(HEX)
-LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/stmf0 -Tmicropeak.ld -n
+LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/stm32l0 -Taltos.ld -n
$(PROG): Makefile $(OBJ) micropeak.ld
$(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) -Wl,-Map=$(PROGNAME)-$(VERSION).map
--- /dev/null
+/*
+ * Copyright © 2020 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.
+ */
+
+#include <ao.h>
+#include <ao_exti.h>
+#include <ao_micropeak.h>
+
+int
+main(void)
+{
+ ao_timer_init();
+
+ ao_led_init();
+ ao_led_on(AO_LED_ORANGE);
+
+ ao_serial_init();
+
+ for (;;) {
+ ao_led_on(AO_LED_ORANGE);
+ ao_delay(AO_MS_TO_TICKS(500));
+ ao_led_off(AO_LED_ORANGE);
+ ao_delay(AO_MS_TO_TICKS(500));
+ printf("hello, world\n");
+ }
+}
}
void
-ao_delay_until(uint16_t target) {
+ao_delay_until(AO_TICK_TYPE target) {
int16_t delay = target - ao_time();
if (delay > 0) {
ao_sleep_for(ao_delay_until, delay);
stm_rcc.apb2enr &= ~(1 << STM_RCC_APB2ENR_ADCEN);
}
-static uint16_t
+static AO_TICK_TYPE
ao_battery_voltage(void)
{
- uint16_t vrefint;
+ AO_TICK_TYPE vrefint;
ao_battery_init();
uint8_t
ao_log_present(void)
{
- uint16_t n_samples;
+ AO_TICK_TYPE n_samples;
ao_eeprom_read(N_SAMPLES_OFFSET, &n_samples, sizeof (n_samples));
extern uint8_t ao_on_battery;
-#define AO_SYSCLK (ao_on_battery ? STM_HSI_FREQ : 48000000)
+#define AO_SYSCLK STM_MSI_FREQ
-#define LED_PORT_ENABLE STM_RCC_AHBENR_IOPAEN
-#define LED_PORT (&stm_gpioa)
-#define LED_PIN_ORANGE 2
-#define AO_LED_ORANGE (1 << LED_PIN_ORANGE)
+#define LED_0_PORT (&stm_gpioa)
+#define LED_0_PIN 1
+#define AO_LED_ORANGE (1 << 0)
#define AO_LED_REPORT AO_LED_ORANGE
#define AO_LED_PANIC AO_LED_ORANGE
#define AO_POWER_MANAGEMENT 0
-/* 48MHz clock based on USB */
-#define AO_HSI48 1
-/* Need HSI running to flash */
-#define AO_NEED_HSI 1
+/* HCLK = MSI (2.097MHz) */
+#define AO_AHB_PRESCALER (1)
+#define AO_RCC_CFGR_HPRE_DIV (STM_RCC_CFGR_HPRE_DIV_1)
-/* HCLK = 12MHz usb / 2MHz battery */
-#define AO_AHB_PRESCALER (ao_on_battery ? 16 : 1)
-#define AO_RCC_CFGR_HPRE_DIV (ao_on_battery ? STM_RCC_CFGR_HPRE_DIV_16 : STM_RCC_CFGR_HPRE_DIV_1)
-
-/* APB = 12MHz usb / 2MHz battery */
-#define AO_APB_PRESCALER (ao_on_battery ? 2 : 1)
-#define AO_RCC_CFGR_PPRE_DIV (ao_on_battery ? STM_RCC_CFGR_PPRE_DIV_2 : STM_RCC_CFGR_PPRE_DIV_1)
-
-#define HAS_USB 1
-#define AO_PA11_PA12_RMP 1
+/* APB = MSI */
+#define AO_APB1_PRESCALER (1)
+#define AO_APB2_PRESCALER (1)
+#define AO_RCC_CFGR_PPRE_DIV (STM_RCC_CFGR_PPRE_DIV_1)
#define PACKET_HAS_SLAVE 0
#define HAS_SERIAL_1 0
#define HAS_SERIAL_2 1
-#define USE_SERIAL_2_STDIN 0
+#define USE_SERIAL_2_STDIN 1
#define USE_SERIAL_2_FLOW 0
#define USE_SERIAL_2_SW_FLOW 0
-#define SERIAL_2_PA2_PA3 1
-#define SERIAL_2_PA14_PA15 0
-#define USE_SERIAL2_FLOW 0
-#define USE_SERIAL2_SW_FLOW 0
+#define SERIAL_2_PA9_PA10 1
#define IS_FLASH_LOADER 0
#define AO_ALT_VALUE(x) ((x) * (alt_t) 10)
-#define AO_DATA_RING 32
-
#define HAS_ADC 0
+#define HAS_AO_DELAY 1
static inline void
ao_power_off(void) __attribute((noreturn));
extern alt_t ao_max_height;
-void ao_delay_until(uint16_t target);
-
#define ao_async_stop() do { \
ao_serial2_drain(); \
stm_moder_set(&stm_gpioa, 2, STM_MODER_OUTPUT); \
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-__flash = 0x08001000;
-__flash_size = 22K;
+__flash = 0x08000000;
+__flash_size = 10K;
__flash__ = __flash + __flash_size;
__flash_end__ = __flash__ + 6K;
__ram = 0x20000000;
-__ram_size = 6K;
+__ram_size = 2K;
__stack_size = 512;
-INCLUDE registers.ld
INCLUDE picolibc.ld