Merge branch 'main' into pwm

pwm
erikkaashoek 3 years ago
commit 7ea9d1ec99

1
.gitignore vendored

@ -18,3 +18,4 @@ ChibiOS
.cproject .cproject
Rubbish* Rubbish*
desktop.ini desktop.ini
*.xml

@ -596,6 +596,27 @@ void ili9341_flip(bool flip) {
send_command(ILI9341_MEMORY_ACCESS_CONTROL, 1, &memAcc); send_command(ILI9341_MEMORY_ACCESS_CONTROL, 1, &memAcc);
} }
void ili9341_define_scroll(uint16_t tfa, uint16_t bfa) {
uint8_t temp[6];
temp[0] = tfa>>8;
temp[1] = tfa;
temp[2] = 0; // One line
temp[3] = 1;
temp[4] = bfa>>8;
temp[5] = bfa;
send_command(ILI9341_VERTICAL_SCROLLING_DEF,6,temp);
}
void ili9341_scroll(uint16_t start) {
uint8_t temp[6];
temp[0] = start>>8;
temp[1] = start;
send_command(ILI9341_VERTICAL_SCROLLING,2, temp);
}
static void ili9341_DMA_bulk(uint16_t x, uint16_t y, uint16_t w, uint16_t h, pixel_t *buffer){ static void ili9341_DMA_bulk(uint16_t x, uint16_t y, uint16_t w, uint16_t h, pixel_t *buffer){
ili9341_setWindow(ILI9341_MEMORY_WRITE, x, y, w, h); ili9341_setWindow(ILI9341_MEMORY_WRITE, x, y, w, h);
dmaChannelSetMemory(LCD_DMA_TX, buffer); dmaChannelSetMemory(LCD_DMA_TX, buffer);

@ -555,8 +555,13 @@ extern void tlv320aic3204_select(int channel);
extern uint16_t _grid_y; extern uint16_t _grid_y;
#define GRIDY _grid_y #define GRIDY _grid_y
extern uint16_t graph_bottom; extern uint16_t graph_bottom;
#ifdef TINYSA4
#define BIG_WATERFALL 180
#define SMALL_WATERFALL 240
#else
#define BIG_WATERFALL 90 #define BIG_WATERFALL 90
#define SMALL_WATERFALL 180 #define SMALL_WATERFALL 180
#endif
#define NO_WATERFALL CHART_BOTTOM #define NO_WATERFALL CHART_BOTTOM
#define CHART_BOTTOM (LCD_HEIGHT-10) #define CHART_BOTTOM (LCD_HEIGHT-10)
#define SCROLL_GRIDY (HEIGHT_SCROLL / NGRIDY) #define SCROLL_GRIDY (HEIGHT_SCROLL / NGRIDY)
@ -1142,6 +1147,8 @@ int ili9341_drawstring_size(const char *str, int x, int y, uint8_t size, int x_
void ili9341_drawfont(uint8_t ch, int x, int y); void ili9341_drawfont(uint8_t ch, int x, int y);
void ili9341_read_memory(int x, int y, int w, int h, uint16_t* out); void ili9341_read_memory(int x, int y, int w, int h, uint16_t* out);
void ili9341_line(int x0, int y0, int x1, int y1); void ili9341_line(int x0, int y0, int x1, int y1);
void ili9341_define_scroll(uint16_t tfa, uint16_t bfa);
void ili9341_scroll(uint16_t start);
void show_version(void); void show_version(void);
void lcd_setBrightness(uint16_t b); void lcd_setBrightness(uint16_t b);
void spi_init(void); void spi_init(void);

@ -18,7 +18,7 @@
#include "si4432.h" // comment out for simulation #include "si4432.h" // comment out for simulation
//#endif //#endif
#include "stdlib.h" #include "stdlib.h"
//#define TINYSA4 #define TINYSA4
#pragma GCC push_options #pragma GCC push_options
#ifdef TINYSA4 #ifdef TINYSA4
@ -2675,7 +2675,7 @@ void update_rbw(void) // calculate the actual_rbw and the vbwSteps (#
if (temp_actual_rbw_x10 == 0) { // if auto rbw if (temp_actual_rbw_x10 == 0) { // if auto rbw
if (setting.step_delay_mode==SD_FAST) { // if in fast scanning if (setting.step_delay_mode==SD_FAST) { // if in fast scanning
temp_actual_rbw_x10 = 2*frequency_step_x10; temp_actual_rbw_x10 = frequency_step_x10;
// } else if (setting.step_delay_mode==SD_PRECISE) { // } else if (setting.step_delay_mode==SD_PRECISE) {
// temp_actual_rbw_x10 = 4*frequency_step_x10; // temp_actual_rbw_x10 = 4*frequency_step_x10;
} else { } else {
@ -3450,6 +3450,9 @@ bool depth_error = false;
static float old_temp = 0.0; static float old_temp = 0.0;
#endif #endif
#define TRACE(X) // { DAC->DHR12R1 = (X*400); }
pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) // Measure the RSSI for one frequency, used from sweep and other measurement routines. Must do all HW setup pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) // Measure the RSSI for one frequency, used from sweep and other measurement routines. Must do all HW setup
{ {
@ -3469,6 +3472,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
calculate_static_correction(); // In case temperature changed. calculate_static_correction(); // In case temperature changed.
} }
#endif #endif
TRACE(10);
if (i == 0 && dirty ) { // if first point in scan and dirty if (i == 0 && dirty ) { // if first point in scan and dirty
#ifdef __ADF4351__ #ifdef __ADF4351__
clear_frequency_cache(); clear_frequency_cache();
@ -3597,6 +3601,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
for (int t=0;t<TRACES_MAX;t++) for (int t=0;t<TRACES_MAX;t++)
setting.scan_after_dirty[t] += 1; setting.scan_after_dirty[t] += 1;
} }
TRACE(0);
// --------------------------------- Pulse at start of low output sweep -------------------------- // --------------------------------- Pulse at start of low output sweep --------------------------
if ((setting.mode == M_GENLOW || (setting.pulse && setting.mode == M_LOW)) && ( setting.frequency_step != 0 || setting.level_sweep != 0.0)) {// pulse high out if ((setting.mode == M_GENLOW || (setting.pulse && setting.mode == M_LOW)) && ( setting.frequency_step != 0 || setting.level_sweep != 0.0)) {// pulse high out
@ -3884,7 +3889,7 @@ modulation_again:
} }
#endif #endif
#endif #endif
TRACE(1);
// -----------------------------------START vbwsteps loop ------------------------------------ // -----------------------------------START vbwsteps loop ------------------------------------
int t = 0; int t = 0;
do { do {
@ -4126,7 +4131,7 @@ again: // Spur redu
local_IF += lf; local_IF += lf;
} }
} // --------------- END IF calculation ------------------------ } // --------------- END IF calculation ------------------------
TRACE(2);
// ------------- Set LO --------------------------- // ------------- Set LO ---------------------------
{ // Else set LO ('s) { // Else set LO ('s)
@ -4299,6 +4304,7 @@ again: // Spur redu
} }
} }
#endif // __ADF4351__ #endif // __ADF4351__
TRACE(8);
if (setting.harmonic && lf > ( setting.mode == M_GENLOW ? ULTRA_MAX_FREQ + 60000000:ULTRA_MAX_FREQ) ) { if (setting.harmonic && lf > ( setting.mode == M_GENLOW ? ULTRA_MAX_FREQ + 60000000:ULTRA_MAX_FREQ) ) {
target_f /= setting.harmonic; target_f /= setting.harmonic;
LO_harmonic = true; LO_harmonic = true;
@ -4348,8 +4354,9 @@ again: // Spur redu
correct_plus: correct_plus:
if (LO_harmonic) if (LO_harmonic)
error_f *= setting.harmonic; error_f *= setting.harmonic;
if (error_f > actual_rbw_x10 * 5 || LO_harmonic) //RBW / 4 if (error_f > actual_rbw_x10 * 5 || LO_harmonic) { //RBW / 4
local_IF += error_f; local_IF += error_f;
}
} else if ( real_old_freq[ADF4351_LO] < target_f) { } else if ( real_old_freq[ADF4351_LO] < target_f) {
error_f = real_old_freq[ADF4351_LO] - target_f; error_f = real_old_freq[ADF4351_LO] - target_f;
if (inverted_f) { if (inverted_f) {
@ -4360,10 +4367,11 @@ again: // Spur redu
if (LO_harmonic) { if (LO_harmonic) {
error_f *= setting.harmonic; error_f *= setting.harmonic;
} }
if ( error_f < - actual_rbw_x10 * 5 || LO_harmonic) //RBW / 4 if ( error_f < - actual_rbw_x10 * 5 || LO_harmonic) { //RBW / 4
local_IF += error_f; local_IF += error_f;
} }
} }
}
#endif #endif
} else if (setting.mode == M_HIGH || direct) { } else if (setting.mode == M_HIGH || direct) {
if (signal_path == PATH_DIRECT) { if (signal_path == PATH_DIRECT) {
@ -4388,7 +4396,7 @@ again: // Spur redu
#endif #endif
} // ----------------- LO's set -------------------------- } // ----------------- LO's set --------------------------
TRACE(8)
#ifdef __MCU_CLOCK_SHIFT__ #ifdef __MCU_CLOCK_SHIFT__
if (setting.mode == M_LOW && !in_selftest) { // Avoid 48MHz spur if (setting.mode == M_LOW && !in_selftest) { // Avoid 48MHz spur
int set_below = false; int set_below = false;
@ -4420,7 +4428,7 @@ again: // Spur redu
} }
} }
#endif #endif
TRACE(3);
// ----------- Set IF ------------------ // ----------- Set IF ------------------
if (local_IF != 0) // When not in one of the high modes and not in direct mode if (local_IF != 0) // When not in one of the high modes and not in direct mode
@ -4439,7 +4447,7 @@ again: // Spur redu
#endif #endif
} }
TRACE(4);
// Calculate the RSSI correction for later use // Calculate the RSSI correction for later use
if (MODE_INPUT(setting.mode)){ // only cases where the value can change on 0 point of sweep if (MODE_INPUT(setting.mode)){ // only cases where the value can change on 0 point of sweep
if (setting.frequency_step != 0 || (i==0 && scandirty)) { if (setting.frequency_step != 0 || (i==0 && scandirty)) {
@ -4645,6 +4653,7 @@ again: // Spur redu
} }
start_of_sweep_timestamp = chVTGetSystemTimeX(); start_of_sweep_timestamp = chVTGetSystemTimeX();
} }
TRACE(5);
#ifdef TINYSA4 #ifdef TINYSA4
if (SI4432_step_delay && (ADF4351_frequency_changed || SI4463_frequency_changed)) { if (SI4432_step_delay && (ADF4351_frequency_changed || SI4463_frequency_changed)) {
int my_step_delay = SI4432_step_delay; int my_step_delay = SI4432_step_delay;
@ -4688,6 +4697,7 @@ again: // Spur redu
my_step_delay += my_step_delay >> 1 ; my_step_delay += my_step_delay >> 1 ;
} }
} }
TRACE(8);
my_microsecond_delay(my_step_delay); my_microsecond_delay(my_step_delay);
ADF4351_frequency_changed = false; ADF4351_frequency_changed = false;
SI4463_frequency_changed = false; SI4463_frequency_changed = false;
@ -4697,7 +4707,7 @@ again: // Spur redu
SI4463_offset_changed = false; SI4463_offset_changed = false;
} }
#endif #endif
TRACE(6);
//else //else
{ {
#ifdef __SI4432__ #ifdef __SI4432__
@ -4766,6 +4776,7 @@ again: // Spur redu
if (break_on_operation && operation_requested) // break subscanning if requested if (break_on_operation && operation_requested) // break subscanning if requested
break; // abort break; // abort
} while (t < local_vbw_steps); // till all sub steps done } while (t < local_vbw_steps); // till all sub steps done
TRACE(7);
#ifdef TINYSA4 #ifdef TINYSA4
// if (old_CFGR != orig_CFGR) { // Never happens ??? // if (old_CFGR != orig_CFGR) { // Never happens ???
// old_CFGR = orig_CFGR; // old_CFGR = orig_CFGR;
@ -4884,6 +4895,7 @@ static bool sweep(bool break_on_operation)
last_guard = current_guard; last_guard = current_guard;
set_sweep_frequency(ST_START, setting.guards[current_guard].start); set_sweep_frequency(ST_START, setting.guards[current_guard].start);
set_sweep_frequency(ST_STOP, setting.guards[current_guard].end); set_sweep_frequency(ST_STOP, setting.guards[current_guard].end);
set_step_delay(SD_FAST);
set_rbw(8000); set_rbw(8000);
set_sweep_points((setting.guards[current_guard].end - setting.guards[current_guard].start) / 800000); set_sweep_points((setting.guards[current_guard].end - setting.guards[current_guard].start) / 800000);
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.