diff options
| -rw-r--r-- | src/telemini-v3.0/ao_pins.h | 202 | ||||
| -rw-r--r-- | src/telemini-v3.0/ao_telemini.c | 52 | ||||
| -rw-r--r-- | src/telemini-v3.0/ao_telemini_calibrate.c | 71 | 
3 files changed, 325 insertions, 0 deletions
| diff --git a/src/telemini-v3.0/ao_pins.h b/src/telemini-v3.0/ao_pins.h new file mode 100644 index 00000000..e060b931 --- /dev/null +++ b/src/telemini-v3.0/ao_pins.h @@ -0,0 +1,202 @@ +/* + * 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. + */ + +#define HAS_BEEP		1 +#define HAS_BATTERY_REPORT	1 + +#define AO_STACK_SIZE	384 + +#define IS_FLASH_LOADER	0 + +/* 40MHz clock based on 16MHz reference */ +//#define AO_HSI48	1 +#define AO_HSE			16000000 +#define AO_RCC_CFGR_PLLMUL	STM_RCC_CFGR_PLLMUL_5 +#define AO_RCC_CFGR2_PLLDIV	STM_RCC_CFGR2_PREDIV_2 +#define AO_PLLMUL		5 +#define AO_PLLDIV		2 + +/* HCLK = 40MHz */ +#define AO_AHB_PRESCALER	1 +#define AO_RCC_CFGR_HPRE_DIV	STM_RCC_CFGR_HPRE_DIV_1 + +/* APB = 40MHz */ +#define AO_APB_PRESCALER	1 +#define AO_RCC_CFGR_PPRE_DIV	STM_RCC_CFGR_PPRE_DIV_1 + +/* Send PLL clock to cc1200 */ +#define AO_MCO_PORT		(&stm_gpioa) +#define AO_MCO_PIN		9 +#define AO_MCO_AF		STM_AFR_AF5 + +#define HAS_USB			0 +#define AO_USB_DIRECTIO		0 +#define AO_PA11_PA12_RMP	0 + +#define PACKET_HAS_SLAVE	1 + +#define AO_LOG_FORMAT		AO_LOG_FORMAT_EASYMINI + +#define HAS_BOOT_RADIO		0 + +#define HAS_ACCEL		0 +#define HAS_GPS			0 +#define HAS_RADIO		1 +#define HAS_RADIO_RATE		1 +#define HAS_FLIGHT		1 +#define HAS_EEPROM		1 +#define HAS_TELEMETRY		1 +#define HAS_APRS		0 +#define HAS_LOG			1 +#define USE_INTERNAL_FLASH	0 +#define HAS_IGNITE		1 +#define HAS_IGNITE_REPORT	1 + +/* Beeper is on Tim1 CH3 */ +#define BEEPER_CHANNEL		3 + +/* LED */ +#define LED_PORT_ENABLE		STM_RCC_AHBENR_IOPAEN +#define LED_PORT		(&stm_gpioa) +#define LED_PIN_GREEN		15 +#define AO_LED_GREEN		(1 << 15) +#define AO_LED_PANIC		AO_LED_GREEN + +#define LEDS_AVAILABLE		AO_LED_GREEN + +/* USART */ + +#define HAS_SERIAL		0 +#define USE_SERIAL_0_STDIN	1 +#define SERIAL_0_18_19		1 +#define SERIAL_0_14_15		0 +#define SERIAL_0_17_18		0 +#define SERIAL_0_26_27		0 + +/* SPI */ + +#define HAS_SPI_0		1 +#define SPI_SCK0_P0_6		1 +#define HAS_SPI_1		1 +#define SPI_SCK1_P1_15		1 +#define SPI_MISO1_P0_22		1 +#define SPI_MOSI1_P0_21		1 + +/* M25 */ + +#define M25_MAX_CHIPS		1 +#define AO_M25_SPI_CS_PORT	(&stm_gpioa) +#define AO_M25_SPI_CS_MASK	(1 << 3) +#define AO_M25_SPI_BUS		AO_SPI_1_PA5_PA6_PA7 + +/* MS5607 */ + +#define HAS_MS5607		1 +#define HAS_MS5611		0 +#define AO_MS5607_PRIVATE_PINS	0 +#define AO_MS5607_CS_PORT	(&stm_gpioa) +#define AO_MS5607_CS_PIN	4 +#define AO_MS5607_CS_MASK	(1 << AO_MS5607_CS_PIN) +#define AO_MS5607_MISO_PORT	(&stm_gpiob) +#define AO_MS5607_MISO_PIN	4 +#define AO_MS5607_MISO_MASK	(1 << AO_MS5607_MISO_PIN) +#define AO_MS5607_SPI_INDEX	AO_SPI_1_PB3_PB4_PB5 + +/* CC1200 */ + +// #define AO_RADIO_CAL_DEFAULT 	5695733 +#define AO_RADIO_CAL_DEFAULT 	5695947 + +#define AO_FEC_DEBUG		0 +#define AO_CC1200_SPI_CS_PORT	(&stm_gpiob) +#define AO_CC1200_SPI_CS_PIN	0 +#define AO_CC1200_SPI_BUS	AO_SPI_1_PA5_PA6_PA7 +#define AO_CC1200_SPI		stm_spi1 + +#define AO_CC1200_INT_PORT		(&stm_gpiob) +#define AO_CC1200_INT_PIN		1 + +#define AO_CC1200_INT_GPIO	2 +#define AO_CC1200_INT_GPIO_IOCFG	CC1200_IOCFG2 + + +#define AO_DATA_RING		16 + +/* + * ADC + */ + +#define HAS_ADC			1 + +#define AO_ADC_PIN0_PORT	(&stm_gpioa) +#define AO_ADC_PIN0_PIN		0 +#define AO_ADC_PIN0_CH		0 +#define AO_ADC_PIN1_PORT	(&stm_gpioa) +#define AO_ADC_PIN1_PIN		1 +#define AO_ADC_PIN1_CH		1 +#define AO_ADC_PIN2_PORT	(&stm_gpioa) +#define AO_ADC_PIN2_PIN		2 +#define AO_ADC_PIN2_CH		2 + +#define AO_ADC_RCC_AHBENR	((1 << STM_RCC_AHBENR_IOPAEN)) + +#define AO_NUM_ADC		3 + +struct ao_adc { +	int16_t		sense_a; +	int16_t		sense_m; +	int16_t		v_batt; +}; + +/* + * Igniter + */ + +#define AO_IGNITER_CLOSED	400 +#define AO_IGNITER_OPEN		60 + +#define AO_IGNITER_DROGUE_PORT	(&stm_gpiob) +#define AO_IGNITER_DROGUE_PIN	7 +#define AO_IGNITER_SET_DROGUE(v)	ao_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, AO_IGNITER_DROGUE, v) + +#define AO_IGNITER_MAIN_PORT	(&stm_gpiob) +#define AO_IGNITER_MAIN_PIN	6 +#define AO_IGNITER_SET_MAIN(v)		ao_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, AO_IGNITER_MAIN, v) + +#define AO_SENSE_DROGUE(p)	((p)->adc.sense_a) +#define AO_SENSE_MAIN(p)	((p)->adc.sense_m) + +#define AO_ADC_DUMP(p) \ +	printf("tick: %5u apogee: %5d main: %5d batt: %5d\n", \ +	       (p)->tick, (p)->adc.sense_a, (p)->adc.sense_m, (p)->adc.v_batt) + +/* + * Voltage divider on ADC battery sampler + */ +#define AO_BATTERY_DIV_PLUS	100	/* 100k */ +#define AO_BATTERY_DIV_MINUS	27	/* 27k */ + +/* + * Voltage divider on ADC igniter samplers + */ +#define AO_IGNITE_DIV_PLUS	100	/* 100k */ +#define AO_IGNITE_DIV_MINUS	27	/* 27k */ + +/* + * ADC reference in decivolts + */ +#define AO_ADC_REFERENCE_DV	33 diff --git a/src/telemini-v3.0/ao_telemini.c b/src/telemini-v3.0/ao_telemini.c new file mode 100644 index 00000000..a0c0aa7c --- /dev/null +++ b/src/telemini-v3.0/ao_telemini.c @@ -0,0 +1,52 @@ +/* + * Copyright © 2011 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> + +void +main(void) +{ +	ao_clock_init(); +	ao_task_init(); +	ao_led_init(LEDS_AVAILABLE); +	ao_led_on(AO_LED_GREEN); +	ao_timer_init(); + +	ao_dma_init(); +	ao_spi_init(); +	ao_exti_init(); + +	ao_adc_init(); + +	ao_beep_init(); +	ao_cmd_init(); + +	ao_ms5607_init(); + +	ao_storage_init(); +	ao_flight_init(); +	ao_log_init(); +	ao_report_init(); +	ao_telemetry_init(); +	ao_radio_init(); +	ao_packet_slave_init(TRUE); +	ao_igniter_init(); +	ao_config_init(); + +	ao_start_scheduler(); +} diff --git a/src/telemini-v3.0/ao_telemini_calibrate.c b/src/telemini-v3.0/ao_telemini_calibrate.c new file mode 100644 index 00000000..7a9d7986 --- /dev/null +++ b/src/telemini-v3.0/ao_telemini_calibrate.c @@ -0,0 +1,71 @@ +/* + * Copyright © 2011 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> + +static void +ao_cal(void) +{ +	ao_config_get(); +	ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(500)); +	for (;;) { +		ao_led_on(AO_LED_GREEN); +		ao_radio_test_on(); +		ao_delay(AO_SEC_TO_TICKS(30)); +		ao_led_off(AO_LED_GREEN); +		ao_radio_test_off(); +		ao_delay(AO_SEC_TO_TICKS(5)); +	} +} + +static struct ao_task ao_cal_task; + +void +main(void) +{ +	ao_clock_init(); +	ao_task_init(); +	ao_led_init(LEDS_AVAILABLE); +	ao_led_on(AO_LED_GREEN); +	ao_timer_init(); + +	ao_dma_init(); +	ao_spi_init(); +	ao_exti_init(); + +//	ao_adc_init(); +	ao_beep_init(); +//	ao_cmd_init(); +//	ao_ms5607_init(); + +	ao_storage_init(); +//	ao_flight_init(); +//	ao_log_init(); +//	ao_report_init(); +//	ao_telemetry_init(); + +	ao_radio_init(); +//	ao_packet_slave_init(TRUE); +//	ao_igniter_init(); + +	ao_config_init(); + +	ao_add_task(&ao_cal_task, ao_cal, "radio_cal"); + +	ao_start_scheduler(); +} | 
