Changeset - 639ea4c6e941
[Not reviewed]
default
0 1 0
Ethan Zonca - 8 years ago 2017-09-24 16:58:46
ez@ethanzonca.com
Altitude seems to work correctly now!
1 file changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/wspr.c
Show inline comments
 
@@ -63,26 +63,27 @@ void wspr_transmit(uint8_t* grid_locator
 
    // Set power to altitude in m / 150
 
    uint8_t altscaled = gps_getdata()->altitude / 150;
 
    if(altscaled > 60)
 
        altscaled = 60;
 

	
 

	
 
    // If alternate packet, send 0XFXXEN82XX
 
    if(send_alternate)
 
    {
 
        /////////////////////////////////////////////////
 
        // Composite altitude and sub-maidenhead locator
 
        ///////////////////////////////////////////////// 
 
        uint16_t maiden_ext = (loc[4] - 'A') + ((loc[5] - 'A') * 24); // 0-575
 
        uint16_t altitude_mod = gps_getdata()->altitude / 20;   
 
        // Use untrimmed locator
 
        uint32_t maiden_ext = (grid_locator[4] - 'A') + ((grid_locator[5] - 'A') * 24); // 0-575
 
        uint32_t altitude_mod = gps_getdata()->altitude / 20;   
 

	
 
        // Ciel at 21,340 meters
 
        if(altitude_mod > 1067)
 
            altitude_mod = 1067; // Don't overflow into maidenhead!
 
    
 
        // Compose composite altitude (lsbs) with maidenhead locator (msbs)
 
        uint32_t subalt = (1068 * maiden_ext) + (gps_getdata()->altitude / 20);
 

	
 

	
 

	
 
        ////////////////////////////////////////////
 
        // Encode extended maidenhead and altitude
 
@@ -222,24 +223,27 @@ void wspr_transmit(uint8_t* grid_locator
 
    htim1.Instance = TIM1;
 
    htim1.Init.Prescaler = 512 / 4; // FIXED gives 64us ticks from 2mhz clock // gives 64uS ticks from 8MHz ahbclk
 
    htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
 
    htim1.Init.Period = ctc; // Count up to this value (how many 64uS ticks per symbol)
 
    htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
 
    htim1.Init.RepetitionCounter = 0;
 
    HAL_TIM_Base_Init(&htim1);
 
    HAL_TIM_Base_Start_IT(&htim1);
 
    HAL_NVIC_SetPriority(TIM1_BRK_UP_TRG_COM_IRQn, 0, 0);
 
    HAL_NVIC_EnableIRQ(TIM1_BRK_UP_TRG_COM_IRQn);
 

	
 

	
 

	
 
    // TODO: Bring up TCXO sooner! Gotta let it warm up or something
 

	
 
    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_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_8MA); // Set for max power if desired (8ma max)
0 comments (0 inline, 0 general)