From 23ba75c3c2ddde65dc543b52cd87b8a1433c5024 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 23 Jan 2013 19:03:26 -0800 Subject: altos/fox: Add fox1ihu bringup firmware Firmware capable of testing fox1ihu hardware Signed-off-by: Keith Packard --- src/fox1ihu/.gitignore | 2 + src/fox1ihu/Makefile | 76 ++++++++++++++++++ src/fox1ihu/ao_fox1ihu.c | 47 +++++++++++ src/fox1ihu/ao_pins.h | 204 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 329 insertions(+) create mode 100644 src/fox1ihu/.gitignore create mode 100644 src/fox1ihu/Makefile create mode 100644 src/fox1ihu/ao_fox1ihu.c create mode 100644 src/fox1ihu/ao_pins.h (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/.gitignore b/src/fox1ihu/.gitignore new file mode 100644 index 00000000..538cf8b2 --- /dev/null +++ b/src/fox1ihu/.gitignore @@ -0,0 +1,2 @@ +ao_product.h +fox1ihu-*.elf diff --git a/src/fox1ihu/Makefile b/src/fox1ihu/Makefile new file mode 100644 index 00000000..f76633aa --- /dev/null +++ b/src/fox1ihu/Makefile @@ -0,0 +1,76 @@ +# +# AltOS build +# +# + +include ../stm/Makefile.defs + +INC = \ + ao.h \ + ao_arch.h \ + ao_arch_funcs.h \ + ao_pins.h \ + ao_product.h \ + ao_task.h \ + stm32l.h \ + Makefile + +#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_interrupt.c \ + ao_product.c \ + ao_romconfig.c \ + ao_cmd.c \ + ao_task.c \ + ao_led.c \ + ao_stdio.c \ + ao_panic.c \ + ao_timer.c \ + ao_mutex.c \ + ao_dma_stm.c \ + ao_spi_stm.c \ + ao_usb_stm.c \ + ao_exti_stm.c \ + ao_adc_stm.c \ + ao_data.c + +PRODUCT=Fox1IHH-v0.1 +PRODUCT_DEF=-DFOX +IDPRODUCT=0x0024 + +CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) $(SAMPLE_PROFILE_DEF) $(STACK_GUARD_DEF) -Os -g + +PROGNAME=fox1ihu-v0.1 +PROG=$(PROGNAME)-$(VERSION).elf + +SRC=$(ALTOS_SRC) ao_fox1ihu.c +OBJ=$(SRC:.c=.o) + +all: $(PROG) + +$(PROG): Makefile $(OBJ) altos.ld + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(SAT_CLIB) -lgcc + +$(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 + rm -f ao_product.h + +install: + +uninstall: diff --git a/src/fox1ihu/ao_fox1ihu.c b/src/fox1ihu/ao_fox1ihu.c new file mode 100644 index 00000000..4d02f0da --- /dev/null +++ b/src/fox1ihu/ao_fox1ihu.c @@ -0,0 +1,47 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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 +#include +#include +#include + +int +main(void) +{ + ao_clock_init(); + +#if HAS_STACK_GUARD + ao_mpu_init(); +#endif + + ao_task_init(); + ao_led_init(LEDS_AVAILABLE); + ao_led_on(AO_LED_RED); + ao_timer_init(); + + ao_spi_init(); + ao_dma_init(); + ao_exti_init(); + + ao_cmd_init(); + + ao_usb_init(); + + ao_start_scheduler(); + return 0; +} diff --git a/src/fox1ihu/ao_pins.h b/src/fox1ihu/ao_pins.h new file mode 100644 index 00000000..e3d8d4d3 --- /dev/null +++ b/src/fox1ihu/ao_pins.h @@ -0,0 +1,204 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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 HAS_TASK_QUEUE 1 + +/* 8MHz High speed external crystal */ +#define AO_HSE 8000000 + +/* PLLVCO = 96MHz (so that USB will work) */ +#define AO_PLLMUL 12 +#define AO_RCC_CFGR_PLLMUL (STM_RCC_CFGR_PLLMUL_12) + +/* SYSCLK = 32MHz (no need to go faster than CPU) */ +#define AO_PLLDIV 3 +#define AO_RCC_CFGR_PLLDIV (STM_RCC_CFGR_PLLDIV_3) + +/* HCLK = 32MHz (CPU clock) */ +#define AO_AHB_PRESCALER 1 +#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1 + +/* Run APB1 at 16MHz (HCLK/2) */ +#define AO_APB1_PRESCALER 2 +#define AO_RCC_CFGR_PPRE1_DIV STM_RCC_CFGR_PPRE2_DIV_2 + +/* Run APB2 at 16MHz (HCLK/2) */ +#define AO_APB2_PRESCALER 2 +#define AO_RCC_CFGR_PPRE2_DIV STM_RCC_CFGR_PPRE2_DIV_2 + +#define HAS_SERIAL_1 1 +#define USE_SERIAL_1_STDIN 0 +#define SERIAL_1_PB6_PB7 0 +#define SERIAL_1_PA9_PA10 1 + +#define HAS_SERIAL_2 0 +#define USE_SERIAL_2_STDIN 0 +#define SERIAL_2_PA2_PA3 0 +#define SERIAL_2_PD5_PD6 0 + +#define HAS_SERIAL_3 0 +#define USE_SERIAL_3_STDIN 0 +#define SERIAL_3_PB10_PB11 0 +#define SERIAL_3_PC10_PC11 1 +#define SERIAL_3_PD8_PD9 0 + +#define HAS_EEPROM 0 +#define USE_INTERNAL_FLASH 0 +#define HAS_USB 1 +#define HAS_BEEP 0 +#define HAS_RADIO 0 +#define HAS_TELEMETRY 0 + +#define HAS_SPI_1 1 +#define SPI_1_PA5_PA6_PA7 0 +#define SPI_1_PB3_PB4_PB5 0 +#define SPI_1_PE13_PE14_PE15 1 /* */ + +#define HAS_SPI_2 0 +#define SPI_2_PB13_PB14_PB15 1 /* */ +#define SPI_2_PD1_PD3_PD4 0 + +#define SPI_2_PORT (&stm_gpiob) +#define SPI_2_SCK_PIN 13 +#define SPI_2_MISO_PIN 14 +#define SPI_2_MOSI_PIN 15 + +#define HAS_I2C_1 1 +#define I2C_1_PB6_PB7 1 +#define I2C_1_PB8_PB9 0 + +#define HAS_I2C_2 1 +#define I2C_2_PB10_PB11 1 + +#define PACKET_HAS_SLAVE 0 +#define PACKET_HAS_MASTER 0 + +#define LOW_LEVEL_DEBUG 0 + +#define LED_PORT_0_ENABLE STM_RCC_AHBENR_GPIOCEN +#define LED_PORT_0 (&stm_gpioc) +#define LED_PORT_0_MASK (0xff) +#define LED_PORT_0_SHIFT 0 +#define LED_PIN_RED 6 +#define LED_PIN_GREEN 7 +#define LED_PIN_RED_2 8 +#define LED_PIN_GREEN_2 9 +#define AO_LED_RED (1 << LED_PIN_RED) +#define AO_LED_GREEN (1 << LED_PIN_GREEN) +#define AO_LED_RED_2 (1 << LED_PIN_RED_2) +#define AO_LED_GREEN_2 (1 << LED_PIN_GREEN_2) + +#define LEDS_AVAILABLE (AO_LED_RED | AO_LED_GREEN | AO_LED_RED_2 | AO_LED_GREEN_2) + +#define HAS_GPS 0 +#define HAS_FLIGHT 0 +#define HAS_ADC 1 +#define HAS_LOG 0 + +/* + * ADC + */ +#define AO_DATA_RING 32 +#define AO_ADC_NUM_SENSE 6 + +struct ao_adc { + int16_t tx_pa_current; /* ADC_IN0 */ + int16_t tx_pa_temp; /* ADC_IN1 */ + int16_t tx_xo_temp; /* ADC_IN2 */ + int16_t rx_xo_temp; /* ADC_IN3 */ + int16_t ihu_current; /* ADC_IN8 */ + int16_t rx_cd; /* ADC_IN9 */ + int16_t ant_sense_1; /* ADC_IN10 */ + int16_t ant_sense_2; /* ADC_IN11 */ +}; + +#define AO_ADC_TX_PA_CURRENT 0 +#define AO_ADC_TX_PA_CURRENT_PORT (&stm_gpioa) +#define AO_ADC_TX_PA_CURRENT_PIN 0 + +#define AO_ADC_TX_PA_TEMP 1 +#define AO_ADC_TX_PA_TEMP_PORT (&stm_gpioa) +#define AO_ADC_TX_PA_TEMP_PIN 1 + +#define AO_ADC_TX_XO_TEMP 2 +#define AO_ADC_TX_XO_TEMP_PORT (&stm_gpioa) +#define AO_ADC_TX_XO_TEMP_PIN 2 + +#define AO_ADC_RX_XO_TEMP 3 +#define AO_ADC_RX_XO_TEMP_PORT (&stm_gpioa) +#define AO_ADC_RX_XO_TEMP_PIN 3 + +#define AO_ADC_IHU_CURRENT 8 +#define AO_ADC_IHU_CURRENT_PORT (&stm_gpiob) +#define AO_ADC_IHU_CURRENT_PIN 0 + +#define AO_ADC_RX_CD 9 +#define AO_ADC_RX_CD_PORT (&stm_gpiob) +#define AO_ADC_RX_CD_PIN 1 + +#define AO_ADC_ANT_SENSE_1 10 +#define AO_ADC_ANT_SENSE_1_PORT (&stm_gpioc) +#define AO_ADC_ANT_SENSE_1_PIN 0 + +#define AO_ADC_ANT_SENSE_2 11 +#define AO_ADC_ANT_SENSE_2_PORT (&stm_gpioc) +#define AO_ADC_ANT_SENSE_2_PIN 1 + +#define AO_ADC_TEMP 16 + +#define AO_ADC_RCC_AHBENR ((1 << STM_RCC_AHBENR_GPIOAEN) | \ + (1 << STM_RCC_AHBENR_GPIOBEN) | \ + (1 << STM_RCC_AHBENR_GPIOCEN)) + +#define AO_NUM_ADC_PIN (9) + +#define AO_ADC_PIN0_PORT AO_ADC_TX_PA_CURRENT_PORT +#define AO_ADC_PIN0_PIN AO_ADC_TX_PA_CURRENT_PIN +#define AO_ADC_PIN1_PORT AO_ADC_TX_PA_TEMP_PORT +#define AO_ADC_PIN1_PIN AO_ADC_TX_PA_TEMP_PIN +#define AO_ADC_PIN2_PORT AO_ADC_TX_XO_TEMP_PORT +#define AO_ADC_PIN2_PIN AO_ADC_TX_XO_TEMP_PIN +#define AO_ADC_PIN3_PORT AO_ADC_RX_XO_TEMP_PORT +#define AO_ADC_PIN3_PIN AO_ADC_RX_XO_TEMP_PIN +#define AO_ADC_PIN4_PORT AO_ADC_IHU_CURRENT_PORT +#define AO_ADC_PIN4_PIN AO_ADC_IHU_CURRENT_PIN +#define AO_ADC_PIN5_PORT AO_ADC_IHU_CURRENT_PORT +#define AO_ADC_PIN5_PIN AO_ADC_IHU_CURRENT_PIN +#define AO_ADC_PIN6_PORT AO_ADC_RX_CD_PORT +#define AO_ADC_PIN6_PIN AO_ADC_RX_CD_PIN +#define AO_ADC_PIN7_PORT AO_ADC_ANT_SENSE_1_PORT +#define AO_ADC_PIN7_PIN AO_ADC_ANT_SENSE_1_PIN +#define AO_ADC_PIN8_PORT AO_ADC_ANT_SENSE_2_PORT +#define AO_ADC_PIN8_PIN AO_ADC_ANT_SENSE_2_PIN + +#define AO_NUM_ADC (AO_NUM_ADC_PIN + 1) /* Add internal temp sensor */ + +#define AO_ADC_SQ1 AO_ADC_TX_PA_CURRENT +#define AO_ADC_SQ2 AO_ADC_TX_PA_TEMP +#define AO_ADC_SQ3 AO_ADC_TX_XO_TEMP +#define AO_ADC_SQ4 AO_ADC_RX_XO_TEMP +#define AO_ADC_SQ5 AO_ADC_IHU_CURRENT +#define AO_ADC_SQ6 AO_ADC_IHU_CURRENT +#define AO_ADC_SQ7 AO_ADC_RX_CD +#define AO_ADC_SQ8 AO_ADC_ANT_SENSE_1 +#define AO_ADC_SQ9 AO_ADC_ANT_SENSE_2 +#define AO_ADC_SQ10 AO_ADC_TEMP + +#endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From fbf01178e560d8a36916e295d7bdb0b0e98d2b02 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Wed, 23 Jan 2013 21:45:28 -0700 Subject: altos/fox: rename fox product It's Fox1IHU-v1 now --- src/fox1ihu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/Makefile b/src/fox1ihu/Makefile index f76633aa..714a308b 100644 --- a/src/fox1ihu/Makefile +++ b/src/fox1ihu/Makefile @@ -43,7 +43,7 @@ ALTOS_SRC = \ ao_adc_stm.c \ ao_data.c -PRODUCT=Fox1IHH-v0.1 +PRODUCT=Fox1IHU-v1 PRODUCT_DEF=-DFOX IDPRODUCT=0x0024 -- cgit v1.2.3 From ff2330a7fedfa7f6be3502ad0d591ab9e5ddddc6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 23 Jan 2013 20:48:04 -0800 Subject: altos/fox: Initialize FOX adc Signed-off-by: Keith Packard --- src/fox1ihu/ao_fox1ihu.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/ao_fox1ihu.c b/src/fox1ihu/ao_fox1ihu.c index 4d02f0da..9e76d267 100644 --- a/src/fox1ihu/ao_fox1ihu.c +++ b/src/fox1ihu/ao_fox1ihu.c @@ -38,6 +38,8 @@ main(void) ao_dma_init(); ao_exti_init(); + ao_adc_init(); + ao_cmd_init(); ao_usb_init(); -- cgit v1.2.3 From 8b783887d7f136d3a389316545b74f4755e43eb4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 23 Jan 2013 21:05:26 -0800 Subject: altos/fox: Fix up Fox ADC bits Update to current schematic Signed-off-by: Keith Packard --- src/fox1ihu/ao_pins.h | 74 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 22 deletions(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/ao_pins.h b/src/fox1ihu/ao_pins.h index e3d8d4d3..506a1360 100644 --- a/src/fox1ihu/ao_pins.h +++ b/src/fox1ihu/ao_pins.h @@ -110,6 +110,7 @@ #define HAS_GPS 0 #define HAS_FLIGHT 0 #define HAS_ADC 1 +#define HAS_ADC_TEMP 1 #define HAS_LOG 0 /* @@ -119,14 +120,18 @@ #define AO_ADC_NUM_SENSE 6 struct ao_adc { - int16_t tx_pa_current; /* ADC_IN0 */ - int16_t tx_pa_temp; /* ADC_IN1 */ - int16_t tx_xo_temp; /* ADC_IN2 */ - int16_t rx_xo_temp; /* ADC_IN3 */ - int16_t ihu_current; /* ADC_IN8 */ - int16_t rx_cd; /* ADC_IN9 */ - int16_t ant_sense_1; /* ADC_IN10 */ - int16_t ant_sense_2; /* ADC_IN11 */ + int16_t tx_pa_current; /* 0 ADC_IN0 */ + int16_t tx_pa_temp; /* 1 ADC_IN1 */ + int16_t tx_xo_temp; /* 2 ADC_IN2 */ + int16_t rx_xo_temp; /* 3 ADC_IN3 */ + int16_t ihu_current; /* 4 ADC_IN8 */ + int16_t rx_cd; /* 5 ADC_IN9 */ + int16_t ant_sense_1; /* 6 ADC_IN10 */ + int16_t ant_sense_2; /* 7 ADC_IN11 */ + int16_t gyro_x_1; /* 8 ADC_IN12 */ + int16_t gyro_z_1; /* 9 ADC_IN13 */ + int16_t gyro_x_2; /* 10 ADC_IN14 */ + int16_t gyro_z_2; /* 11 ADC_IN15 */ }; #define AO_ADC_TX_PA_CURRENT 0 @@ -161,13 +166,29 @@ struct ao_adc { #define AO_ADC_ANT_SENSE_2_PORT (&stm_gpioc) #define AO_ADC_ANT_SENSE_2_PIN 1 +#define AO_ADC_GYRO_X_1 12 +#define AO_ADC_GYRO_X_1_PORT (&stm_gpioc) +#define AO_ADC_GYRO_X_1_PIN 2 + +#define AO_ADC_GYRO_Z_1 13 +#define AO_ADC_GYRO_Z_1_PORT (&stm_gpioc) +#define AO_ADC_GYRO_Z_1_PIN 3 + +#define AO_ADC_GYRO_X_2 14 +#define AO_ADC_GYRO_X_2_PORT (&stm_gpioc) +#define AO_ADC_GYRO_X_2_PIN 4 + +#define AO_ADC_GYRO_Z_2 15 +#define AO_ADC_GYRO_Z_2_PORT (&stm_gpioc) +#define AO_ADC_GYRO_Z_2_PIN 5 + #define AO_ADC_TEMP 16 #define AO_ADC_RCC_AHBENR ((1 << STM_RCC_AHBENR_GPIOAEN) | \ (1 << STM_RCC_AHBENR_GPIOBEN) | \ (1 << STM_RCC_AHBENR_GPIOCEN)) -#define AO_NUM_ADC_PIN (9) +#define AO_NUM_ADC_PIN (12) #define AO_ADC_PIN0_PORT AO_ADC_TX_PA_CURRENT_PORT #define AO_ADC_PIN0_PIN AO_ADC_TX_PA_CURRENT_PIN @@ -179,14 +200,20 @@ struct ao_adc { #define AO_ADC_PIN3_PIN AO_ADC_RX_XO_TEMP_PIN #define AO_ADC_PIN4_PORT AO_ADC_IHU_CURRENT_PORT #define AO_ADC_PIN4_PIN AO_ADC_IHU_CURRENT_PIN -#define AO_ADC_PIN5_PORT AO_ADC_IHU_CURRENT_PORT -#define AO_ADC_PIN5_PIN AO_ADC_IHU_CURRENT_PIN -#define AO_ADC_PIN6_PORT AO_ADC_RX_CD_PORT -#define AO_ADC_PIN6_PIN AO_ADC_RX_CD_PIN -#define AO_ADC_PIN7_PORT AO_ADC_ANT_SENSE_1_PORT -#define AO_ADC_PIN7_PIN AO_ADC_ANT_SENSE_1_PIN -#define AO_ADC_PIN8_PORT AO_ADC_ANT_SENSE_2_PORT -#define AO_ADC_PIN8_PIN AO_ADC_ANT_SENSE_2_PIN +#define AO_ADC_PIN5_PORT AO_ADC_RX_CD_PORT +#define AO_ADC_PIN5_PIN AO_ADC_RX_CD_PIN +#define AO_ADC_PIN6_PORT AO_ADC_ANT_SENSE_1_PORT +#define AO_ADC_PIN6_PIN AO_ADC_ANT_SENSE_1_PIN +#define AO_ADC_PIN7_PORT AO_ADC_ANT_SENSE_2_PORT +#define AO_ADC_PIN7_PIN AO_ADC_ANT_SENSE_2_PIN +#define AO_ADC_PIN8_PORT AO_ADC_GYRO_X_1_PORT +#define AO_ADC_PIN8_PIN AO_ADC_GYRO_X_1_PIN +#define AO_ADC_PIN9_PORT AO_ADC_GYRO_Z_1_PORT +#define AO_ADC_PIN9_PIN AO_ADC_GYRO_Z_1_PIN +#define AO_ADC_PIN10_PORT AO_ADC_GYRO_X_2_PORT +#define AO_ADC_PIN10_PIN AO_ADC_GYRO_X_2_PIN +#define AO_ADC_PIN11_PORT AO_ADC_GYRO_Z_2_PORT +#define AO_ADC_PIN11_PIN AO_ADC_GYRO_Z_2_PIN #define AO_NUM_ADC (AO_NUM_ADC_PIN + 1) /* Add internal temp sensor */ @@ -195,10 +222,13 @@ struct ao_adc { #define AO_ADC_SQ3 AO_ADC_TX_XO_TEMP #define AO_ADC_SQ4 AO_ADC_RX_XO_TEMP #define AO_ADC_SQ5 AO_ADC_IHU_CURRENT -#define AO_ADC_SQ6 AO_ADC_IHU_CURRENT -#define AO_ADC_SQ7 AO_ADC_RX_CD -#define AO_ADC_SQ8 AO_ADC_ANT_SENSE_1 -#define AO_ADC_SQ9 AO_ADC_ANT_SENSE_2 -#define AO_ADC_SQ10 AO_ADC_TEMP +#define AO_ADC_SQ6 AO_ADC_RX_CD +#define AO_ADC_SQ7 AO_ADC_ANT_SENSE_1 +#define AO_ADC_SQ8 AO_ADC_ANT_SENSE_2 +#define AO_ADC_SQ9 AO_ADC_GYRO_X_1 +#define AO_ADC_SQ10 AO_ADC_GYRO_Z_1 +#define AO_ADC_SQ11 AO_ADC_GYRO_X_2 +#define AO_ADC_SQ12 AO_ADC_GYRO_Z_2 +#define AO_ADC_SQ13 AO_ADC_TEMP #endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From 524afb040aa34d93abae7d04afa1df7a626f9877 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 23 Jan 2013 21:36:18 -0800 Subject: altos/fox: Provide names for fox ADC channels Signed-off-by: Keith Packard --- src/fox1ihu/ao_pins.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/ao_pins.h b/src/fox1ihu/ao_pins.h index 506a1360..09fd5e99 100644 --- a/src/fox1ihu/ao_pins.h +++ b/src/fox1ihu/ao_pins.h @@ -218,17 +218,30 @@ struct ao_adc { #define AO_NUM_ADC (AO_NUM_ADC_PIN + 1) /* Add internal temp sensor */ #define AO_ADC_SQ1 AO_ADC_TX_PA_CURRENT +#define AO_ADC_SQ1_NAME "tx_pa_current" #define AO_ADC_SQ2 AO_ADC_TX_PA_TEMP +#define AO_ADC_SQ2_NAME "tx_pa_temp" #define AO_ADC_SQ3 AO_ADC_TX_XO_TEMP +#define AO_ADC_SQ3_NAME "tx_xo_temp" #define AO_ADC_SQ4 AO_ADC_RX_XO_TEMP +#define AO_ADC_SQ4_NAME "rx_xo_temp" #define AO_ADC_SQ5 AO_ADC_IHU_CURRENT +#define AO_ADC_SQ5_NAME "ihu_current" #define AO_ADC_SQ6 AO_ADC_RX_CD +#define AO_ADC_SQ6_NAME "rx_cd" #define AO_ADC_SQ7 AO_ADC_ANT_SENSE_1 +#define AO_ADC_SQ7_NAME "ant_sense_1" #define AO_ADC_SQ8 AO_ADC_ANT_SENSE_2 +#define AO_ADC_SQ8_NAME "ant_sense_2" #define AO_ADC_SQ9 AO_ADC_GYRO_X_1 +#define AO_ADC_SQ9_NAME "gyro_x_1" #define AO_ADC_SQ10 AO_ADC_GYRO_Z_1 +#define AO_ADC_SQ10_NAME "gyro_z_1" #define AO_ADC_SQ11 AO_ADC_GYRO_X_2 +#define AO_ADC_SQ11_NAME "gyro_x_2" #define AO_ADC_SQ12 AO_ADC_GYRO_Z_2 +#define AO_ADC_SQ12_NAME "gyro_z_2" #define AO_ADC_SQ13 AO_ADC_TEMP +#define AO_ADC_SQ13_NAME "temp" #endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From 6adf9d2a17d701ed0ceb742f322fa72723149980 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 23 Jan 2013 21:37:24 -0800 Subject: altos/fox: Turn on all of the fox lights Fox has two red and two green LEDs Signed-off-by: Keith Packard --- src/fox1ihu/ao_fox1ihu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/ao_fox1ihu.c b/src/fox1ihu/ao_fox1ihu.c index 9e76d267..43ae2ea8 100644 --- a/src/fox1ihu/ao_fox1ihu.c +++ b/src/fox1ihu/ao_fox1ihu.c @@ -31,7 +31,7 @@ main(void) ao_task_init(); ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_RED); + ao_led_on(AO_LED_RED|AO_LED_GREEN|AO_LED_RED_2|AO_LED_GREEN_2); ao_timer_init(); ao_spi_init(); -- cgit v1.2.3 From e0c969910a516c018e64eaa73cdbe4bc2f979835 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 21 Mar 2013 09:49:15 -0700 Subject: altos/fox: Add watchdog timer Runs at 25Hz, can be enabled and disabled via the command line Signed-off-by: Keith Packard --- src/fox1ihu/Makefile | 3 ++- src/fox1ihu/ao_fox1ihu.c | 2 ++ src/fox1ihu/ao_pins.h | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/Makefile b/src/fox1ihu/Makefile index 714a308b..94315e79 100644 --- a/src/fox1ihu/Makefile +++ b/src/fox1ihu/Makefile @@ -41,7 +41,8 @@ ALTOS_SRC = \ ao_usb_stm.c \ ao_exti_stm.c \ ao_adc_stm.c \ - ao_data.c + ao_data.c \ + ao_watchdog.c PRODUCT=Fox1IHU-v1 PRODUCT_DEF=-DFOX diff --git a/src/fox1ihu/ao_fox1ihu.c b/src/fox1ihu/ao_fox1ihu.c index 43ae2ea8..9f7821f7 100644 --- a/src/fox1ihu/ao_fox1ihu.c +++ b/src/fox1ihu/ao_fox1ihu.c @@ -44,6 +44,8 @@ main(void) ao_usb_init(); + ao_watchdog_init(); + ao_start_scheduler(); return 0; } diff --git a/src/fox1ihu/ao_pins.h b/src/fox1ihu/ao_pins.h index 09fd5e99..e73ef63a 100644 --- a/src/fox1ihu/ao_pins.h +++ b/src/fox1ihu/ao_pins.h @@ -244,4 +244,10 @@ struct ao_adc { #define AO_ADC_SQ13 AO_ADC_TEMP #define AO_ADC_SQ13_NAME "temp" +/* Watchdog timer */ + +#define AO_WATCHDOG_INTERVAL AO_MS_TO_TICKS(40) +#define AO_WATCHDOG_PORT (&stm_gpiod) +#define AO_WATCHDOG_BIT 3 + #endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From f517aa5e042af8dd7fd36be47e4b196f212e79b0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 21 Mar 2013 10:16:35 -0700 Subject: altos/fox: Enable M25 driver for MRAM. The M25 driver can also talk to the MRAM chip, with a few adjustments Signed-off-by: Keith Packard --- src/fox1ihu/Makefile | 4 ++++ src/fox1ihu/ao_fox1ihu.c | 6 ++++-- src/fox1ihu/ao_pins.h | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/Makefile b/src/fox1ihu/Makefile index 94315e79..d702cca8 100644 --- a/src/fox1ihu/Makefile +++ b/src/fox1ihu/Makefile @@ -11,6 +11,8 @@ INC = \ ao_arch_funcs.h \ ao_pins.h \ ao_product.h \ + ao_watchdog.h \ + ao_storage.h \ ao_task.h \ stm32l.h \ Makefile @@ -42,6 +44,8 @@ ALTOS_SRC = \ ao_exti_stm.c \ ao_adc_stm.c \ ao_data.c \ + ao_storage.c \ + ao_m25.c \ ao_watchdog.c PRODUCT=Fox1IHU-v1 diff --git a/src/fox1ihu/ao_fox1ihu.c b/src/fox1ihu/ao_fox1ihu.c index 9f7821f7..5bbad328 100644 --- a/src/fox1ihu/ao_fox1ihu.c +++ b/src/fox1ihu/ao_fox1ihu.c @@ -17,8 +17,8 @@ #include #include -#include -#include +#include +#include int main(void) @@ -44,6 +44,8 @@ main(void) ao_usb_init(); + ao_storage_init(); + ao_watchdog_init(); ao_start_scheduler(); diff --git a/src/fox1ihu/ao_pins.h b/src/fox1ihu/ao_pins.h index e73ef63a..f901a96b 100644 --- a/src/fox1ihu/ao_pins.h +++ b/src/fox1ihu/ao_pins.h @@ -250,4 +250,11 @@ struct ao_adc { #define AO_WATCHDOG_PORT (&stm_gpiod) #define AO_WATCHDOG_BIT 3 +/* MRAM device */ + +#define M25_MAX_CHIPS 1 +#define AO_M25_SPI_CS_PORT (&stm_gpiod) +#define AO_M25_SPI_CS_MASK (1 << 0) +#define AO_M25_SPI_BUS AO_SPI_2_PB13_PB14_PB15 + #endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From 4c37ccc63d37ff0a4382f6812060d3c5fd4b6cfb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 25 Apr 2013 21:25:12 -0700 Subject: altos/fox: Add MRAM and SD card drivers Signed-off-by: Keith Packard --- src/fox1ihu/Makefile | 8 +++++++- src/fox1ihu/ao_fox1ihu.c | 3 +++ src/fox1ihu/ao_pins.h | 22 +++++++++++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/Makefile b/src/fox1ihu/Makefile index d702cca8..aa5c6b4a 100644 --- a/src/fox1ihu/Makefile +++ b/src/fox1ihu/Makefile @@ -15,6 +15,9 @@ INC = \ ao_storage.h \ ao_task.h \ stm32l.h \ + ao_sdcard.h \ + ao_bufio.h \ + ao_fat.h \ Makefile #PROFILE=ao_profile.c @@ -45,7 +48,10 @@ ALTOS_SRC = \ ao_adc_stm.c \ ao_data.c \ ao_storage.c \ - ao_m25.c \ + ao_mr25.c \ + ao_sdcard.c \ + ao_bufio.c \ + ao_fat.c \ ao_watchdog.c PRODUCT=Fox1IHU-v1 diff --git a/src/fox1ihu/ao_fox1ihu.c b/src/fox1ihu/ao_fox1ihu.c index 5bbad328..2e1a2fdf 100644 --- a/src/fox1ihu/ao_fox1ihu.c +++ b/src/fox1ihu/ao_fox1ihu.c @@ -19,6 +19,7 @@ #include #include #include +#include int main(void) @@ -48,6 +49,8 @@ main(void) ao_watchdog_init(); + ao_fat_init(); + ao_start_scheduler(); return 0; } diff --git a/src/fox1ihu/ao_pins.h b/src/fox1ihu/ao_pins.h index f901a96b..028360a5 100644 --- a/src/fox1ihu/ao_pins.h +++ b/src/fox1ihu/ao_pins.h @@ -70,10 +70,13 @@ #define SPI_1_PA5_PA6_PA7 0 #define SPI_1_PB3_PB4_PB5 0 #define SPI_1_PE13_PE14_PE15 1 /* */ +#define SPI_1_OSPEEDR STM_OSPEEDR_10MHz -#define HAS_SPI_2 0 +#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_10MHz +#define HAS_STORAGE_DEBUG 1 #define SPI_2_PORT (&stm_gpiob) #define SPI_2_SCK_PIN 13 @@ -252,9 +255,18 @@ struct ao_adc { /* MRAM device */ -#define M25_MAX_CHIPS 1 -#define AO_M25_SPI_CS_PORT (&stm_gpiod) -#define AO_M25_SPI_CS_MASK (1 << 0) -#define AO_M25_SPI_BUS AO_SPI_2_PB13_PB14_PB15 +#define AO_MR25_SPI_CS_PORT (&stm_gpiod) +#define AO_MR25_SPI_CS_PIN 0 +#define AO_MR25_SPI_BUS AO_SPI_2_PB13_PB14_PB15 + +/* SD card */ + +#define AO_SDCARD_SPI_CS_PORT (&stm_gpiod) +#define AO_SDCARD_SPI_CS_PIN 1 +#define AO_SDCARD_SPI_BUS AO_SPI_2_PB13_PB14_PB15 +#define AO_SDCARD_SPI_PORT (&stm_gpiob) +#define AO_SDCARD_SPI_SCK_PIN 13 +#define AO_SDCARD_SPI_MISO_PIN 14 +#define AO_SDCARD_SPI_MOSI_PIN 15 #endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From 36cf713ead58a52539c87de764b022ba0dcde27d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 27 Apr 2013 16:06:48 -0700 Subject: altos/fox: Add fox1ihu flash loader Signed-off-by: Keith Packard --- src/fox1ihu/flash-loader/Makefile | 8 ++++++++ src/fox1ihu/flash-loader/ao_pins.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/fox1ihu/flash-loader/Makefile create mode 100644 src/fox1ihu/flash-loader/ao_pins.h (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/flash-loader/Makefile b/src/fox1ihu/flash-loader/Makefile new file mode 100644 index 00000000..454bc6fb --- /dev/null +++ b/src/fox1ihu/flash-loader/Makefile @@ -0,0 +1,8 @@ +# +# AltOS flash loader build +# +# + +TOPDIR=../.. +HARDWARE=fox1ihu +include $(TOPDIR)/stm/Makefile-flash.defs diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h new file mode 100644 index 00000000..bcc3cc9c --- /dev/null +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2013 Keith Packard + * + * 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_ + +/* External crystal at 8MHz */ +#define AO_HSE 8000000 + +#include + +/* Detatched signal, PD6 */ + +#define AO_BOOT_PIN 1 +#define AO_BOOT_APPLICATION_GPIO stm_gpiod +#define AO_BOOT_APPLICATION_PIN 6 +#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_MODE 0 + +#endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From e79202f95f0e5b4a01da31d3742a775bea62cc92 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 28 Apr 2013 00:05:39 -0700 Subject: altos/fox: Run app when PD6 is low Signed-off-by: Keith Packard --- src/fox1ihu/flash-loader/ao_pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h index bcc3cc9c..3a942c9c 100644 --- a/src/fox1ihu/flash-loader/ao_pins.h +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -28,7 +28,7 @@ #define AO_BOOT_PIN 1 #define AO_BOOT_APPLICATION_GPIO stm_gpiod #define AO_BOOT_APPLICATION_PIN 6 -#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_VALUE 0 #define AO_BOOT_APPLICATION_MODE 0 #endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From ca58096665fc1a11ca5683f0e6aafaf3e153af37 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 28 Apr 2013 00:42:31 -0700 Subject: altos/fox: update product name to show v2, enable watchdog by default Signed-off-by: Keith Packard --- src/fox1ihu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/Makefile b/src/fox1ihu/Makefile index aa5c6b4a..d80cb7af 100644 --- a/src/fox1ihu/Makefile +++ b/src/fox1ihu/Makefile @@ -54,7 +54,7 @@ ALTOS_SRC = \ ao_fat.c \ ao_watchdog.c -PRODUCT=Fox1IHU-v1 +PRODUCT=Fox1IHU-v2 PRODUCT_DEF=-DFOX IDPRODUCT=0x0024 -- cgit v1.2.3 From 54da028c492464802b048cb949d392cd83994e75 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 31 Jan 2014 17:44:45 -0800 Subject: altos/fox: Transition to current altos build environment Fix the library usage, use $(LIBS) instead of $(SAT_CLIB) -lgcc Signed-off-by: Keith Packard --- src/fox1ihu/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/Makefile b/src/fox1ihu/Makefile index d80cb7af..e3226a24 100644 --- a/src/fox1ihu/Makefile +++ b/src/fox1ihu/Makefile @@ -31,6 +31,7 @@ INC = \ #STACK_GUARD_DEF=-DHAS_STACK_GUARD=1 ALTOS_SRC = \ + ao_boot_chain.c \ ao_interrupt.c \ ao_product.c \ ao_romconfig.c \ @@ -62,14 +63,15 @@ CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) $(SAMPLE_PROFILE_DEF) $(STA PROGNAME=fox1ihu-v0.1 PROG=$(PROGNAME)-$(VERSION).elf +HEX=$(PROGNAME)-$(VERSION).ihx SRC=$(ALTOS_SRC) ao_fox1ihu.c OBJ=$(SRC:.c=.o) -all: $(PROG) +all: $(PROG) $(HEX) $(PROG): Makefile $(OBJ) altos.ld - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(SAT_CLIB) -lgcc + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) $(OBJ): $(INC) -- cgit v1.2.3 From 04aa1dfa7918dcf4eea9ec4cef5a31ac2a61a00d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 31 Jan 2014 22:39:58 -0800 Subject: altos/fox: Update ADC to fox-1 IHU Revision 2 Change ADC pin definitions to match new hardware. Signed-off-by: Keith Packard --- src/fox1ihu/ao_pins.h | 189 +++++++++++++++++++++++++++++++------------------- 1 file changed, 117 insertions(+), 72 deletions(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/ao_pins.h b/src/fox1ihu/ao_pins.h index 028360a5..b5dd7283 100644 --- a/src/fox1ihu/ao_pins.h +++ b/src/fox1ihu/ao_pins.h @@ -120,42 +120,58 @@ * ADC */ #define AO_DATA_RING 32 -#define AO_ADC_NUM_SENSE 6 struct ao_adc { int16_t tx_pa_current; /* 0 ADC_IN0 */ - int16_t tx_pa_temp; /* 1 ADC_IN1 */ - int16_t tx_xo_temp; /* 2 ADC_IN2 */ - int16_t rx_xo_temp; /* 3 ADC_IN3 */ - int16_t ihu_current; /* 4 ADC_IN8 */ - int16_t rx_cd; /* 5 ADC_IN9 */ - int16_t ant_sense_1; /* 6 ADC_IN10 */ - int16_t ant_sense_2; /* 7 ADC_IN11 */ - int16_t gyro_x_1; /* 8 ADC_IN12 */ - int16_t gyro_z_1; /* 9 ADC_IN13 */ - int16_t gyro_x_2; /* 10 ADC_IN14 */ - int16_t gyro_z_2; /* 11 ADC_IN15 */ + int16_t tx_temp; /* 1 ADC_IN1 */ + int16_t exp4_temp; /* 2 ADC_IN2 */ + int16_t rx_temp; /* 3 ADC_IN3 */ + int16_t tx_analog_1; /* 4 ADC_IN4 */ + int16_t sense_batt; /* 5 ADC_IN5 */ + int16_t rx_analog_1; /* 6 ADC_IN6 */ + int16_t rx_rssi; /* 7 ADC_IN8 */ + int16_t rx_cd; /* 8 ADC_IN9 */ + int16_t ant_sense_1; /* 9 ADC_IN10 */ + int16_t ant_sense_2; /* 10 ADC_IN11 */ + int16_t gyro_x_1; /* 11 ADC_IN12 */ + int16_t gyro_z_1; /* 12 ADC_IN13 */ + int16_t gyro_vref_1; /* 13 ADC_IN24 */ + int16_t gyro_x_2; /* 14 ADC_IN14 */ + int16_t gyro_z_2; /* 15 ADC_IN15 */ + int16_t gyro_vref_2; /* 16 ADC_IN25 */ }; #define AO_ADC_TX_PA_CURRENT 0 #define AO_ADC_TX_PA_CURRENT_PORT (&stm_gpioa) #define AO_ADC_TX_PA_CURRENT_PIN 0 -#define AO_ADC_TX_PA_TEMP 1 -#define AO_ADC_TX_PA_TEMP_PORT (&stm_gpioa) -#define AO_ADC_TX_PA_TEMP_PIN 1 +#define AO_ADC_TX_TEMP 1 +#define AO_ADC_TX_TEMP_PORT (&stm_gpioa) +#define AO_ADC_TX_TEMP_PIN 1 -#define AO_ADC_TX_XO_TEMP 2 -#define AO_ADC_TX_XO_TEMP_PORT (&stm_gpioa) -#define AO_ADC_TX_XO_TEMP_PIN 2 +#define AO_ADC_EXP4_TEMP 2 +#define AO_ADC_EXP4_TEMP_PORT (&stm_gpioa) +#define AO_ADC_EXP4_TEMP_PIN 2 -#define AO_ADC_RX_XO_TEMP 3 -#define AO_ADC_RX_XO_TEMP_PORT (&stm_gpioa) -#define AO_ADC_RX_XO_TEMP_PIN 3 +#define AO_ADC_RX_TEMP 3 +#define AO_ADC_RX_TEMP_PORT (&stm_gpioa) +#define AO_ADC_RX_TEMP_PIN 3 -#define AO_ADC_IHU_CURRENT 8 -#define AO_ADC_IHU_CURRENT_PORT (&stm_gpiob) -#define AO_ADC_IHU_CURRENT_PIN 0 +#define AO_ADC_TX_ANALOG_1 4 +#define AO_ADC_TX_ANALOG_1_PORT (&stm_gpioa) +#define AO_ADC_TX_ANALOG_1_PIN 4 + +#define AO_ADC_SENSE_BATT 5 +#define AO_ADC_SENSE_BATT_PORT (&stm_gpioa) +#define AO_ADC_SENSE_BATT_PIN 5 + +#define AO_ADC_RX_ANALOG_1 6 +#define AO_ADC_RX_ANALOG_1_PORT (&stm_gpioa) +#define AO_ADC_RX_ANALOG_1_PIN 6 + +#define AO_ADC_RX_RSSI 8 +#define AO_ADC_RX_RSSI_PORT (&stm_gpiob) +#define AO_ADC_RX_RSSI_PIN 0 #define AO_ADC_RX_CD 9 #define AO_ADC_RX_CD_PORT (&stm_gpiob) @@ -177,6 +193,10 @@ struct ao_adc { #define AO_ADC_GYRO_Z_1_PORT (&stm_gpioc) #define AO_ADC_GYRO_Z_1_PIN 3 +#define AO_ADC_GYRO_VREF_1 24 +#define AO_ADC_GYRO_VREF_1_PORT (&stm_gpioe) +#define AO_ADC_GYRO_VREF_1_PIN 9 + #define AO_ADC_GYRO_X_2 14 #define AO_ADC_GYRO_X_2_PORT (&stm_gpioc) #define AO_ADC_GYRO_X_2_PIN 4 @@ -185,67 +205,92 @@ struct ao_adc { #define AO_ADC_GYRO_Z_2_PORT (&stm_gpioc) #define AO_ADC_GYRO_Z_2_PIN 5 +#define AO_ADC_GYRO_VREF_2 25 +#define AO_ADC_GYRO_VREF_2_PORT (&stm_gpioe) +#define AO_ADC_GYRO_VREF_2_PIN 10 + #define AO_ADC_TEMP 16 #define AO_ADC_RCC_AHBENR ((1 << STM_RCC_AHBENR_GPIOAEN) | \ (1 << STM_RCC_AHBENR_GPIOBEN) | \ - (1 << STM_RCC_AHBENR_GPIOCEN)) + (1 << STM_RCC_AHBENR_GPIOCEN) | \ + (1 << STM_RCC_AHBENR_GPIOEEN)) -#define AO_NUM_ADC_PIN (12) +#define AO_NUM_ADC_PIN (17) #define AO_ADC_PIN0_PORT AO_ADC_TX_PA_CURRENT_PORT #define AO_ADC_PIN0_PIN AO_ADC_TX_PA_CURRENT_PIN -#define AO_ADC_PIN1_PORT AO_ADC_TX_PA_TEMP_PORT -#define AO_ADC_PIN1_PIN AO_ADC_TX_PA_TEMP_PIN -#define AO_ADC_PIN2_PORT AO_ADC_TX_XO_TEMP_PORT -#define AO_ADC_PIN2_PIN AO_ADC_TX_XO_TEMP_PIN -#define AO_ADC_PIN3_PORT AO_ADC_RX_XO_TEMP_PORT -#define AO_ADC_PIN3_PIN AO_ADC_RX_XO_TEMP_PIN -#define AO_ADC_PIN4_PORT AO_ADC_IHU_CURRENT_PORT -#define AO_ADC_PIN4_PIN AO_ADC_IHU_CURRENT_PIN -#define AO_ADC_PIN5_PORT AO_ADC_RX_CD_PORT -#define AO_ADC_PIN5_PIN AO_ADC_RX_CD_PIN -#define AO_ADC_PIN6_PORT AO_ADC_ANT_SENSE_1_PORT -#define AO_ADC_PIN6_PIN AO_ADC_ANT_SENSE_1_PIN -#define AO_ADC_PIN7_PORT AO_ADC_ANT_SENSE_2_PORT -#define AO_ADC_PIN7_PIN AO_ADC_ANT_SENSE_2_PIN -#define AO_ADC_PIN8_PORT AO_ADC_GYRO_X_1_PORT -#define AO_ADC_PIN8_PIN AO_ADC_GYRO_X_1_PIN -#define AO_ADC_PIN9_PORT AO_ADC_GYRO_Z_1_PORT -#define AO_ADC_PIN9_PIN AO_ADC_GYRO_Z_1_PIN -#define AO_ADC_PIN10_PORT AO_ADC_GYRO_X_2_PORT -#define AO_ADC_PIN10_PIN AO_ADC_GYRO_X_2_PIN -#define AO_ADC_PIN11_PORT AO_ADC_GYRO_Z_2_PORT -#define AO_ADC_PIN11_PIN AO_ADC_GYRO_Z_2_PIN +#define AO_ADC_PIN1_PORT AO_ADC_TX_TEMP_PORT +#define AO_ADC_PIN1_PIN AO_ADC_TX_TEMP_PIN +#define AO_ADC_PIN2_PORT AO_ADC_EXP4_TEMP_PORT +#define AO_ADC_PIN2_PIN AO_ADC_EXP4_TEMP_PIN +#define AO_ADC_PIN3_PORT AO_ADC_RX_TEMP_PORT +#define AO_ADC_PIN3_PIN AO_ADC_RX_TEMP_PIN +#define AO_ADC_PIN4_PORT AO_ADC_TX_ANALOG_1_PORT +#define AO_ADC_PIN4_PIN AO_ADC_TX_ANALOG_1_PIN +#define AO_ADC_PIN5_PORT AO_ADC_SENSE_BATT_PORT +#define AO_ADC_PIN5_PIN AO_ADC_SENSE_BATT_PIN +#define AO_ADC_PIN6_PORT AO_ADC_RX_ANALOG_1_PORT +#define AO_ADC_PIN6_PIN AO_ADC_RX_ANALOG_1_PIN +#define AO_ADC_PIN7_PORT AO_ADC_RX_RSSI_PORT +#define AO_ADC_PIN7_PIN AO_ADC_RX_RSSI_PIN +#define AO_ADC_PIN8_PORT AO_ADC_RX_CD_PORT +#define AO_ADC_PIN8_PIN AO_ADC_RX_CD_PIN +#define AO_ADC_PIN9_PORT AO_ADC_ANT_SENSE_1_PORT +#define AO_ADC_PIN9_PIN AO_ADC_ANT_SENSE_1_PIN +#define AO_ADC_PIN10_PORT AO_ADC_ANT_SENSE_2_PORT +#define AO_ADC_PIN10_PIN AO_ADC_ANT_SENSE_2_PIN +#define AO_ADC_PIN11_PORT AO_ADC_GYRO_X_1_PORT +#define AO_ADC_PIN11_PIN AO_ADC_GYRO_X_1_PIN +#define AO_ADC_PIN12_PORT AO_ADC_GYRO_Z_1_PORT +#define AO_ADC_PIN12_PIN AO_ADC_GYRO_Z_1_PIN +#define AO_ADC_PIN13_PORT AO_ADC_GYRO_VREF_1_PORT +#define AO_ADC_PIN13_PIN AO_ADC_GYRO_VREF_1_PIN +#define AO_ADC_PIN14_PORT AO_ADC_GYRO_X_2_PORT +#define AO_ADC_PIN14_PIN AO_ADC_GYRO_X_2_PIN +#define AO_ADC_PIN15_PORT AO_ADC_GYRO_Z_2_PORT +#define AO_ADC_PIN15_PIN AO_ADC_GYRO_Z_2_PIN +#define AO_ADC_PIN16_PORT AO_ADC_GYRO_VREF_2_PORT +#define AO_ADC_PIN16_PIN AO_ADC_GYRO_VREF_2_PIN #define AO_NUM_ADC (AO_NUM_ADC_PIN + 1) /* Add internal temp sensor */ #define AO_ADC_SQ1 AO_ADC_TX_PA_CURRENT #define AO_ADC_SQ1_NAME "tx_pa_current" -#define AO_ADC_SQ2 AO_ADC_TX_PA_TEMP -#define AO_ADC_SQ2_NAME "tx_pa_temp" -#define AO_ADC_SQ3 AO_ADC_TX_XO_TEMP -#define AO_ADC_SQ3_NAME "tx_xo_temp" -#define AO_ADC_SQ4 AO_ADC_RX_XO_TEMP -#define AO_ADC_SQ4_NAME "rx_xo_temp" -#define AO_ADC_SQ5 AO_ADC_IHU_CURRENT -#define AO_ADC_SQ5_NAME "ihu_current" -#define AO_ADC_SQ6 AO_ADC_RX_CD -#define AO_ADC_SQ6_NAME "rx_cd" -#define AO_ADC_SQ7 AO_ADC_ANT_SENSE_1 -#define AO_ADC_SQ7_NAME "ant_sense_1" -#define AO_ADC_SQ8 AO_ADC_ANT_SENSE_2 -#define AO_ADC_SQ8_NAME "ant_sense_2" -#define AO_ADC_SQ9 AO_ADC_GYRO_X_1 -#define AO_ADC_SQ9_NAME "gyro_x_1" -#define AO_ADC_SQ10 AO_ADC_GYRO_Z_1 -#define AO_ADC_SQ10_NAME "gyro_z_1" -#define AO_ADC_SQ11 AO_ADC_GYRO_X_2 -#define AO_ADC_SQ11_NAME "gyro_x_2" -#define AO_ADC_SQ12 AO_ADC_GYRO_Z_2 -#define AO_ADC_SQ12_NAME "gyro_z_2" -#define AO_ADC_SQ13 AO_ADC_TEMP -#define AO_ADC_SQ13_NAME "temp" +#define AO_ADC_SQ2 AO_ADC_TX_TEMP +#define AO_ADC_SQ2_NAME "tx_temp" +#define AO_ADC_SQ3 AO_ADC_EXP4_TEMP +#define AO_ADC_SQ3_NAME "expr_temp" +#define AO_ADC_SQ4 AO_ADC_RX_TEMP +#define AO_ADC_SQ4_NAME "rx_temp" +#define AO_ADC_SQ5 AO_ADC_TX_ANALOG_1 +#define AO_ADC_SQ5_NAME "tx_analog_1" +#define AO_ADC_SQ6 AO_ADC_SENSE_BATT +#define AO_ADC_SQ6_NAME "sense_batt" +#define AO_ADC_SQ7 AO_ADC_RX_ANALOG_1 +#define AO_ADC_SQ7_NAME "rx_analog_1" +#define AO_ADC_SQ8 AO_ADC_RX_RSSI +#define AO_ADC_SQ8_NAME "rx_rssi" +#define AO_ADC_SQ9 AO_ADC_RX_CD +#define AO_ADC_SQ9_NAME "rx_cd" +#define AO_ADC_SQ10 AO_ADC_ANT_SENSE_1 +#define AO_ADC_SQ10_NAME "ant_sense_1" +#define AO_ADC_SQ11 AO_ADC_ANT_SENSE_2 +#define AO_ADC_SQ11_NAME "ant_sense_2" +#define AO_ADC_SQ12 AO_ADC_GYRO_X_1 +#define AO_ADC_SQ12_NAME "gyro_x_1" +#define AO_ADC_SQ13 AO_ADC_GYRO_Z_1 +#define AO_ADC_SQ13_NAME "gyro_z_1" +#define AO_ADC_SQ14 AO_ADC_GYRO_VREF_1 +#define AO_ADC_SQ14_NAME "gyro_vref_1" +#define AO_ADC_SQ15 AO_ADC_GYRO_X_2 +#define AO_ADC_SQ15_NAME "gyro_x_2" +#define AO_ADC_SQ16 AO_ADC_GYRO_Z_2 +#define AO_ADC_SQ16_NAME "gyro_z_2" +#define AO_ADC_SQ17 AO_ADC_GYRO_VREF_2 +#define AO_ADC_SQ17_NAME "gyro_vref_2" +#define AO_ADC_SQ18 AO_ADC_TEMP +#define AO_ADC_SQ18_NAME "temp" /* Watchdog timer */ -- cgit v1.2.3 From 6247e0c81084b59365ceca0ced33d2db92a72444 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 1 Feb 2014 00:06:30 -0800 Subject: altos/fox: Enable system timer in flash loader and prod watchdog with it This makes it possible to reflash the board without needing to disable the watchdog. Signed-off-by: Keith Packard --- src/fox1ihu/flash-loader/ao_pins.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h index 3a942c9c..90917a38 100644 --- a/src/fox1ihu/flash-loader/ao_pins.h +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -21,6 +21,20 @@ /* External crystal at 8MHz */ #define AO_HSE 8000000 +#define AO_WATCHDOG_PORT (&stm_gpiod) +#define AO_WATCHDOG_BIT 3 + +#define AO_FLASH_LOADER_INIT do { \ + ao_enable_output(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG, 0); \ + } while (0) + +#define AO_TIMER_HOOK do { \ + static uint8_t watchdog; \ + ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_PIN, watchdog); \ + watchdog ^= 1; \ + } while (0) + +#define HAS_TICK 1 #include /* Detatched signal, PD6 */ -- cgit v1.2.3 From 9003147a89074f8d991d1707f307fd4e41435aa3 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Mon, 5 May 2014 17:32:22 -0600 Subject: move signal that forces flash-loader on to PB8, active high --- src/fox1ihu/flash-loader/ao_pins.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h index 90917a38..a7afaabb 100644 --- a/src/fox1ihu/flash-loader/ao_pins.h +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -37,12 +37,12 @@ #define HAS_TICK 1 #include -/* Detatched signal, PD6 */ +/* Attached signal, PB8 */ #define AO_BOOT_PIN 1 -#define AO_BOOT_APPLICATION_GPIO stm_gpiod -#define AO_BOOT_APPLICATION_PIN 6 -#define AO_BOOT_APPLICATION_VALUE 0 +#define AO_BOOT_APPLICATION_GPIO stm_gpiob +#define AO_BOOT_APPLICATION_PIN 8 +#define AO_BOOT_APPLICATION_VALUE 1 #define AO_BOOT_APPLICATION_MODE 0 #endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From c408c773793b5a5685d95c11ba6f710200505c25 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Tue, 6 May 2014 00:38:33 -0600 Subject: had the sense backwards .. presence of 'attached' should put us in the loader --- src/fox1ihu/flash-loader/ao_pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h index a7afaabb..31201eb0 100644 --- a/src/fox1ihu/flash-loader/ao_pins.h +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -42,7 +42,7 @@ #define AO_BOOT_PIN 1 #define AO_BOOT_APPLICATION_GPIO stm_gpiob #define AO_BOOT_APPLICATION_PIN 8 -#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_VALUE 0 #define AO_BOOT_APPLICATION_MODE 0 #endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From 0dfaecc25a12da57248541a66dd5118161616cce Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 21 Apr 2018 16:16:18 -0700 Subject: altos/fox1ihu: Pull down radio control pin in flash loader Ensures that the radio is powered down while in the flash loader. Signed-off-by: Keith Packard --- src/fox1ihu/flash-loader/ao_pins.h | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/fox1ihu') diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h index 31201eb0..19f29b08 100644 --- a/src/fox1ihu/flash-loader/ao_pins.h +++ b/src/fox1ihu/flash-loader/ao_pins.h @@ -22,16 +22,27 @@ #define AO_HSE 8000000 #define AO_WATCHDOG_PORT (&stm_gpiod) +#define AO_WATCHDOG_PORT_BIT (1 << STM_RCC_AHBENR_GPIODEN) #define AO_WATCHDOG_BIT 3 - -#define AO_FLASH_LOADER_INIT do { \ - ao_enable_output(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG, 0); \ +#define AO_WATCHDOG_VALUE 0 + +#define AO_RADIO_CONTROL_PORT (&stm_gpioe) +#define AO_RADIO_CONTROL_PORT_BIT (1 << STM_RCC_AHBENR_GPIOEEN) +#define AO_RADIO_CONTROL_BIT 12 +#define AO_RADIO_CONTROL_VALUE 1 + +#define AO_FLASH_LOADER_INIT do { \ + stm_rcc.ahbenr |= AO_WATCHDOG_PORT_BIT | AO_RADIO_CONTROL_PORT_BIT; \ + \ + stm_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_VALUE); \ + stm_moder_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, STM_MODER_OUTPUT); \ + \ + stm_gpio_set(AO_RADIO_CONTROL_PORT, AO_RADIO_CONTROL_BIT, AO_RADIO_CONTROL_VALUE); \ + stm_moder_set(AO_RADIO_CONTROL_PORT, AO_RADIO_CONTROL_BIT, STM_MODER_OUTPUT); \ } while (0) - + #define AO_TIMER_HOOK do { \ - static uint8_t watchdog; \ - ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_PIN, watchdog); \ - watchdog ^= 1; \ + AO_WATCHDOG_PORT->odr ^= (1 << AO_WATCHDOG_BIT); \ } while (0) #define HAS_TICK 1 -- cgit v1.2.3