[Refactor] Completed replacement of Si4060 with si_trx

rocketry
Richard Eoin Meadows 2014-11-18 15:47:17 +00:00
rodzic 92e7f3412d
commit 7b509fcaca
4 zmienionych plików z 55 dodań i 45 usunięć

Wyświetl plik

@ -25,6 +25,8 @@
#ifndef SI_TRX_H
#define SI_TRX_H
float si_trx_get_temperature(void);
void si_trx_on(void);
void si_trx_off(void);

Wyświetl plik

@ -149,6 +149,24 @@ enum {
SI_STATE_CHANGE_RX = (8 << 8) | SI_CMD_CHANGE_STATE,
};
/**
* Si Get ADC reading
*/
enum {
SI_GET_ADC_READING_TEMPERATURE = (1 << 4),
SI_GET_ADC_READING_BATTERY = (1 << 3),
SI_GET_ADC_READING_GPIO = (1 << 2),
SI_GET_ADC_READING_GPIO_PIN_GPIO3 = 3,
SI_GET_ADC_READING_GPIO_PIN_GPIO2 = 2,
SI_GET_ADC_READING_GPIO_PIN_GPIO1 = 1,
SI_GET_ADC_READING_GPIO_PIN_GPIO0 = 0,
SI_GET_ADC_READING_RANGE_0V8 = 0,
SI_GET_ADC_READING_RANGE_1V6 = 4,
SI_GET_ADC_READING_RANGE_3V2 = 5,
SI_GET_ADC_READING_RANGE_2V4 = 8,
SI_GET_ADC_READING_RANGE_3V6 = 9
};
/**
* =============================================================================
* PROPERTY DEFINITIONS

Wyświetl plik

@ -47,49 +47,6 @@
#define CALLSIGN "UBSEDSx"
void si4060_hw_init(void)
{
/* Configure the SDN pin */
port_pin_set_config(SI406X_SDN_PIN,
PORT_PIN_DIR_OUTPUT, /* Direction */
PORT_PIN_PULL_NONE, /* Pull */
false); /* Powersave */
/* Put the SI406x in shutdown */
//_si406x_sdn_enable();
si4060_shutdown();
/* Configure the SDN pin */
port_pin_set_config(SI406X_SEL_PIN,
PORT_PIN_DIR_OUTPUT, /* Direction */
PORT_PIN_PULL_NONE, /* Pull */
false); /* Powersave */
/* Put the SEL pin in reset */
_si406x_cs_disable();
/* Configure the serial port */
spi_bitbang_init(SI406X_SERCOM_MOSI_PIN,
SI406X_SERCOM_MISO_PIN,
SI406X_SERCOM_SCK_PIN);
}
void si4060_gpio_init()
{
/* Configure the GPIO and IRQ pins */
port_pin_set_config(SI406X_GPIO0_PIN,
PORT_PIN_DIR_OUTPUT, /* Direction */
PORT_PIN_PULL_NONE, /* Pull */
false); /* Powersave */
port_pin_set_output_level(SI406X_GPIO0_PIN, 0);
/* Configure the GPIO and IRQ pins */
port_pin_set_config(SI406X_GPIO1_PIN,
PORT_PIN_DIR_OUTPUT, /* Direction */
PORT_PIN_PULL_NONE, /* Pull */
false); /* Powersave */
port_pin_set_output_level(SI406X_GPIO1_PIN, 0);
}
/**
* Initialises the status LED
@ -233,7 +190,7 @@ void output_telemetry_string(void)
/* Analogue */
float battery = get_battery();
float temperature = si4060_get_temperature();
float temperature = si_trx_get_temperature();
/* Sleep Wait */
while (rtty_get_index() < (len - 4)) {

Wyświetl plik

@ -162,6 +162,40 @@ static void si_trx_set_gpio_configuration(si_gpio_t gpio0, si_gpio_t gpio1,
_si_trx_transfer(8, 0, buffer);
}
/**
* Gets readings from the auxillary ADC
*/
static void si_trx_get_adc_reading(uint8_t enable, uint8_t configuration,
uint16_t* gpio_value,
uint16_t* battery_value,
uint16_t* temperature_value)
{
uint8_t buffer[6];
buffer[0] = SI_CMD_GET_ADC_READING;
buffer[1] = enable;
buffer[2] = configuration;
_si_trx_transfer(3, 6, buffer);
*gpio_value = ((buffer[0] & 0x7) << 8) | buffer[1];
*battery_value = ((buffer[2] & 0x7) << 8) | buffer[3];
*temperature_value = ((buffer[4] & 0x7) << 8) | buffer[5];
}
/**
* Returns the measured internal die temperature of the radio
*/
float si_trx_get_temperature(void)
{
uint16_t raw_gpio, raw_battery, raw_temperature;
/* Get the reading from the adc */
si_trx_get_adc_reading(SI_GET_ADC_READING_TEMPERATURE, 0,
&raw_gpio, &raw_battery, &raw_temperature);
return (((float)raw_temperature * 568.0) / 2560.0) - 297.0;
}
/**
* Sets the internal frac-n pll synthesiser divisiors
*/
@ -304,7 +338,6 @@ void si_trx_reset(void)
/* Disable all interrupts */
_si_trx_set_property_8(SI_PROPERTY_GROUP_INT_CTL, SI_INT_CTL_ENABLE, 0);
// TODO Lower drive dtrength
/* Configure GPIOs */
si_trx_set_gpio_configuration(SI_GPIO_PIN_CFG_GPIO_MODE_INPUT,
SI_GPIO_PIN_CFG_GPIO_MODE_INPUT | SI_GPIO_PIN_CFG_PULL_ENABLE,