Merge branch 'master' into tinySA-V4-SI4463

Removed_REF_marker
erikkaashoek 5 years ago
commit 48f9ea33a8

@ -864,8 +864,12 @@ config_t config = {
.magic = CONFIG_MAGIC,
.dac_value = 1922,
// .touch_cal = { 693, 605, 124, 171 }, // 2.4 inch LCD panel
// .touch_cal = { 347, 495, 160, 205 }, // 2.8 inch LCD panel
#ifdef TINYSA3
.touch_cal = { 347, 495, 160, 205 }, // 2.8 inch LCD panel
#endif
#ifdef TINYSA4
.touch_cal = { 261, 605, 115, 146 }, // 4 inch panel
#endif
._mode = _MODE_USB,
._serial_speed = USART_SPEED_SETTING(SERIAL_DEFAULT_BITRATE),
#ifdef __VNA__
@ -873,11 +877,19 @@ config_t config = {
#endif
.lcd_palette = LCD_DEFAULT_PALETTE,
.vbat_offset = 500,
#ifdef TINYSA4
.frequency_IF2 = 0,
#endif
.low_level_offset = 100, // Uncalibrated
.high_level_offset = 100, // Uncalibrated
#ifdef TINYSA3
.correction_frequency = { 10000, 100000, 200000, 500000, 50000000, 140000000, 200000000, 300000000, 330000000, 350000000 },
.correction_value = { +6.0, +2.8, +1.6, -0.4, 0.0, -0.4, +0.4, +3.0, +4.0, +8.1 },
#endif
#ifdef TINYSA4
.correction_frequency = { 10000, 100000, 200000, 500000, 50000000, 140000000, 200000000, 300000000, 330000000, 350000000 },
.correction_value = { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 },
#endif
.setting_frequency_10mhz = 10000000,
.cor_am = -14,
.cor_wfm = -17,
@ -2396,8 +2408,7 @@ static const VNAShellCommand commands[] =
#ifdef ENABLE_THREADS_COMMAND
{"threads" , cmd_threads , 0},
#endif
{ "y", cmd_y, CMD_WAIT_MUTEX },
{ "z", cmd_z, CMD_WAIT_MUTEX },
{ "y", cmd_y, CMD_WAIT_MUTEX },
{ "i", cmd_i, CMD_WAIT_MUTEX },
{ "v", cmd_v, CMD_WAIT_MUTEX },
{ "a", cmd_a, CMD_WAIT_MUTEX },
@ -2411,8 +2422,9 @@ static const VNAShellCommand commands[] =
{ "o", cmd_o, CMD_WAIT_MUTEX },
{ "d", cmd_d, CMD_WAIT_MUTEX },
{ "f", cmd_f, CMD_WAIT_MUTEX },
#ifdef TINYSA4
{ "g", cmd_g, CMD_WAIT_MUTEX },
// { "g", cmd_g, 0 },
#endif
#ifdef __ULTRA_SA__
{ "x", cmd_x, 0 },
#endif
@ -2858,7 +2870,7 @@ int main(void)
// menu_mode_cb(setting.mode,0);
// }
redraw_frame();
#if 0
#ifdef TINYSA3
set_mode(M_HIGH);
set_sweep_frequency(ST_STOP, (uint32_t) 30000000);
sweep(false);

@ -20,15 +20,23 @@
#ifdef TINYSA_F303
#include "adc_F303.h"
#define TINYSA4
#else
#define TINYSA3
#endif
// Need enable HAL_USE_SPI in halconf.h
#define __USE_DISPLAY_DMA__
#define __SA__
//#define __SI4432__
//#define __PE4302__
#ifdef TINYSA3
#define __SI4432__
#endif
#ifdef TINYSA4
#define __SI4463__
#define __SI4468__
#define __ADF4351__
#endif
#define __PE4302__
//#define __SIMULATION__
//#define __PIPELINE__
#define __SCROLL__
@ -43,14 +51,20 @@
//#define __ULTRA_SA__ // Adds ADF4351 control for extra high 1st IF stage
#define __SPUR__ // Does spur reduction by shifting IF
//#define __USE_SERIAL_CONSOLE__ // Enable serial I/O connection (need enable HAL_USE_SERIAL as TRUE in halconf.h)
#define __SI4463__
#define __SI4468__
#ifdef TINYSA3
#define DEFAULT_IF 433800000
#define DEFAULT_SPUR_IF 434000000
#define DEFAULT_MAX_FREQ 350000000
#define HIGH_MIN_FREQ_MHZ 240
#define HIGH_MAX_FREQ_MHZ 960
#endif
#ifdef TINYSA4
#define DEFAULT_IF 978000000
#define DEFAULT_SPUR_IF 979000000
#define DEFAULT_MAX_FREQ 800000000
#define HIGH_MIN_FREQ_MHZ 850
#define HIGH_MAX_FREQ_MHZ 1150
#endif
/*
* main.c
*/
@ -307,11 +321,11 @@ extern uint16_t graph_bottom;
#define BIG_WATERFALL 90
#define SMALL_WATERFALL 180
#define NO_WATERFALL CHART_BOTTOM
#define CHART_BOTTOM 310
#define CHART_BOTTOM (LCD_HEIGHT-10)
#define SCROLL_GRIDY (HEIGHT_SCROLL / NGRIDY)
#define NOSCROLL_GRIDY (CHART_BOTTOM / NGRIDY)
#else
#define GRIDY (310 / NGRIDY)
#define GRIDY (CHART_BOTTOM / NGRIDY)
#endif
#define WIDTH (LCD_WIDTH - 1 - OFFSETX)
@ -321,7 +335,7 @@ extern uint16_t graph_bottom;
#define CELLHEIGHT (32)
#define FREQUENCIES_XPOS1 OFFSETX
#define FREQUENCIES_XPOS2 320
#define FREQUENCIES_XPOS2 (LCD_WIDTH-120)
#define FREQUENCIES_YPOS (LCD_HEIGHT-8)
//
@ -340,7 +354,7 @@ extern uint16_t graph_bottom;
// Maximum menu buttons count
#define MENU_BUTTON_MAX 8
#define MENU_BUTTON_WIDTH 80
#define MENU_BUTTON_HEIGHT 38
#define MENU_BUTTON_HEIGHT (LCD_HEIGHT/8-2)
#define MENU_BUTTON_BORDER 1
#define KEYBOARD_BUTTON_BORDER 2
#define FORM_BUTTON_BORDER 2
@ -355,7 +369,12 @@ extern int16_t area_width;
extern int16_t area_height;
// Define marker size (can be 0 or 1)
#ifdef TINYSA3
#define _MARKER_SIZE_ 0
#endif
#ifdef TINYSA4
#define _MARKER_SIZE_ 1
#endif
// font
extern const uint8_t x5x7_bits [];
extern const uint8_t x7x11b_bits [];
@ -481,7 +500,9 @@ typedef struct config {
uint16_t gridlines;
uint16_t hambands;
#ifdef TINYSA4
uint32_t frequency_IF2;
#endif
int8_t _mode;
int8_t cor_am;
int8_t cor_wfm;
@ -1053,6 +1074,7 @@ void calibrate(void);
float to_dBm(float);
uint32_t calc_min_sweep_time_us(void);
pureRSSI_t perform(bool b, int i, uint32_t f, int e);
void interpolate_maximum(int m);
enum {
M_OFF, M_IMD, M_OIP3, M_PHASE_NOISE, M_STOP_BAND, M_PASS_BAND, M_LINEARITY, M_AM, M_FM, M_THD

@ -273,10 +273,8 @@ VNA_SHELL_FUNCTION(cmd_if)
return;
} else {
int a = my_atoi(argv[0]);
#ifdef __SI4432__
if (a!= 0 &&( a < 433000000 || a>435000000))
if (a!= 0 &&( a < (DEFAULT_IF - 2000000) || a>(DEFAULT_IF + 2000000)))
goto usage;
#endif
#ifdef __SI4463__
if (a!= 0 &&( a < 977000000 || a>980000000))
goto usage;

@ -66,10 +66,7 @@ void update_min_max_freq(void)
switch(setting.mode) {
case M_LOW:
minFreq = 0;
if (config.frequency_IF2 == 0)
maxFreq = DEFAULT_MAX_FREQ;
else
maxFreq = config.frequency_IF2;
maxFreq = DEFAULT_MAX_FREQ;
break;
#ifdef __ULTRA__
case M_ULTRA:
@ -237,7 +234,7 @@ void set_refer_output(int v)
{
setting.refer = v;
#ifdef __SI4432__
SI4432_SetReference(setting.refer);
set_calibration_freq(setting.refer);
#endif
#ifdef __SI4463__
Si4463_set_refer(setting.refer);
@ -401,6 +398,7 @@ void set_IF(int f)
dirty = true;
}
#ifdef TINYSA4
void set_IF2(int f)
{
@ -422,6 +420,7 @@ void set_modulo(uint32_t f)
//ADF4351_spur_mode(f);
dirty = true;
}
#endif
#define POWER_STEP 0 // Should be 5 dB but appearently it is lower
#define POWER_OFFSET 15
@ -1031,7 +1030,7 @@ void apply_settings(void) // Ensure all settings in the setting structure
}
#ifdef __SI4432__
SI4432_SetReference(setting.refer);
set_calibration_freq(setting.refer);
#endif
update_rbw();
calculate_step_delay();
@ -1159,7 +1158,7 @@ static uint32_t old_frequency_step;
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) // Do not change HW if not needed
return;
#ifdef __SI4432__
if (V <= 1) {
@ -1314,13 +1313,13 @@ case M_ULTRA:
set_switch_off();
// SI4432_Receive(); For noise testing only
SI4432_Transmit(setting.drive);
// SI4432_SetReference(setting.refer);
// set_calibration_freq(setting.refer);
#endif
break;
case M_HIGH: // Direct into 1
mute:
#ifdef __SI4432__
// SI4432_SetReference(-1); // Stop reference output
// set_calibration_freq(-1); // Stop reference output
SI4432_Sel = SI4432_RX ; // both as receiver to avoid spurs
set_switch_receive();
SI4432_Receive();
@ -1423,7 +1422,7 @@ void update_rbw(void) // calculate the actual_rbw and the vbwSteps (#
if (setting.spur_removal && actual_rbw_x10 > 3000)
actual_rbw_x10 = 2500; // if spur suppression reduce max rbw to fit within BPF
SI4432_Sel = MODE_SELECT(setting.mode);
actual_rbw_x10 = SI4432_SET_RBW(actual_rbw_x10); // see what rbw the SI4432 can realize
actual_rbw_x10 = set_rbw(actual_rbw_x10); // see what rbw the SI4432 can realize
#endif
#ifdef __SI4463__
// if (setting.spur_removal && actual_rbw_x10 > 3000) // Will depend on BPF width <------------------ TODO -------------------------
@ -1902,8 +1901,6 @@ modulation_again:
#endif
#ifdef __SPUR__
} else if (setting.mode== M_LOW && setting.spur_removal){ // If in low input mode and spur reduction is on
#ifndef __SI4463__
#if 0 // <------------------------- DISABLED !!!!!!!!!!!!!!!
if (S_IS_AUTO(setting.below_IF) && (lf < local_IF / 2 || lf > local_IF) ) // if below 150MHz and auto_below_IF <-------------------TODO ---------------------
{ // else low/above IF
if (setting.spur_removal == 1)
@ -1912,19 +1909,9 @@ modulation_again:
setting.below_IF = S_AUTO_OFF; // and above IF in second pass
}
else
#endif
#endif
{
#ifdef __SI4432__
int32_t spur_offset = actual_rbw_x10 * 100; // Can not use below IF so calculate IF shift that hopefully will kill the spur.
{
if (setting.spur_removal == -1) // If second spur pass
spur_offset = - spur_offset; // IF shift in the other direction
local_IF = local_IF + spur_offset; // apply IF spur shift
#endif
#ifdef __SI4463__
if (setting.spur_removal == -1) // If second spur pass
local_IF = local_IF + 1000000; // apply IF spur shift
#endif
local_IF = local_IF + 1000000; // apply IF spur shift
}
#endif
}
@ -1936,14 +1923,8 @@ modulation_again:
#ifdef __SI4432__
if (setting.mode == M_LOW || setting.mode == M_GENLOW )
{
set_freq (SI4432_RX , local_IF);
}
#endif
#ifdef __SI4463__
// if ((setting.mode == M_LOW || setting.mode == M_GENLOW ) && i == 0)
// {
// set_freq (SI4463_RX , local_IF);
// }
set_freq (SI4432_RX , local_IF);
}
#endif
#ifdef __ULTRA__
} else if (setting.mode == M_ULTRA) { // No above/below IF mode in Ultra
@ -1981,9 +1962,6 @@ modulation_again:
#endif
{ // Else set LO ('s)
#ifdef __ULTRA_SA__
//#define IF_1 2550000000
#define IF_2 config.frequency_IF2 // First IF in Ultra SA mode
set_freq (2, config.frequency_IF2 + lf); // Scanning LO up to IF2
set_freq (3, config.frequency_IF2 - DEFAULT_IF); // Down from IF2 to fixed second IF in Ultra SA mode
set_freq (SI4432_LO, DEFAULT_IF); // Second IF fixed in Ultra SA mode
@ -2190,9 +2168,12 @@ static bool sweep(bool break_on_operation)
// if (setting.mode== -1)
// return;
// START_PROFILE;
#ifdef TINYSA3
palClearPad(GPIOB, GPIOB_LED);
#endif
#ifdef TINYSA4
palClearPad(GPIOC, GPIOC_LED);
#endif
downslope = true; // Initialize the peak search algorithm
temppeakLevel = -150;
float temp_min_level = 100;
@ -2291,6 +2272,7 @@ sweep_again: // stay in sweep loop when output mo
if (setting.subtract_stored) {
RSSI = RSSI - stored_t[i] + setting.normalize_level;
}
#ifdef __SI4432__
//#define __DEBUG_AGC__
#ifdef __DEBUG_AGC__ // For debugging the AGC control
stored_t[i] = (SI4432_Read_Byte(0x69) & 0x01f) * 3.0 - 90.0; // Display the AGC value in the stored trace
@ -2791,8 +2773,13 @@ sweep_again: // stay in sweep loop when output mo
// redraw_marker(peak_marker, FALSE);
// STOP_PROFILE;
#ifdef TINYSA3
palSetPad(GPIOB, GPIOB_LED);
#endif
#ifdef TINYSA4
palSetPad(GPIOC, GPIOC_LED);
#endif
return true;
}
@ -3839,12 +3826,8 @@ void self_test(int test)
#endif
setting.step_delay = setting.step_delay * 5 / 4;
setting.offset_delay = setting.step_delay / 2;
#ifdef __SI4432__
setting.rbw_x10 = SI4432_force_RBW(j);
#endif
#ifdef __SI4463__
setting.rbw_x10 = SI4463_force_RBW(j);
#endif
setting.rbw_x10 = force_RBW(j);
shell_printf("RBW = %f, ",setting.rbw_x10/10.0);
#if 0
set_sweep_frequency(ST_SPAN, (uint32_t)(setting.rbw_x10 * 1000)); // Wide

@ -424,7 +424,7 @@ const int SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t)));
static pureRSSI_t SI4432_RSSI_correction = float_TO_PURE_RSSI(-120);
uint16_t SI4432_force_RBW(int i)
uint16_t force_rbw(int i)
{
SI4432_Write_Byte(SI4432_IF_FILTER_BW, RBW_choices[i].reg); // Write RBW settings to Si4432
SI4432_RSSI_correction = float_TO_PURE_RSSI(RBW_choices[i].RSSI_correction_x_10 - 1200)/10; // Set RSSI correction
@ -432,12 +432,12 @@ uint16_t SI4432_force_RBW(int i)
return RBW_choices[i].RBWx10; // RBW achieved by Si4432 in kHz * 10
}
uint16_t SI4432_SET_RBW(uint16_t WISH) {
uint16_t set_rbw(uint16_t WISH) {
int i;
for (i=0; i < SI4432_RBW_count - 1; i++)
if (WISH <= RBW_choices[i].RBWx10)
break;
return SI4432_force_RBW(i);
return force_rbw(i);
}
@ -654,7 +654,7 @@ void SI4432_Sub_Init(void)
// Clock Recovery Gearshift Value
SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_GEARSHIFT, 0x00);
// IF Filter Bandwidth
SI4432_SET_RBW(100) ;
set_rbw(100) ;
// // Register 0x75 Frequency Band Select
// uint8_t sbsel = 1 ; // recommended setting
// uint8_t hbsel = 0 ; // low bands
@ -753,7 +753,7 @@ void SI4432_Init()
// SI4432_Write_Byte(Si4432_UC_OUTPUT_CLOCK, 0x02) ; // Set 10MHz output
}
void SI4432_SetReference(int freq)
void set_calibration_freq(int freq)
{
SI4432_Sel = SI4432_LO; //Select Lo module
if (freq < 0 || freq > 7 ) {
@ -823,8 +823,8 @@ bool PE4302_Write_Byte(unsigned char DATA )
//-----------------SI4432 dummy------------------
void SI4432_Write_Byte(unsigned char ADR, unsigned char DATA ) {}
unsigned char SI4432_Read_Byte(unsigned char ADR) {return ADR;}
float SI4432_SET_RBW(float WISH) {return (WISH > 600.0?600: (WISH<3.0?3:WISH));}
void SI4432_SetReference(int p) {}
float set_rbw(float WISH) {return (WISH > 600.0?600: (WISH<3.0?3:WISH));}
void set_calibration_freq(int p) {}
void SI4432_Set_Frequency(long f) {}
void PE4302_Write_Byte(unsigned char DATA ) {}
void PE4302_init(void) {}

@ -125,6 +125,7 @@ uint8_t SI4432_Read_Byte( uint8_t ADR );
void SI4432_Transmit(int d);
void SI4432_Receive(void);
void SI4432_Reset(void);
void SI4432_Init(void);
void SI4432_Drive(int);
@ -135,10 +136,10 @@ float Simulated_SI4432_RSSI(uint32_t i, int s);
#endif
void SI4432_Set_Frequency ( uint32_t Freq );
uint16_t SI4432_force_RBW(int i);
uint16_t SI4432_SET_RBW(uint16_t WISH);
uint16_t force_rbw(int i);
uint16_t set_rbw(uint16_t WISH);
extern const int SI4432_RBW_count;
void SI4432_SetReference(int freq);
void set_calibration_freq(int freq);
#ifdef __FAST_SWEEP__
void SI4432_Fill(int s, int start);
#if 0

Loading…
Cancel
Save

Powered by TurnKey Linux.