Removed_REF_marker
erikkaashoek 5 years ago
parent d55ead2ea8
commit 94e620bf0d

@ -354,7 +354,7 @@
PIN_MODE_INPUT(11) | \
PIN_MODE_INPUT(12) | \
PIN_MODE_OUTPUT(GPIOC_LED) | \
PIN_MODE_INPUT(14) | \
PIN_MODE_OUTPUT(14) | \
PIN_MODE_OUTPUT(15))
#define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(0) | \
PIN_OTYPE_PUSHPULL(1) | \

@ -197,6 +197,7 @@ void SetGenerate(int);
void set_RBW(uint32_t rbw_x10);
void set_drive(int d);
void set_IF(int f);
void set_IF2(int f);
void set_step_delay(int t);
void set_offset_delay(int t);
void set_repeat(int);
@ -471,6 +472,7 @@ typedef struct config {
uint16_t ham_color;
uint16_t gridlines;
uint16_t hambands;
uint32_t frequency_IF2;
int8_t cor_am;
int8_t cor_wfm;
int8_t cor_nfm;

@ -381,6 +381,13 @@ void set_IF(int f)
dirty = true;
}
void set_IF2(int f)
{
config.frequency_IF2 = f;
dirty = true;
}
#define POWER_STEP 0 // Should be 5 dB but appearently it is lower
#define POWER_OFFSET 15
#define SWITCH_ATTENUATION 30
@ -1154,18 +1161,20 @@ void set_freq(int V, unsigned long freq) // translate the requested frequency
ADF4351_set_frequency(V-2,freq,3);
real_old_freq[V] = freq;
}
}
if (V==SI4463_RX) {
if (setting.frequency_step<930000) // maximum step size is 937.49kHz
SI4463_set_freq(freq,setting.frequency_step);
else
SI4463_set_freq(freq,1000);
old_frequency_step = setting.frequency_step;
}
#ifdef __ULTRA_SA__
else {
} else if (V==ADF4351_LO2){
ADF4351_set_frequency(V-2,freq,3);
}
} else
if (V==SI4463_RX) {
if (setting.frequency_step<930000) // maximum step size is 937.49kHz
SI4463_set_freq(freq,setting.frequency_step);
else
SI4463_set_freq(freq,1000);
old_frequency_step = setting.frequency_step;
}
#ifdef __ULTRA_SA__
else {
ADF4351_set_frequency(V-2,freq,3);
}
#endif
old_freq[V] = freq;
}
@ -1843,10 +1852,10 @@ modulation_again:
{ // Else set LO ('s)
#ifdef __ULTRA_SA__
//#define IF_1 2550000000
#define IF_2 2025000000 // First IF in Ultra SA mode
#define IF_2 config.frequency_IF2 // First IF in Ultra SA mode
set_freq (2, IF_2 + lf); // Scanning LO up to IF2
set_freq (3, IF_2 - 433800000); // Down from IF2 to fixed second IF in Ultra SA mode
set_freq (2, config.frequency_IF2 + lf); // Scanning LO up to IF2
set_freq (3, config.frequency_IF2 - 433800000); // Down from IF2 to fixed second IF in Ultra SA mode
set_freq (SI4432_LO, 433800000); // Second IF fixed in Ultra SA mode
#else
#ifdef __SI4432__
@ -1858,15 +1867,20 @@ modulation_again:
#ifdef __ADF4351__
// START_PROFILE;
if (setting.mode == M_LOW) {
uint32_t extra_IF = local_IF;
if (config.frequency_IF2 != 0) {
extra_IF = config.frequency_IF2;
set_freq (ADF4351_LO2, config.frequency_IF2 - local_IF); // Down from IF2 to fixed second IF in Ultra SA mode
}
if (!setting.tracking && S_STATE(setting.below_IF)) { // if in low input mode and below IF
if (lf > local_IF)
set_freq (ADF4351_LO, lf - local_IF); // set LO SI4432 to below IF frequency
if (lf > extra_IF)
set_freq (ADF4351_LO, lf - extra_IF); // set LO SI4432 to below IF frequency
else
set_freq (ADF4351_LO, local_IF-lf); // set LO SI4432 to below IF frequency
set_freq (ADF4351_LO, extra_IF-lf); // set LO SI4432 to below IF frequency
} else
set_freq (ADF4351_LO, local_IF+lf); // otherwise to above IF
set_freq (ADF4351_LO, extra_IF+lf); // otherwise to above IF
} else if (setting.mode == M_HIGH) {
set_freq (SI4463_RX, local_IF+lf); // sweep RX
set_freq (SI4463_RX, local_IF+lf); // sweep RX, local_IF = 0 in high mode
}
// STOP_PROFILE;
#endif

@ -1234,6 +1234,8 @@ void ADF4351_prep_frequency(int channel, unsigned long freq, int drive) // freq
#define Npresc 0 // No High performance mode
#define MIN_DELAY 1
#include <string.h>
void SI4463_write_byte(uint8_t ADR, uint8_t DATA)
@ -1244,14 +1246,14 @@ void SI4463_write_byte(uint8_t ADR, uint8_t DATA)
// SI4432_guard = 1;
// SPI1_CLK_LOW;
palClearPad(GPIOB, GPIOB_RX_SEL);
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
// my_microsecond_delay(SELECT_DELAY);
ADR |= 0x80 ; // RW = 1
shiftOut( ADR );
shiftOut( DATA );
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
palSetPad(GPIOB, GPIOB_RX_SEL);
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
// SI4432_guard = 0;
}
@ -1263,15 +1265,15 @@ void SI4463_write_buffer(uint8_t ADR, uint8_t *DATA, int len)
// SI4432_guard = 1;
// SPI1_CLK_LOW;
palClearPad(GPIOB, GPIOB_RX_SEL);
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
// my_microsecond_delay(SELECT_DELAY);
ADR |= 0x80 ; // RW = 1
shiftOut( ADR );
while (len-- > 0)
shiftOut( *(DATA++) );
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
palSetPad(GPIOB, GPIOB_RX_SEL);
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
// SI4432_guard = 0;
}
@ -1286,13 +1288,13 @@ uint8_t SI4463_read_byte( uint8_t ADR )
// SPI1_CLK_LOW;
set_SPI_mode(SPI_MODE_SI);
palClearPad(GPIOB, GPIOB_RX_SEL);
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
shiftOut( ADR );
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
DATA = shiftIn();
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
palSetPad(GPIOB, GPIOB_RX_SEL);
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
// SI4432_guard = 0;
return DATA ;
}
@ -1306,21 +1308,21 @@ uint8_t SI4463_get_response(void* buff, uint8_t len)
// SI4432_guard = 1;
// SPI1_CLK_LOW;
palClearPad(GPIOB, GPIOB_RX_SEL);
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
shiftOut( SI446X_CMD_READ_CMD_BUFF );
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
cts = (shiftIn() == 0xFF);
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
if (cts)
{
// Get response data
for(uint8_t i=0;i<len;i++) {
((uint8_t*)buff)[i] = shiftIn();
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
}
}
palSetPad(GPIOB, GPIOB_RX_SEL);
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
return cts;
}
@ -1329,7 +1331,7 @@ uint8_t SI4463_wait_response(void* buff, uint8_t len, uint8_t use_timeout)
uint16_t timeout = 40000;
while(!SI4463_get_response(buff, len))
{
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
if(use_timeout && !--timeout)
{
return 0;
@ -1344,14 +1346,14 @@ void SI4463_do_api(void* data, uint8_t len, void* out, uint8_t outLen)
{
// set_SPI_mode(SPI_MODE_SI);
palClearPad(GPIOB, GPIOB_RX_SEL);
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
for(uint8_t i=0;i<len;i++) {
shiftOut(((uint8_t*)data)[i]); // (pgm_read_byte(&((uint8_t*)data)[i]));
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
}
my_microsecond_delay(2);
// my_microsecond_delay(MIN_DELAY);
palSetPad(GPIOB, GPIOB_RX_SEL);
my_microsecond_delay(2);
my_microsecond_delay(MIN_DELAY);
if(((uint8_t*)data)[0] == SI446X_CMD_IRCAL) // If we're doing an IRCAL then wait for its completion without a timeout since it can sometimes take a few seconds
SI4463_wait_response(NULL, 0, false);
else if(out != NULL) // If we have an output buffer then read command response into it

@ -185,6 +185,7 @@ extern si446x_info_t SI4463_info;
void Si446x_getInfo(si446x_info_t* info);
void SI4463_init(void);
#define ADF4351_LO 2
#define ADF4351_LO2 4
#define SI4463_RX 3
#endif

@ -407,7 +407,7 @@ enum {
KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_REFLEVEL, KM_SCALE, KM_ATTENUATION,
KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE,
KM_10MHZ, KM_REPEAT, KM_OFFSET, KM_TRIGGER, KM_LEVELSWEEP, KM_SWEEP_TIME, KM_OFFSET_DELAY,
KM_FAST_SPEEDUP, KM_GRIDLINES, KM_MARKER, KM_MODULATION,KM_COR_AM,KM_COR_WFM, KM_COR_NFM,
KM_FAST_SPEEDUP, KM_GRIDLINES, KM_MARKER, KM_MODULATION,KM_COR_AM,KM_COR_WFM, KM_COR_NFM, KM_IF2,
KM_NONE // always at enum end
};
@ -1642,6 +1642,8 @@ static const menuitem_t menu_settings3[] =
// { MT_KEYPAD, KM_COR_AM, "COR\nAM", "Enter AM modulation correction"},
{ MT_KEYPAD, KM_COR_WFM, "COR\nWFM", "Enter WFM modulation correction"},
{ MT_KEYPAD, KM_COR_NFM, "COR\nNFM", "Enter NFM modulation correction"},
{ MT_KEYPAD | MT_LOW, KM_IF2, "IF2 FREQ", "Set to zero for no IF2"},
#ifdef __HAM_BAND__
{ MT_ADV_CALLBACK, 0, "HAM\nBANDS", menu_settings_ham_bands},
#endif
@ -1970,6 +1972,10 @@ static void fetch_numeric_target(void)
uistat.value = setting.frequency_IF;
plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0);
break;
case KM_IF2:
uistat.value = config.frequency_IF2;
plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0);
break;
case KM_SAMPLETIME:
uistat.value = setting.step_delay;
plot_printf(uistat.text, sizeof uistat.text, "%3dus", ((int32_t)uistat.value));
@ -2087,6 +2093,10 @@ set_numeric_value(void)
case KM_IF:
setting.auto_IF = false;
set_IF(uistat.value);
// config_save();
break;
case KM_IF2:
set_IF2(uistat.value);
// config_save();
break;
case KM_SAMPLETIME:

Loading…
Cancel
Save

Powered by TurnKey Linux.