Changeset - 30ab6b66325f
[Not reviewed]
default
0 12 0
Ethan Zonca - 7 years ago 2019-09-01 19:12:19
ez@ethanzonca.com
Add pilot tone and some power-saving stuff that really doesn't help at all
11 files changed with 100 insertions and 49 deletions:
0 comments (0 inline, 0 general)
.cproject
Show inline comments
 
@@ -8,18 +8,20 @@
 
					<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
 
					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
 
					<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
 
					<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
 
					<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
 
					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
 
					<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
 
					<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
 
				</extensions>
 
			</storageModule>
 
			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
 
				<configuration buildProperties="" id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1766192373" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
 
				<configuration artifactName="${ProjName}" buildProperties="" description="" id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1766192373" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
 
					<folderInfo id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1766192373.916722003" name="/" resourcePath="">
 
						<toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1146369181" name="Cross ARM GCC" superClass="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base">
 
						<toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1146369181" name="Cross ARM GCC">
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.architecture.1198449147" name="Architecture" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.architecture"/>
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.prefix.1554715887" name="Prefix" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.prefix"/>
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.suffix.1885501034" name="Suffix" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.suffix"/>
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.c.346952497" name="C compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.c"/>
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.cpp.1266843195" name="C++ compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.cpp"/>
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.ar.1782451793" name="Archiver" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.ar"/>
 
@@ -84,46 +86,14 @@
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.other.832542964" name="Other warning flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.other"/>
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.300518905" name="Debug level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level"/>
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format.925925746" name="Debug format" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format"/>
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.prof.1656054194" name="Generate prof information (-p)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.prof"/>
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.gprof.854647627" name="Generate gprof information (-pg)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.gprof"/>
 
							<option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.other.1915699559" name="Other debugging flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.other"/>
 
							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.971030964" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/>
 
							<builder id="ilg.gnuarmeclipse.managedbuild.cross.builder.2082002245" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="ilg.gnuarmeclipse.managedbuild.cross.builder"/>
 
							<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.1134351891" name="Cross ARM GNU Assembler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler">
 
								<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1814170446" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
 
								<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.1976458517" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/>
 
							</tool>
 
							<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.66269454" name="Cross ARM C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler">
 
								<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.1877426653" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
 
							</tool>
 
							<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.31521072" name="Cross ARM C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler">
 
								<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.538112757" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
 
							</tool>
 
							<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.695260548" name="Cross ARM C Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker">
 
								<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.gcsections.1175234160" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
 
							</tool>
 
							<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.95766250" name="Cross ARM C++ Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker">
 
								<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections.1934782132" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
 
								<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input.2063228079" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input">
 
									<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
 
									<additionalInput kind="additionalinput" paths="$(LIBS)"/>
 
								</inputType>
 
							</tool>
 
							<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver.943394393" name="Cross ARM GNU Archiver" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver"/>
 
							<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash.1947850374" name="Cross ARM GNU Create Flash Image" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash"/>
 
							<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting.995734243" name="Cross ARM GNU Create Listing" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting">
 
								<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source.363398502" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source" useByScannerDiscovery="false" value="true" valueType="boolean"/>
 
								<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.allheaders.2134601491" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.allheaders" useByScannerDiscovery="false" value="true" valueType="boolean"/>
 
								<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.demangle.1315779547" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.demangle" useByScannerDiscovery="false" value="true" valueType="boolean"/>
 
								<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.linenumbers.75607248" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.linenumbers" useByScannerDiscovery="false" value="true" valueType="boolean"/>
 
								<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.wide.1656042397" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.wide" useByScannerDiscovery="false" value="true" valueType="boolean"/>
 
							</tool>
 
							<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize.1698996853" name="Cross ARM GNU Print Size" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize">
 
								<option id="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format.1148857532" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format" useByScannerDiscovery="false"/>
 
							</tool>
 
							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.971030964" isAbstract="false" osList="all"/>
 
							<builder id="ilg.gnuarmeclipse.managedbuild.cross.builder.2082002245" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder.Default"/>
 
						</toolChain>
 
					</folderInfo>
 
				</configuration>
 
			</storageModule>
 
			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
 
		</cconfiguration>
 
@@ -150,7 +120,9 @@
 
		</scannerConfigBuildInfo>
 
		<scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1766192373;ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1766192373.916722003;ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.31521072;ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.538112757">
 
			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 
		</scannerConfigBuildInfo>
 
	</storageModule>
 
	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
 
	<storageModule moduleId="refreshScope"/>
 
	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
 
</cproject>
.settings/language.settings.xml
Show inline comments
 
@@ -2,13 +2,13 @@
 
<project>
 
	<configuration id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1766192373" name="Default">
 
		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
 
			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 
			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
 
			<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
 
			<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1836845659980131172" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 
			<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1122202595071" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 
				<language-scope id="org.eclipse.cdt.core.gcc"/>
 
				<language-scope id="org.eclipse.cdt.core.g++"/>
 
			</provider>
 
			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
 
		</extension>
 
	</configuration>
Makefile
Show inline comments
 
@@ -35,13 +35,13 @@ USER_INCLUDES =
 
SI5351_INCLUDES = -Ilib/si5351
 

	
 
JTENCODE_INCLUDES = -Ilib/jtencode
 

	
 
# USER_CFLAGS: user C flags (enable warnings, enable debug info)
 
USER_CFLAGS = -Wall -g -ffunction-sections -fdata-sections -Os -fno-common --function-sections -fdata-sections 
 
USER_CFLAGS += -flto
 
#USER_CFLAGS += -flto
 

	
 
# USER_LDFLAGS:  user LD flags
 
USER_LDFLAGS = -fno-exceptions -ffunction-sections -fdata-sections -Wl,--gc-sections 
 
USER_LDFLAGS += -flto
 
USER_LDFLAGS += --static
 
#USER_LDFLAGS += -nostartfiles 
inc/config.h
Show inline comments
 
@@ -3,19 +3,19 @@
 

	
 

	
 
// --------------------------------------------------------------------------
 
// Transmitter config 
 
// --------------------------------------------------------------------------
 

	
 

	
 
//#define LED_DISABLE
 

	
 
// --------------------------------------------------------------------------
 
// ADC config (adc.c)
 
// --------------------------------------------------------------------------
 

	
 
// Temperature sensor offset (die temperature from ambient, esimate, in Celcius)
 
// Temperature sensor offset (die temperature from ambient, estimate, in Celcius)
 
#define ADC_TEMPERATURE_OFFSET -10
 

	
 

	
 
// --------------------------------------------------------------------------
 
// AX.25 config (ax25.c)
 
// --------------------------------------------------------------------------
inc/wspr.h
Show inline comments
 
@@ -3,9 +3,9 @@
 

	
 
// Prototypes
 
void wspr_init(void);
 
void wspr_sleep(void);
 
void wspr_wakeup(void);
 
void wspr_transmit(uint8_t* grid_locator, uint8_t send_alternate);
 

	
 
void wspr_pilot_tone(void);
 

	
 
#endif
lib/si5351/si5351.h
Show inline comments
 
@@ -32,13 +32,13 @@
 
#include <stdint.h>
 
#include "stm32f0xx_hal.h"
 

	
 
/* Define definitions */
 

	
 
#define SI5351_BUS_BASE_ADDR				((0x60 & 0x7f) << 1)
 
#define SI5351_XTAL_FREQ					25000000
 
#define SI5351_XTAL_FREQ					26000000
 
#define SI5351_PLL_FIXED					90000000000ULL
 
#define SI5351_FREQ_MULT					100ULL
 
#define SI5351_DEFAULT_CLK					1000000000ULL
 

	
 
#define SI5351_PLL_VCO_MIN					600000000
 
#define SI5351_PLL_VCO_MAX					900000000
src/adc.c
Show inline comments
 
@@ -69,19 +69,25 @@ void adc_init(void)
 
 
 
}
 
 
void adc_start(void)
 
{
 
	// TODO: Is stopping the clocks enough? Might need to disable periph?
 
    __ADC1_CLK_ENABLE();
 
	__DMA1_CLK_ENABLE();
 
    HAL_ADC_Start_DMA(&hadc, adc_buffer, ADC_BUF_LEN);
 
}
 
 
 
void adc_stop(void)
 
{
 
    HAL_ADC_Stop_DMA(&hadc);
 
    __DMA1_CLK_DISABLE();
 
    __ADC1_CLK_DISABLE();
 
 
}
 
 
 
uint8_t adc_get_vbatt(void)
 
{
 
    return 33; //adc_buffer[0] / 62.5; // tenths of volts ish
src/gpio.c
Show inline comments
 
#include "gpio.h"
 
#include "config.h"
 
 
// Initialize GPIOs
 
void gpio_init(void)
 
{
 
 
  GPIO_InitTypeDef GPIO_InitStruct;
 
 
  /* GPIO Ports Clock Enable */
 
@@ -64,14 +66,16 @@ void gpio_init(void)
 
  HAL_GPIO_WritePin(TCXO_EN_GPIO_Port, TCXO_EN_Pin, 0); // disable
 
 
}
 
 
void led_blink(uint8_t n)
 
{
 
	#ifndef LED_DISABLE
 
    for(int i = 0; i < n; i++)
 
    {
 
        HAL_GPIO_WritePin(LED_BLUE, 1);
 
        HAL_Delay(100);
 
        HAL_GPIO_WritePin(LED_BLUE, 0);
 
        HAL_Delay(100);
 
    }
 
	#endif
 
}
src/main.c
Show inline comments
 
@@ -8,12 +8,13 @@
 
#include "i2c.h"
 
#include "uart.h"
 
#include "gpio.h"
 
#include "wspr.h"
 
#include "rtc.h"
 
#include "gps.h"
 
#include "config.h"
 
 
 
// We have access to the 1PPS pin of the gps... could have trim routine for internal oscillator based on this when we have a fix
 
// Probable wake up 1 minute early -- 0.45min possible +/- on wakeup time with 15min sync intervals
 
 
 
@@ -60,22 +61,29 @@ int main(void)
 
    uint32_t nextwspr_time = 0;
 
    uint8_t nextwspr_time_valid = 0;
 
    uint32_t last_wspr_tx_time = 0;
 
 
    uint8_t packet_type = 0;
 
 
    // Transmit pilot tone to test TX on bootup
 
    HAL_Delay(1000);
 
    wspr_pilot_tone();
 
    adc_stop();
 
    HAL_Delay(1000);
 
 
    while (1)
 
    {
 
    	// TODO: Disable GPIO port clocking when not needed!
 
 
    	// Every 10 minutes, wake up and try to wspr
 
    	if(state == SYSTEM_IDLE && (HAL_GetTick() - last_wspr_tx_time > 60000 * 10))
 
    	{
 
    		state = SYSTEM_GPSACQ;
 
    	}
 
//    	if(state == SYSTEM_IDLE && (HAL_GetTick() - last_wspr_tx_time > 60000 * 10))
 
//    	{
 
//    		state = SYSTEM_GPSACQ;
 
//    	}
 
 
        // Update fix status every 2 seconds
 
        // Update fix status every 2 seconds, only if the GPS is powered on
 
        if(HAL_GetTick() - gps_polltimer > 2000)
 
        {
 
            if(gps_ison())
 
            {
 
            	gps_update_data();
 
 
@@ -139,12 +147,15 @@ int main(void)
 
                if(!gps_ison())
 
                {
 
                	fix_acq_starttime = HAL_GetTick();
 
                    gps_poweron(); // power on and initialize GPS module
 
                }
 
 
                // TODO: Move GPS processing into here from above!
 
 
 
                // If 3d fix with a decent enough precision
 
                if( ((gps_getdata()->fixtype == 2) || (gps_getdata()->fixtype == 3)) && gps_getdata()->pdop < 10 && nextwspr_time_valid == 1)
 
                {
 
                    // Disable GPS module
 
                    gps_poweroff();
 
 
@@ -210,31 +221,32 @@ int main(void)
 
                    HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI);
 
                    HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI);
 
                    HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI);
 
                    HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI);
 
            	}
 
 
                // Schedule next wakeup (maybe 2mins prior ot timeslot if no osc trim)
 
                // Schedule next wakeup (maybe 2mins prior to timeslot if no osc trim)
 
                // Next wakeup should enter SYSTEM_GPSACQ state...
 
 
            } break;
 
 
        }
 
 
 
		#ifndef LED_DISABLE
 
        if(HAL_GetTick() - led_timer > blink_rate)
 
        {
 
            ledpulse();
 
            led_timer = HAL_GetTick();
 
        }
 
 
        if(statled_ontime && HAL_GetTick() - statled_ontime > 10)
 
        {
 
            HAL_GPIO_WritePin(LED_BLUE, 0);
 
            statled_ontime = 0;
 
        }
 
		#endif
 
 
    }
 
}
 
 
static void ledpulse(void)
 
{
src/system.c
Show inline comments
 
@@ -29,12 +29,13 @@ void enter_deepsleep(void)
 
void sysclk_init(void)
 
{
 
    RCC_OscInitTypeDef RCC_OscInitStruct;
 
    RCC_ClkInitTypeDef RCC_ClkInitStruct;
 
    RCC_PeriphCLKInitTypeDef PeriphClkInit;
 

	
 
    // TODO: Probably disable HSI14? This only drives the ADC
 
    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI14|RCC_OSCILLATORTYPE_LSI;
 
    RCC_OscInitStruct.HSIState = RCC_HSI_ON;
 
    RCC_OscInitStruct.HSI14State = RCC_HSI14_ON;
 
    RCC_OscInitStruct.HSICalibrationValue = 16;
 
    RCC_OscInitStruct.HSI14CalibrationValue = 16;
 
    RCC_OscInitStruct.LSIState = RCC_LSI_ON;
src/wspr.c
Show inline comments
 
@@ -2,12 +2,13 @@
 
#include "si5351.h"
 
#include "jtencode.h"
 
#include "gpio.h"
 
#include "wspr.h"
 
#include "i2c.h"
 
#include "gps.h"
 
#include "adc.h"
 
#include "config.h"
 

	
 

	
 
#define WSPR_DEFAULT_FREQ 10140100UL
 
#define WSPR_TONE_SPACING 146 // ~1.46 Hz
 
#define WSPR_CTC 10672 // CTC value for WSPR
 
@@ -301,6 +302,61 @@ void wspr_transmit(uint8_t* grid_locator
 

	
 
    __TIM1_CLK_DISABLE();
 

	
 

	
 
}
 

	
 

	
 
// 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);
 

	
 
}
 

	
0 comments (0 inline, 0 general)