add easymotor-v1 initial attempt
authorBdale Garbee <bdale@gag.com>
Thu, 13 Dec 2018 22:51:36 +0000 (15:51 -0700)
committerBdale Garbee <bdale@gag.com>
Thu, 13 Dec 2018 22:51:36 +0000 (15:51 -0700)
src/easymotor-v1/Makefile [new file with mode: 0644]
src/easymotor-v1/ao_easymotor.c [new file with mode: 0644]
src/easymotor-v1/ao_pins.h [new file with mode: 0644]
src/easymotor-v1/flash-loader/Makefile [new file with mode: 0644]
src/easymotor-v1/flash-loader/ao_pins.h [new file with mode: 0644]

diff --git a/src/easymotor-v1/Makefile b/src/easymotor-v1/Makefile
new file mode 100644 (file)
index 0000000..2d11cc9
--- /dev/null
@@ -0,0 +1,113 @@
+#
+# AltOS build
+#
+#
+
+include ../stm/Makefile.defs
+
+INC = \
+       ao.h \
+       ao_arch.h \
+       ao_arch_funcs.h \
+       ao_boot.h \
+       ao_companion.h \
+       ao_data.h \
+       ao_sample.h \
+       ao_pins.h \
+       altitude-pa.h \
+       ao_kalman.h \
+       ao_product.h \
+       ao_adxl375.h \
+       ao_profile.h \
+       ao_task.h \
+       ao_whiten.h \
+       ao_sample_profile.h \
+       ao_quaternion.h \
+       ao_mpu.h \
+       stm32l.h \
+       Makefile
+
+#
+# Common AltOS sources
+#
+
+#PROFILE=ao_profile.c
+#PROFILE_DEF=-DAO_PROFILE=1
+
+#SAMPLE_PROFILE=ao_sample_profile.c \
+#      ao_sample_profile_timer.c
+#SAMPLE_PROFILE_DEF=-DHAS_SAMPLE_PROFILE=1
+
+#STACK_GUARD=ao_mpu_stm.c
+#STACK_GUARD_DEF=-DHAS_STACK_GUARD=1
+
+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_stm.c \
+       ao_stdio.c \
+       ao_panic.c \
+       ao_timer.c \
+       ao_mutex.c \
+       ao_dma_stm.c \
+       ao_spi_stm.c \
+       ao_data.c \
+       ao_adxl375.c \
+       ao_adc_stm.c \
+       ao_beep_stm.c \
+       ao_eeprom_stm.c \
+       ao_storage.c \
+       ao_m25.c \
+       ao_usb_stm.c \
+       ao_exti_stm.c \
+       ao_report.c \
+       ao_convert_volt.c \
+       ao_log.c \
+       ao_log_mega.c \
+       ao_sample.c \
+       ao_kalman.c \
+       ao_flight.c \
+       $(PROFILE) \
+       $(SAMPLE_PROFILE) \
+       $(STACK_GUARD)
+
+PRODUCT=EasyMotor-v1
+PRODUCT_DEF=-DEASYMOTOR
+IDPRODUCT=0x000a
+
+CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) $(SAMPLE_PROFILE_DEF) $(STACK_GUARD_DEF) -Os -g
+
+PROGNAME=easymotor-v1
+PROG=$(PROGNAME)-$(VERSION).elf
+HEX=$(PROGNAME)-$(VERSION).ihx
+
+SRC=$(ALTOS_SRC) ao_easymotor.c
+OBJ=$(SRC:.c=.o)
+
+all: $(PROG) $(HEX)
+
+$(PROG): Makefile $(OBJ) altos.ld
+       $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
+
+../altitude-pa.h: make-altitude-pa
+       nickle $< > $@
+
+$(OBJ): $(INC)
+
+ao_product.h: ao-make-product.5c ../Version
+       $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
+
+distclean:     clean
+
+clean:
+       rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx
+       rm -f ao_product.h
+
+install:
+
+uninstall:
diff --git a/src/easymotor-v1/ao_easymotor.c b/src/easymotor-v1/ao_easymotor.c
new file mode 100644 (file)
index 0000000..231dbfb
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright © 2018 Bdale Garbee <bdale@gag.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_adxl375.h>
+#include <ao_log.h>
+#include <ao_exti.h>
+#include <ao_profile.h>
+#include <ao_eeprom.h>
+#if HAS_SAMPLE_PROFILE
+#include <ao_sample_profile.h>
+#endif
+#if HAS_STACK_GUARD
+#include <ao_mpu.h>
+#endif
+
+int
+main(void)
+{
+       ao_clock_init();
+
+#if HAS_STACK_GUARD
+       ao_mpu_init();
+#endif
+
+       ao_task_init();
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
+       ao_timer_init();
+
+       ao_spi_init();
+       ao_dma_init();
+       ao_exti_init();
+
+       ao_adc_init();
+       ao_beep_init();
+       ao_cmd_init();
+
+       ao_adxl375_init();
+
+       ao_eeprom_init();
+       ao_storage_init();
+
+       ao_flight_init();
+       ao_log_init();
+       ao_report_init();
+
+       ao_usb_init();
+
+       ao_config_init();
+#if AO_PROFILE
+       ao_profile_init();
+#endif
+#if HAS_SAMPLE_PROFILE
+       ao_sample_profile_init();
+#endif
+
+       ao_led_off(LEDS_AVAILABLE);
+       ao_start_scheduler();
+       return 0;
+}
diff --git a/src/easymotor-v1/ao_pins.h b/src/easymotor-v1/ao_pins.h
new file mode 100644 (file)
index 0000000..ce2a5ac
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ * Copyright © 2018 Bdale Garbee <bdale@gag.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 AO_STACK_SIZE           512
+
+#define AO_HSE                  32000000
+#define AO_RCC_CFGR_PLLMUL      STM_RCC_CFGR_PLLMUL_3
+#define AO_RCC_CFGR2_PLLDIV     STM_RCC_CFGR2_PREDIV_2
+#define AO_PLLMUL               3
+#define AO_PLLDIV               2
+
+/* 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 IS_FLASH_LOADER         0
+#define HAS_TASK_QUEUE          1
+
+/*
+ * Serial ports
+ */
+#define HAS_SERIAL_1            0
+#define USE_SERIAL_1_STDIN      0
+#define SERIAL_1_PB6_PB7        0
+#define SERIAL_1_PA9_PA10       0
+
+#define HAS_SERIAL_2            0
+#define USE_SERIAL_2_STDIN      0
+#define DELAY_SERIAL_2_STDIN    0
+#define USE_SERIAL_2_FLOW       0
+#define USE_SERIAL_2_SW_FLOW    0
+#define SERIAL_2_PA2_PA3        0
+#define SERIAL_2_PD5_PD6        0
+#define SERIAL_2_PORT_RTS       (&stm_gpioa)
+#define SERIAL_2_PIN_RTS        0
+#define SERIAL_2_PORT_CTS       (&stm_gpioa)
+#define SERIAL_2_PIN_CTS        0
+
+#define AO_CONFIG_MAX_SIZE      1024
+
+#define HAS_EEPROM              0
+#define USE_INTERNAL_FLASH      0
+#define USE_EEPROM_CONFIG       0
+#define USE_STORAGE_CONFIG      0
+#define HAS_BEEP                1
+#define HAS_BATTERY_REPORT      1
+#define HAS_RADIO               0
+#define HAS_TELEMETRY           0
+#define HAS_APRS                0
+#define HAS_ACCEL               1
+#define HAS_AES                 0
+
+#define HAS_SPI_1               1
+#define SPI_1_PA5_PA6_PA7       1       /* sensors */
+#define SPI_1_PB3_PB4_PB5       0
+#define SPI_1_PE13_PE14_PE15    0
+#define SPI_1_OSPEEDR           STM_OSPEEDR_HIGH
+
+#define HAS_SPI_2               1
+#define SPI_2_PB13_PB14_PB15    1
+#define SPI_2_PD1_PD3_PD4       0
+#define SPI_2_OSPEEDR           STM_OSPEEDR_HIGH
+
+#define HAS_I2C_1               0
+#define I2C_1_PB8_PB9           0
+
+#define HAS_I2C_2               0
+#define I2C_2_PB10_PB11         0
+
+#define PACKET_HAS_SLAVE        0
+#define PACKET_HAS_MASTER       0
+
+#define LOW_LEVEL_DEBUG         0
+
+#define LED_PORT_0_ENABLE       STM_RCC_AHBENR_IOPCEN
+#define LED_PORT_0              (&stm_gpioc)
+#define LED_PORT_0_SHIFT        13
+#define LED_PIN_GREEN           (0 + LED_PORT_0_SHIFT)
+#define AO_LED_GREEN            (1 << LED_PIN_GREEN)
+#define LED_PORT_0_MASK         (AO_LED_GREEN)
+
+#define LEDS_AVAILABLE          (AO_LED_GREEN)
+
+#define HAS_GPS                 0
+#define HAS_FLIGHT              1
+#define HAS_ADC                 1
+#define HAS_ADC_TEMP            0
+#define HAS_LOG                 0
+
+/*
+ * ADC
+ */
+#define AO_DATA_RING            32
+#define AO_ADC_NUM_SENSE        2
+
+struct ao_adc {
+        int16_t                 v_batt;
+};
+
+#define AO_ADC_DUMP(p) \
+        printf("tick: %5u batt %5d\n", \
+               (p)->tick, \
+               (p)->adc.v_batt);
+
+#define AO_ADC_V_BATT           0
+#define AO_ADC_V_BATT_PORT      (&stm_gpiob)
+#define AO_ADC_V_BATT_PIN       0
+
+#define AO_ADC_RCC_AHBENR       ((1 << STM_RCC_AHBENR_IOPAEN))
+
+#define AO_NUM_ADC_PIN          1
+
+#define AO_ADC_PIN0_PORT        AO_ADC_V_BATT_PORT
+#define AO_ADC_PIN0_PIN         AO_ADC_V_BATT_PIN
+#define AO_ADC_PIN0_CH          AO_ADC_V_BATT_PIN
+
+#define AO_NUM_ADC              (AO_NUM_ADC_PIN)
+
+#define AO_ADC_SQ1              AO_ADC_V_BATT
+
+/*
+ * Voltage divider on ADC battery sampler
+ */
+#define AO_BATTERY_DIV_PLUS     100     /* 100k */
+#define AO_BATTERY_DIV_MINUS    27      /* 27k */
+
+/*
+ * ADC reference in decivolts
+ */
+#define AO_ADC_REFERENCE_DV     33
+
+
+
+#define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX       (1024 * 1024)
+#define LOG_ERASE_MARK                         0x55
+#define LOG_MAX_ERASE                          128
+#define AO_LOG_FORMAT                          AO_LOG_FORMAT_EASYMOTOR_1
+
+#define BEEPER_TIMER           2
+#define BEEPER_CHANNEL         3
+#define BEEPER_PORT            (&stm_gpioa)
+#define BEEPER_PIN             2
+
+/*
+ * SPI Flash memory
+ */
+
+#define M25_MAX_CHIPS          1
+#define AO_M25_SPI_CS_PORT     (&stm_gpioa)
+#define AO_M25_SPI_CS_PIN      0
+#define AO_M25_SPI_CS_MASK     (1 << AO_M25_SPI_CS_PIN)
+#define AO_M25_SPI_BUS         AO_SPI_1_PA5_PA6_PA7
+
+/* ADXL375 */
+
+#define HAS_ADXL375            1
+#define AO_ADXL375_SPI_INDEX   (AO_SPI_1_PA5_PA6_PA7 | AO_SPI_MODE_3)
+#define AO_ADXL375_CS_PORT     (&stm_gpiob)
+#define AO_ADXL375_CS_PIN      10
+#define AO_ADXL375_SPI_SPEED   AO_SPI_SPEED_4MHz
+
+#define AO_ADXL375_INT1_PORT   (&stm_gpiob)
+#define AO_ADXL375_INT1_PIN    2
+
+#define AO_ADXL375_INT2_PORT   (&stm_gpiob)
+#define AO_ADXL375_INT2_PIN    1
+
+#define AO_ADXL375_AXIS                x
+#define AO_ADXL375_INVERT      1
+
+#define NUM_CMDS               16
+
+/*
+ * Monitor
+ */
+
+#define HAS_MONITOR            0
+#define LEGACY_MONITOR         0
+#define HAS_MONITOR_PUT                0
+#define AO_MONITOR_LED         0
+#define HAS_RSSI               0
+
+#endif /* _AO_PINS_H_ */
diff --git a/src/easymotor-v1/flash-loader/Makefile b/src/easymotor-v1/flash-loader/Makefile
new file mode 100644 (file)
index 0000000..2122354
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# AltOS flash loader build
+#
+#
+
+TOPDIR=../..
+HARDWARE=easymotor-v1
+include $(TOPDIR)/stmf0/Makefile-flash.defs
diff --git a/src/easymotor-v1/flash-loader/ao_pins.h b/src/easymotor-v1/flash-loader/ao_pins.h
new file mode 100644 (file)
index 0000000..c0e445b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2018 Bdale Garbee <bdale@gag.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>
+
+/* ground companion pin 6 (pin 1 is ground) to force bootload */
+
+#define AO_BOOT_PIN                    1
+#define AO_BOOT_APPLICATION_GPIO       stm_gpiob
+#define AO_BOOT_APPLICATION_PIN                12
+#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_ */