diff --git a/src/wspr.c b/src/wspr.c --- a/src/wspr.c +++ b/src/wspr.c @@ -5,6 +5,7 @@ #include "wspr.h" #include "i2c.h" #include "gps.h" +#include "adc.h" #include "config.h" @@ -304,3 +305,58 @@ void wspr_transmit(uint8_t* grid_locator } + +// Transmit boot-up test tones to check tx +void wspr_pilot_tone(void) +{ + // Bring up TCXO + HAL_GPIO_WritePin(OSC_NOTEN, 0); + HAL_GPIO_WritePin(TCXO_EN, 1); + HAL_Delay(100); + + // Bring up the chip + i2c_init(); + si5351_init(i2c_get(), SI5351_CRYSTAL_LOAD_8PF, 0); + si5351_set_correction(0); + si5351_set_freq(WSPR_DEFAULT_FREQ * 100, 0, SI5351_CLK0); + si5351_drive_strength(SI5351_CLK0, SI5351_DRIVE_6MA); // Set for max power if desired (8ma max) + si5351_output_enable(SI5351_CLK0, 1); + + // Make sure the other outputs of the SI5351 are disabled + si5351_output_enable(SI5351_CLK1, 0); // Disable the clock initially + si5351_output_enable(SI5351_CLK2, 0); // Disable the clock initially + + // disable clock powers + si5351_set_clock_pwr(SI5351_CLK1, 0); + si5351_set_clock_pwr(SI5351_CLK2, 0); + + // Key transmitter + si5351_output_enable(SI5351_CLK0, 1); + + uint8_t tone_table[7] = {50, 100, 70, 50, 0, 10, 0}; + + // Boot-up pilot tones + for(uint8_t i=0; i<7; i++) + { + uint32_t freq2 = (WSPR_DEFAULT_FREQ + 10*tone_table[i]) * 100; + si5351_set_freq(freq2, 0, SI5351_CLK0); + #ifndef LED_DISABLE + HAL_GPIO_TogglePin(LED_BLUE); + #endif + HAL_Delay(500); + } + + + // Disable transmitter + si5351_output_enable(SI5351_CLK0, 0); + + HAL_GPIO_WritePin(OSC_NOTEN, 1); + HAL_GPIO_WritePin(TCXO_EN, 0); + + i2c_deinit(); + + // Make sure LED is off if we had an odd number of toggles above + HAL_GPIO_WritePin(LED_BLUE, 0); + +} +