Separate frequency for APRS, APRS values set through setter function

aprs_dev
Richard Meadows 2015-04-14 16:08:33 +01:00
rodzic 920a6cc077
commit 4d67632ae2
6 zmienionych plików z 41 dodań i 23 usunięć

Wyświetl plik

@ -42,8 +42,9 @@
*/
#define APRS_SYMBOL "/O" /* Balloon */
void aprs_init(void);
void aprs_start(float lat, float lon, float altitude);
void aprs_set_location(float lat, float lon, float altitude);
void aprs_start(void);
uint8_t aprs_tick(void);
#endif /* APRS_H */

Wyświetl plik

@ -126,8 +126,9 @@
#define XOSC_GCLK1_DIVIDE 4
/**
* Timings
* Telemetry
*/
#define TELEMETRY_FREQUENCY 434600000
#define TELEMETRY_INTERVAL 30
/**

Wyświetl plik

@ -29,7 +29,7 @@
float si_trx_get_temperature(void);
void si_trx_on(uint8_t modulation_type, uint16_t deviation);
void si_trx_on(uint8_t modulation_type, uint32_t frequency, uint16_t deviation);
void si_trx_off(void);
void si_trx_switch_channel(int16_t channel);

Wyświetl plik

@ -54,16 +54,37 @@ void base91_encode(char *str, uint8_t n, uint32_t value)
}
/**
* SET VALUES
* =============================================================================
*/
float _lat = 0, _lon = 0, _altitude;
void aprs_set_location(float lat, float lon, float altitude) {
_lat = lat; _lon = lon; _altitude = altitude;
}
/**
* START / TICK
* =============================================================================
*/
/**
* Start the transmission of an aprs frame
*/
void aprs_start(float lat, float lon, float altitude)
void aprs_start(void)
{
char addresses[50];
char information[50];
char compressed_lat[5];
char compressed_lon[5];
/* Don't run without a valid position */
if (_lat == 0 && _lon == 0) return;
/* Encode the destination / source / path addresses */
uint32_t addresses_len = sprintf(addresses, "%-6s%c%-6s%c%-6s%c",
"APRS", 0,
@ -71,11 +92,11 @@ void aprs_start(float lat, float lon, float altitude)
"WIDE2", 1);
/* Prepare the aprs position report */
uint32_t compressed_lat_value = (uint32_t)round(380926 * ( 90 - lat));
uint32_t compressed_lon_value = (uint32_t)round(190463 * (180 + lon));
uint32_t compressed_lat_value = (uint32_t)round(380926 * ( 90 - _lat));
uint32_t compressed_lon_value = (uint32_t)round(190463 * (180 + _lon));
base91_encode(compressed_lat, 4, compressed_lat_value);
base91_encode(compressed_lon, 4, compressed_lon_value);
uint32_t altitude_feet = altitude * 3.2808; /* Oh yeah feet! Everyone loves feet */
uint32_t altitude_feet = _altitude * 3.2808; /* Oh yeah feet! Everyone loves feet */
/* Encode the information field */
/* Compressed Lat/Long position report, no timestamp */

Wyświetl plik

@ -30,13 +30,8 @@
#include "si_trx_defs.h"
#include "hw_config.h"
//#define RADIO_FREQUENCY 434600000
#define RADIO_FREQUENCY 144888000
#define RADIO_POWER 0x3f
#define VCXO_FREQUENCY SI406X_TCXO_FREQUENCY
#define RF_DEVIATION 200
void _si_trx_transfer_nocts(int tx_count, int rx_count, uint8_t *data)
@ -402,7 +397,7 @@ static float si_trx_set_frequency(uint32_t frequency, uint16_t deviation)
/**
* Resets the transceiver
*/
void si_trx_reset(uint8_t modulation_type, uint16_t deviation)
void si_trx_reset(uint8_t modulation_type, uint32_t frequency, uint16_t deviation)
{
_si_trx_sdn_enable(); /* active high shutdown = reset */
@ -429,7 +424,7 @@ void si_trx_reset(uint8_t modulation_type, uint16_t deviation)
SI_GPIO_PIN_CFG_GPIO_MODE_INPUT | SI_GPIO_PIN_CFG_PULL_ENABLE,
SI_GPIO_PIN_CFG_DRV_STRENGTH_LOW);
si_trx_set_frequency(RADIO_FREQUENCY, deviation);
si_trx_set_frequency(frequency, deviation);
si_trx_set_tx_power(RADIO_POWER);
si_trx_modem_set_tx_datarate(3000);
@ -446,9 +441,9 @@ void si_trx_reset(uint8_t modulation_type, uint16_t deviation)
/**
* Enables the radio and starts transmitting
*/
void si_trx_on(uint8_t modulation_type, uint16_t deviation)
void si_trx_on(uint8_t modulation_type, uint32_t frequency, uint16_t deviation)
{
si_trx_reset(modulation_type, deviation);
si_trx_reset(modulation_type, frequency, deviation);
si_trx_start_tx(0);
}
/**

Wyświetl plik

@ -236,7 +236,7 @@ void telemetry_tick(void) {
if (!radio_on) {
/* Contestia: We use the modem offset to modulate */
si_trx_on(SI_MODEM_MOD_TYPE_CW, 1);
si_trx_on(SI_MODEM_MOD_TYPE_CW, TELEMETRY_FREQUENCY, 1);
radio_on = 1;
contestia_preamble();
}
@ -257,7 +257,7 @@ void telemetry_tick(void) {
if (!radio_on) {
/* RTTY: We use the modem offset to modulate */
si_trx_on(SI_MODEM_MOD_TYPE_CW, 1);
si_trx_on(SI_MODEM_MOD_TYPE_CW, TELEMETRY_FREQUENCY, 1);
radio_on = 1;
rtty_preamble();
}
@ -288,7 +288,7 @@ void telemetry_tick(void) {
/* RSID: We PWM frequencies with the external pin */
telemetry_gpio1_pwm_init();
si_trx_on(SI_MODEM_MOD_TYPE_2GFSK, 1);
si_trx_on(SI_MODEM_MOD_TYPE_2GFSK, TELEMETRY_FREQUENCY, 1);
radio_on = 1;
return;
@ -308,9 +308,9 @@ void telemetry_tick(void) {
if (!radio_on) {
/* APRS: We use pwm to control gpio1 */
aprs_start(51.47, -2.58, 10);
aprs_start();
si_trx_on(SI_MODEM_MOD_TYPE_2GFSK, 400);
si_trx_on(SI_MODEM_MOD_TYPE_2GFSK, 144888000, 400);
radio_on = 1;
}
@ -326,7 +326,7 @@ void telemetry_tick(void) {
if (!radio_on) { /* Turn on */
/* Pips: Cw */
si_trx_on(SI_MODEM_MOD_TYPE_CW, 1); radio_on = 1;
si_trx_on(SI_MODEM_MOD_TYPE_CW, TELEMETRY_FREQUENCY, 1); radio_on = 1;
timer0_tick_frequency(PIPS_ON_FREQUENCY);
} else { /* Turn off */