kopia lustrzana https://github.com/bristol-seds/pico-tracker
RF power set in hw_config, full power for APRS. RF tests in separate file, aprs shuts stops on error correctly
rodzic
9f6aa97ba4
commit
31edebc9e0
|
@ -44,7 +44,7 @@
|
|||
|
||||
void aprs_set_location(float lat, float lon, float altitude);
|
||||
|
||||
void aprs_start(void);
|
||||
uint8_t aprs_start(void);
|
||||
uint8_t aprs_tick(void);
|
||||
|
||||
#endif /* APRS_H */
|
||||
|
|
|
@ -118,6 +118,15 @@
|
|||
#define SI406X_GPIO1_PINMUX PINMUX_PA25F_TC5_WO1
|
||||
#define SI406X_TCXO_FREQUENCY 16369000
|
||||
|
||||
/**
|
||||
* RF Power @ 1.8V
|
||||
*
|
||||
* These values are taken from the datasheet, but the
|
||||
* difference between them has been measured as 6dB
|
||||
*/
|
||||
#define RF_POWER_14dBm 0x7f
|
||||
#define RF_POWER_8dBm 36
|
||||
|
||||
/**
|
||||
* XOSC
|
||||
*/
|
||||
|
@ -130,8 +139,14 @@
|
|||
*/
|
||||
#define TELEMETRY_FREQUENCY 434600000
|
||||
#define TELEMETRY_INTERVAL 30
|
||||
#define TELEMETRY_POWER RF_POWER_8dBm
|
||||
|
||||
/**
|
||||
* APRS
|
||||
*/
|
||||
#define APRS_ENABLE 1
|
||||
#define APRS_INTERVAL 180
|
||||
#define APRS_POWER RF_POWER_14dBm
|
||||
|
||||
/**
|
||||
* Watchdog Timer
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
|
||||
float si_trx_get_temperature(void);
|
||||
|
||||
void si_trx_on(uint8_t modulation_type, uint32_t frequency, uint16_t deviation);
|
||||
void si_trx_on(uint8_t modulation_type, uint32_t frequency,
|
||||
uint16_t deviation, uint8_t power);
|
||||
void si_trx_off(void);
|
||||
void si_trx_switch_channel(int16_t channel);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ int telemetry_active(void);
|
|||
int telemetry_start(enum telemetry_t type, int32_t length);
|
||||
int telemetry_start_rsid(rsid_code_t rsid);
|
||||
void telemetry_aprs_set_frequency(int32_t frequency);
|
||||
void telemetry_stop(void);
|
||||
void telemetry_request_stop(void);
|
||||
float telemetry_si_temperature(void);
|
||||
|
||||
float timer0_tick_init(float frequency);
|
||||
|
|
|
@ -75,7 +75,7 @@ void aprs_set_location(float lat, float lon, float altitude) {
|
|||
/**
|
||||
* Start the transmission of an aprs frame
|
||||
*/
|
||||
void aprs_start(void)
|
||||
uint8_t aprs_start(void)
|
||||
{
|
||||
char addresses[50];
|
||||
char information[50];
|
||||
|
@ -83,7 +83,7 @@ void aprs_start(void)
|
|||
char compressed_lon[5];
|
||||
|
||||
/* Don't run without a valid position */
|
||||
if (_lat == 0 && _lon == 0) return;
|
||||
if (_lat == 0 && _lon == 0) return 0;
|
||||
|
||||
/* Encode the destination / source / path addresses */
|
||||
uint32_t addresses_len = sprintf(addresses, "%-6s%c%-6s%c%-6s%c",
|
||||
|
@ -114,9 +114,11 @@ void aprs_start(void)
|
|||
/* Let's actually try that out.. We can add comment etc. later */
|
||||
|
||||
|
||||
/* Transmit the frame */
|
||||
/* Transmit the frame using ax25 */
|
||||
ax25_start(addresses, addresses_len,
|
||||
information, information_len);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t aprs_tick(void)
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "analogue.h"
|
||||
#include "spi_bitbang.h"
|
||||
#include "system/interrupt.h"
|
||||
#include "rf_tests.h"
|
||||
|
||||
#define CALLSIGN "UBSEDSx"
|
||||
|
||||
|
@ -209,33 +210,6 @@ void aprs_telemetry(void) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* APRS function for use during testing. Not for flight
|
||||
*/
|
||||
void aprs_test(void)
|
||||
{
|
||||
if (!gps_is_locked()) return; /* Don't bother with no GPS */
|
||||
|
||||
while(1) {
|
||||
struct ubx_nav_posllh pos = gps_get_nav_posllh();
|
||||
float lat = (float)pos.payload.lat / 10000000.0; // This division is from the gps reciver, not for geofence
|
||||
float lon = (float)pos.payload.lon / 10000000.0;
|
||||
uint32_t altitude = pos.payload.height / 1000;
|
||||
|
||||
/* Set location */
|
||||
aprs_set_location(lat, lon, altitude);
|
||||
|
||||
/* Set frequency */
|
||||
telemetry_aprs_set_frequency(144800000);
|
||||
|
||||
/* Transmit packet and wait */
|
||||
telemetry_start(TELEMETRY_APRS, 0xFFFF);
|
||||
while (telemetry_active()) {
|
||||
system_sleep();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xosc_measure_callback(uint32_t result)
|
||||
{
|
||||
|
@ -278,6 +252,12 @@ int main(void)
|
|||
|
||||
init(timepulse_callback);
|
||||
|
||||
/* Maybe do some rf tests */
|
||||
rf_tests();
|
||||
|
||||
/* Turn off LED to show we've initialised correctly */
|
||||
led_off();
|
||||
|
||||
while (1) {
|
||||
/* Send a packet */
|
||||
output_telemetry_string((telemetry_alternate++ & 1) ?
|
||||
|
@ -305,7 +285,7 @@ int main(void)
|
|||
telemetry_trigger_flag = 0;
|
||||
|
||||
/* End pips */
|
||||
telemetry_stop();
|
||||
telemetry_request_stop();
|
||||
while (telemetry_active()) {
|
||||
system_sleep();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "si_trx_defs.h"
|
||||
#include "hw_config.h"
|
||||
|
||||
#define RADIO_POWER 0x3f
|
||||
|
||||
#define VCXO_FREQUENCY SI406X_TCXO_FREQUENCY
|
||||
|
||||
|
||||
|
@ -397,7 +397,8 @@ static float si_trx_set_frequency(uint32_t frequency, uint16_t deviation)
|
|||
/**
|
||||
* Resets the transceiver
|
||||
*/
|
||||
void si_trx_reset(uint8_t modulation_type, uint32_t frequency, uint16_t deviation)
|
||||
void si_trx_reset(uint8_t modulation_type, uint32_t frequency,
|
||||
uint16_t deviation, uint8_t power)
|
||||
{
|
||||
_si_trx_sdn_enable(); /* active high shutdown = reset */
|
||||
|
||||
|
@ -425,7 +426,7 @@ void si_trx_reset(uint8_t modulation_type, uint32_t frequency, uint16_t deviatio
|
|||
SI_GPIO_PIN_CFG_DRV_STRENGTH_LOW);
|
||||
|
||||
si_trx_set_frequency(frequency, deviation);
|
||||
si_trx_set_tx_power(RADIO_POWER);
|
||||
si_trx_set_tx_power(power);
|
||||
|
||||
si_trx_modem_set_tx_datarate(3000);
|
||||
|
||||
|
@ -441,9 +442,10 @@ void si_trx_reset(uint8_t modulation_type, uint32_t frequency, uint16_t deviatio
|
|||
/**
|
||||
* Enables the radio and starts transmitting
|
||||
*/
|
||||
void si_trx_on(uint8_t modulation_type, uint32_t frequency, uint16_t deviation)
|
||||
void si_trx_on(uint8_t modulation_type, uint32_t frequency,
|
||||
uint16_t deviation, uint8_t power)
|
||||
{
|
||||
si_trx_reset(modulation_type, frequency, deviation);
|
||||
si_trx_reset(modulation_type, frequency, deviation, power);
|
||||
si_trx_start_tx(0);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -197,15 +197,6 @@ void telemetry_aprs_set_frequency(int32_t frequency) {
|
|||
_aprs_frequency = frequency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the ongoing telemetry at the earliest possible moment (end of
|
||||
* symbol / block).
|
||||
*/
|
||||
void telemetry_stop(void) {
|
||||
if (telemetry_active()) {
|
||||
telemetry_stop_flag = 1;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the SI radio temperature at the end of the last transmission.
|
||||
*/
|
||||
|
@ -213,29 +204,44 @@ float telemetry_si_temperature(void) {
|
|||
return _si_temperature;
|
||||
}
|
||||
|
||||
void telemetry_stop(void) {
|
||||
/* All done, deactivate */
|
||||
telemetry_string_length = 0;
|
||||
telemetry_stop_flag = 0;
|
||||
|
||||
/* Turn radio off */
|
||||
if (radio_on) {
|
||||
si_trx_state_ready(); /* Stop RF */
|
||||
_si_temperature = si_trx_get_temperature();
|
||||
si_trx_off(); /* Shutdown */
|
||||
|
||||
radio_on = 0;
|
||||
}
|
||||
|
||||
/* De-init timer */
|
||||
timer0_tick_deinit();
|
||||
}
|
||||
uint8_t is_telemetry_finished(void) {
|
||||
if (telemetry_index >= telemetry_string_length || telemetry_stop_flag) {
|
||||
/* All done, deactivate */
|
||||
telemetry_string_length = 0;
|
||||
telemetry_stop_flag = 0;
|
||||
|
||||
/* Turn radio off */
|
||||
if (radio_on) {
|
||||
si_trx_state_ready(); /* Stop RF */
|
||||
_si_temperature = si_trx_get_temperature();
|
||||
si_trx_off(); /* Shutdown */
|
||||
|
||||
radio_on = 0;
|
||||
}
|
||||
|
||||
/* De-init timer */
|
||||
timer0_tick_deinit();
|
||||
|
||||
/* Finish telemetry */
|
||||
telemetry_stop();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Stops the ongoing telemetry at the earliest possible moment (end of
|
||||
* symbol / block).
|
||||
*/
|
||||
void telemetry_request_stop(void) {
|
||||
if (telemetry_active()) {
|
||||
telemetry_stop_flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called at the telemetry mode's baud rate
|
||||
*/
|
||||
|
@ -246,7 +252,7 @@ void telemetry_tick(void) {
|
|||
|
||||
if (!radio_on) {
|
||||
/* Contestia: We use the modem offset to modulate */
|
||||
si_trx_on(SI_MODEM_MOD_TYPE_CW, TELEMETRY_FREQUENCY, 1);
|
||||
si_trx_on(SI_MODEM_MOD_TYPE_CW, TELEMETRY_FREQUENCY, 1, TELEMETRY_POWER);
|
||||
radio_on = 1;
|
||||
contestia_preamble();
|
||||
}
|
||||
|
@ -267,16 +273,16 @@ void telemetry_tick(void) {
|
|||
|
||||
if (!radio_on) {
|
||||
/* RTTY: We use the modem offset to modulate */
|
||||
si_trx_on(SI_MODEM_MOD_TYPE_CW, TELEMETRY_FREQUENCY, 1);
|
||||
si_trx_on(SI_MODEM_MOD_TYPE_CW, TELEMETRY_FREQUENCY, 1, TELEMETRY_POWER);
|
||||
radio_on = 1;
|
||||
rtty_preamble();
|
||||
}
|
||||
|
||||
if (!rtty_tick()) {
|
||||
/* Transmission Finished */
|
||||
/* Maybe the transmission is finished */
|
||||
if (is_telemetry_finished()) return;
|
||||
|
||||
/* Let's start again */
|
||||
/* Otherwise go for the next byte */
|
||||
uint8_t data = telemetry_string[telemetry_index];
|
||||
telemetry_index++;
|
||||
|
||||
|
@ -298,7 +304,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, TELEMETRY_FREQUENCY, 1);
|
||||
si_trx_on(SI_MODEM_MOD_TYPE_2GFSK, TELEMETRY_FREQUENCY, 1, TELEMETRY_POWER);
|
||||
radio_on = 1;
|
||||
|
||||
return;
|
||||
|
@ -318,21 +324,20 @@ void telemetry_tick(void) {
|
|||
|
||||
if (!radio_on) {
|
||||
/* APRS: We use pwm to control gpio1 */
|
||||
aprs_start();
|
||||
if (aprs_start() && _aprs_frequency) {
|
||||
|
||||
// if (_aprs_frequency) { TODO configurable frequency
|
||||
// si_trx_on(SI_MODEM_MOD_TYPE_2GFSK, _aprs_frequency, 400);
|
||||
// radio_on = 1;
|
||||
// }
|
||||
|
||||
si_trx_on(SI_MODEM_MOD_TYPE_2GFSK, 144800000, 400);
|
||||
/* Radio on */
|
||||
si_trx_on(SI_MODEM_MOD_TYPE_2GFSK, _aprs_frequency, 400, APRS_POWER);
|
||||
radio_on = 1;
|
||||
|
||||
} else {
|
||||
/* Stop immediately */
|
||||
telemetry_stop();
|
||||
}
|
||||
}
|
||||
|
||||
if (!aprs_tick()) {
|
||||
/* Transmission Finished */
|
||||
telemetry_stop();
|
||||
telemetry_request_stop();
|
||||
if (is_telemetry_finished()) return;
|
||||
}
|
||||
|
||||
|
@ -342,7 +347,8 @@ void telemetry_tick(void) {
|
|||
|
||||
if (!radio_on) { /* Turn on */
|
||||
/* Pips: Cw */
|
||||
si_trx_on(SI_MODEM_MOD_TYPE_CW, TELEMETRY_FREQUENCY, 1); radio_on = 1;
|
||||
si_trx_on(SI_MODEM_MOD_TYPE_CW, TELEMETRY_FREQUENCY, 1, TELEMETRY_POWER);
|
||||
radio_on = 1;
|
||||
timer0_tick_frequency(PIPS_ON_FREQUENCY);
|
||||
|
||||
} else { /* Turn off */
|
||||
|
|
Ładowanie…
Reference in New Issue