kopia lustrzana https://github.com/bristol-seds/pico-tracker
Added pips, now outputs full rsid / contestia telemetry
rodzic
67719ea8b5
commit
d985c90dfc
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Definitions for telemetry pips
|
||||
* Copyright (C) 2015 Richard Meadows <richardeoin>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PIPS_H
|
||||
#define PIPS_H
|
||||
|
||||
/**
|
||||
* 10ms pips, once per second
|
||||
*/
|
||||
|
||||
#define PIPS_RATE 1
|
||||
#define PIPS_LENGTH_MS 50
|
||||
|
||||
#define PIPS_ON_FREQUENCY (1000 / PIPS_LENGTH_MS)
|
||||
#define PIPS_OFF_FREQUENCY PIPS_RATE
|
||||
|
||||
#endif /* PIPS_H */
|
|
@ -54,6 +54,7 @@ void telemetry_set_length(int32_t length);
|
|||
|
||||
|
||||
float timer0_tick_init(float frequency);
|
||||
void timer0_tick_frequency(float frequency);
|
||||
void timer0_tick_deinit();
|
||||
void telemetry_gpio1_pwm_init(void);
|
||||
void telemetry_gpio1_pwm_duty(float duty_cycle);
|
||||
|
|
|
@ -170,7 +170,6 @@ void output_telemetry_string(void)
|
|||
while (gps_update_time_pending()) {
|
||||
system_sleep();
|
||||
}
|
||||
// for (int i = 0; i < 100*1000; i++);
|
||||
|
||||
/* Time */
|
||||
struct ubx_nav_timeutc time = gps_get_nav_timeutc();
|
||||
|
@ -189,7 +188,18 @@ void output_telemetry_string(void)
|
|||
/* swap buffers */
|
||||
ARRAY_DBUFFER_SWAP(&telemetry_dbuffer_string);
|
||||
|
||||
/* start - SI NOW BELONGS TO TELEMETRY, WE CANNOT ACCESS */
|
||||
|
||||
|
||||
/* RSID */
|
||||
/* start - SI NOW BELONGS TO TELEMETRY, WE CANNOT ACCESS */
|
||||
#ifdef CONTESTIA
|
||||
telemetry_start_rsid(RSID_CONTESTIA_32_1000);
|
||||
#endif
|
||||
|
||||
/* Sleep Wait for RSID to be done */
|
||||
while (telemetry_active()) {
|
||||
system_sleep();
|
||||
}
|
||||
#ifdef RTTY
|
||||
telemetry_start(TELEMETRY_RTTY);
|
||||
#endif
|
||||
|
@ -210,9 +220,9 @@ void output_telemetry_string(void)
|
|||
/* Request updates from the gps */
|
||||
gps_update_position();
|
||||
if (gps_is_locked()) {
|
||||
led_on();
|
||||
// led_on();
|
||||
} else {
|
||||
led_off();
|
||||
// led_off();
|
||||
}
|
||||
|
||||
/* Wait for the gps update. Move on if it's urgent */
|
||||
|
@ -221,9 +231,9 @@ void output_telemetry_string(void)
|
|||
}
|
||||
|
||||
if (gps_is_locked()) {
|
||||
led_off();
|
||||
// led_off();
|
||||
} else {
|
||||
led_on();
|
||||
// led_on();
|
||||
}
|
||||
|
||||
/* GPS Status */
|
||||
|
@ -316,7 +326,7 @@ int main(void)
|
|||
/* Initialise Si4060 interface */
|
||||
si_trx_init();
|
||||
|
||||
led_on();
|
||||
// led_on();
|
||||
|
||||
|
||||
while (1) {
|
||||
|
@ -324,9 +334,10 @@ int main(void)
|
|||
//wdt_reset_count();
|
||||
|
||||
/* Send the next packet */
|
||||
//output_telemetry_string();
|
||||
output_telemetry_string();
|
||||
|
||||
telemetry_start_rsid(RSID_CONTESTIA_32_1000);
|
||||
telemetry_start(TELEMETRY_PIPS);
|
||||
telemetry_set_length(5);
|
||||
|
||||
/* Sleep Wait */
|
||||
while (telemetry_active()) {
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "rtty.h"
|
||||
#include "contestia.h"
|
||||
#include "rsid.h"
|
||||
#include "pips.h"
|
||||
#include "si_trx.h"
|
||||
#include "si_trx_defs.h"
|
||||
#include "system/gclk.h"
|
||||
|
@ -38,6 +39,25 @@
|
|||
#include "tc/tc_driver.h"
|
||||
#include "hw_config.h"
|
||||
|
||||
|
||||
#include "system/port.h"
|
||||
/**
|
||||
* Turns the status LED on
|
||||
*/
|
||||
static inline void led_on(void)
|
||||
{
|
||||
port_pin_set_output_level(LED0_PIN, 0); /* LED is active low */
|
||||
}
|
||||
/**
|
||||
* Turns the status lED off
|
||||
*/
|
||||
static inline void led_off(void)
|
||||
{
|
||||
port_pin_set_output_level(LED0_PIN, 1); /* LED is active low */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* CYCLIC REDUNDANCY CHECK (CRC)
|
||||
* =============================================================================
|
||||
|
@ -136,8 +156,13 @@ int telemetry_start(enum telemetry_t type) {
|
|||
case TELEMETRY_RTTY:
|
||||
timer0_tick_init(RTTY_BITRATE);
|
||||
break;
|
||||
case TELEMETRY_PIPS:
|
||||
timer0_tick_init(PIPS_OFF_FREQUENCY);
|
||||
break;
|
||||
case TELEMETRY_APRS:
|
||||
case TELEMETRY_RSID: /* Not used - see function below */
|
||||
break;
|
||||
}
|
||||
|
||||
return 0; /* Success */
|
||||
} else {
|
||||
return 1; /* Already active */
|
||||
|
@ -168,7 +193,6 @@ int telemetry_start_rsid(rsid_code_t rsid) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the index of the current byte being outputted from the buffer
|
||||
*/
|
||||
|
@ -272,6 +296,22 @@ void telemetry_tick(void) {
|
|||
telemetry_gpio1_pwm_deinit();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case TELEMETRY_PIPS: /* ---- ---- A pips mode! */
|
||||
|
||||
if (!radio_on) { /* Turn on */
|
||||
/* Pips: Cw */
|
||||
si_trx_on(SI_MODEM_MOD_TYPE_CW); radio_on = 1;
|
||||
timer0_tick_frequency(PIPS_ON_FREQUENCY);
|
||||
|
||||
} else { /* Turn off */
|
||||
si_trx_off(); radio_on = 0;
|
||||
timer0_tick_frequency(PIPS_OFF_FREQUENCY);
|
||||
|
||||
telemetry_index++;
|
||||
if (is_telemetry_finished()) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -308,6 +348,8 @@ float timer0_tick_init(float frequency)
|
|||
{
|
||||
//si_gclk_setup();
|
||||
|
||||
led_on();
|
||||
|
||||
/* Calculate the wrap value for the given frequency */
|
||||
//float gclk_frequency = SI406X_TCXO_FREQUENCY;
|
||||
float gclk_frequency = (float)system_gclk_chan_get_hz(0);
|
||||
|
@ -328,7 +370,7 @@ float timer0_tick_init(float frequency)
|
|||
false, /* Oneshot */
|
||||
true, /* Run in standby */
|
||||
0x0000, /* Initial value */
|
||||
count, /* Top value */
|
||||
0x0000, /* Top value */
|
||||
t0_capture_channel_enables, /* Capture Channel Enables */
|
||||
t0_compare_channel_values); /* Compare Channels Values */
|
||||
|
||||
|
@ -350,6 +392,19 @@ float timer0_tick_init(float frequency)
|
|||
/* Return the frequency we actually initialised */
|
||||
return gclk_frequency / (float)count;
|
||||
}
|
||||
/**
|
||||
* Changes the timer0 frequency
|
||||
*/
|
||||
void timer0_tick_frequency(float frequency)
|
||||
{
|
||||
float gclk_frequency = (float)system_gclk_chan_get_hz(0);
|
||||
uint32_t count = (uint32_t)(gclk_frequency / frequency);
|
||||
|
||||
tc_set_compare_value(TC0,
|
||||
TC_COMPARE_CAPTURE_CHANNEL_0,
|
||||
count);
|
||||
tc_set_count_value(TC0, 0);
|
||||
}
|
||||
/**
|
||||
* Disables the timer
|
||||
*/
|
||||
|
@ -358,8 +413,6 @@ void timer0_tick_deinit()
|
|||
tc_stop_counter(TC0);
|
||||
tc_disable(TC0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called at the symbol rate
|
||||
*/
|
||||
|
|
Ładowanie…
Reference in New Issue