new TX Watchdog added

pull/65/head
Antennen-Wolfgang 2023-12-03 14:49:28 +01:00
rodzic 3e5369dd90
commit c72a298d80
8 zmienionych plików z 251 dodań i 67 usunięć

Wyświetl plik

@ -56,10 +56,10 @@ volatile bool system_initialized = false;
* Maximum length: 64 characters.
*/
char *cw_message_templates[] = {
// "$cs $loc6 $altm $gs km/h $tiC",
"vvv de $cs solar rs41 $loc8 $altm $gs kmh sk",
// "$cs $loc6",
// "$alt m",
// "$gs km/h $ti C",
// "$gs kmh $ti C",
NULL
};
@ -78,7 +78,7 @@ char *pip_message_templates[] = {
* Note that many hardware APRS receivers show a limited number of APRS comment characters, such as 43 or 67 chars.
*/
char *aprs_comment_templates[] = {
// " B$bu $teC $hu% $prmb $hh:$mm:$ss @ $tow ms - " APRS_COMMENT,
" $ $altm $gskm/h $bvmV $clvel dir:$he - " APRS_COMMENT,
// " B$bu $teC $hu% $prmb - " APRS_COMMENT,
// " B$bu $loc12 $hh:$mm:$ss - " APRS_COMMENT,
// " $loc12 - " APRS_COMMENT,

Wyświetl plik

@ -6,15 +6,14 @@
// NOTE: DFM-17 radiosondes require a GPS lock (and clear visibility to the sky) to calibrate its internal oscillator.
// DFM-17 transmissions, especially APRS, may not decode correctly because of incorrect timing before the internal oscillator has been calibrated.
// Define radiosonde type. Remove the "//" comment to select either RS41 or DFM17.
//#define RS41
//#define DFM17
// Define radiosonde type.
// This clone supports only RS41 - DO NOT TRY TO USES DFM17 !!!!!!!!!
// ------------------------------------------------------------------
#define RS41
// ------------------------------------------------------------------
#if !defined(RS41) && !defined(DFM17)
#error "No hardware type specified. Please define RS41 or DFM17."
#endif
#if defined(RS41) && defined(DFM17)
#error "Please define either RS41 or DFM17."
#if !defined(RS41)
#error "Please define ONLY RS41. Support DFM17 is not fully implemented yet"
#endif
@ -29,7 +28,7 @@
*/
// Set the tracker amateur radio call sign here
#define CALLSIGN "MYCALL"
#define CALLSIGN "yourCall"
// Disabling LEDs will save power
// Red LED: Lit during initialization and transmit.
@ -43,12 +42,14 @@
#define ALLOW_POWER_OFF false
// Number of character pairs to include in locator
#define LOCATOR_PAIR_COUNT_FULL 6 // max. 6 (12 characters WWL)
#define LOCATOR_PAIR_COUNT_FULL 12 // max. 6 (12 characters WWL)
// Delay after transmission for modes that do not use time synchronization. Zero delay allows continuous transmit mode for Horus V1 and V2.
#define RADIO_POST_TRANSMIT_DELAY_MS 1000
// Threshold for time-synchronized modes regarding how far from scheduled transmission time the transmission is still allowed
// best Results for 4FSK : 2500
// if value here is to high, TX send packets more than once
#define RADIO_TIME_SYNC_THRESHOLD_MS 2000
// Number of leap seconds to add to the raw GPS time reported by the GPS chip (see https://timetoolsltd.com/gps/what-is-gps-time/ for more info)
@ -59,10 +60,16 @@
#define GPS_REQUIRE_3D_FIX true
// Enable this setting to make a cold start on the CPU if GPS-Fix missing longer then GPS_REBOOT_MISSING_GPS_FIX_SECONDS
#define GPS_REBOOT_MISSING_GPS_FIX_ENABLE false
#define GPS_REBOOT_MISSING_GPS_FIX_ENABLE true
// If enabled above, define threschold how long a missing GPS-Fix before cold start (dont hold it to short)
#define GPS_REBOOT_MISSING_GPS_FIX_SECONDS 200
// 5 Minutes no GPS Signal than REBOOT
#define GPS_REBOOT_MISSING_GPS_FIX_SECONDS 300
// Enable this setting to watch TX and make a cold start on the CPU if no transmission occured after TX_LOST_FOR_SECONDS
// TX hangs up longer then 10 min, then REBOOT
#define RADIO_TX_LOST_CHECK_ENABLE true
#define RADIO_TX_LOST_FOR_SECONDS 600
// Enable power-saving features of the GPS chip to save power.
// This option should be safe to enable, as it enters a selective power saving mode.
@ -72,7 +79,7 @@
// Based on measurements Mark VK5QI, enabling this reduces power consumption by about 30-40 mA (~50%) to around 30-50 mA,
// where the consumption is 70-90 mA when power saving is not enabled and any radio transmitters are idle.
// See the README for details about power consumption.
#define GPS_POWER_SAVING_ENABLE false
#define GPS_POWER_SAVING_ENABLE true
// Enable NMEA output from GPS via external serial port. This disables use of I²C bus (Si5351 and sensors) because the pins are shared.
#define GPS_NMEA_OUTPUT_VIA_SERIAL_PORT_ENABLE false
@ -152,13 +159,13 @@
#define RADIO_SI4032_TX_CW false
#define RADIO_SI4032_TX_CW_COUNT 1
#define RADIO_SI4032_TX_PIP false
#define RADIO_SI4032_TX_PIP_COUNT 6
#define RADIO_SI4032_TX_APRS true
#define RADIO_SI4032_TX_PIP_COUNT 1
#define RADIO_SI4032_TX_APRS false
#define RADIO_SI4032_TX_APRS_COUNT 2
#define RADIO_SI4032_TX_HORUS_V1 false
#define RADIO_SI4032_TX_HORUS_V1_COUNT 1
#define RADIO_SI4032_TX_HORUS_V2 true
#define RADIO_SI4032_TX_HORUS_V2_COUNT 6
#define RADIO_SI4032_TX_HORUS_V2_COUNT 1
// Continuous transmit mode can be enabled for *either* Horus V1 or V2, but not both. This disables all other transmission modes.
// The continuous mode transmits Horus 4FSK preamble between transmissions
@ -167,15 +174,17 @@
#define RADIO_SI4032_TX_HORUS_V2_CONTINUOUS false
// Transmit frequencies for the Si4032 transmitter modes
#define RADIO_SI4032_TX_FREQUENCY_CW 432500000
#define RADIO_SI4032_TX_FREQUENCY_PIP 432500000
#define RADIO_SI4032_TX_FREQUENCY_CW 432051000
#define RADIO_SI4032_TX_FREQUENCY_PIP 434713000
#define RADIO_SI4032_TX_FREQUENCY_APRS_1200 432500000
// Use a frequency offset to place FSK tones slightly above the defined frequency for SSB reception
#define RADIO_SI4032_TX_FREQUENCY_HORUS_V1 432501000
#define RADIO_SI4032_TX_FREQUENCY_HORUS_V2 432501000
#define RADIO_SI4032_TX_FREQUENCY_HORUS_V1 434714000
#define RADIO_SI4032_TX_FREQUENCY_HORUS_V2 434714000
// Use a rotating alternate 2nd frequency for HORUS_V2 (not continously)
#define RADIO_SI4032_TX_FREQUENCY2_HORUS_V2_ACTIV false
#define RADIO_SI4032_TX_FREQUENCY2_HORUS_V2 437600000
#define RADIO_SI4032_TX_FREQUENCY2_HORUS_V2 437600500
#define RADIO_SI4032_TX_FREQUENCY2_HORUS_V1_ACTIV false
#define RADIO_SI4032_TX_FREQUENCY2_HORUS_V1 437600500
/**
@ -192,11 +201,11 @@
#define RADIO_SI4063_TX_CW_COUNT 1
#define RADIO_SI4063_TX_PIP false
#define RADIO_SI4063_TX_PIP_COUNT 6
#define RADIO_SI4063_TX_APRS true
#define RADIO_SI4063_TX_APRS_COUNT 2
#define RADIO_SI4063_TX_APRS false
#define RADIO_SI4063_TX_APRS_COUNT 1
#define RADIO_SI4063_TX_HORUS_V1 false
#define RADIO_SI4063_TX_HORUS_V1_COUNT 1
#define RADIO_SI4063_TX_HORUS_V2 true
#define RADIO_SI4063_TX_HORUS_V2 false
#define RADIO_SI4063_TX_HORUS_V2_COUNT 6
// Continuous transmit mode can be enabled for *either* Horus V1 or V2, but not both. This disables all other transmission modes.
@ -223,14 +232,14 @@
// Which modes to transmit using an externally connected Si5351 chip in the I²C bus
// The COUNT settings define the number of times that each type of transmission is repeated
#define RADIO_SI5351_TX_CW true
#define RADIO_SI5351_TX_CW false
#define RADIO_SI5351_TX_CW_COUNT 1
#define RADIO_SI5351_TX_PIP false
#define RADIO_SI5351_TX_PIP_COUNT 6
#define RADIO_SI5351_TX_HORUS_V1 false
#define RADIO_SI5351_TX_HORUS_V1_COUNT 1
#define RADIO_SI5351_TX_HORUS_V2 true
#define RADIO_SI5351_TX_HORUS_V2_COUNT 4
#define RADIO_SI5351_TX_HORUS_V2 false
#define RADIO_SI5351_TX_HORUS_V2_COUNT 1
#define RADIO_SI5351_TX_JT9 false
#define RADIO_SI5351_TX_JT9_COUNT 1
#define RADIO_SI5351_TX_JT65 false
@ -245,14 +254,14 @@
#define RADIO_SI5351_TX_FT8_COUNT 1
// Transmit frequencies for the Si5351 transmitter modes
#define RADIO_SI5351_TX_FREQUENCY_CW 3595000UL
#define RADIO_SI5351_TX_FREQUENCY_CW 14105000UL
#define RADIO_SI5351_TX_FREQUENCY_PIP 3595000UL
#define RADIO_SI5351_TX_FREQUENCY_HORUS_V1 3608000UL
#define RADIO_SI5351_TX_FREQUENCY_HORUS_V2 3608000UL
#define RADIO_SI5351_TX_FREQUENCY_HORUS_V2 3605000UL
#define RADIO_SI5351_TX_FREQUENCY_JT9 14085000UL // Was: 14078700UL
#define RADIO_SI5351_TX_FREQUENCY_JT65 14085000UL // Was: 14078300UL
#define RADIO_SI5351_TX_FREQUENCY_JT4 14085000UL // Was: 14078500UL
#define RADIO_SI5351_TX_FREQUENCY_WSPR 14085000UL // Was: 14097200UL
#define RADIO_SI5351_TX_FREQUENCY_WSPR 14097200UL // Was: 14097200UL
#define RADIO_SI5351_TX_FREQUENCY_FSQ 3608350UL // Was: 7105350UL // Base freq is 1350 Hz higher than dial freq in USB
#define RADIO_SI5351_TX_FREQUENCY_FT8 14085000UL // Was: 14075000UL
@ -284,18 +293,18 @@
// See APRS symbol table documentation in: http://www.aprs.org/symbols/symbolsX.txt
#define APRS_SYMBOL_TABLE '/' // '/' denotes primary and '\\' denotes alternate APRS symbol table
#define APRS_SYMBOL 'O'
#define APRS_COMMENT "RS41ng radiosonde firmware test"
#define APRS_COMMENT " RS41"
#define APRS_RELAYS "WIDE1-1,WIDE2-1"
#define APRS_DESTINATION "APZ41N"
#define APRS_DESTINATION_SSID '0'
#define APRS_DESTINATION_SSID 'B'
// Generate an APRS weather report instead of a position report. This will override the APRS symbol with the weather station symbol.
#define APRS_WEATHER_REPORT_ENABLE false
// Schedule transmission every N seconds, counting from beginning of an hour (based on GPS time). Set to zero to disable time sync.
// See the README file for more detailed documentation about time sync and its offset setting
#define APRS_TIME_SYNC_SECONDS 0
#define APRS_TIME_SYNC_SECONDS 60
// Delay transmission for an N second offset, counting from the scheduled time set with TIME_SYNC_SECONDS.
#define APRS_TIME_SYNC_OFFSET_SECONDS 0
#define APRS_TIME_SYNC_OFFSET_SECONDS 53
/**
* Common Horus 4FSK mode settings
@ -341,42 +350,42 @@
// Schedule transmission every N seconds, counting from beginning of an hour (based on GPS time). Set to zero to disable time sync.
// See the README file for more detailed documentation about time sync and its offset setting
#define HORUS_V2_TIME_SYNC_SECONDS 0
#define HORUS_V2_TIME_SYNC_SECONDS 60
// Delay transmission for an N second offset, counting from the scheduled time set with TIME_SYNC_SECONDS.
#define HORUS_V2_TIME_SYNC_OFFSET_SECONDS 0
#define HORUS_V2_TIME_SYNC_OFFSET_SECONDS 15
/**
* CW settings
*/
// CW speed in WPM, range 5 - 40
#define CW_SPEED_WPM 20
#define CW_SPEED_WPM 30
// Schedule transmission every N seconds, counting from beginning of an hour (based on GPS time). Set to zero to disable time sync.
// See the README file for more detailed documentation about time sync and its offset setting
#define CW_TIME_SYNC_SECONDS 0
#define CW_TIME_SYNC_SECONDS 60
// Delay transmission for an N second offset, counting from the scheduled time set with TIME_SYNC_SECONDS.
#define CW_TIME_SYNC_OFFSET_SECONDS 0
#define CW_TIME_SYNC_OFFSET_SECONDS 25
/**
* Pip settings (short beep generated using CW to indicate presence of the transmitter)
*/
// Pip speed is defined as CW WPM, range 5 - 40
#define PIP_SPEED_WPM 18
#define PIP_SPEED_WPM 27
// Schedule transmission every N seconds, counting from beginning of an hour (based on GPS time). Set to zero to disable time sync.
// See the README file for more detailed documentation about time sync and its offset setting
#define PIP_TIME_SYNC_SECONDS 0
#define PIP_TIME_SYNC_SECONDS 60
// Delay transmission for an N second offset, counting from the scheduled time set with TIME_SYNC_SECONDS.
#define PIP_TIME_SYNC_OFFSET_SECONDS 0
#define PIP_TIME_SYNC_OFFSET_SECONDS 43
/**
* WSPR settings
*/
#define WSPR_CALLSIGN CALLSIGN
#define WSPR_LOCATOR_FIXED_ENABLED false
#define WSPR_LOCATOR_FIXED "AA00"
#define WSPR_LOCATOR_FIXED_ENABLED true
#define WSPR_LOCATOR_FIXED "JN49"
#define WSPR_DBM 10
// Schedule transmission every N seconds, counting from beginning of an hour (based on GPS time). Set to zero to disable time sync.

Wyświetl plik

@ -1,3 +1,4 @@
#include <string.h>
#include "hal/system.h"
@ -801,7 +802,6 @@ void ubxg6010_handle_incoming_byte(uint8_t data)
static uint8_t buffer_pos = 0;
static uint8_t incoming_packet_buffer[sizeof(uBloxPacket) + sizeof(uBloxChecksum)];
static uBloxPacket *incoming_packet = (uBloxPacket *) incoming_packet_buffer;
if (!sync_ubx && (sync_nmea < 3)) {
if (!buffer_pos && data == 0xB5) {
buffer_pos = 1;
@ -820,6 +820,7 @@ void ubxg6010_handle_incoming_byte(uint8_t data)
ubxg6010_handle_nmea_output(data);
} else {
((uint8_t *) incoming_packet)[buffer_pos] = data;
if ((buffer_pos >= sizeof(uBloxHeader) - 1) &&
(buffer_pos - 1 == (incoming_packet->header.payloadSize + sizeof(uBloxHeader) + sizeof(uBloxChecksum)))) {
ubxg6010_handle_packet((uBloxPacket *) incoming_packet);

104
src/hal/gpio.h 100644
Wyświetl plik

@ -0,0 +1,104 @@
#ifndef __GPIO_H
#define __GPIO_H
#include <system_stm32f10x.h>
#include <stm32f10x_gpio.h>
#include "config.h"
// GPIO definitions for devices we use
#if defined (RS41)
#define BANK_SHUTDOWN GPIOA
#define PIN_SHUTDOWN GPIO_Pin_12
#define BANK_VOLTAGE GPIOA
#define PIN_VOLTAGE GPIO_Pin_5
#define ADC_VOLTAGE ADC1
#define CHANNEL_VOLTAGE ADC_Channel_5
#define BANK_BUTTON GPIOA
#define PIN_BUTTON GPIO_Pin_6
#define ADC_BUTTON ADC1
#define CHANNEL_BUTTON ADC_Channel_6
#define BANK_RED_LED GPIOB
#define PIN_RED_LED GPIO_Pin_8
#define BANK_GREEN_LED GPIOB
#define PIN_GREEN_LED GPIO_Pin_7
#define BANK_MOSI GPIOB
#define PIN_MOSI GPIO_Pin_15
#define BANK_SCK GPIOB
#define PIN_SCK GPIO_Pin_13
#define BANK_MISO GPIOB
#define PIN_MISO GPIO_Pin_14
#define APBPERIPHERAL_SPI RCC_APB1Periph_SPI2
#define PERIPHERAL_SPI SPI2
#define RCC_SPIPeriphClockCmd RCC_APB1PeriphClockCmd
#define PIN_USART_TX GPIO_Pin_9
#define BANK_USART_TX GPIOA
#define PIN_USART_RX GPIO_Pin_10
#define BANK_USART_RX GPIOA
#define USART_IRQ USART1_IRQn
#define USART_IT USART1
#define APBPERIPHERAL_USART RCC_APB2Periph_USART1
#define USART_IRQ_HANDLER USART1_IRQHandler
#elif defined (DFM17)
#define BANK_SHUTDOWN GPIOC
#define PIN_SHUTDOWN GPIO_Pin_0
#define BANK_VOLTAGE GPIOA // Needs confirmation
#define PIN_VOLTAGE GPIO_Pin_0 // Needs confirmation
#define ADC_VOLTAGE ADC1 // Needs confirmation
#define CHANNEL_VOLTAGE ADC_Channel_0 // Needs confirmation
#define BANK_BUTTON GPIOC
#define PIN_BUTTON GPIO_Pin_8
// No ADC available on the GPIOC, so we have to use digital reads/writes for the button
#define BANK_RED_LED GPIOB
#define PIN_RED_LED GPIO_Pin_12
#define BANK_GREEN_LED GPIOC
#define PIN_GREEN_LED GPIO_Pin_6
#define BANK_YELLOW_LED GPIOC
#define PIN_YELLOW_LED GPIO_Pin_7
#define BANK_MOSI GPIOA
#define PIN_MOSI GPIO_Pin_7
#define BANK_SCK GPIOA
#define PIN_SCK GPIO_Pin_5
#define BANK_MISO GPIOA
#define PIN_MISO GPIO_Pin_6
#define APBPERIPHERAL_SPI RCC_APB2Periph_SPI1
#define PERIPHERAL_SPI SPI1
#define RCC_SPIPeriphClockCmd RCC_APB2PeriphClockCmd
#define PIN_USART_TX GPIO_Pin_2
#define BANK_USART_TX GPIOA
#define PIN_USART_RX GPIO_Pin_3
#define BANK_USART_RX GPIOA
#define USART_IRQ USART2_IRQn
#define USART_IT USART2
#define APBPERIPHERAL_USART RCC_APB1Periph_USART2
#define USART_IRQ_HANDLER USART2_IRQHandler
#else
Compiler error. You must define RS41 or DFM17.
#endif // RS41 or DFM17
// Hardware Sanity Check
#if defined (RS41) && defined (DFM17)
Compiler error. You must define RS41 or DFM17 but not both.
#endif
#endif // __GPIO_H

Wyświetl plik

@ -11,6 +11,7 @@
#include "system.h"
#include "delay.h"
#include "log.h"
#include "hal/gpio.h"
#include "hal/cmsis/core_cm3.h" // for NVIC_SystemReset
#define BUTTON_PRESS_LONG_COUNT SYSTEM_SCHEDULER_TIMER_TICKS_PER_SECOND

Wyświetl plik

@ -15,6 +15,8 @@
#include "config.h"
#include "log.h"
uint32_t counter = 0;
bool led_state = true;
uint32_t noFixCounter = 0;
@ -27,7 +29,7 @@ void handle_timer_tick()
{
if (inuse_handle_timer_tick) { return; }
else {
inuse_handle_timer_tick = true;
inuse_handle_timer_tick = true;
}
if (!system_initialized) {
inuse_handle_timer_tick = false;
@ -37,6 +39,7 @@ void handle_timer_tick()
counter = (counter + 1) % SYSTEM_SCHEDULER_TIMER_TICKS_PER_SECOND;
if (counter == 0) {
// WATCHDOG - Check, if lost GPX-Fix for longer then GPS_REBOOT_MISSING_GPS_FIX_SECONDS
ubxg6010_get_current_gps_data(&current_gps_data);
if (GPS_REBOOT_MISSING_GPS_FIX_ENABLE) {
if (!GPS_HAS_FIX(current_gps_data)) {
@ -52,11 +55,25 @@ void handle_timer_tick()
// request cold boot on the STM32 processor
inuse_handle_timer_tick = false;
//log_info("** GPS LOST - REBOOT ** \n");
//delay_ms(1000);
nvic_cold_start();
return;
}
}
} else { noFixCounter = 0; }
// WATCHDOG - Check, if no TX after longer then RADIO_TX_LOST_FOR_SECONDS
if (RADIO_TX_LOST_CHECK_ENABLE) {
if (radio_Inc_tx_watchdog_counter() >= RADIO_TX_LOST_FOR_SECONDS) {
radio_reset_tx_watchdog_counter();
// request cold boot on the STM32 processor
inuse_handle_timer_tick = false;
//log_info("** TX LOST - REBOOT ** \n");
nvic_cold_start();
return;
}
} else { radio_reset_tx_watchdog_counter(); }
}
if (leds_enabled) {
@ -185,6 +202,7 @@ int main(void)
log_info("Si5351 init\n");
success = si5351_handler_init();
if (success) {
log_info("Si5351 OK\n");
break;
}
log_error("Si5351 init failed, retrying...");

Wyświetl plik

@ -12,6 +12,7 @@
#include "codecs/mfsk/mfsk.h"
#include "codecs/jtencode/jtencode.h"
#include "drivers/ubxg6010/ubxg6010.h"
#include "radio.h"
#include "radio_internal.h"
#include "radio_si4032.h"
#include "radio_si5351.h"
@ -319,7 +320,10 @@ static volatile uint32_t radio_post_transmit_delay_counter = 0;
static volatile uint32_t radio_next_symbol_counter = 0;
static radio_transmit_entry *radio_start_transmit_entry = NULL;
static uint8_t radio_alternate_frequency = 1;
static uint32_t radio_alternate_frequency_v1 = 1;
static uint32_t radio_alternate_frequency_v2 = 1;
static uint32_t radio_tx_watchdog_counter = 0;
static uint32_t radio_previous_time_sync_scheduled = 0;
@ -404,12 +408,21 @@ static bool radio_start_transmit(radio_transmit_entry *entry)
radio_shared_state.radio_symbol_count_loop = 0;
telemetry_collect(&current_telemetry_data);
#ifdef SEMIHOSTING_ENABLE
log_info("radio_start_transmit template\n");
#endif
if (entry->messages != NULL && entry->message_count > 0) {
#ifdef SEMIHOSTING_ENABLE
log_info("radio_start_transmit template\n");
#endif
template_replace(radio_current_payload_message, sizeof(radio_current_payload_message),
entry->messages[entry->current_message_index], &current_telemetry_data);
} else {
radio_current_payload_message[0] = '\0';
#ifdef SEMIHOSTING_ENABLE
log_info("radio_start_transmit no template filled\n");
#endif
radio_current_payload_message[0] = '\0';
}
radio_current_payload_length = entry->payload_encoder->encode(
@ -418,14 +431,14 @@ static bool radio_start_transmit(radio_transmit_entry *entry)
log_info("Full payload length: %d\n", radio_current_payload_length);
#ifdef SEMIHOSTING_ENABLE
log_info("Payload: ");
log_bytes_hex(radio_current_payload_length, (char *) radio_current_payload);
log_info("\n ");
log_bytes(radio_current_payload_length, (char *) radio_current_payload);
log_info("\n");
log_info("Battery: %d mV\n", current_telemetry_data.battery_voltage_millivolts);
// log_bytes(radio_current_payload_length, (char *) radio_current_payload);
// log_info("\n");
// log_info("Battery: %d mV\n", current_telemetry_data.battery_voltage_millivolts);
#endif
// USART interrupts may interfere with transmission timing
@ -467,7 +480,8 @@ static bool radio_start_transmit(radio_transmit_entry *entry)
break;
case RADIO_DATA_MODE_HORUS_V2:
// GPS should not disturb the timing of Horus modes
enable_gps_during_transmit = true;
// WOHA - Temp false
enable_gps_during_transmit = false;
mfsk_encoder_new(&entry->fsk_encoder, MFSK_4, entry->symbol_rate, HORUS_V2_TONE_SPACING_HZ_SI5351 * 100);
radio_shared_state.radio_current_symbol_rate = entry->fsk_encoder_api->get_symbol_rate(&entry->fsk_encoder);
@ -666,15 +680,26 @@ static void radio_next_transmit_entry()
if (radio_current_transmit_entry->enabled) {
if (radio_current_transmit_entry->data_mode == RADIO_DATA_MODE_HORUS_V2) {
if (RADIO_SI4032_TX_FREQUENCY2_HORUS_V2_ACTIV) {
if (radio_alternate_frequency == 0) {
radio_alternate_frequency = 1;
if (radio_alternate_frequency_v2 == 0) {
radio_alternate_frequency_v2 = 1;
radio_current_transmit_entry->frequency = RADIO_SI4032_TX_FREQUENCY2_HORUS_V2;
} else {
radio_alternate_frequency = 0;
radio_alternate_frequency_v2 = 0;
radio_current_transmit_entry->frequency = RADIO_SI4032_TX_FREQUENCY_HORUS_V2;
}
}
}
if (radio_current_transmit_entry->data_mode == RADIO_DATA_MODE_HORUS_V1) {
if (RADIO_SI4032_TX_FREQUENCY2_HORUS_V1_ACTIV) {
if (radio_alternate_frequency_v1 == 0) {
radio_alternate_frequency_v1 = 1;
radio_current_transmit_entry->frequency = RADIO_SI4032_TX_FREQUENCY2_HORUS_V1;
} else {
radio_alternate_frequency_v1 = 0;
radio_current_transmit_entry->frequency = RADIO_SI4032_TX_FREQUENCY_HORUS_V1;
}
}
}
}
} while (!radio_current_transmit_entry->enabled);
}
@ -724,7 +749,7 @@ bool radio_handle_time_sync()
ubxg6010_get_current_gps_data(&gps);
if (!gps.updated) {
// The GPS data has not been updated yet
// The GPS data has not been updated yet
return false;
}
@ -759,21 +784,23 @@ bool radio_handle_time_sync()
bool is_scheduled_time = time_sync_period_millis < RADIO_TIME_SYNC_THRESHOLD_MS;
log_debug("Time with offset: %lu, sync period: %lu, scheduled: %d\n", time_with_offset_millis, time_sync_period_millis, is_scheduled_time);
// log_info("---- Time with offset: %lu, sync period: %lu, scheduled: %d\n", time_with_offset_millis, time_sync_period_millis, is_scheduled_time);
if (!is_scheduled_time) {
log_info("Time: %lu, GPS fix: %d - Waiting for time sync at every %d seconds with offset of %d\n", time_millis,
/*
log_info("Time: %lu, GPS fix: %d - SyncWait every %d sec+offset %d\n", time_millis,
gps.fix,
radio_current_transmit_entry->time_sync_seconds,
radio_current_transmit_entry->time_sync_seconds_offset);
*/
return false;
}
log_info("Time: %lu, GPS fix: %d, sync period: %lu - Scheduling transmit at %d seconds with offset of %d\n",
/*
log_info("Time: %lu, GPS fix: %d, sync period: %lu - Schedule TX at %d sec+offset %d\n",
time_millis, gps.fix,
time_sync_period_millis, radio_current_transmit_entry->time_sync_seconds,
radio_current_transmit_entry->time_sync_seconds_offset);
*/
radio_previous_time_sync_scheduled = time_millis;
return true;
@ -793,10 +820,13 @@ void radio_handle_main_loop()
}
radio_reset_transmit_delay_counter();
radio_start_transmit_entry = radio_current_transmit_entry;
// log_info("main_loop: oben\n");
} else if (!radio_shared_state.radio_transmission_active && radio_post_transmit_delay_counter == 0) {
// log_info("main_loop: unten\n");
#if defined(SEMIHOSTING_ENABLE) && defined(LOGGING_ENABLE)
telemetry_collect(&current_telemetry_data);
log_info("Battery: %d mV\n", current_telemetry_data.battery_voltage_millivolts);
log_info("Battery: %d mV.\n", current_telemetry_data.battery_voltage_millivolts);
log_info("Internal temperature: %ld C\n", current_telemetry_data.internal_temperature_celsius_100 / 100);
log_info("Time: %02d:%02d:%02d\n",
current_telemetry_data.gps.hours, current_telemetry_data.gps.minutes,
@ -819,12 +849,13 @@ void radio_handle_main_loop()
bool first_symbol = false;
if (radio_start_transmit_entry != NULL) {
log_info("Start transmit\n");
log_info("Start TX\n");
bool success = radio_start_transmit(radio_start_transmit_entry);
start_tick = system_get_tick();
radio_start_transmit_entry = NULL;
if (!success) {
log_info("main_loop: Fehler radio_start_transmit\n");
radio_next_transmit_entry();
return;
}
@ -858,6 +889,10 @@ void radio_handle_main_loop()
radio_next_transmit_entry();
log_info("TX stop\n");
// Watchdog: TX counter reset
radio_reset_tx_watchdog_counter();
/*
log_info("Symbol count (interrupt): %ld\n", radio_shared_state.radio_symbol_count_interrupt);
log_info("Symbol count (loop): %ld\n", radio_shared_state.radio_symbol_count_loop);
log_info("Total ticks: %ld\n", end_tick - start_tick);
@ -865,9 +900,22 @@ void radio_handle_main_loop()
log_info("Symbol rate: %ld\n", radio_shared_state.radio_current_symbol_rate);
log_info("Symbol delay: %ld\n", radio_shared_state.radio_current_symbol_delay_ms_100);
log_info("Tone spacing: %ld\n", radio_shared_state.radio_current_tone_spacing_hz_100);
*/
}
}
void radio_reset_tx_watchdog_counter ()
{
radio_tx_watchdog_counter = 0;
}
uint32_t radio_Inc_tx_watchdog_counter ()
{
radio_tx_watchdog_counter++;
return radio_tx_watchdog_counter;
}
void radio_init()
{
uint8_t count;

Wyświetl plik

@ -6,4 +6,7 @@ void radio_handle_timer_tick();
void radio_handle_data_timer_tick();
void radio_handle_main_loop();
void radio_reset_tx_watchdog_counter ();
uint32_t radio_Inc_tx_watchdog_counter ();
#endif