[low-power-solar] hw-config changes, add header guards for no timepulse or and no i2c operation

main-solar-only
Richard Meadows 2016-03-26 21:50:01 +00:00
rodzic 3f17b1c505
commit d008103d76
4 zmienionych plików z 73 dodań i 60 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
/* /*
* Hardware definitions and configuations * Hardware definitions and configuations
* Copyright (C) 2014 Richard Meadows <richardeoin> * Copyright (C) 2016 Richard Meadows <richardeoin>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -75,27 +75,10 @@
#define GPS_SERCOM_MUX USART_RX_3_TX_2_XCK_3 #define GPS_SERCOM_MUX USART_RX_3_TX_2_XCK_3
#define GPS_GCLK GCLK_GENERATOR_0 #define GPS_GCLK GCLK_GENERATOR_0
#ifdef V0986
#define GPS_TYPE_OSP #define GPS_TYPE_OSP
#define GPS_BAUD_RATE 115200 #define GPS_BAUD_RATE 115200
#define GPS_TIMEPULSE_PIN PIN_PA04
#define GPS_TIMEPULSE_PINMUX PINMUX_PA04A_EIC_EXTINT4
#define GPS_TIMEPULSE_FREQ 1
#define GPS_TIMEPULSE_EXTINT 4
#define GPS_SE_ON_OFF_PIN PIN_PA05 #define GPS_SE_ON_OFF_PIN PIN_PA05
#define GPS_RESET_PIN PIN_PA01 /* Hacky resistor switch on the board */ #define GPS_RESET_PIN PIN_PA01
#else
#define GPS_TYPE_UBX
#define GPS_BAUD_RATE 9600
#define GPS_PLATFORM_MODEL UBX_PLATFORM_MODEL_AIRBORNE_1G
#define GPS_TIMEPULSE_PIN PIN_PA05
#define GPS_TIMEPULSE_PINMUX PINMUX_PA05A_EIC_EXTINT5
#define GPS_TIMEPULSE_FREQ 1
#define GPS_TIMEPULSE_EXTINT 5
#define GPS_RESET_PIN PIN_PA15
#endif
#define GPS_FLIGHT_STATE_THREASHOLD_M 8000 /* 8km altitude */ #define GPS_FLIGHT_STATE_THREASHOLD_M 8000 /* 8km altitude */
@ -119,17 +102,8 @@
#define FLASH_CSN_PIN PIN_PA10 #define FLASH_CSN_PIN PIN_PA10
/** /**
* I2C Bus * I2C Bus - NOT USED
*/ */
#define I2C_SERCOM (SercomI2cm*)SERCOM1
#ifdef V0987
#define I2C_SERCOM_SDA_PIN PIN_PA27
#else
#define I2C_SERCOM_SDA_PIN PIN_PA00
#define I2C_SERCOM_SDA_PINMUX PINMUX_PA00D_SERCOM1_PAD0
#endif
#define I2C_SERCOM_SCL_PIN PIN_PA01
#define I2C_SERCOM_SCL_PINMUX PINMUX_PA01D_SERCOM1_PAD1
/** /**
* Barometer * Barometer
@ -143,43 +117,46 @@
* Battery ADC * Battery ADC
*/ */
#define BATTERY_ADC 1 #define BATTERY_ADC 1
#define BATTERY_ADC_PIN PIN_PA02 #define BATTERY_ADC_PIN PIN_PA04
#define BATTERY_ADC_PINMUX PINMUX_PA02B_ADC_AIN0 #define BATTERY_ADC_PINMUX PINMUX_PA04B_ADC_AIN4
#define BATTERY_ADC_CHANNEL ADC_POSITIVE_INPUT_PIN0 #define BATTERY_ADC_CHANNEL ADC_POSITIVE_INPUT_PIN4
#define BATTERY_ADC_CHANNEL_DIV 1 /*0.3125*/ #define BATTERY_ADC_CHANNEL_DIV 0.23256 /* 33k,10k divider */
#define BATTERY_ADC_REFERENCE ADC_REFERENCE_INT1V #define BATTERY_ADC_REFERENCE ADC_REFERENCE_INT1V
/** /**
* External Thermistor ADC * External Thermistor ADC
*/ */
#define THERMISTOR_ADC 1 #define THERMISTOR_ADC 1
#define THERMISTOR_ADC_PIN PIN_PA03 #define THERMISTOR_ADC_PIN PIN_PA02
#define THERMISTOR_ADC_PINMUX PINMUX_PA03 #define THERMISTOR_ADC_PINMUX PINMUX_PA02B_ADC_AIN0
#define THERMISTOR_ADC_CHANNEL ADC_POSITIVE_INPUT_PIN1 #define THERMISTOR_ADC_CHANNEL ADC_POSITIVE_INPUT_PIN0
#define THERMISTOR_ADC_CHANNEL_DIV 1.48 #define THERMISTOR_ADC_CHANNEL_DIV 1.48
#define THERMISTOR_ADC_REFERENCE ADC_REFERENCE_INTVCC0 /* internal 1/1.48 VCC reference */ #define THERMISTOR_ADC_REFERENCE ADC_REFERENCE_INTVCC0 /* internal 1/1.48 VCC reference */
/** /**
* Solar ADC * Solar ADC
*/ */
#ifdef V0986
#define SOLAR_ADC 0
#define SOLAR_ADC_PIN PIN_PA02
#else
#define SOLAR_ADC 1 #define SOLAR_ADC 1
#define SOLAR_ADC_PIN PIN_PA04 #define SOLAR_ADC_PIN PIN_PA03
#endif #define SOLAR_ADC_PINMUX PINMUX_PA03B_ADC_AIN1
#define SOLAR_ADC_PINMUX PINMUX_PA04B_ADC_AIN4 #define SOLAR_ADC_CHANNEL ADC_POSITIVE_INPUT_PIN1
#define SOLAR_ADC_CHANNEL ADC_POSITIVE_INPUT_PIN4 #define SOLAR_ADC_CHANNEL_DIV 0.23256 /* 33k,10k divider */
#define SOLAR_ADC_CHANNEL_DIV 1
#define SOLAR_ADC_REFERENCE ADC_REFERENCE_INT1V #define SOLAR_ADC_REFERENCE ADC_REFERENCE_INT1V
/**
* Battery
*/
/* We enable charging when bus > battery */
#define CHG_ENABLE_PIN PIN_PA27
#define CHG_ENABLE_HYSTERESIS (1*15) /* up to 1 hour at once-per-four-minutes */
/** /**
* Cold out * Cold out
*/ */
#define COLD_OUT_VOLTAGE (2.6) /* if both bus and battery are below this then cold */
#define COLD_OUT_TEMPERATURE (-58.0) #define COLD_OUT_TEMPERATURE (-58.0)
#define COLD_OUT_SECONDS (15*60) /* 15 minutes */ #define COLD_OUT_SECONDS (15*60) /* 15 minutes */
#define COLD_OUT_COUNT_MAX (16*4) /* up to 16 hours */ #define COLD_OUT_COUNT_MAX (16*4) /* up to 16 hours*/
/** /**
* Radio * Radio
@ -199,10 +176,7 @@
#define SI4xxx_GPIO1_PIN PIN_PA25 #define SI4xxx_GPIO1_PIN PIN_PA25
#define SI4xxx_GPIO1_PINMUX PINMUX_PA25F_TC5_WO1 #define SI4xxx_GPIO1_PINMUX PINMUX_PA25F_TC5_WO1
#define SI4xxx_TCXO_FREQUENCY 16369000 #define SI4xxx_TCXO_FREQUENCY 16369000
#ifdef V0986
#define SI4xxx_TCXO_REG_EN_PIN PIN_PA16 #define SI4xxx_TCXO_REG_EN_PIN PIN_PA16
#endif
/** /**
* RF Power @ 1.8V * RF Power @ 1.8V
@ -224,13 +198,7 @@
/** /**
* LF Clock * LF Clock
*/ */
#ifdef V0987
#define USE_LFTIMER 1 #define USE_LFTIMER 1
#else
#define USE_LFTIMER 0
#define LFTIMER_GCLKIO_0_PIN PIN_PA27
#define LFTIMER_GCLKIO_0_PINMUX PINMUX_PA27H_GCLK_IO0
#endif
/** /**
* HF Clock * HF Clock

Wyświetl plik

@ -1103,11 +1103,13 @@ void gps_reset(void)
} }
void gps_init_timepulse_pin(void) { void gps_init_timepulse_pin(void) {
#ifdef GPS_TIMEPULSE_PIN
/* Timepulse_Pin */ /* Timepulse_Pin */
port_pin_set_config(GPS_TIMEPULSE_PIN, port_pin_set_config(GPS_TIMEPULSE_PIN,
PORT_PIN_DIR_INPUT, /* Direction */ PORT_PIN_DIR_INPUT, /* Direction */
PORT_PIN_PULL_NONE, /* Pull */ PORT_PIN_PULL_NONE, /* Pull */
false); /* Powersave */ false); /* Powersave */
#endif
} }
/** /**

Wyświetl plik

@ -27,6 +27,10 @@
#include "system/port.h" #include "system/port.h"
#include "i2c_bb.h" #include "i2c_bb.h"
#ifdef I2C_SERCOM_SDA_PIN
#ifdef I2C_SERCOM_SCL_PIN
#define SDA I2C_SERCOM_SDA_PIN #define SDA I2C_SERCOM_SDA_PIN
#define SCL I2C_SERCOM_SCL_PIN #define SCL I2C_SERCOM_SCL_PIN
@ -234,3 +238,31 @@ void i2c_bb_init(void)
i2c_bb_stop(); /* stop. release both */ i2c_bb_stop(); /* stop. release both */
} }
#endif
#else
/**
* Dummy functions for if i2c pins are not defined.
*/
i2c_bb_result_t i2c_bb_read(uint8_t address, uint8_t* data, uint8_t data_length)
{
(void)address;
(void)data;
(void)data_length;
return I2C_BB_SUCCESS;
}
/**
* Dummy functions for if i2c pins are not defined.
*/
i2c_bb_result_t i2c_bb_write(uint8_t address, uint8_t* data, uint8_t data_length)
{
(void)address;
(void)data;
(void)data_length;
return I2C_BB_SUCCESS;
}
#endif

Wyświetl plik

@ -331,6 +331,7 @@ void gclk2_init(void)
*/ */
void timepulse_extint_event_source(void) void timepulse_extint_event_source(void)
{ {
#ifdef GPS_TIMEPULSE_EXTINT
/* Enable extint events for timepulse */ /* Enable extint events for timepulse */
struct extint_events events; struct extint_events events;
memset(&events, 0, sizeof(struct extint_events)); memset(&events, 0, sizeof(struct extint_events));
@ -355,9 +356,13 @@ void timepulse_extint_event_source(void)
0); 0);
extint_enable(); extint_enable();
#endif
} }
void timepulse_extint_event_source_disable(void) { void timepulse_extint_event_source_disable(void)
{
#ifdef GPS_TIMEPULSE_EXTINT
extint_disable(); extint_disable();
#endif
} }
/** /**
@ -386,7 +391,8 @@ void lftimer_event_source_disable(void) {
* A callback from the timer interrupt is available. Obviously don't dwell here too long. * A callback from the timer interrupt is available. Obviously don't dwell here too long.
*/ */
void measure_xosc(enum xosc_measurement_t measurement_t, void measure_xosc(enum xosc_measurement_t measurement_t,
measurement_result_t callback, uint8_t oneshot) { measurement_result_t callback, uint8_t oneshot)
{
measure_state = MEASURE_WAIT_FOR_FIRST_EVENT; measure_state = MEASURE_WAIT_FOR_FIRST_EVENT;
_measurement_t = measurement_t; _measurement_t = measurement_t;
@ -441,8 +447,8 @@ void measure_xosc(enum xosc_measurement_t measurement_t,
tc_enable(TC2); tc_enable(TC2);
} }
void measure_xosc_disable(enum xosc_measurement_t measurement_t) { void measure_xosc_disable(enum xosc_measurement_t measurement_t)
{
tc_disable(TC2); tc_disable(TC2);
switch (measurement_t) { switch (measurement_t) {
@ -460,7 +466,8 @@ void measure_xosc_disable(enum xosc_measurement_t measurement_t) {
/** /**
* Triggered on timer 2 capture * Triggered on timer 2 capture
*/ */
void TC2_Handler(void) { void TC2_Handler(void)
{
uint32_t capture_value; uint32_t capture_value;
uint32_t source_freq; uint32_t source_freq;
@ -478,7 +485,11 @@ void TC2_Handler(void) {
/* Calcuate the frequency of GLCK1 relative to this source */ /* Calcuate the frequency of GLCK1 relative to this source */
switch (_measurement_t) { switch (_measurement_t) {
case XOSC_MEASURE_TIMEPULSE: case XOSC_MEASURE_TIMEPULSE:
#ifdef GPS_TIMEPULSE_FREQ
source_freq = capture_value * XOSC_GCLK_DIVIDE * GPS_TIMEPULSE_FREQ; source_freq = capture_value * XOSC_GCLK_DIVIDE * GPS_TIMEPULSE_FREQ;
#else
source_freq = capture_value * XOSC_GCLK_DIVIDE;
#endif
break; break;
case XOSC_MEASURE_LFTIMER: case XOSC_MEASURE_LFTIMER:
source_freq = capture_value * XOSC_GCLK_DIVIDE; source_freq = capture_value * XOSC_GCLK_DIVIDE;