Revert "Revert "Hidden HW refresh and wide offset scanning""

This reverts commit 1d6409649f.
pull/4/head
erikkaashoek 6 years ago
parent 1d6409649f
commit 38805e7531

@ -919,6 +919,8 @@ void setupSA(void)
extern int SI4432_frequency_changed; extern int SI4432_frequency_changed;
extern int SI4432_offset_changed; extern int SI4432_offset_changed;
//#define __WIDE_OFFSET__
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) { // Do not change HW if not needed if (old_freq[V] != freq) { // Do not change HW if not needed
@ -930,11 +932,11 @@ void set_freq(int V, unsigned long freq) // translate the requested frequency
} }
#if 1 #if 1
if (setting.step_delay_mode == SD_FAST) { // If in extra fast scanning mode if (setting.step_delay_mode == SD_FAST) { // If in extra fast scanning mode
int delta = freq - real_old_freq[V]; int delta = ((int32_t)freq) - (int32_t)real_old_freq[V]; // subtracting uint can't create a negative number
if (real_old_freq[V] >= 480000000) // 480MHz, high band if (real_old_freq[V] >= 480000000) // 480MHz, high band
delta = delta >> 1; delta = delta >> 1;
if (delta > 0 && delta < 80000) { // and requested frequency can be reached by using the offset registers if (delta > -80000 && delta < 80000) { // and requested frequency can be reached by using the offset registers
#if 0 #if 0
if (real_old_freq[V] >= 480000000) if (real_old_freq[V] >= 480000000)
shell_printf("%d: Offs %q HW %d\r\n", SI4432_Sel, (uint32_t)(real_old_freq[V]+delta*2), real_old_freq[V]); shell_printf("%d: Offs %q HW %d\r\n", SI4432_Sel, (uint32_t)(real_old_freq[V]+delta*2), real_old_freq[V]);
@ -950,16 +952,29 @@ void set_freq(int V, unsigned long freq) // translate the requested frequency
} }
} }
#endif #endif
#ifdef __WIDE_OFFSET__
if (freq >= 480000000) {
SI4432_Set_Frequency(freq + 160000 ); // Impossible to use offset so set SI4432 to new frequency
SI4432_Write_Byte(SI4432_FREQ_OFFSET1, 0); // set offset to most negative
SI4432_Write_Byte(SI4432_FREQ_OFFSET2, 0x02);
real_old_freq[V] = freq + 160000;
} else {
SI4432_Set_Frequency(freq + 80000 ); // Impossible to use offset so set SI4432 to new frequency
SI4432_Write_Byte(SI4432_FREQ_OFFSET1, 0); // set offset to most negative
SI4432_Write_Byte(SI4432_FREQ_OFFSET2, 0x02);
real_old_freq[V] = freq + 80000;
}
#else
SI4432_Set_Frequency(freq); // Impossible to use offset so set SI4432 to new frequency SI4432_Set_Frequency(freq); // Impossible to use offset so set SI4432 to new frequency
SI4432_Write_Byte(SI4432_FREQ_OFFSET1, 0); // set offset to zero SI4432_Write_Byte(SI4432_FREQ_OFFSET1, 0); // set offset to zero
SI4432_Write_Byte(SI4432_FREQ_OFFSET2, 0); SI4432_Write_Byte(SI4432_FREQ_OFFSET2, 0);
#endif
#ifdef __ULTRA_SA__ #ifdef __ULTRA_SA__
} else { } else {
ADF4351_set_frequency(V-2,freq,3); ADF4351_set_frequency(V-2,freq,3);
#endif #endif
} }
old_freq[V] = freq; old_freq[V] = freq;
real_old_freq[V] = freq;
} }
} }
@ -1661,14 +1676,18 @@ static bool sweep(bool break_on_operation)
// shell_printf("\r\n"); // shell_printf("\r\n");
modulation_counter = 0; // init modulation counter in case needed modulation_counter = 0; // init modulation counter in case needed
int refreshing = false;
if (sweep_counter > 5000 && setting.average == AV_OFF && setting.frequency_step > 0) // refresh HW after 5000 sweeps
dirty = true;
if (dirty) // Calculate new scanning solution if (dirty) // Calculate new scanning solution
sweep_counter = 0; sweep_counter = 0;
else else if ( MODE_INPUT(setting.mode) && setting.frequency_step > 0) {
sweep_counter++; sweep_counter++;
if (sweep_counter > 50 ) { // refresh HW after 50 sweeps
dirty = true;
refreshing = true;
sweep_counter = 0;
}
}
again: // Waiting for a trigger jumps back to here again: // Waiting for a trigger jumps back to here
setting.measure_sweep_time_us = 0; // start measure sweep time setting.measure_sweep_time_us = 0; // start measure sweep time
@ -1682,6 +1701,8 @@ sweep_again: // stay in sweep loop when output mo
RSSI = perform(break_on_operation, i, frequencies[i], setting.tracking); // Measure RSSI for one of the frequencies RSSI = perform(break_on_operation, i, frequencies[i], setting.tracking); // Measure RSSI for one of the frequencies
// if break back to top level to handle ui operation // if break back to top level to handle ui operation
if (refreshing)
scandirty = false;
if (break_on_operation && operation_requested) { // break loop if needed if (break_on_operation && operation_requested) { // break loop if needed
if (setting.actual_sweep_time_us > ONE_SECOND_TIME && MODE_INPUT(setting.mode)) { if (setting.actual_sweep_time_us > ONE_SECOND_TIME && MODE_INPUT(setting.mode)) {
ili9341_fill(OFFSETX, HEIGHT_NOSCROLL+1, WIDTH, 1, 0); // Erase progress bar ili9341_fill(OFFSETX, HEIGHT_NOSCROLL+1, WIDTH, 1, 0); // Erase progress bar

@ -188,7 +188,7 @@ void SI4432_Reset(void)
SI4432_Read_Byte (SI4432_INT_STATUS2); SI4432_Read_Byte (SI4432_INT_STATUS2);
// always perform a system reset (don't send 0x87) // always perform a system reset (don't send 0x87)
SI4432_Write_Byte(SI4432_STATE, 0x80); SI4432_Write_Byte(SI4432_STATE, 0x80);
chThdSleepMilliseconds(50); chThdSleepMilliseconds(10);
// wait for chiprdy bit // wait for chiprdy bit
while (count++ < 100 && ( SI4432_Read_Byte (SI4432_INT_STATUS2) & 0x02 ) == 0) { while (count++ < 100 && ( SI4432_Read_Byte (SI4432_INT_STATUS2) & 0x02 ) == 0) {
chThdSleepMilliseconds(10); chThdSleepMilliseconds(10);
@ -206,11 +206,11 @@ void SI4432_Transmit(int d)
SI4432_Write_Byte(SI4432_TX_POWER, (byte) (0x18+(d & 7))); SI4432_Write_Byte(SI4432_TX_POWER, (byte) (0x18+(d & 7)));
if (( SI4432_Read_Byte(SI4432_DEV_STATUS) & 0x03 ) == 2) if (( SI4432_Read_Byte(SI4432_DEV_STATUS) & 0x03 ) == 2)
return; // Already in transmit mode return; // Already in transmit mode
chThdSleepMilliseconds(20); chThdSleepMilliseconds(3);
SI4432_Write_Byte(SI4432_STATE, 0x02); SI4432_Write_Byte(SI4432_STATE, 0x02);
chThdSleepMilliseconds(20); chThdSleepMilliseconds(3);
SI4432_Write_Byte(SI4432_STATE, 0x0b); SI4432_Write_Byte(SI4432_STATE, 0x0b);
chThdSleepMilliseconds(100); chThdSleepMilliseconds(10);
while (count++ < 100 && ( SI4432_Read_Byte(SI4432_DEV_STATUS) & 0x03 ) != 2) { while (count++ < 100 && ( SI4432_Read_Byte(SI4432_DEV_STATUS) & 0x03 ) != 2) {
chThdSleepMilliseconds(10); chThdSleepMilliseconds(10);
} }
@ -221,11 +221,11 @@ void SI4432_Receive(void)
int count = 0; int count = 0;
if (( SI4432_Read_Byte (SI4432_DEV_STATUS) & 0x03 ) == 1) if (( SI4432_Read_Byte (SI4432_DEV_STATUS) & 0x03 ) == 1)
return; // Already in receive mode return; // Already in receive mode
chThdSleepMilliseconds(20); chThdSleepMilliseconds(3);
SI4432_Write_Byte(SI4432_STATE, 0x02); SI4432_Write_Byte(SI4432_STATE, 0x02);
chThdSleepMilliseconds(20); chThdSleepMilliseconds(3);
SI4432_Write_Byte(SI4432_STATE, 0x07); SI4432_Write_Byte(SI4432_STATE, 0x07);
chThdSleepMilliseconds(100); chThdSleepMilliseconds(10);
while (count++ < 100 && ( SI4432_Read_Byte(SI4432_DEV_STATUS) & 0x03 ) != 1) { while (count++ < 100 && ( SI4432_Read_Byte(SI4432_DEV_STATUS) & 0x03 ) != 1) {
chThdSleepMilliseconds(5); chThdSleepMilliseconds(5);
} }
@ -602,7 +602,7 @@ void SI4432_Init()
SPI2_SDI_LOW; // will be set with any data out SPI2_SDI_LOW; // will be set with any data out
palClearPad(GPIOB, GPIO_RF_PWR); // Drop power palClearPad(GPIOB, GPIO_RF_PWR); // Drop power
chThdSleepMilliseconds(20); // Wait chThdSleepMilliseconds(10); // Wait
palSetPad(GPIOB, GPIO_RF_PWR); // Restore power palSetPad(GPIOB, GPIO_RF_PWR); // Restore power
CS_SI0_HIGH; // And set chip select lines back to inactive CS_SI0_HIGH; // And set chip select lines back to inactive
CS_SI1_HIGH; CS_SI1_HIGH;

Loading…
Cancel
Save

Powered by TurnKey Linux.