Update modes

Removed_REF_marker
erikkaashoek 5 years ago
parent a1e4ac0bb7
commit 183b932157

@ -215,7 +215,8 @@ int is_paused(void);
void set_actual_power(float); void set_actual_power(float);
void SetGenerate(int); void SetGenerate(int);
void set_RBW(uint32_t rbw_x10); void set_RBW(uint32_t rbw_x10);
void set_drive(int d); void set_lo_drive(int d);
void set_rx_drive(int d);
void set_IF(int f); void set_IF(int f);
void set_IF2(int f); void set_IF2(int f);
void set_R(int f); void set_R(int f);
@ -739,7 +740,8 @@ typedef struct setting
int average; int average;
int show_stored; int show_stored;
int subtract_stored; int subtract_stored;
int drive; // 0-7 , 7=+20dBm, 3dB steps int lo_drive; // 0-3 , 3dB steps
int rx_drive; // 0-15 , 7=+20dBm, 3dB steps
int agc; int agc;
int lna; int lna;
int auto_reflevel; int auto_reflevel;
@ -790,6 +792,7 @@ typedef struct setting
float normalize_level; // Level to set normalize to, zero if not doing anything float normalize_level; // Level to set normalize to, zero if not doing anything
int modulation_frequency; int modulation_frequency;
uint32_t checksum; uint32_t checksum;
int ultra;
}setting_t; }setting_t;
extern setting_t setting; extern setting_t setting;

@ -460,7 +460,7 @@ VNA_SHELL_FUNCTION(cmd_d)
(void) argc; (void) argc;
(void) argv; (void) argv;
int32_t a = my_atoi(argv[0]); int32_t a = my_atoi(argv[0]);
setting.drive=a; setting.lo_drive=a;
dirty = true; dirty = true;
} }

@ -66,7 +66,7 @@ void update_min_max_freq(void)
switch(setting.mode) { switch(setting.mode) {
case M_LOW: case M_LOW:
minFreq = 0; minFreq = 0;
maxFreq = DEFAULT_MAX_FREQ; maxFreq = 3000000000; // DEFAULT_MAX_FREQ; <---------------- TODO
break; break;
#ifdef __ULTRA__ #ifdef __ULTRA__
case M_ULTRA: case M_ULTRA:
@ -83,8 +83,8 @@ void update_min_max_freq(void)
maxFreq = HIGH_MAX_FREQ_MHZ * 1000000; maxFreq = HIGH_MAX_FREQ_MHZ * 1000000;
break; break;
case M_GENHIGH: case M_GENHIGH:
minFreq = 240000000; minFreq = 135000000;
maxFreq = 960000000; maxFreq = 4290000000U;
break; break;
} }
} }
@ -108,7 +108,8 @@ void reset_settings(int m)
setting.auto_attenuation = false; setting.auto_attenuation = false;
setting.subtract_stored = 0; setting.subtract_stored = 0;
setting.normalize_level = 0.0; setting.normalize_level = 0.0;
setting.drive=13; setting.lo_drive=1;
setting.rx_drive=13;
setting.atten_step = 0; // Only used in low output mode setting.atten_step = 0; // Only used in low output mode
setting.agc = S_AUTO_ON; setting.agc = S_AUTO_ON;
setting.lna = S_AUTO_OFF; setting.lna = S_AUTO_OFF;
@ -152,6 +153,7 @@ void reset_settings(int m)
setting.attenuate = 0.0; // <---------------- WARNING ----------------- setting.attenuate = 0.0; // <---------------- WARNING -----------------
setting.auto_attenuation = false; // <---------------- WARNING ----------------- setting.auto_attenuation = false; // <---------------- WARNING -----------------
setting.sweep_time_us = 0; setting.sweep_time_us = 0;
setting.lo_drive=1;
break; break;
#ifdef __ULTRA__ #ifdef __ULTRA__
case M_ULTRA: case M_ULTRA:
@ -162,7 +164,8 @@ void reset_settings(int m)
break; break;
#endif #endif
case M_GENLOW: case M_GENLOW:
setting.drive=8; setting.rx_drive=8;
setting.lo_drive=1;
set_sweep_frequency(ST_CENTER, 10000000); set_sweep_frequency(ST_CENTER, 10000000);
set_sweep_frequency(ST_SPAN, 0); set_sweep_frequency(ST_SPAN, 0);
setting.sweep_time_us = 10*ONE_SECOND_TIME; setting.sweep_time_us = 10*ONE_SECOND_TIME;
@ -173,7 +176,7 @@ void reset_settings(int m)
setting.sweep_time_us = 0; setting.sweep_time_us = 0;
break; break;
case M_GENHIGH: case M_GENHIGH:
setting.drive=8; setting.lo_drive=1;
set_sweep_frequency(ST_CENTER, 300000000); set_sweep_frequency(ST_CENTER, 300000000);
set_sweep_frequency(ST_SPAN, 0); set_sweep_frequency(ST_SPAN, 0);
setting.sweep_time_us = 10*ONE_SECOND_TIME; setting.sweep_time_us = 10*ONE_SECOND_TIME;
@ -276,9 +279,15 @@ void set_measurement(int m)
} }
dirty = true; dirty = true;
} }
void set_drive(int d) void set_lo_drive(int d)
{
setting.lo_drive = d;
dirty = true;
}
void set_rx_drive(int d)
{ {
setting.drive = d; setting.rx_drive = d;
dirty = true; dirty = true;
} }
@ -433,7 +442,7 @@ float get_attenuation(void)
if (setting.atten_step) if (setting.atten_step)
return ( -(POWER_OFFSET + setting.attenuate - (setting.atten_step-1)*POWER_STEP + SWITCH_ATTENUATION)); return ( -(POWER_OFFSET + setting.attenuate - (setting.atten_step-1)*POWER_STEP + SWITCH_ATTENUATION));
else else
return ( -POWER_OFFSET - setting.attenuate + (setting.drive & 7) * 3); return ( -POWER_OFFSET - setting.attenuate + (setting.rx_drive & 7) * 3);
} else if (setting.atten_step) { } else if (setting.atten_step) {
if (setting.mode == M_LOW) if (setting.mode == M_LOW)
return setting.attenuate + RECEIVE_SWITCH_ATTENUATION; return setting.attenuate + RECEIVE_SWITCH_ATTENUATION;
@ -448,9 +457,9 @@ static pureRSSI_t get_signal_path_loss(void){
if (setting.mode == M_ULTRA) if (setting.mode == M_ULTRA)
return float_TO_PURE_RSSI(-15); // Loss in dB, -9.5 for v0.1, -12.5 for v0.2 return float_TO_PURE_RSSI(-15); // Loss in dB, -9.5 for v0.1, -12.5 for v0.2
#endif #endif
if (setting.mode == M_LOW) // if (setting.mode == M_LOW)
return float_TO_PURE_RSSI(-5.5); // Loss in dB, -9.5 for v0.1, -12.5 for v0.2 // return float_TO_PURE_RSSI(-5.5); // Loss in dB, -9.5 for v0.1, -12.5 for v0.2
return float_TO_PURE_RSSI(+7); // Loss in dB (+ is gain) return float_TO_PURE_RSSI(0); // Loss in dB (+ is gain)
} }
static const int drive_dBm [16] = {-38,-35,-33,-30,-27,-24,-21,-19,-7,-4,-2, 1, 4, 7, 10, 13}; static const int drive_dBm [16] = {-38,-35,-33,-30,-27,-24,-21,-19,-7,-4,-2, 1, 4, 7, 10, 13};
@ -463,7 +472,7 @@ void set_level(float v) // Set the drive level of the LO
d++; d++;
if (d == 8 && v < -12) // Round towards closest level if (d == 8 && v < -12) // Round towards closest level
d = 7; d = 7;
set_drive(d); set_rx_drive(d);
} else { } else {
setting.level = v; setting.level = v;
set_attenuation((int)v); set_attenuation((int)v);
@ -476,16 +485,16 @@ void set_attenuation(float a) // Is used both in output mode and input mod
if (setting.mode == M_GENLOW) { if (setting.mode == M_GENLOW) {
a = a + POWER_OFFSET; a = a + POWER_OFFSET;
if (a > 6) { // +9dB if (a > 6) { // +9dB
setting.drive = 11; // Maximum save drive for SAW filters. setting.rx_drive = 11; // Maximum save drive for SAW filters.
a = a - 9; a = a - 9;
} else if (a > 3) { // +6dB } else if (a > 3) { // +6dB
setting.drive = 10; setting.rx_drive = 10;
a = a - 6; a = a - 6;
} else if (a > 0) { // +3dB } else if (a > 0) { // +3dB
setting.drive = 9; setting.rx_drive = 9;
a = a - 3; a = a - 3;
} else } else
setting.drive = 8; // defined as 0dB level setting.rx_drive = 8; // defined as 0dB level
if (a > 0) if (a > 0)
a = 0; a = 0;
if( a > - SWITCH_ATTENUATION) { if( a > - SWITCH_ATTENUATION) {
@ -1116,7 +1125,12 @@ void setupSA(void)
#endif #endif
ADF4351_Setup(); ADF4351_Setup();
#if 0 // Measure fast scan time enable_lna(false);
enable_ultra(false);
enable_rx_output(false);
enable_high(false);
#if 0 // Measure fast scan time
setting.sweep_time_us = 0; setting.sweep_time_us = 0;
setting.additional_step_delay_us = 0; setting.additional_step_delay_us = 0;
START_PROFILE // measure 90 points to get overhead START_PROFILE // measure 90 points to get overhead
@ -1216,10 +1230,10 @@ void set_freq(int V, unsigned long freq) // translate the requested frequency
} }
#endif #endif
if (freq) { if (freq) {
real_old_freq[V] = ADF4351_set_frequency(V-ADF4351_LO,freq,setting.drive-12); real_old_freq[V] = ADF4351_set_frequency(V-ADF4351_LO,freq);
} }
} else if (V==ADF4351_LO2){ } else if (V==ADF4351_LO2){
real_old_freq[V] = ADF4351_set_frequency(V-ADF4351_LO,freq,setting.drive-12); real_old_freq[V] = ADF4351_set_frequency(V-ADF4351_LO, freq);
} else } else
if (V==SI4463_RX) { if (V==SI4463_RX) {
SI4463_set_freq(freq); SI4463_set_freq(freq);
@ -1275,6 +1289,10 @@ case M_ULTRA:
SI4463_init_rx(); // Must be before ADF4351_setup!!!! SI4463_init_rx(); // Must be before ADF4351_setup!!!!
#endif #endif
set_AGC_LNA(); set_AGC_LNA();
ADF4351_enable(true);
ADF4351_drive(setting.lo_drive);
ADF4351_enable_aux_out(false);
ADF4351_enable_out(true);
#ifdef __SI4432__ #ifdef __SI4432__
SI4432_Sel = SI4432_LO ; SI4432_Sel = SI4432_LO ;
@ -1286,6 +1304,10 @@ case M_ULTRA:
SI4432_Transmit(setting.drive); SI4432_Transmit(setting.drive);
// set_calibration_freq(setting.refer); // set_calibration_freq(setting.refer);
#endif #endif
enable_rx_output(false);
enable_high(false);
enable_lna(setting.lna);
enable_ultra(setting.ultra);
break; break;
case M_HIGH: // Direct into 1 case M_HIGH: // Direct into 1
mute: mute:
@ -1307,6 +1329,14 @@ mute:
SI4463_init_rx(); SI4463_init_rx();
#endif #endif
set_AGC_LNA(); set_AGC_LNA();
ADF4351_enable_aux_out(false);
ADF4351_enable_out(false);
ADF4351_enable(false);
enable_rx_output(false);
enable_high(true);
enable_lna(false);
enable_ultra(false);
break; break;
case M_GENLOW: // Mixed output from 0 case M_GENLOW: // Mixed output from 0
@ -1333,6 +1363,20 @@ case M_GENLOW: // Mixed output from 0
#ifdef __SI4468__ #ifdef __SI4468__
SI4463_init_tx(); SI4463_init_tx();
#endif #endif
ADF4351_enable_out(true);
ADF4351_drive(setting.lo_drive);
ADF4351_enable(true);
ADF4351_enable_aux_out(false);
if (setting.atten_step) { // use switch as attenuator
enable_rx_output(false);
} else {
enable_rx_output(true);
}
SI4463_set_output_level(setting.rx_drive);
enable_high(false);
enable_lna(false);
enable_ultra(false);
break; break;
case M_GENHIGH: // Direct output from 1 case M_GENHIGH: // Direct output from 1
if (setting.mute) if (setting.mute)
@ -1351,8 +1395,21 @@ case M_GENHIGH: // Direct output from 1
SI4432_Transmit(setting.drive); SI4432_Transmit(setting.drive);
#endif #endif
#ifdef __SI4468__ #ifdef __SI4468__
SI4463_init_tx(); SI4463_init_rx();
#endif #endif
ADF4351_enable(true);
#ifndef TINYSA4_PROTO
ADF4351_enable_aux_out(false);
ADF4351_enable_out(true);
#else
ADF4351_enable_aux_out(true);
ADF4351_enable_out(false);
#endif
ADF4351_aux_drive(setting.lo_drive);
enable_rx_output(false);
enable_high(true);
enable_lna(false);
enable_ultra(false);
break; break;
} }
@ -1823,10 +1880,10 @@ modulation_again:
if (MODE_HIGH(setting.mode)) { if (MODE_HIGH(setting.mode)) {
local_IF = 0; local_IF = 0;
} else if (MODE_LOW(setting.mode)){ // All low mode } else if (MODE_LOW(setting.mode)){ // All low mode
if (!setting.auto_IF) { if (!setting.auto_IF)
local_IF = setting.frequency_IF; local_IF = setting.frequency_IF;
} else
local_IF = DEFAULT_IF; local_IF = DEFAULT_IF;
if (setting.mode == M_LOW) { if (setting.mode == M_LOW) {
if (tracking) { // VERY SPECIAL CASE!!!!! Measure BPF if (tracking) { // VERY SPECIAL CASE!!!!! Measure BPF
local_IF += lf - reffer_freq[setting.refer]; // Offset so fundamental of reffer is visible local_IF += lf - reffer_freq[setting.refer]; // Offset so fundamental of reffer is visible
@ -1943,8 +2000,10 @@ modulation_again:
local_IF += error_f; local_IF += error_f;
} }
#endif #endif
} else if (MODE_HIGH(setting.mode)) { } else if (setting.mode == M_HIGH) {
set_freq (SI4463_RX, lf); // sweep RX, local_IF = 0 in high mode set_freq (SI4463_RX, lf); // sweep RX, local_IF = 0 in high mode
} else if (setting.mode == M_GENHIGH) {
set_freq (ADF4351_LO, lf); // sweep LO, local_IF = 0 in high mode
} }
// STOP_PROFILE; // STOP_PROFILE;
#endif #endif

@ -51,19 +51,6 @@ static uint32_t old_port_moder;
static uint32_t new_port_moder; static uint32_t new_port_moder;
#endif #endif
#define CS_SI0_HIGH palSetPad(GPIO_RX_SEL_PORT, GPIO_RX_SEL)
#define CS_SI1_HIGH palSetPad(GPIO_RX_SEL_PORT, GPIOB_LO_SEL)
//#define CS_PE_HIGH palSetPad(GPIOA, GPIOA_PE_SEL)
#define RF_POWER_HIGH palSetPad(GPIOB, GPIOB_RF_PWR)
//#define SPI2_CLK_HIGH palSetPad(GPIOB, GPIO_SPI2_CLK)
//#define SPI2_CLK_LOW palClearPad(GPIOB, GPIO_SPI2_CLK)
#define CS_SI0_LOW palClearPad(GPIO_RX_SEL_PORT, GPIO_RX_SEL)
#define CS_SI1_LOW palClearPad(GPIO_RX_SEL_PORT, GPIOB_LO_SEL)
//#define CS_PE_LOW palClearPad(GPIOA, GPIOA_PE_SEL)
#define SPI1_CLK_HIGH palSetPad(GPIOB, GPIOB_SPI_SCLK) #define SPI1_CLK_HIGH palSetPad(GPIOB, GPIOB_SPI_SCLK)
#define SPI1_CLK_LOW palClearPad(GPIOB, GPIOB_SPI_SCLK) #define SPI1_CLK_LOW palClearPad(GPIOB, GPIOB_SPI_SCLK)
@ -944,7 +931,7 @@ void ADF4351_Setup(void)
ADF4351_set_frequency(0,2000000000,0); ADF4351_set_frequency(0,2000000000);
// ADF4351_set_frequency(1,150000000,0); // ADF4351_set_frequency(1,150000000,0);
@ -983,17 +970,19 @@ void ADF4351_Set(int channel)
} }
} }
#if 0
void ADF4351_disable_output(void) void ADF4351_disable_output(void)
{ {
bitClear (registers[4], 5); // digital lock bitClear (registers[4], 5); // main output
ADF4351_Set(0); ADF4351_Set(0);
} }
void ADF4351_enable_output(void) void ADF4351_enable_output(void)
{ {
bitSet (registers[4], 5); // digital lock bitSet (registers[4], 5); // main output
ADF4351_Set(0); ADF4351_Set(0);
} }
#endif
static uint32_t prev_actual_freq = 0; static uint32_t prev_actual_freq = 0;
@ -1001,14 +990,14 @@ void ADF4351_force_refresh(void) {
prev_actual_freq = 0; prev_actual_freq = 0;
} }
uint32_t ADF4351_set_frequency(int channel, uint32_t freq, int drive) // freq / 10Hz uint32_t ADF4351_set_frequency(int channel, uint32_t freq) // freq / 10Hz
{ {
// freq -= 71000; // freq -= 71000;
// SI4463_set_gpio(3,GPIO_HIGH); // SI4463_set_gpio(3,GPIO_HIGH);
// uint32_t offs = ((freq / 1000)* ( 0) )/ 1000; // uint32_t offs = ((freq / 1000)* ( 0) )/ 1000;
uint32_t offs = 0; uint32_t offs = 0;
uint32_t actual_freq = ADF4351_prep_frequency(channel,freq + offs, drive); uint32_t actual_freq = ADF4351_prep_frequency(channel,freq + offs);
// SI4463_set_gpio(3,GPIO_LOW); // SI4463_set_gpio(3,GPIO_LOW);
if (actual_freq != prev_actual_freq) { if (actual_freq != prev_actual_freq) {
//START_PROFILE; //START_PROFILE;
@ -1031,6 +1020,7 @@ void ADF4351_spur_mode(int S)
bitSet (registers[2], 30); // R set to 8 bitSet (registers[2], 30); // R set to 8
else else
bitClear (registers[2], 30); // R set to 8 bitClear (registers[2], 30); // R set to 8
ADF4351_Set(0);
} }
void ADF4351_R_counter(int R) void ADF4351_R_counter(int R)
@ -1056,18 +1046,28 @@ static int old_R;
} }
registers[2] &= ~ (((unsigned long)0x3FF) << 14); registers[2] &= ~ (((unsigned long)0x3FF) << 14);
registers[2] |= (((unsigned long)R) << 14); registers[2] |= (((unsigned long)R) << 14);
ADF4351_Set(0);
} }
void ADF4351_CP(int p) void ADF4351_CP(int p)
{ {
registers[2] &= ~ (((unsigned long)0xF) << 9); registers[2] &= ~ (((unsigned long)0xF) << 9);
registers[2] |= (((unsigned long)p) << 9); registers[2] |= (((unsigned long)p) << 9);
ADF4351_Set(0);
} }
void ADF4351_level(int p) void ADF4351_drive(int p)
{ {
registers[4] &= ~ (((unsigned long)0x3) << 3); registers[4] &= ~ (((unsigned long)0x3) << 3);
registers[4] |= (((unsigned long)p) << 3); registers[4] |= (((unsigned long)p) << 3);
ADF4351_Set(0);
}
void ADF4351_aux_drive(int p)
{
registers[4] &= ~ (((unsigned long)0x3) << 6);
registers[4] |= (((unsigned long)p) << 6);
ADF4351_Set(0);
} }
static uint32_t gcd(uint32_t x, uint32_t y) static uint32_t gcd(uint32_t x, uint32_t y)
@ -1081,7 +1081,7 @@ static uint32_t gcd(uint32_t x, uint32_t y)
return x; return x;
} }
uint32_t ADF4351_prep_frequency(int channel, unsigned long freq, int drive) // freq / 10Hz uint32_t ADF4351_prep_frequency(int channel, unsigned long freq) // freq / 10Hz
{ {
if (freq >= 2200000000) { if (freq >= 2200000000) {
OutputDivider = 1; OutputDivider = 1;
@ -1147,34 +1147,39 @@ uint32_t ADF4351_prep_frequency(int channel, unsigned long freq, int drive) //
registers[1] = MOD << 3; registers[1] = MOD << 3;
registers[1] = registers[1] + 1 ; // restore address "001" registers[1] = registers[1] + 1 ; // restore address "001"
bitSet (registers[1], 27); // Prescaler at 8/9 bitSet (registers[1], 27); // Prescaler at 8/9
if (drive == 0) {
bitClear (registers[4], 3); // +5dBm + out
bitClear (registers[4], 4); // +5dBm
bitClear (registers[4], 6); // +5dBm - out
bitClear (registers[4], 7); // +5dBm
} else if (drive == 1) {
bitSet (registers[4], 6); // +5dBm
bitClear (registers[4], 7); // +5dBm - out
bitSet (registers[4], 3); // +5dBm
bitClear (registers[4], 4); // +5dBm + out
} else if (drive == 2) {
bitClear (registers[4], 6); // +5dBm - out
bitSet (registers[4], 7); // +5dBm
bitClear (registers[4], 3); // +5dBm + out
bitSet (registers[4], 4); // +5dBm
}
else {
bitSet (registers[4], 6); // +5dBm - out
bitSet (registers[4], 7); // +5dBm
bitSet (registers[4], 3); // +5dBm + out
bitSet (registers[4], 4); // +5dBm
}
return actual_freq; return actual_freq;
} }
#endif #endif
void ADF4351_enable(int s)
{
if (s)
bitClear(registers[4], 11); // Inverse logic!!!!!
else
bitSet(registers[4], 11);
ADF4351_Set(0);
}
void ADF4351_enable_aux_out(int s)
{
if (s)
bitSet(registers[4], 8);
else
bitClear(registers[4], 8);
ADF4351_Set(0);
}
void ADF4351_enable_out(int s)
{
if (s)
bitSet(registers[4], 5);
else
bitClear(registers[4], 5);
ADF4351_Set(0);
}
// ------------------------------ SI4463 ------------------------------------- // ------------------------------ SI4463 -------------------------------------
@ -1212,22 +1217,22 @@ int SI4463_wait_for_cts(void)
void SI4463_write_byte(uint8_t ADR, uint8_t DATA) void SI4463_write_byte(uint8_t ADR, uint8_t DATA)
{ {
set_SPI_mode(SPI_MODE_SI); set_SPI_mode(SPI_MODE_SI);
palClearLine(LINE_RX_SEL); SI_CS_LOW;
ADR |= 0x80 ; // RW = 1 ADR |= 0x80 ; // RW = 1
shiftOut( ADR ); shiftOut( ADR );
shiftOut( DATA ); shiftOut( DATA );
palSetLine(LINE_RX_SEL); SI_CS_HIGH;
} }
void SI4463_write_buffer(uint8_t ADR, uint8_t *DATA, int len) void SI4463_write_buffer(uint8_t ADR, uint8_t *DATA, int len)
{ {
set_SPI_mode(SPI_MODE_SI); set_SPI_mode(SPI_MODE_SI);
palClearLine(LINE_RX_SEL); SI_CS_LOW;
ADR |= 0x80 ; // RW = 1 ADR |= 0x80 ; // RW = 1
shiftOut( ADR ); shiftOut( ADR );
while (len-- > 0) while (len-- > 0)
shiftOut( *(DATA++) ); shiftOut( *(DATA++) );
palSetLine(LINE_RX_SEL); SI_CS_HIGH;
} }
@ -1236,10 +1241,10 @@ uint8_t SI4463_read_byte( uint8_t ADR )
set_SPI_mode(SPI_MODE_SI); set_SPI_mode(SPI_MODE_SI);
uint8_t DATA ; uint8_t DATA ;
set_SPI_mode(SPI_MODE_SI); set_SPI_mode(SPI_MODE_SI);
palClearLine(LINE_RX_SEL); SI_CS_LOW;
shiftOut( ADR ); shiftOut( ADR );
DATA = shiftIn(); DATA = shiftIn();
palSetLine(LINE_RX_SEL); SI_CS_HIGH;
return DATA ; return DATA ;
} }
@ -1251,7 +1256,7 @@ uint8_t SI4463_get_response(void* buff, uint8_t len)
if (!cts) { if (!cts) {
return false; return false;
} }
palClearLine(LINE_RX_SEL); SI_CS_LOW;
shiftOut( SI446X_CMD_READ_CMD_BUFF ); shiftOut( SI446X_CMD_READ_CMD_BUFF );
cts = (shiftIn() == 0xFF); cts = (shiftIn() == 0xFF);
if (cts) if (cts)
@ -1261,7 +1266,7 @@ uint8_t SI4463_get_response(void* buff, uint8_t len)
((uint8_t*)buff)[i] = shiftIn(); ((uint8_t*)buff)[i] = shiftIn();
} }
} }
palSetLine(LINE_RX_SEL); SI_CS_HIGH;
return cts; return cts;
} }
@ -1289,11 +1294,11 @@ void SI4463_do_api(void* data, uint8_t len, void* out, uint8_t outLen)
if (SI4463_wait_for_cts()) if (SI4463_wait_for_cts())
#endif #endif
{ {
palClearLine(LINE_RX_SEL); SI_CS_LOW;
for(uint8_t i=0;i<len;i++) { for(uint8_t i=0;i<len;i++) {
shiftOut(((uint8_t*)data)[i]); // (pgm_read_byte(&((uint8_t*)data)[i])); shiftOut(((uint8_t*)data)[i]); // (pgm_read_byte(&((uint8_t*)data)[i]));
} }
palSetLine(LINE_RX_SEL); SI_CS_HIGH;
#if 0 #if 0
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 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
#if 0 #if 0
@ -2114,7 +2119,7 @@ void SI4463_set_freq(uint32_t freq)
while(1) while(1)
my_microsecond_delay(10); my_microsecond_delay(10);
} }
if ((SI4463_band == prev_band)) { if (false && (SI4463_band == prev_band)) {
uint8_t data[] = { uint8_t data[] = {
0x36, 0x36,
(uint8_t) R, // R data[4] (uint8_t) R, // R data[4]
@ -2297,6 +2302,45 @@ again:
prev_band = -1; // 433MHz prev_band = -1; // 433MHz
} }
void enable_lna(int s)
{
#ifdef TINYSA4_PROTO
if (s)
palClearLine(LINE_LNA); // Inverted logic!!!
else
palSetLine(LINE_LNA);
#else
(void)s;
#endif
}
void enable_ultra(int s)
{
#ifdef TINYSA4_PROTO
if (s)
palSetLine(LINE_ULTRA);
else
palClearLine(LINE_ULTRA);
#else
(void)s;
#endif
}
void enable_rx_output(int s)
{
if (s)
SI4463_set_gpio(3,GPIO_HIGH);
else
SI4463_set_gpio(3,GPIO_LOW);
}
void enable_high(int s)
{
if (s)
SI4463_set_gpio(2,GPIO_HIGH);
else
SI4463_set_gpio(2,GPIO_LOW);
}
#pragma GCC pop_options #pragma GCC pop_options

@ -160,18 +160,23 @@ void ADF4351_Setup(void);
void ADF4351_WriteRegister32(int channel, const uint32_t value); void ADF4351_WriteRegister32(int channel, const uint32_t value);
uint32_t ADF4351_set_frequency(int channel, uint32_t freq, int drive_strength); uint32_t ADF4351_set_frequency(int channel, uint32_t freq);
uint32_t ADF4351_prep_frequency(int channel, uint32_t freq, int drive_strength); uint32_t ADF4351_prep_frequency(int channel, uint32_t freq);
//int ADF4351_set_frequency_with_offset(uint32_t freq, int offset, uint8_t drive_strength); //int ADF4351_set_frequency_with_offset(uint32_t freq, int offset, uint8_t drive_strength);
void ADF4351_Set(int channel); void ADF4351_Set(int channel);
void ADF4351_enable_output(void);
void ADF4351_disable_output(void);
void ADF4351_spur_mode(int S); void ADF4351_spur_mode(int S);
void ADF4351_R_counter(int R); void ADF4351_R_counter(int R);
void ADF4351_channel_spacing(int spacing); void ADF4351_channel_spacing(int spacing);
void ADF4351_CP(int p); void ADF4351_CP(int p);
void ADF4351_level(int p); void ADF4351_drive(int p);
void ADF4351_aux_drive(int p);
void ADF4351_enable(int p);
void ADF4351_enable_aux_out(int p);
void ADF4351_enable_out(int p);
int ADF4351_locked(void); int ADF4351_locked(void);
void ADF4351_enable(int s);
void ADF4351_enable_aux_out(int s);
#endif #endif
#ifdef __SI4463__ #ifdef __SI4463__
@ -191,4 +196,12 @@ void SI4463_init(void);
#endif #endif
#ifdef TINYSA4
void enable_lna(int s);
void enable_ultra(int s);
void enable_rx_output(int s);
void enable_high(int s);
#endif
#endif //__SI4432_H__ #endif //__SI4432_H__

@ -427,7 +427,7 @@ static const struct {
{keypads_plusmin_unit, "ACTUAL\nPOWER"}, // actual power {keypads_plusmin_unit, "ACTUAL\nPOWER"}, // actual power
{keypads_freq , "IF"}, // IF {keypads_freq , "IF"}, // IF
{keypads_positive , "SAMPLE\nDELAY"}, // sample delay {keypads_positive , "SAMPLE\nDELAY"}, // sample delay
{keypads_positive , "DRIVE"}, // drive {keypads_positive , "DRIVE"}, // KM_DRIVE
{keypads_plusmin , "LEVEL"}, // KM_LOWOUTLEVEL {keypads_plusmin , "LEVEL"}, // KM_LOWOUTLEVEL
{keypads_positive , "SCANS"}, // KM_DECAY {keypads_positive , "SCANS"}, // KM_DECAY
{keypads_positive , "NOISE\nLEVEL"}, // KM_NOISE {keypads_positive , "NOISE\nLEVEL"}, // KM_NOISE
@ -704,11 +704,27 @@ static UI_FUNCTION_ADV_CALLBACK(menu_drive_acb)
(void)item; (void)item;
if(b){ if(b){
b->param_1.i = menu_drive_value[data]; b->param_1.i = menu_drive_value[data];
b->icon = data == setting.drive ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP; b->icon = data == setting.rx_drive ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return; return;
} }
//Serial.println(item); //Serial.println(item);
set_drive(data); set_rx_drive(data);
menu_move_back();
// ui_mode_normal();
// draw_cal_status();
}
const int8_t menu_lo_drive_value[]={4,7,10,13};
static UI_FUNCTION_ADV_CALLBACK(menu_lo_drive_acb)
{
(void)item;
if(b){
b->param_1.i = menu_lo_drive_value[data];
b->icon = data == setting.lo_drive ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return;
}
//Serial.println(item);
set_lo_drive(data);
menu_move_back(); menu_move_back();
// ui_mode_normal(); // ui_mode_normal();
// draw_cal_status(); // draw_cal_status();
@ -718,7 +734,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_sdrive_acb){
(void)item; (void)item;
(void)data; (void)data;
if(b){ if(b){
b->param_1.i = menu_drive_value[setting.drive]; b->param_1.i = menu_drive_value[setting.lo_drive];
return; return;
} }
menu_push_submenu(menu_drive_wide); menu_push_submenu(menu_drive_wide);
@ -1378,11 +1394,11 @@ static const menuitem_t menu_load_preset[] =
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_drive[] = { static const menuitem_t menu_lo_drive[] = {
{ MT_ADV_CALLBACK, 15, "%+ddBm", menu_drive_acb}, { MT_ADV_CALLBACK, 3, "%+ddBm", menu_lo_drive_acb},
{ MT_ADV_CALLBACK, 14, "%+ddBm", menu_drive_acb}, { MT_ADV_CALLBACK, 2, "%+ddBm", menu_lo_drive_acb},
{ MT_ADV_CALLBACK, 13, "%+ddBm", menu_drive_acb}, { MT_ADV_CALLBACK, 1, "%+ddBm", menu_lo_drive_acb},
{ MT_ADV_CALLBACK, 12, "%+ddBm", menu_drive_acb}, { MT_ADV_CALLBACK, 0, "%+ddBm", menu_lo_drive_acb},
{ MT_CANCEL, 255, S_LARROW" BACK", NULL }, { MT_CANCEL, 255, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
@ -1709,7 +1725,7 @@ static const menuitem_t menu_settings[] =
{ MT_KEYPAD | MT_LOW, KM_IF, "IF FREQ", "Set to zero for auto IF"}, { MT_KEYPAD | MT_LOW, KM_IF, "IF FREQ", "Set to zero for auto IF"},
{ MT_SUBMENU,0, "SCAN SPEED", menu_scanning_speed}, { MT_SUBMENU,0, "SCAN SPEED", menu_scanning_speed},
{ MT_KEYPAD, KM_REPEAT, "SAMPLE\nREPEAT", "1..100"}, { MT_KEYPAD, KM_REPEAT, "SAMPLE\nREPEAT", "1..100"},
{ MT_SUBMENU | MT_LOW,0, "MIXER\nDRIVE", menu_drive}, { MT_SUBMENU | MT_LOW,0, "MIXER\nDRIVE", menu_lo_drive},
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_settings2}, { MT_SUBMENU, 0, S_RARROW" MORE", menu_settings2},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
@ -2024,7 +2040,7 @@ static void fetch_numeric_target(void)
plot_printf(uistat.text, sizeof uistat.text, "%2d", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%2d", ((int32_t)uistat.value));
break; break;
case KM_DRIVE: case KM_DRIVE:
uistat.value = setting.drive; uistat.value = setting.rx_drive;
plot_printf(uistat.text, sizeof uistat.text, "%3ddB", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%3ddB", ((int32_t)uistat.value));
break; break;
case KM_LOWOUTLEVEL: case KM_LOWOUTLEVEL:
@ -2159,7 +2175,7 @@ set_numeric_value(void)
set_repeat(uistat.value); set_repeat(uistat.value);
break; break;
case KM_DRIVE: case KM_DRIVE:
set_drive(uistat.value); set_rx_drive(uistat.value);
break; break;
case KM_LOWOUTLEVEL: case KM_LOWOUTLEVEL:
set_level(uistat.value); set_level(uistat.value);

Loading…
Cancel
Save

Powered by TurnKey Linux.