Skip to content

Commit

Permalink
Merge pull request #1814 from db4ple/lapwing_exp
Browse files Browse the repository at this point in the history
Memory Mode, Ghz Digit Support, Lapwing Support
  • Loading branch information
df8oe authored Oct 26, 2019
2 parents 3e4a97d + dcd53e4 commit c5c8daf
Show file tree
Hide file tree
Showing 8 changed files with 586 additions and 74 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ script:
- mkdir -p mchf-eclipse/build/fw-f4-ili9486-480
- mkdir -p mchf-eclipse/build/fw-f4-small
- mkdir -p mchf-eclipse/build/fw-h7
- mkdir -p mchf-eclipse/build/fw-f7-lapwing
- cd $BUILDLOC/fw-h7
- cd ../bl-h7
- make $MAKEFLAGS -f $ROOTLOC/Makefile OPT_GCC_ARM=$GCC_DIR ROOTLOC=$ROOTLOC BUILDFOR="H7" TRX_ID="i40h7" TRX_NAME="OVI40H7" CONFIGFLAGS="-DUI_BRD_OVI40" bootloader
- cd ../fw-h7
- make $MAKEFLAGS -f $ROOTLOC/Makefile OPT_GCC_ARM=$GCC_DIR ROOTLOC=$ROOTLOC BUILDFOR="H7" TRX_ID="i40h7" TRX_NAME="OVI40H7" CONFIGFLAGS="-DUI_BRD_OVI40 -DRF_BRD_MCHF -DRF_BRD_OVI40" all
- cd ../fw-f7-lapwing
- make $MAKEFLAGS -f $ROOTLOC/Makefile OPT_GCC_ARM=$GCC_DIR ROOTLOC=$ROOTLOC BUILDFOR="F7" TRX_ID="lapf7" TRX_NAME="LAPWING" CONFIGFLAGS="-DUI_BRD_OVI40 -DRF_BRD_LAPWING" all
- cd ../fw-f4
- make $MAKEFLAGS -f $ROOTLOC/Makefile OPT_GCC_ARM=$GCC_DIR ROOTLOC=$ROOTLOC CONFIGFLAGS="-DUI_BRD_MCHF -DRF_BRD_MCHF" all
- cd ../bl-f4
Expand Down
422 changes: 422 additions & 0 deletions mchf-eclipse/.cproject

Large diffs are not rendered by default.

56 changes: 45 additions & 11 deletions mchf-eclipse/drivers/ui/oscillator/osc_si570.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,32 @@
// -------------------------------------------------------------------------------------
// Local Oscillator
// ------------------

// The SI570 Min/Max frequencies are 4x the actual tuning frequencies
#define SI570_MIN_FREQ 10000000 // 10=2.5 MHz
#define SI570_MAX_FREQ 160000000 // 160=40 Mhz
//
// These are "hard limit" frequencies below/above which the synthesizer cannot be adjusted or else the system may crash
#define SI570_HARD_MIN_FREQ 3500000 // 3.5= 0.875 MHz
#define SI570_HARD_MAX_FREQ 220000000 // 220=55 MHz
/* There are two supported alternative choices for the Si570:
USE_SI570_CMOS frequencies up to 160/220 Mhz, used in most boards
USE_SI570_CGRADE frequencies up to 280 Mhz, used in Lapwing
*/
#ifndef RF_BRD_LAPWING
#define USE_SI570_CMOS
#else
#define USE_SI570_CGRADE
#endif

// The SI570 Min/Max frequencies id spec sheet
// The "hard limits" frequencies below/above which the synthesizer cannot be adjusted or else the system may crash
// Lower limits apply to all cases

#define SI570_MIN_FREQ 10000000 //10.0=2.5 MHz
#define SI570_HARD_MIN_FREQ 3500000 // 3.5=0.875 MHz

#ifdef USE_SI570_CGRADE
#define SI570_MAX_FREQ 280000000 // 280=70 Mhz
#define SI570_HARD_MAX_FREQ 280000000 // 280=70 MHz
#endif

#ifdef USE_SI570_CMOS
#define SI570_MAX_FREQ 160000000 // 160=40 Mhz
#define SI570_HARD_MAX_FREQ 220000000 // 220=55 MHz
#endif

#define SI570_RECALL (1<<0)
#define SI570_FREEZE_DCO (1<<4)
Expand Down Expand Up @@ -607,14 +625,31 @@ static bool Oscillator_IsPresent()

static uint32_t Si570_getMinFrequency()
{
#ifdef RF_BRD_LAPWING
return 1240000000L;
#else
return SI570_HARD_MIN_FREQ/4;
#endif
}

static uint32_t Si570_getMaxFrequency()
{
#ifdef RF_BRD_LAPWING
return 1300000000L;
#else
return SI570_HARD_MAX_FREQ/4;
#endif
}

static uint32_t Si570_translateExt2Osc(uint32_t freq)
{
#ifdef RF_BRD_LAPWING
return freq - 1124500000L;
#else
return freq * 4;
// frequency multiplied with 4 since we drive a johnson counter for phased clock generation
#endif
}
const OscillatorInterface_t osc_si570 =
{
.init = Si570_Init,
Expand Down Expand Up @@ -702,7 +737,7 @@ void Si570_Init()

/**
* @brief prepares all necessary information for the next frequency change
* @param freq frequency in Hz to which the LO should be tuned. This is the true LO frequency, i.e. four times the center frequency of the IQ signal
* @param freq frequency in Hz to which the LO should be tuned.
* @param calib the calibration correction value for the real vs. data sheet frequency of the Si570.
* @param temp_factor the SoftTCXO code calculates a temperature correct value which is used to make a virtual tcxo out of the Si570.
*
Expand All @@ -715,8 +750,7 @@ static Oscillator_ResultCodes_t Si570_PrepareNextFrequency(ulong freq, int temp_
if (osc->isPresent() == true) {
float64_t freq_calc, temp_scale;

freq_calc = freq * 4.0;
// frequency multiplied with 4 since we drive a johnson counter for phased clock generation
freq_calc = Si570_translateExt2Osc(freq);

temp_scale = ((float64_t)temp_factor)/14000000.0;
// calculate scaling factor for the temperature correction (referenced to 14.000 MHz)
Expand Down
22 changes: 22 additions & 0 deletions mchf-eclipse/drivers/ui/radio_management.c
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,8 @@ void RadioManagement_SetDemodMode(uint8_t new_mode)
}

/**
* * Is the given frequency in the limits of a band?
* @param bandInfo* ptr to band info for this band
* @param freq the frequency to check
*/
bool RadioManagement_FreqIsInBand(const BandInfo* bandinfo, const uint32_t freq)
Expand All @@ -1273,6 +1275,26 @@ bool RadioManagement_FreqIsInBand(const BandInfo* bandinfo, const uint32_t freq)
return (freq >= bandinfo->tune) && (freq <= (bandinfo->tune + bandinfo->size));
}

/**
* Is the given frequency in an enabled band?
* @param freq the frequency to check
* @returns true if in any of the currently enabled bands
*/
bool RadioManagement_FreqIsInEnabledBand ( uint32_t freq )
{
bool retval = false;
for ( int idx = 0; idx < MAX_BAND_NUM; idx++ )
{
if ( band_enabled[idx] )
{
retval = true;
RadioManagement_FreqIsInBand( bandInfo[idx], freq);
break; // we found the first enabled band following the current one
}
}
return retval;
}

/**
* Identify ham band for a given frequency
* @param freq in Hz
Expand Down
8 changes: 6 additions & 2 deletions mchf-eclipse/drivers/ui/radio_management.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include "uhsdr_types.h"
#include "uhsdr_board.h"
// Frequency public structure

#define MAX_DIGITS 10

typedef struct DialFrequency
{
// pot values
Expand Down Expand Up @@ -52,9 +55,9 @@ typedef struct DialFrequency


// Virtual segments
uint8_t dial_digits[9];
uint8_t dial_digits[MAX_DIGITS];
// Second display
uint8_t sdial_digits[9];
uint8_t sdial_digits[MAX_DIGITS];

} DialFrequency;

Expand Down Expand Up @@ -329,6 +332,7 @@ inline bool RadioManagement_IsTxDisabledBy(uint8_t whom)
uint32_t RadioManagement_GetRealFreqTranslationMode(uint32_t txrx_mode, uint32_t dmod_mode, uint32_t iq_freq_mode);
const BandInfo* RadioManagement_GetBand(ulong freq);
bool RadioManagement_FreqIsInBand(BandInfo_c * bandinfo, const uint32_t freq);
bool RadioManagement_FreqIsInEnabledBand ( uint32_t freq );
const BandInfo* RadioManagement_GetBandInfo(uint8_t new_band_index);
bool RadioManagement_SetPowerLevel(const BandInfo* band, power_level_t power_level);
bool RadioManagement_Tune(bool tune);
Expand Down
23 changes: 17 additions & 6 deletions mchf-eclipse/drivers/ui/ui_configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,15 @@ static uint16_t UiWriteSettingEEPROM_UInt32(uint16_t addrH, uint16_t addrL, uint
static uint32_t UiConfiguration_LimitFrequency(BandInfo_c* bandInfo, const uint32_t freq, bool set_to_default)
{
uint32_t retval = freq;
bool do_reset = false;

#ifndef USE_MEMORY_MODE
// Load default for this band
const uint32_t resetval = bandInfo->tune + DEFAULT_FREQ_OFFSET;
#else
const uint32_t resetval = DEFAULT_MEMORY_FREQ;
#endif


// this code handles the migration of stored frequency settings from the older approach to/from the newer
// approach. We will have to introduce the newer approach with firmware 2.11.0 in order not to cause
Expand All @@ -514,18 +523,20 @@ static uint32_t UiConfiguration_LimitFrequency(BandInfo_c* bandInfo, const uint3

if(set_to_default)
{
// Load default for this band
retval = bandInfo->tune + DEFAULT_FREQ_OFFSET;
do_reset = true;
}
else
{
if((ts.flags2 & FLAGS2_FREQ_MEM_LIMIT_RELAX) == 0 && RadioManagement_FreqIsInBand(bandInfo,retval) == false) // xxxx relax memory-save frequency restrictions and is it within the allowed range?
if((ts.flags2 & FLAGS2_FREQ_MEM_LIMIT_RELAX) == 0)
{
// Load default for this band
retval = bandInfo->tune + DEFAULT_FREQ_OFFSET;
#ifndef USE_MEMORY_MODE
do_reset = RadioManagement_FreqIsInBand(bandInfo,retval) == false; // xxxx relax memory-save frequency restrictions and is it within the allowed range?
#else
do_reset = RadioManagement_FreqIsInEnabledBand(retval) == false;
#endif
}
}
return retval;
return do_reset == true? resetval : retval;
}

void UiReadSettingsBandMode(const uint8_t i, const uint16_t band_mode, const uint16_t band_freq_high, const uint16_t band_freq_low, VfoReg* vforeg, bool load_default)
Expand Down
Loading

0 comments on commit c5c8daf

Please sign in to comment.