Changeset - f76c13fc8299
[Not reviewed]
default
0 1 0
Ethan Zonca - 10 years ago 2016-03-07 20:00:41
ez@ethanzonca.com
Cycle through different tones son the si5351
1 file changed with 43 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/main.c
Show inline comments
 
@@ -2,30 +2,63 @@
 
#include "si5351.h"
 
#include "jtencode.h"
 
#include "adc.h"
 
#include "dma.h"
 
#include "i2c.h"
 
#include "usart.h"
 
#include "gpio.h"
 
#include "gps.h"
 
 
 
void sysclk_init(void);
 
#define WSPR_DEFAULT_FREQ 14097100UL
 
#define WSPR_TONE_SPACING 146 // ~1.46 Hz
 
#define WSPR_CTC 10672 // CTC value for WSPR
 
 
char call[7] = "N0CALL";
 
char loc[5] = "AA00";
 
uint8_t dbm = 27;
 
uint8_t tx_buffer[255];
 
 
 
uint32_t freq = WSPR_DEFAULT_FREQ;
 
uint8_t symbol_count = WSPR_SYMBOL_COUNT;
 
uint16_t ctc = WSPR_CTC;
 
uint16_t tone_spacing = WSPR_TONE_SPACING;
 
volatile uint8_t proceed = 0;
 
 
void encode_wspr(void)
 
{
 
    uint8_t i;
 
    //for(i=0; i<255; i++)
 
    //    tx_buffer[i] = 0;
 
 
    wspr_encode(call, loc, dbm, tx_buffer);
 
 
 
    //si5351_output_enable(SI5351_CLK0, 1);
 
 
    for(i=0; i<symbol_count; i++)
 
    {
 
 
        uint32_t freq2 = (freq * 100) + (tx_buffer[i] * tone_spacing);
 
        si5351_set_freq(freq2, 0, SI5351_CLK0);
 
 
          //si5351_set_freq((freq * 100) + (tx_buffer[i] * tone_spacing), 0, SI5351_CLK0);
 
          HAL_Delay(300);
 
          //proceed = 0;
 
          //while(!proceed);
 
    }
 
}
 
 
int main(void)
 
{
 
    HAL_Init();
 
 
    sysclk_init();
 
    gpio_init();
 
    MX_DMA_Init();
 
    MX_ADC_Init();
 
    i2c_init();
 
 
    HAL_GPIO_WritePin(OSC_NOTEN, 0);
 
    HAL_GPIO_WritePin(TCXO_EN, 1);
 
@@ -35,36 +68,44 @@ int main(void)
 
 
    jtencode_init();
 
    //gps_init();
 
    si5351_init(i2c_get(), SI5351_CRYSTAL_LOAD_8PF, 0);
 
    si5351_set_correction(0);
 
    //si5351_set_pll(SI5351_PLL_FIXED, SI5351_PLLA);
 
    //si5351_set_ms_source(SI5351_CLK0, SI5351_PLLA);
 
    si5351_set_freq(WSPR_DEFAULT_FREQ * 100, 0, SI5351_CLK0);
 
    si5351_drive_strength(SI5351_CLK0, SI5351_DRIVE_2MA); // Set for max power if desired (8ma max)
 
    si5351_output_enable(SI5351_CLK0, 1);
 
    //si5351_pll_reset(SI5351_PLLA);
 
 
    wspr_encode(call, loc, dbm, tx_buffer);
 
    //wspr_encode(call, loc, dbm, tx_buffer);
 
 
    encode_wspr();
 
 
    HAL_Delay(1000);
 
 
    uint32_t led_timer = HAL_GetTick();
 
    uint32_t last_gps  = HAL_GetTick();
 
    uint32_t last_wspr  = HAL_GetTick();
 
 
    while (1)
 
    {
 
        if(HAL_GetTick() - last_wspr > 6000)
 
        {
 
            last_wspr = HAL_GetTick();
 
        }
 
        
 
        if(HAL_GetTick() - led_timer > 100)
 
        {
 
            HAL_GPIO_TogglePin(LED_BLUE);
 
            //HAL_GPIO_TogglePin(LED_BLUE);
 
            led_timer = HAL_GetTick();
 
        }
 
        if(HAL_GetTick() - last_gps > 100)
 
        {
 
//            gps_process();
 
            last_gps = HAL_GetTick();
 
        }
 
    }
 
}
 
 
 
// Initialize system clocks
0 comments (0 inline, 0 general)