summaryrefslogtreecommitdiff
path: root/src/detherm
diff options
context:
space:
mode:
Diffstat (limited to 'src/detherm')
-rw-r--r--src/detherm/.gitignore2
-rw-r--r--src/detherm/Makefile82
-rw-r--r--src/detherm/ao_detherm.c50
-rw-r--r--src/detherm/ao_pins.h115
-rw-r--r--src/detherm/flash-loader/.gitignore2
-rw-r--r--src/detherm/flash-loader/Makefile8
-rw-r--r--src/detherm/flash-loader/ao_pins.h36
7 files changed, 295 insertions, 0 deletions
diff --git a/src/detherm/.gitignore b/src/detherm/.gitignore
new file mode 100644
index 00000000..4f11d9a0
--- /dev/null
+++ b/src/detherm/.gitignore
@@ -0,0 +1,2 @@
+ao_product.h
+detherm-*
diff --git a/src/detherm/Makefile b/src/detherm/Makefile
new file mode 100644
index 00000000..6b0e0bf8
--- /dev/null
+++ b/src/detherm/Makefile
@@ -0,0 +1,82 @@
+#
+# AltOS build
+#
+#
+
+include ../stmf0/Makefile.defs
+
+INC = \
+ ao.h \
+ ao_arch.h \
+ ao_arch_funcs.h \
+ ao_pins.h \
+ ao_product.h \
+ ao_task.h \
+ stm32f0.h
+
+#
+# Common AltOS sources
+#
+ALTOS_SRC = \
+ ao_interrupt.c \
+ ao_timer.c \
+ ao_panic.c \
+ ao_mutex.c \
+ ao_dma_stm.c \
+ ao_usb_stm.c \
+ ao_spi_stm.c \
+ ao_exti_stm.c \
+ ao_stdio.c \
+ ao_led.c \
+ ao_log.c \
+ ao_log_mini.c \
+ ao_sample.c \
+ ao_data.c \
+ ao_kalman.c \
+ ao_flight.c \
+ ao_report.c \
+ ao_storage.c \
+ ao_m25.c \
+ ao_romconfig.c \
+ ao_boot_chain.c \
+ ao_ms5607.c \
+ ao_convert_pa.c \
+ ao_pwm.c \
+ ao_servo.c \
+ ao_task.c \
+ ao_config.c \
+ ao_cmd.c \
+ ao_product.c
+
+PRODUCT=Detherm-v1.0
+PRODUCT_DEF=-DDETHERM_V_1_0
+IDPRODUCT=0x0013
+
+CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS) -g -Os
+
+PROGNAME=detherm-v1.0
+PROG=$(PROGNAME)-$(VERSION).elf
+HEX=$(PROGNAME)-$(VERSION).ihx
+
+SRC=$(ALTOS_SRC) ao_detherm.c
+OBJ=$(SRC:.c=.o)
+
+all: $(PROG) $(HEX)
+
+$(PROG): Makefile $(OBJ) altos.ld
+ $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
+
+ao_product.h: ao-make-product.5c ../Version
+ $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) -o $@
+
+$(OBJ): $(INC)
+
+distclean: clean
+
+clean:
+ rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx
+ rm -f ao_product.h
+
+install:
+
+uninstall:
diff --git a/src/detherm/ao_detherm.c b/src/detherm/ao_detherm.c
new file mode 100644
index 00000000..fba9195e
--- /dev/null
+++ b/src/detherm/ao_detherm.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2014 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.
+ */
+
+#include <ao.h>
+#include <ao_exti.h>
+#include <ao_pwm.h>
+#include <ao_servo.h>
+
+void main(void)
+{
+ ao_led_init(LEDS_AVAILABLE);
+
+ ao_led_on(AO_LED_RED);
+
+ ao_clock_init();
+ ao_task_init();
+ ao_timer_init();
+ ao_exti_init();
+
+ ao_dma_init();
+ ao_spi_init();
+ ao_usb_init();
+
+ ao_storage_init();
+ ao_ms5607_init();
+// ao_flight_init();
+ ao_pwm_init();
+ ao_servo_init();
+ ao_log_init();
+ ao_report_init();
+ ao_config_init();
+
+ ao_cmd_init();
+
+ ao_start_scheduler();
+}
diff --git a/src/detherm/ao_pins.h b/src/detherm/ao_pins.h
new file mode 100644
index 00000000..1c577b6e
--- /dev/null
+++ b/src/detherm/ao_pins.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright © 2015 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_
+
+#define LED_PORT_ENABLE STM_RCC_AHBENR_IOPAEN
+#define LED_PORT (&stm_gpioa)
+#define LED_PIN_RED 3
+#define AO_LED_RED (1 << LED_PIN_RED)
+
+#define LEDS_AVAILABLE (AO_LED_RED)
+
+#define HAS_BEEP 0
+
+/* 48MHz clock based on USB */
+//#define AO_HSI48 1
+#define AO_HSE 16000000
+#define AO_RCC_CFGR_PLLMUL STM_RCC_CFGR_PLLMUL_3
+#define AO_PLLMUL 3
+#define AO_PLLDIV 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 1
+
+#define IS_FLASH_LOADER 0
+
+#define AO_DATA_RING 16
+
+#define HAS_ADC 0
+#define HAS_ACCEL 0
+#define HAS_GPS 0
+#define HAS_RADIO 0
+#define HAS_FLIGHT 1
+#define HAS_EEPROM 1
+#define HAS_LOG 1
+
+#define AO_LOG_FORMAT AO_LOG_FORMAT_DETHERM
+
+#define USE_INTERNAL_FLASH 0
+
+/* SPI */
+#define HAS_SPI_1 1
+#define HAS_SPI_2 0
+#define SPI_1_PA5_PA6_PA7 1
+#define SPI_1_PB3_PB4_PB5 1
+#define SPI_1_OSPEEDR STM_OSPEEDR_HIGH
+
+/* MS5607 */
+#define HAS_MS5607 1
+
+#define AO_MS5607_CS_PORT (&stm_gpioa)
+#define AO_MS5607_CS_PIN 0
+#define AO_MS5607_SPI_INDEX AO_SPI_1_PB3_PB4_PB5
+#define AO_MS5607_MISO_PORT (&stm_gpiob)
+#define AO_MS5607_MISO_PIN 4
+#define AO_MS5607_PRIVATE_PINS 1
+#define AO_MS5607_SPI_SPEED AO_SPI_SPEED_6MHz
+
+/* Flash */
+
+#define M25_MAX_CHIPS 1
+#define AO_M25_SPI_CS_PORT (&stm_gpioa)
+#define AO_M25_SPI_CS_MASK (1 << 4)
+#define AO_M25_SPI_BUS AO_SPI_1_PA5_PA6_PA7
+
+/* PWM */
+
+#define NUM_PWM 1
+#define AO_PWM_TIMER (&stm_tim3)
+#define AO_PWM_0_GPIO (&stm_gpiob)
+#define AO_PWM_0_PIN 1
+#define AO_PWM_0_CH 4
+#define PWM_MAX 20000
+#define AO_PWM_TIMER_ENABLE STM_RCC_APB1ENR_TIM3EN
+#define AO_PWM_TIMER_SCALE 32
+
+/* Servo */
+
+#define AO_SERVO_DIR_PORT (&stm_gpiob)
+#define AO_SERVO_DIR_BIT 0
+#define AO_SERVO_SPEED_PWM 0
+
+/* limit 2 */
+#define AO_SERVO_LIMIT_FORE_PORT (&stm_gpiob)
+#define AO_SERVO_LIMIT_FORE_BIT 6
+
+/* limit 1 */
+#define AO_SERVO_LIMIT_BACK_PORT (&stm_gpiob)
+#define AO_SERVO_LIMIT_BACK_BIT 7
+
+#endif /* _AO_PINS_H_ */
diff --git a/src/detherm/flash-loader/.gitignore b/src/detherm/flash-loader/.gitignore
new file mode 100644
index 00000000..d0d4657e
--- /dev/null
+++ b/src/detherm/flash-loader/.gitignore
@@ -0,0 +1,2 @@
+ao_product.h
+detherm*
diff --git a/src/detherm/flash-loader/Makefile b/src/detherm/flash-loader/Makefile
new file mode 100644
index 00000000..5210aa09
--- /dev/null
+++ b/src/detherm/flash-loader/Makefile
@@ -0,0 +1,8 @@
+#
+# AltOS flash loader build
+#
+#
+
+TOPDIR=../..
+HARDWARE=detherm-v1.0
+include $(TOPDIR)/stmf0/Makefile-flash.defs
diff --git a/src/detherm/flash-loader/ao_pins.h b/src/detherm/flash-loader/ao_pins.h
new file mode 100644
index 00000000..570800ca
--- /dev/null
+++ b/src/detherm/flash-loader/ao_pins.h
@@ -0,0 +1,36 @@
+/*
+ * 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_
+
+#include <ao_flash_stm_pins.h>
+
+/* Pin 5 on debug connector */
+
+#define AO_BOOT_PIN 1
+#define AO_BOOT_APPLICATION_GPIO stm_gpioa
+#define AO_BOOT_APPLICATION_PIN 15
+#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 1
+
+#endif /* _AO_PINS_H_ */