Solved SPI bug

Removed_REF_marker
erikkaashoek 5 years ago
parent 8693b7ad67
commit 965823a6cb

@ -335,6 +335,7 @@ void set_SPI_mode(uint16_t mode){
static void send_command(uint8_t cmd, uint8_t len, const uint8_t *data) static void send_command(uint8_t cmd, uint8_t len, const uint8_t *data)
{ {
// Uncomment on low speed SPI (possible get here before previous tx complete) // Uncomment on low speed SPI (possible get here before previous tx complete)
// while (SPI_IN_TX_RX(LCD_SPI))
// while (SPI_IN_TX_RX); // while (SPI_IN_TX_RX);
set_SPI_mode(SPI_MODE_LCD); set_SPI_mode(SPI_MODE_LCD);
LCD_CS_LOW; LCD_CS_LOW;

@ -49,8 +49,8 @@
#define DEFAULT_IF 978000000 #define DEFAULT_IF 978000000
#define DEFAULT_SPUR_IF 979000000 #define DEFAULT_SPUR_IF 979000000
#define DEFAULT_MAX_FREQ 800000000 #define DEFAULT_MAX_FREQ 800000000
#define HIGH_MIN_FREQ_MHZ 110 #define HIGH_MIN_FREQ_MHZ 850
#define HIGH_MAX_FREQ_MHZ 1200 #define HIGH_MAX_FREQ_MHZ 1150
/* /*
* main.c * main.c
*/ */
@ -1069,4 +1069,12 @@ extern int SI4463_R;
void Si4463_set_refer(int ref); void Si4463_set_refer(int ref);
void SI446x_set_AGC_LNA(uint8_t v); void SI446x_set_AGC_LNA(uint8_t v);
#endif #endif
void set_R(int f);
void set_modulo(uint32_t f);
#ifdef __ADF4351__
extern uint32_t ADF4350_modulo;
void ADF4351_Set(int channel);
void ADF4351_force_refresh(void);
#endif
/*EOF*/ /*EOF*/

@ -409,7 +409,15 @@ void set_IF2(int f)
void set_R(int f) void set_R(int f)
{ {
ADF4351_R_counter(f); ADF4351_R_counter(f % 10);
ADF4351_spur_mode(f/10);
dirty = true;
}
void set_modulo(uint32_t f)
{
ADF4350_modulo = f;
//ADF4351_spur_mode(f);
dirty = true; dirty = true;
} }
@ -1145,8 +1153,8 @@ static uint32_t old_frequency_step;
void set_freq(int V, unsigned long freq) // translate the requested frequency into a setting of the SI4432 void set_freq(int V, unsigned long freq) // translate the requested frequency into a setting of the SI4432
{ {
if (old_freq[V] == freq && setting.frequency_step == old_frequency_step) // Do not change HW if not needed // if (old_freq[V] == freq && setting.frequency_step == old_frequency_step) // Do not change HW if not needed
return; // return;
#ifdef __SI4432__ #ifdef __SI4432__
if (V <= 1) { if (V <= 1) {
SI4432_Sel = V; SI4432_Sel = V;
@ -1211,6 +1219,7 @@ void set_freq(int V, unsigned long freq) // translate the requested frequency
} else } else
#endif #endif
if (V==ADF4351_LO){ if (V==ADF4351_LO){
#if 0
if (setting.step_delay_mode == SD_FAST) { // If in fast scanning mode and NOT SI4432_RX !!!!!! if (setting.step_delay_mode == SD_FAST) { // If in fast scanning mode and NOT SI4432_RX !!!!!!
int delta = - (freq - real_old_freq[V]); // delta grows with increasing freq int delta = - (freq - real_old_freq[V]); // delta grows with increasing freq
if (setting.frequency_step < 100000 && 0 < delta && delta < 100000) { if (setting.frequency_step < 100000 && 0 < delta && delta < 100000) {
@ -1220,6 +1229,7 @@ void set_freq(int V, unsigned long freq) // translate the requested frequency
SI4463_start_rx(0 / setting.frequency_step); // Start at maximum positive offset SI4463_start_rx(0 / setting.frequency_step); // Start at maximum positive offset
} }
} }
#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,setting.drive-12);
} }
@ -1672,6 +1682,9 @@ pureRSSI_t perform(bool break_on_operation, int i, uint32_t f, int tracking)
int modulation_delay = 0; int modulation_delay = 0;
int modulation_index = 0; int modulation_index = 0;
if (i == 0 && dirty ) { // if first point in scan and dirty if (i == 0 && dirty ) { // if first point in scan and dirty
#ifdef __ADF4351__
ADF4351_force_refresh();
#endif
calculate_correction(); // pre-calculate correction factor dividers to avoid float division calculate_correction(); // pre-calculate correction factor dividers to avoid float division
apply_settings(); // Initialize HW apply_settings(); // Initialize HW
scandirty = true; // This is the first pass with new settings scandirty = true; // This is the first pass with new settings
@ -1971,6 +1984,7 @@ modulation_again:
local_IF = config.frequency_IF2; local_IF = config.frequency_IF2;
} }
#if 0
if (lf < 500000000 && 0) { if (lf < 500000000 && 0) {
uint32_t tf = ((lf + actual_rbw_x10*200) / 26000000) * 26000000; uint32_t tf = ((lf + actual_rbw_x10*200) / 26000000) * 26000000;
if (tf >= lf && tf < lf + actual_rbw_x10*200) if (tf >= lf && tf < lf + actual_rbw_x10*200)
@ -1978,7 +1992,7 @@ modulation_again:
else else
ADF4351_R_counter(1); ADF4351_R_counter(1);
} }
#endif
uint32_t target_f; uint32_t target_f;
if (!setting.tracking && S_STATE(setting.below_IF)) { // if in low input mode and below IF if (!setting.tracking && S_STATE(setting.below_IF)) { // if in low input mode and below IF

@ -1,5 +1,4 @@
/* All rights reserved. /*
*
* This is free software; you can redistribute it and/or modify * This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option) * the Free Software Foundation; either version 3, or (at your option)
@ -44,7 +43,7 @@
// Hardware or software SPI use // Hardware or software SPI use
#ifdef USE_HARDWARE_SPI_MODE #ifdef USE_HARDWARE_SPI_MODE
#define SI4432_SPI SPI1 #define SI4432_SPI SPI1
#define SI4432_SPI_SPEED SPI_BR_DIV32 #define SI4432_SPI_SPEED SPI_BR_DIV16
//#define SI4432_SPI_SPEED SPI_BR_DIV64 //#define SI4432_SPI_SPEED SPI_BR_DIV64
static uint32_t old_spi_settings; static uint32_t old_spi_settings;
#else #else
@ -134,6 +133,7 @@ static uint8_t shiftIn(void)
{ {
#ifdef USE_HARDWARE_SPI_MODE #ifdef USE_HARDWARE_SPI_MODE
SPI_WRITE_8BIT(SI4432_SPI, 0xFF); SPI_WRITE_8BIT(SI4432_SPI, 0xFF);
while (SPI_IS_BUSY(SI4432_SPI)) // drop rx and wait tx
while (SPI_RX_IS_EMPTY(SI4432_SPI)); //wait rx data in buffer while (SPI_RX_IS_EMPTY(SI4432_SPI)); //wait rx data in buffer
return SPI_READ_8BIT(SI4432_SPI); return SPI_READ_8BIT(SI4432_SPI);
#else #else
@ -917,7 +917,8 @@ double RFout, //Output freq in MHz
unsigned int long RFint, // Output freq/10Hz unsigned int long RFint, // Output freq/10Hz
INTA, // Temp INTA, // Temp
RFcalc, //UI RFcalc, //UI
MOD, //Temp ADF4350_modulo = 3125, //Temp
MOD,
FRAC; //Temp FRAC; //Temp
uint8_t OutputDivider; // Temp uint8_t OutputDivider; // Temp
@ -943,6 +944,8 @@ void ADF4351_Setup(void)
ADF4351_R_counter(1); ADF4351_R_counter(1);
ADF4351_set_frequency(0,2000000000,0); ADF4351_set_frequency(0,2000000000,0);
@ -998,6 +1001,12 @@ void ADF4351_enable_output(void)
ADF4351_Set(0); ADF4351_Set(0);
} }
static uint32_t prev_actual_freq = 0;
void ADF4351_force_refresh(void) {
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, int drive) // freq / 10Hz
{ {
// freq -= 71000; // freq -= 71000;
@ -1005,9 +1014,12 @@ uint32_t ADF4351_set_frequency(int channel, uint32_t freq, int drive) // freq /
// 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, drive);
if (actual_freq != prev_actual_freq) {
//START_PROFILE; //START_PROFILE;
ADF4351_frequency_changed = true; ADF4351_frequency_changed = true;
ADF4351_Set(channel); ADF4351_Set(channel);
prev_actual_freq = actual_freq;
}
//STOP_PROFILE; //STOP_PROFILE;
return actual_freq; return actual_freq;
} }
@ -1126,8 +1138,9 @@ uint32_t ADF4351_prep_frequency(int channel, unsigned long freq, int drive) //
} }
INTA = (RFout * OutputDivider) / PFDRFout[channel]; INTA = (RFout * OutputDivider) / PFDRFout[channel];
// MOD = (PFDRFout[channel] / OutputChannelSpacing) + 0.01; // ADF4350_modulo = (PFDRFout[channel] / OutputChannelSpacing) + 0.01;
MOD = 3125; // ADF4350_modulo = 3125;
MOD = ADF4350_modulo;
FRACF = (((RFout * OutputDivider) / PFDRFout[channel]) - INTA) * MOD; FRACF = (((RFout * OutputDivider) / PFDRFout[channel]) - INTA) * MOD;
FRAC = round(FRACF); FRAC = round(FRACF);
@ -1136,7 +1149,7 @@ uint32_t ADF4351_prep_frequency(int channel, unsigned long freq, int drive) //
MOD = MOD >> 1; MOD = MOD >> 1;
// Serial.println( "MOD/FRAC reduced"); // Serial.println( "MOD/FRAC reduced");
} }
#if 0 // Don't reduce for now <----------------------------------------------------- #if 1 // Don't reduce for now <-----------------------------------------------------
int32_t k = gcd(FRAC, MOD); int32_t k = gcd(FRAC, MOD);
if (k > 1) { if (k > 1) {
FRAC /= k; FRAC /= k;
@ -1240,8 +1253,8 @@ int SI4463_frequency_changed = false;
static int SI4463_band = -1; static int SI4463_band = -1;
static int SI4463_outdiv = -1; static int SI4463_outdiv = -1;
static uint32_t SI4463_prev_freq = 0; static uint32_t SI4463_prev_freq = 0;
float SI4463_step_size = 0; static float SI4463_step_size = 100; // Will be recalculated once used
uint8_t SI4463_channel = 0; static uint8_t SI4463_channel = 0;
int SI4463_R = 5; int SI4463_R = 5;
@ -1377,6 +1390,7 @@ uint8_t SI4463_wait_response(void* buff, uint8_t len, uint8_t use_timeout)
void SI4463_do_api(void* data, uint8_t len, void* out, uint8_t outLen) void SI4463_do_api(void* data, uint8_t len, void* out, uint8_t outLen)
{ {
set_SPI_mode(SPI_MODE_SI);
#if 0 #if 0
if(SI4463_wait_response(NULL, 0, true)) // Make sure it's ok to send a command if(SI4463_wait_response(NULL, 0, true)) // Make sure it's ok to send a command
#else #else
@ -1508,6 +1522,15 @@ retry:
#endif #endif
} }
void SI4463_short_start_rx(void)
{
uint8_t data[] = {
SI446X_CMD_ID_START_RX,
};
retry:
SI4463_do_api(data, sizeof(data), NULL, 0);
}
void SI4463_clear_int_status() void SI4463_clear_int_status()
{ {
uint8_t data[9] = { uint8_t data[9] = {
@ -1570,11 +1593,11 @@ void Si446x_getInfo(si446x_info_t* info)
info->func = data[5]; info->func = data[5];
} }
uint8_t SI4463_get_device_status() static uint8_t SI4463_get_device_status(void)
{ {
uint8_t data[2] = uint8_t data[2] =
{ {
SI446X_CMD_ID_REQUEST_DEVICE_STATE, 0, 0 SI446X_CMD_ID_REQUEST_DEVICE_STATE, 0
}; };
SI4463_do_api(data, 1, data, SI446X_CMD_REPLY_COUNT_REQUEST_DEVICE_STATE); SI4463_do_api(data, 1, data, SI446X_CMD_REPLY_COUNT_REQUEST_DEVICE_STATE);
return(data[0]); return(data[0]);
@ -1592,14 +1615,32 @@ uint8_t getFRR(uint8_t reg)
// Get current radio state // Get current radio state
si446x_state_t getState(void) si446x_state_t getState(void)
{ {
#if 0
#if 0
uint8_t data[2] = {
SI446X_CMD_REQUEST_DEVICE_STATE
};
SI4463_do_api(data, 1, data, 2);
uint8_t state = data[0] & 0x0F;
#endif
uint8_t state = SI4463_get_device_status();
#else
again:
SI4463_wait_for_cts(); SI4463_wait_for_cts();
uint8_t state = getFRR(SI446X_CMD_READ_FRR_B); uint8_t state = getFRR(SI446X_CMD_READ_FRR_B);
#endif
if (state == 255) {
my_microsecond_delay(100);
goto again;
}
if(state == SI446X_STATE_TX_TUNE) if(state == SI446X_STATE_TX_TUNE)
state = SI446X_STATE_TX; state = SI446X_STATE_TX;
else if(state == SI446X_STATE_RX_TUNE) else if(state == SI446X_STATE_RX_TUNE)
state = SI446X_STATE_RX; state = SI446X_STATE_RX;
else if(state == SI446X_STATE_READY2) else if(state == SI446X_STATE_READY2)
state = SI446X_STATE_READY; state = SI446X_STATE_READY;
else
state = state;
return (si446x_state_t)state; return (si446x_state_t)state;
} }
@ -1658,9 +1699,13 @@ int16_t Si446x_RSSI(void)
my_microsecond_delay(SI4432_step_delay); my_microsecond_delay(SI4432_step_delay);
ADF4351_frequency_changed = false; ADF4351_frequency_changed = false;
SI4463_frequency_changed = false; SI4463_frequency_changed = false;
} else if (SI4432_offset_delay && SI4463_frequency_changed) {
my_microsecond_delay(SI4432_offset_delay);
ADF4351_frequency_changed = false;
SI4463_frequency_changed = false;
} }
int i = 3; //setting.repeat; int i = 1; //setting.repeat;
int RSSI_RAW[3]; int RSSI_RAW[3];
do{ do{
@ -1688,7 +1733,7 @@ int16_t Si446x_RSSI(void)
if (i == 0) break; if (i == 0) break;
my_microsecond_delay(100); my_microsecond_delay(100);
}while(1); }while(1);
#if 1 #if 0
int t; int t;
if (RSSI_RAW[0] > RSSI_RAW[1]) { if (RSSI_RAW[0] > RSSI_RAW[1]) {
t = RSSI_RAW[1]; t = RSSI_RAW[1];
@ -2043,12 +2088,13 @@ uint16_t SI4463_force_RBW(int f)
} }
SI4463_clear_int_status(); SI4463_clear_int_status();
retry: retry:
SI4463_start_rx(SI4463_channel); SI4463_short_start_rx();
#if 0
my_microsecond_delay(15000); my_microsecond_delay(15000);
si446x_state_t s = getState(); si446x_state_t s = getState();
if (s != SI446X_STATE_RX) { if (s != SI446X_STATE_RX) {
SI4463_start_rx(SI4463_channel); SI4463_short_start_rx();
osalThreadSleepMilliseconds(1000); osalThreadSleepMilliseconds(1000);
si446x_state_t s = getState(); si446x_state_t s = getState();
if (s != SI446X_STATE_RX) { if (s != SI446X_STATE_RX) {
@ -2058,6 +2104,7 @@ retry:
} }
ili9341_drawstring_7x13("Waiting done ", 50, 200); ili9341_drawstring_7x13("Waiting done ", 50, 200);
} }
#endif
set_RSSI_comp(); set_RSSI_comp();
SI4463_RSSI_correction = float_TO_PURE_RSSI(RBW_choices[f].RSSI_correction_x_10 - 1200)/10; // Set RSSI correction SI4463_RSSI_correction = float_TO_PURE_RSSI(RBW_choices[f].RSSI_correction_x_10 - 1200)/10; // Set RSSI correction
return RBW_choices[f].RBWx10; // RBW achieved by SI4463 in kHz * 10 return RBW_choices[f].RBWx10; // RBW achieved by SI4463 in kHz * 10
@ -2079,9 +2126,9 @@ static int prev_band = -1;
void SI4463_set_freq(uint32_t freq, uint32_t step_size) void SI4463_set_freq(uint32_t freq, uint32_t step_size)
{ {
// uint32_t offs = ((freq / 1000)* 147) / 1000; (void) step_size;
uint32_t offs = 0;
float RFout=(freq+offs)/1000000.0; // To MHz float RFout=freq/1000000.0; // To MHz
if (RFout >= 822 && RFout <= 1140) { // till 1140MHz if (RFout >= 822 && RFout <= 1140) { // till 1140MHz
SI4463_band = 0; SI4463_band = 0;
SI4463_outdiv = 4; SI4463_outdiv = 4;
@ -2107,20 +2154,46 @@ void SI4463_set_freq(uint32_t freq, uint32_t step_size)
return; return;
int S = 4 ; // Aprox 100 Hz channels int S = 4 ; // Aprox 100 Hz channels
SI4463_step_size = S * (Npresc ? 2000000*freq_xco : 4000000*freq_xco) / ((2<<18) * SI4463_outdiv); // SI4463_step_size = S * (Npresc ? 2000000*freq_xco : 4000000*freq_xco) / ((2<<18) * SI4463_outdiv);
// SI4463_channel = (freq - SI4463_prev_freq) / SI4463_step_size; // Recalculate in case step size changed
if (freq < SI4463_prev_freq || freq > SI4463_prev_freq + 255 * SI4463_step_size ) {
SI4463_channel = 0; // 128 <--------------------------BUG!!!!!!!!!!!!!!!!!!!!!!!!!! // if (freq < SI4463_prev_freq || freq > SI4463_prev_freq + 255 * SI4463_step_size ) {
SI4463_prev_freq = freq - SI4463_channel * SI4463_step_size; SI4463_channel = 0;
// SI4463_prev_freq = freq - SI4463_channel * SI4463_step_size;
RFout -= SI4463_channel * SI4463_step_size / 1000000.0; // shift for channel 128
int32_t R = (RFout * SI4463_outdiv) / (Npresc ? 2*freq_xco : 4*freq_xco) - 1; // R between 0x00 and 0x7f (127) int32_t R = (RFout * SI4463_outdiv) / (Npresc ? 2*freq_xco : 4*freq_xco) - 1; // R between 0x00 and 0x7f (127)
float MOD = 524288.0; float MOD = 524288.0;
int32_t F = (((RFout * SI4463_outdiv) / (Npresc ? 2*freq_xco : 4*freq_xco)) - R) * MOD; int32_t F = (((RFout * SI4463_outdiv) / (Npresc ? 2*freq_xco : 4*freq_xco)) - R) * MOD;
if ((SI4463_band == prev_band) /* && !ADF4351_frequency_changed */ ) {
uint8_t data[] = {
0x36,
(uint8_t) R, // R data[4]
(uint8_t) ((F>>16) & 255), // F2,F1,F0 data[5] .. data[7]
(uint8_t) ((F>> 8) & 255), // F2,F1,F0 data[5] .. data[7]
(uint8_t) ((F ) & 255), // F2,F1,F0 data[5] .. data[7]
0x09,
0x66
};
SI4463_do_api(data, sizeof(data), NULL, 0);
#if 0
my_microsecond_delay(200);
si446x_state_t s = getState();
if (s != SI446X_STATE_RX) {
SI4463_short_start_rx();
osalThreadSleepMilliseconds(1000);
si446x_state_t s = getState();
if (s != SI446X_STATE_RX) {
osalThreadSleepMilliseconds(3000);
goto retry;
}
}
#endif
SI4463_frequency_changed = true;
return;
}
setState(SI446X_STATE_READY); setState(SI446X_STATE_READY);
my_microsecond_delay(100); my_microsecond_delay(100);
@ -2152,9 +2225,6 @@ void SI4463_set_freq(uint32_t freq, uint32_t step_size)
0x20, // Window gate 0x20, // Window gate
0xFF // Adj count 0xFF // Adj count
}; };
SI4463_do_api(data, sizeof(data), NULL, 0); SI4463_do_api(data, sizeof(data), NULL, 0);
if (SI4463_band != prev_band) { if (SI4463_band != prev_band) {
@ -2176,9 +2246,14 @@ void SI4463_set_freq(uint32_t freq, uint32_t step_size)
my_microsecond_delay(30000); my_microsecond_delay(30000);
prev_band = SI4463_band; prev_band = SI4463_band;
} }
// SI4463_clear_int_status(); // SI4463_clear_int_status();
retry: retry:
SI4463_start_rx(SI4463_channel); SI4463_start_rx(SI4463_channel);
#if 0
my_microsecond_delay(200); my_microsecond_delay(200);
si446x_state_t s = getState(); si446x_state_t s = getState();
if (s != SI446X_STATE_RX) { if (s != SI446X_STATE_RX) {
@ -2190,30 +2265,10 @@ void SI4463_set_freq(uint32_t freq, uint32_t step_size)
goto retry; goto retry;
} }
} }
} else #endif
{
SI4463_channel = (freq - SI4463_prev_freq)/SI4463_step_size;
SI4463_start_rx(SI4463_channel);
/*
uint8_t data[] = {
0x36,
(uint8_t) R, // R data[4]
(uint8_t) ((F>>16) & 255), // F2,F1,F0 data[5] .. data[7]
(uint8_t) ((F>> 8) & 255), // F2,F1,F0 data[5] .. data[7]
(uint8_t) ((F ) & 255), // F2,F1,F0 data[5] .. data[7]
0x00,
0xFF
};
SI4463_do_api(data, sizeof(data), NULL, 0);
my_microsecond_delay(200);
*/
}
SI4463_frequency_changed = true; SI4463_frequency_changed = true;
} }
void SI4463_init(void) void SI4463_init(void)
{ {
reset: reset:
@ -2223,13 +2278,14 @@ reset:
my_microsecond_delay(1000); my_microsecond_delay(1000);
SI_SDN_LOW; SI_SDN_LOW;
my_microsecond_delay(1000); my_microsecond_delay(1000);
#if 0
ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
while (!SI4463_READ_CTS) { while (!SI4463_READ_CTS) {
ili9341_drawstring_7x13("Waiting", 50, 200); ili9341_drawstring_7x13("Waiting", 50, 200);
my_microsecond_delay(100); my_microsecond_delay(100);
} }
ili9341_drawstring_7x13("Proceed", 50, 200); ili9341_drawstring_7x13("Proceed", 50, 200);
#endif
#if 0 #if 0
for(uint16_t i=0;i<sizeof(SI4463_config);i++) for(uint16_t i=0;i<sizeof(SI4463_config);i++)
@ -2242,10 +2298,10 @@ for(uint16_t i=0;i<sizeof(SI4463_config);i++)
#endif #endif
#ifdef __SI4468__ #ifdef __SI4468__
uint16_t i=0; uint16_t i=0;
#if 0
SI4463_do_api((void *)&SI4468_config[i+1], SI4468_config[i], NULL, 0); SI4463_do_api((void *)&SI4468_config[i+1], SI4468_config[i], NULL, 0);
i += SI4468_config[i]+1; i += SI4468_config[i]+1;
my_microsecond_delay(2000000); my_microsecond_delay(2000000);
#if 0
SI4463_do_api((void *)&SI4468_config[i+1], SI4468_config[i], NULL, 0); SI4463_do_api((void *)&SI4468_config[i+1], SI4468_config[i], NULL, 0);
i += SI4468_config[i]+1; i += SI4468_config[i]+1;
//my_microsecond_delay(2000000); //my_microsecond_delay(2000000);
@ -2266,6 +2322,7 @@ for(;i<sizeof(SI4468_config);i++)
//#define SI446X_ADC_SPEED 10 //#define SI446X_ADC_SPEED 10
// RSSI = getADC(SI446X_ADC_CONV_BATT, (SI446X_ADC_SPEED<<4), 2); // RSSI = getADC(SI446X_ADC_CONV_BATT, (SI446X_ADC_SPEED<<4), 2);
#if 0
volatile si446x_state_t s ; volatile si446x_state_t s ;
again: again:
Si446x_getInfo(&SI4463_info); Si446x_getInfo(&SI4463_info);
@ -2280,6 +2337,7 @@ again:
goto reset; goto reset;
} }
ili9341_drawstring_7x13("Waiting ready ", 50, 200); ili9341_drawstring_7x13("Waiting ready ", 50, 200);
#endif
// Si446x_RSSI(); // Si446x_RSSI();
// goto again; // goto again;

@ -408,7 +408,7 @@ enum {
KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE, 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_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_IF2, KM_FAST_SPEEDUP, KM_GRIDLINES, KM_MARKER, KM_MODULATION,KM_COR_AM,KM_COR_WFM, KM_COR_NFM, KM_IF2,
KM_R, KM_R,KM_MOD,
KM_NONE // always at enum end KM_NONE // always at enum end
}; };
@ -447,6 +447,7 @@ static const struct {
{keypads_plusmin , "COR\nNFM"}, // KM_COR_NFM {keypads_plusmin , "COR\nNFM"}, // KM_COR_NFM
{keypads_freq , "IF2"}, // KM_IF2 {keypads_freq , "IF2"}, // KM_IF2
{keypads_positive , "R"}, // KM_R {keypads_positive , "R"}, // KM_R
{keypads_positive , "MODULO"}, // KM_MOD
}; };
@ -1655,10 +1656,10 @@ static const menuitem_t menu_sweep_speed[] =
{ {
{ MT_ADV_CALLBACK, SD_NORMAL, "NORMAL", menu_scanning_speed_acb}, // order must match definition of enum { MT_ADV_CALLBACK, SD_NORMAL, "NORMAL", menu_scanning_speed_acb}, // order must match definition of enum
{ MT_ADV_CALLBACK, SD_PRECISE, "PRECISE", menu_scanning_speed_acb}, { MT_ADV_CALLBACK, SD_PRECISE, "PRECISE", menu_scanning_speed_acb},
{ MT_ADV_CALLBACK | MT_LOW,SD_FAST, "FAST", menu_scanning_speed_acb}, { MT_ADV_CALLBACK, SD_FAST, "FAST", menu_scanning_speed_acb},
{ MT_KEYPAD, KM_SWEEP_TIME, "SWEEP\nTIME", "0..600s, 0=disable"}, // This must be item 3 to match highlighting { MT_KEYPAD, KM_SWEEP_TIME, "SWEEP\nTIME", "0..600s, 0=disable"}, // This must be item 3 to match highlighting
{ MT_SUBMENU, 0, "SWEEP\nPOINTS", menu_sweep_points}, { MT_SUBMENU, 0, "SWEEP\nPOINTS", menu_sweep_points},
{ MT_KEYPAD | MT_LOW,KM_FAST_SPEEDUP,"FAST\nSPEEDUP", "2..20, 0=disable"}, { MT_KEYPAD, KM_FAST_SPEEDUP,"FAST\nSPEEDUP", "2..20, 0=disable"},
{ 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
}; };
@ -1669,9 +1670,10 @@ static const menuitem_t menu_settings3[] =
{ MT_KEYPAD, KM_GRIDLINES, "MINIMUM\nGRIDLINES", "Enter minimum horizontal grid divisions"}, { MT_KEYPAD, KM_GRIDLINES, "MINIMUM\nGRIDLINES", "Enter minimum horizontal grid divisions"},
// { MT_KEYPAD, KM_COR_AM, "COR\nAM", "Enter AM modulation correction"}, // { 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_WFM, "COR\nWFM", "Enter WFM modulation correction"},
{ MT_KEYPAD, KM_COR_NFM, "COR\nNFM", "Enter NFM 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"}, // { MT_KEYPAD | MT_LOW, KM_IF2, "IF2 FREQ", "Set to zero for no IF2"},
{ MT_KEYPAD, KM_R, "R", "Set R"}, { MT_KEYPAD, KM_R, "R", "Set R"},
{ MT_KEYPAD, KM_MOD, "MODULO", "Set MODULO"},
#ifdef __HAM_BAND__ #ifdef __HAM_BAND__
{ MT_ADV_CALLBACK, 0, "HAM\nBANDS", menu_settings_ham_bands}, { MT_ADV_CALLBACK, 0, "HAM\nBANDS", menu_settings_ham_bands},
@ -2009,6 +2011,10 @@ static void fetch_numeric_target(void)
uistat.value = SI4463_R; uistat.value = SI4463_R;
plot_printf(uistat.text, sizeof uistat.text, "%3d", uistat.value); plot_printf(uistat.text, sizeof uistat.text, "%3d", uistat.value);
break; break;
case KM_MOD:
uistat.value = ADF4350_modulo;
plot_printf(uistat.text, sizeof uistat.text, "%4d", uistat.value);
break;
case KM_SAMPLETIME: case KM_SAMPLETIME:
uistat.value = setting.step_delay; uistat.value = setting.step_delay;
plot_printf(uistat.text, sizeof uistat.text, "%3dus", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%3dus", ((int32_t)uistat.value));
@ -2134,6 +2140,10 @@ set_numeric_value(void)
break; break;
case KM_R: case KM_R:
set_R(uistat.value); set_R(uistat.value);
// config_save();
break;
case KM_MOD:
set_modulo(uistat.value);
// config_save(); // config_save();
break; break;
case KM_SAMPLETIME: case KM_SAMPLETIME:

Loading…
Cancel
Save

Powered by TurnKey Linux.