Merge branch 'master' into tinySA-V4-SI4463

Removed_REF_marker
erikkaashoek 5 years ago
commit 42fd2b713b

@ -128,7 +128,7 @@
PIN_MODE_INPUT(1U) | \
PIN_MODE_INPUT(2U) | \
PIN_MODE_INPUT(3U) | \
PIN_MODE_INPUT(4U) | \
PIN_MODE_ANALOG(4U) | \
PIN_MODE_INPUT(5U) | \
PIN_MODE_ANALOG(GPIOA_XP) | \
PIN_MODE_ANALOG(GPIOA_YP) | \
@ -160,7 +160,7 @@
PIN_OSPEED_2M(1) | \
PIN_OSPEED_2M(2) | \
PIN_OSPEED_2M(3) | \
PIN_OSPEED_100M(4) | \
PIN_OSPEED_2M(4) | \
PIN_OSPEED_100M(5) | \
PIN_OSPEED_2M(6) | \
PIN_OSPEED_2M(7) | \
@ -176,7 +176,7 @@
PIN_PUPDR_PULLDOWN(1) | \
PIN_PUPDR_PULLDOWN(2) | \
PIN_PUPDR_PULLDOWN(3) | \
PIN_PUPDR_PULLDOWN(4) | \
PIN_PUPDR_FLOATING(4) | \
PIN_PUPDR_PULLDOWN(5) | \
PIN_PUPDR_FLOATING(6) | \
PIN_PUPDR_FLOATING(7) | \

@ -24,6 +24,8 @@
#include "spi.h"
// Allow enable DMA for read display data
#define __USE_DISPLAY_DMA_RX__
@ -471,15 +473,14 @@ void ili9341_fill(int x, int y, int w, int h)
dmaStreamSetMemory0(dmatx, &background_color);
dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD);
dmaStreamFlush(w * h);
#ifdef __REMOTE_DESKTOP__
if (auto_capture) {
send_region("fill", x,y,w,h);
spi_buffer[0] = background_color;
send_buffer((uint8_t *)spi_buffer, 2);
osalThreadSleepMilliseconds(2);
// auto_capture = false;
}
// LCD_CS_HIGH;
#endif
}
// Copy spi_buffer to region
@ -493,16 +494,13 @@ void ili9341_bulk(int x, int y, int w, int h)
dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD |
STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_MINC);
dmaStreamFlush(w * h);
#if 1
#ifdef __REMOTE_DESKTOP__
if (auto_capture) {
send_region("bulk", x,y,w,h);
send_buffer((uint8_t *)spi_buffer, w*h*2);
osalThreadSleepMilliseconds(2);
// auto_capture = false;
}
#endif
// LCD_CS_HIGH;
}
#endif

@ -107,7 +107,6 @@ static int8_t drive_strength = DRIVE_STRENGTH_AUTO;
uint8_t sweep_mode = SWEEP_ENABLE;
volatile uint8_t redraw_request = 0; // contains REDRAW_XXX flags
volatile int auto_capture = false;
// Version text, displayed in Config->Version menu, also send by info command
const char *info_about[]={
BOARD_NAME,
@ -145,9 +144,11 @@ static THD_FUNCTION(Thread1, arg)
// call from lowest level to save stack space
self_test(setting.test);
// sweep_mode = SWEEP_ENABLE;
} else if (sweep_mode & SWEEP_REMOTE) {
#ifdef __SINGLE_LETTER__
} else if (sweep_mode & SWEEP_REMOTE) {
sweep_remote();
} else if (sweep_mode & SWEEP_CALIBRATE) {
#endif
} else if (sweep_mode & SWEEP_CALIBRATE) {
// call from lowest level to save stack space
calibrate();
sweep_mode = SWEEP_ENABLE;
@ -807,6 +808,7 @@ VNA_SHELL_FUNCTION(cmd_dump)
}
#endif
#ifdef __REMOTE_DESKTOP__
VNA_SHELL_FUNCTION(cmd_refresh)
{
// read pixel count at one time (PART*2 bytes required for read buffer)
@ -839,6 +841,7 @@ VNA_SHELL_FUNCTION(cmd_release)
mouse_down = false;
handle_touch_interrupt();
}
#endif
VNA_SHELL_FUNCTION(cmd_capture)
{
@ -953,13 +956,13 @@ config_t config = {
.low_level_output_offset = 0.0, // Uncalibrated
.high_level_output_offset = 0.0, // Uncalibrated
#ifdef TINYSA3
.low_correction_frequency = { 10000, 100000, 200000, 500000, 50000000, 140000000, 200000000, 300000000, 330000000, 350000000 },
.low_correction_frequency = { 10000, 100000, 200000, 500000, 30000000, 140000000, 200000000, 300000000, 330000000, 350000000 },
.low_correction_value = { +6.0, +2.8, +1.6, -0.4, 0.0, -0.4, +0.4, +3.0, +4.0, +8.1 },
.high_correction_frequency = { 240000000, 280000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 960000000 },
.high_correction_value = { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 },
#endif
#ifdef TINYSA4
.low_correction_frequency = { 10000, 100000, 200000, 500000, 50000000, 140000000, 200000000, 300000000, 330000000, 350000000 },
.low_correction_frequency = { 10000, 100000, 200000, 500000, 30000000, 140000000, 200000000, 300000000, 330000000, 350000000 },
.low_correction_value = { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 },
.high_correction_frequency = { 10000, 100000, 200000, 500000, 50000000, 140000000, 200000000, 300000000, 330000000, 350000000 },
.high_correction_value = { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 },
@ -969,6 +972,7 @@ config_t config = {
.cor_wfm = -55,
.cor_nfm = -55,
.ultra = false,
.sweep_voltage = 3.3,
};
//properties_t current_props;
@ -2410,6 +2414,7 @@ static const VNAShellCommand commands[] =
{"time" , cmd_time , 0},
#endif
{"dac" , cmd_dac , 0},
{"sweep_voltage",cmd_sweep_voltage,0},
{"saveconfig" , cmd_saveconfig , 0},
{"clearconfig" , cmd_clearconfig , 0},
{"data" , cmd_data , CMD_WAIT_MUTEX},
@ -2449,10 +2454,11 @@ static const VNAShellCommand commands[] =
{"edelay" , cmd_edelay , 0},
#endif
{"capture" , cmd_capture , CMD_WAIT_MUTEX},
#ifdef __REMOTE_DESKTOP__
{"refresh" , cmd_refresh , 0},
{"touch" , cmd_touch , 0},
{"release" , cmd_release , 0},
#endif
{"vbat" , cmd_vbat , CMD_WAIT_MUTEX}, // Uses same adc as touch!!!!!
#ifdef ENABLE_VBAT_OFFSET_COMMAND
{"vbat_offset" , cmd_vbat_offset , 0},
@ -2491,6 +2497,7 @@ static const VNAShellCommand commands[] =
#ifdef ENABLE_THREADS_COMMAND
{"threads" , cmd_threads , 0},
#endif
#ifdef __SINGLE_LETTER__
{ "y", cmd_y, CMD_WAIT_MUTEX },
{ "i", cmd_i, CMD_WAIT_MUTEX },
{ "v", cmd_v, CMD_WAIT_MUTEX },
@ -2505,9 +2512,10 @@ static const VNAShellCommand commands[] =
{ "o", cmd_o, CMD_WAIT_MUTEX },
{ "d", cmd_d, CMD_WAIT_MUTEX },
{ "f", cmd_f, CMD_WAIT_MUTEX },
#endif
#ifdef TINYSA4
{ "g", cmd_g, CMD_WAIT_MUTEX },
#endif
#endif
#ifdef __ADF4351__
{ "x", cmd_x, CMD_WAIT_MUTEX },
#endif
@ -2520,7 +2528,11 @@ VNA_SHELL_FUNCTION(cmd_help)
(void)argv;
const VNAShellCommand *scp = commands;
shell_printf("Commands:");
while (scp->sc_name != NULL && scp->sc_function != cmd_y) {
while (scp->sc_name != NULL
#ifdef __SINGLE_LETTER__
&& scp->sc_function != cmd_y
#endif
) {
shell_printf(" %s", scp->sc_name);
scp++;
}
@ -2771,7 +2783,6 @@ static const I2CConfig i2ccfg = {
.cr2 = 0
};
#endif
static DACConfig dac1cfg1 = {
//init: 2047U,
init: 1922U,
@ -3017,7 +3028,7 @@ void HardFault_Handler(void)
void hard_fault_handler_c(uint32_t *sp)
{
#if 1
#if 0
uint32_t r0 = sp[0];
uint32_t r1 = sp[1];
uint32_t r2 = sp[2];
@ -3080,7 +3091,10 @@ void hard_fault_handler_c(uint32_t *sp)
#endif
shell_printf("===================================\r\n");
#else
(void)sp;
ili9341_set_background(LCD_BG_COLOR);
ili9341_set_foreground(LCD_FG_COLOR);
ili9341_drawstring("FATAL ERROR", OFFSETX, 120);
(void)sp;
#endif
while (true) {
}

@ -57,7 +57,10 @@
#define __HARMONIC__
#define __SINGLE_LETTER__
#define __NICE_BIG_FONT__
#define __QUASI_PEAK__
#define __REMOTE_DESKTOP__
#ifdef TINYSA3
#define DEFAULT_IF 433800000
@ -111,10 +114,12 @@ typedef float measurement_t[TRACES_MAX][POINTS_COUNT];
extern measurement_t measured;
#endif
#ifdef __REMOTE_DESKTOP__
extern volatile int auto_capture;
extern volatile int mouse_x;
extern volatile int mouse_y;
extern volatile int mouse_down;
#endif
#ifdef __VNA__
// Minimum frequency set
@ -185,9 +190,10 @@ freq_t get_sweep_frequency(int type);
void my_microsecond_delay(int t);
float my_atof(const char *p);
int shell_printf(const char *fmt, ...);
#ifdef __REMOTE_DESKTOP__
void send_region(const char *t, int x, int y, int w, int h);
void send_buffer(uint8_t * buf, int s);
#endif
void set_marker_frequency(int m, freq_t f);
void toggle_sweep(void);
void toggle_mute(void);
@ -469,7 +475,7 @@ extern const uint8_t numfont16x22[];
#define bFONT_GET_DATA(ch) ( &x7x11b_bits[(ch-bFONT_START_CHAR)*bFONT_GET_HEIGHT])
#define bFONT_GET_WIDTH(ch) (8-(x7x11b_bits[(ch-bFONT_START_CHAR)*bFONT_GET_HEIGHT]&7))
#if 1 // Set to 0 to save 3kByte and loose nice font
#ifdef __NICE_BIG_FONT__
#define wFONT_START_CHAR 0x17
#define wFONT_MAX_WIDTH 12
#define wFONT_GET_HEIGHT 14
@ -590,6 +596,7 @@ typedef struct config {
int8_t cor_wfm;
int8_t cor_nfm;
int8_t ultra;
float sweep_voltage;
uint32_t dummy;
// uint8_t _reserved[22];
freq_t checksum;

@ -39,7 +39,9 @@ static void cell_blit_bitmap(int x, int y, uint16_t w, uint16_t h, const uint8_t
static void draw_battery_status(void);
static void update_waterfall(void);
void cell_draw_test_info(int x0, int y0);
#ifndef wFONT_GET_DATA
static void cell_drawstring_size(char *str, int x, int y, int size);
#endif
static int16_t grid_offset;
static int16_t grid_width;
static freq_t grid_span;
@ -2448,7 +2450,7 @@ static void update_waterfall(void){
gamma_correct(b);
color = RGB565(r, g, b);
#else
uint16_t y = CELL_Y(index[i])* (graph_bottom == BIG_WATERFALL ? 2 : 1); // should be always in range 0 - graph_bottom *2 depends on height of scroll
uint16_t y = SMALL_WATERFALL - CELL_Y(index[i])* (graph_bottom == BIG_WATERFALL ? 2 : 1); // should be always in range 0 - graph_bottom *2 depends on height of scroll
// Calculate gradient palette for range 0 .. 192
// idx r g b
// 0 - 127 0 0

@ -18,7 +18,6 @@
uint32_t xtoi(char *t);
static int VFO = 0;
static int points = 101; // For 's' and 'm' commands
VNA_SHELL_FUNCTION(cmd_mode)
@ -258,14 +257,7 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
config.high_level_offset = v;
else
goto usage;
} else if (argc == 3) {
float v = my_atof(argv[2]);
if (strcmp(argv[0],"low") == 0)
config.low_level_output_offset = v;
else if (strcmp(argv[0],"high") == 0)
config.high_level_output_offset = v;
else
goto usage;
dirty = true;
} else {
usage:
shell_printf("leveloffset [low|high] {output} [<offset>]\r\n");
@ -285,6 +277,17 @@ VNA_SHELL_FUNCTION(cmd_deviceid)
}
}
VNA_SHELL_FUNCTION(cmd_sweep_voltage)
{
float value;
if (argc != 1) {
shell_printf("usage: sweep_voltage {value(0-3.3)}\r\n"\
"current value: %f\r\n", config.sweep_voltage);
return;
}
value = my_atof(argv[0]);
config.sweep_voltage = value;
}
VNA_SHELL_FUNCTION(cmd_rbw)
{
@ -380,75 +383,6 @@ usage:
}
VNA_SHELL_FUNCTION(cmd_v)
{
if (argc != 1) {
shell_printf("%d\r\n", VFO);
return;
}
VFO = my_atoi(argv[0]) > 0 ? 1 : 0;
shell_printf("VFO %d\r\n", VFO);
}
VNA_SHELL_FUNCTION(cmd_y)
{
if (argc < 1) {
shell_printf("usage: y {addr(0-FF)} [value(0-FF)]+\r\n");
return;
}
#ifdef __SI4432__
int lvalue = 0;
int rvalue;
rvalue = xtoi(argv[0]);
SI4432_Sel = VFO;
if (argc == 2){
lvalue = my_atoui(argv[1]);
SI4432_Write_Byte(rvalue, lvalue);
} else {
lvalue = SI4432_Read_Byte(rvalue);
shell_printf("%x\r\n", lvalue);
}
#endif
#ifdef __SI4463__
uint8_t data[16];
data[0] = xtoi(argv[0]);
for (int i=1; i < argc; i++) {
data[i] = xtoi(argv[i]);
}
SI4463_do_api(data, argc, data, 16);
for (int i=0; i<16; i++)
shell_printf("%02x ", data[i]);
shell_printf("\r\n");
#endif
}
#if 0 // not used
VNA_SHELL_FUNCTION(cmd_z)
{
static const char cmd_z_list[] = "t|r|i";
if (argc != 1) {
shell_printf("usage: z %s\r\n", cmd_z_list);
return;
}
if (argc == 1) {
#ifdef __SI4432__
SI4432_Sel = VFO;
int type = get_str_index(argv[0], cmd_z_list);
switch(type) {
case 0:
SI4432_Transmit(3);
break;
case 1:
SI4432_Receive();
break;
case 2:
SI4432_Reset();
break;
}
#endif
}
}
#endif
VNA_SHELL_FUNCTION(cmd_selftest)
{
if (argc < 1 || argc > 2) {
@ -463,6 +397,10 @@ VNA_SHELL_FUNCTION(cmd_selftest)
sweep_mode = SWEEP_SELFTEST;
}
#ifdef __SINGLE_LETTER__
static int VFO = 0;
#ifdef __ADF4351__
uint32_t xtoi(char *t)
@ -508,7 +446,6 @@ VNA_SHELL_FUNCTION(cmd_x)
}
#endif
VNA_SHELL_FUNCTION(cmd_i)
{
(void)argc;
@ -637,6 +574,81 @@ VNA_SHELL_FUNCTION(cmd_s)
points = my_atoi(argv[0]);
}
VNA_SHELL_FUNCTION(cmd_v)
{
if (argc != 1) {
shell_printf("%d\r\n", VFO);
return;
}
VFO = my_atoi(argv[0]) > 0 ? 1 : 0;
shell_printf("VFO %d\r\n", VFO);
}
VNA_SHELL_FUNCTION(cmd_y)
{
if (argc < 1) {
shell_printf("usage: y {addr(0-FF)} [value(0-FF)]+\r\n");
return;
}
#ifdef __SI4432__
int lvalue = 0;
int rvalue;
rvalue = xtoi(argv[0]);
SI4432_Sel = VFO;
if (argc == 2){
lvalue = my_atoui(argv[1]);
SI4432_Write_Byte(rvalue, lvalue);
} else {
lvalue = SI4432_Read_Byte(rvalue);
shell_printf("%x\r\n", lvalue);
}
#endif
#ifdef __SI4463__
uint8_t data[16];
data[0] = xtoi(argv[0]);
for (int i=1; i < argc; i++) {
data[i] = xtoi(argv[i]);
}
SI4463_do_api(data, argc, data, 16);
for (int i=0; i<16; i++)
shell_printf("%02x ", data[i]);
shell_printf("\r\n");
#endif
}
#if 0 // not used
VNA_SHELL_FUNCTION(cmd_z)
{
static const char cmd_z_list[] = "t|r|i";
if (argc != 1) {
shell_printf("usage: z %s\r\n", cmd_z_list);
return;
}
if (argc == 1) {
#ifdef __SI4432__
SI4432_Sel = VFO;
int type = get_str_index(argv[0], cmd_z_list);
switch(type) {
case 0:
SI4432_Transmit(3);
break;
case 1:
SI4432_Receive();
break;
case 2:
SI4432_Reset();
break;
}
#endif
}
}
#endif
#endif
#ifdef __SINGLE_LETTER__
void sweep_remote(void)
{
uint32_t i;
@ -723,6 +735,7 @@ VNA_SHELL_FUNCTION(cmd_f)
setting.test_argument = my_atoi(argv[0]);;
sweep_mode = SWEEP_SELFTEST;
}
#endif
VNA_SHELL_FUNCTION(cmd_correction)
{

@ -2033,6 +2033,17 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
}
}
if (setting.mode == M_GENLOW && ( setting.frequency_step != 0 || setting.level_sweep != 0.0)) {// start burst
SI4432_Sel = SI4432_LO ;
if (i == 0) {
// set_switch_transmit();
SI4432_Write_Byte(SI4432_GPIO2_CONF, 0x1D) ; // Set GPIO2 output to ground
} else if (i == 1) {
// set_switch_off();
SI4432_Write_Byte(SI4432_GPIO2_CONF, 0x1F) ; // Set GPIO2 output to ground
}
}
if (setting.mode == M_GENLOW && ( setting.frequency_step != 0 || setting.level_sweep != 0.0 || i == 0)) {// if in low output mode and level sweep or frequency weep is active or at start of sweep
float ls=setting.level_sweep; // calculate and set the output level
if (ls > 0)
@ -2733,6 +2744,8 @@ sweep_again: // stay in sweep loop when output mo
return false;
}
dacPutChannelX(&DACD2, 0, (((float)i)*config.sweep_voltage)*4.279); // Output sweep voltage 4095 -> 3.3 Volt
// ----------------------- in loop AGC ---------------------------------
#ifdef __SI4432__
@ -2790,7 +2803,7 @@ sweep_again: // stay in sweep loop when output mo
#endif
#ifdef __SI4432__
if (check_for_AM) {
int AGC_value = (SI4432_Read_Byte(0x69) & 0x01f) * 3.0 - 90.0;
int AGC_value = (SI4432_Read_Byte(0x69) & 0x01f) * 3 - 90;
if (AGC_value < last_AGC_value && last_AGC_direction_up ) {
AGC_flip_count++;
} else if (AGC_value > last_AGC_value && !last_AGC_direction_up ) {
@ -3045,7 +3058,7 @@ sweep_again: // stay in sweep loop when output mo
#ifdef __SI4432__
if (!in_selftest && MODE_INPUT(setting.mode)) {
if (S_IS_AUTO(setting.agc)) {
float actual_max_level = actual_t[max_index[0]] - get_attenuation();
int actual_max_level = actual_t[max_index[0]] - get_attenuation(); // No need to use float
if (UNIT_IS_LINEAR(setting.unit)) { // Auto AGC in linear mode
if (actual_max_level > - 45)
auto_set_AGC_LNA(false, 0); // Strong signal, no AGC and no LNA
@ -3225,10 +3238,11 @@ sweep_again: // stay in sweep loop when output mo
}
} else if (setting.measurement == M_AM) { // ----------------AM measurement
if (S_IS_AUTO(setting.agc )) {
if (actual_t[max_index[0]] - get_attenuation() > -20 ) {
int actual_level = actual_t[max_index[0]] - get_attenuation(); // no need for float
if (actual_level > -20 ) {
setting.agc = S_AUTO_OFF;
setting.lna = S_AUTO_OFF;
} else if (actual_t[max_index[0]] - get_attenuation() < -45 ) {
} else if (actual_level < -45 ) {
setting.agc = S_AUTO_ON;
setting.lna = S_AUTO_ON;
} else {
@ -3383,7 +3397,7 @@ int marker_search_max(void)
return found;
}
#define MINMAX_DELTA 10
#define MINMAX_DELTA_X10 100
int
@ -3394,22 +3408,22 @@ marker_search_left_min(int from)
if (uistat.current_trace == -1)
return -1;
float value = actual_t[from];
int value_x10 = actual_t[from]*10;
for (i = from - 1; i >= 0; i--) {
float new_value = actual_t[i];
if (new_value > value) {
value = new_value; // follow up
int new_value_x10 = actual_t[i]*10;
if (new_value_x10 > value_x10) {
value_x10 = new_value_x10; // follow up
// found = i;
} else if (new_value < value - MINMAX_DELTA )
} else if (new_value_x10 < value_x10 - MINMAX_DELTA_X10 )
break; // past the maximum
}
for (; i >= 0; i--) {
float new_value = actual_t[i];
if (new_value < value) {
value = new_value; // follow down
int new_value_x10 = actual_t[i]*10;
if (new_value_x10 < value_x10) {
value_x10 = new_value_x10; // follow down
found = i;
} else if (new_value > value + MINMAX_DELTA )
} else if (new_value_x10 > value_x10 + MINMAX_DELTA_X10 )
break;
}
return found;
@ -3423,21 +3437,21 @@ marker_search_right_min(int from)
if (uistat.current_trace == -1)
return -1;
float value = actual_t[from];
int value_x10 = actual_t[from]*10;
for (i = from + 1; i < sweep_points; i++) {
float new_value = actual_t[i];
if (new_value > value) { // follow up
value = new_value;
int new_value_x10 = actual_t[i]*10;
if (new_value_x10 > value_x10) { // follow up
value_x10 = new_value_x10;
// found = i;
} else if (new_value < value - MINMAX_DELTA) // less then largest value - noise
} else if (new_value_x10 < value_x10 - MINMAX_DELTA_X10) // less then largest value_x10 - noise
break; // past the maximum
}
for (; i < sweep_points; i++) {
float new_value = actual_t[i];
if (new_value < value) { // follow down
value = new_value;
int new_value_x10 = actual_t[i]*10;
if (new_value_x10 < value_x10) { // follow down
value_x10 = new_value_x10;
found = i;
} else if (new_value > value + MINMAX_DELTA) // larger then smallest value + noise
} else if (new_value_x10 > value_x10 + MINMAX_DELTA_X10) // larger then smallest value_x10 + noise
break;
}
return found;
@ -3585,8 +3599,12 @@ int validate_signal_within(int i, float margin)
if (fabsf(peakLevel-test_case[i].pass) > margin) {
return TS_CRITICAL;
}
if (setting.measurement == M_PASS_BAND) {
peakFreq = (markers[2].frequency + markers[1].frequency)/2;
markers[0].frequency = peakFreq;
}
test_fail_cause[i] = "Frequency ";
if (peakFreq < test_case[i].center * 1000000 - 1000000 || test_case[i].center * 1000000 + 1000000 < peakFreq )
if (peakFreq < test_case[i].center * 1000000 - 100000 || test_case[i].center * 1000000 + 100000 < peakFreq )
return TS_FAIL;
test_fail_cause[i] = "";
return TS_PASS;
@ -3652,21 +3670,20 @@ int validate_atten(int i) {
float summed_peak_level = 0;
#define ATTEN_TEST_SWEEPS 5
for (int k=0; k<ATTEN_TEST_SWEEPS; k++) {
// setting.sweep_time_us = 1000000;
test_acquire(TEST_ATTEN); // Acquire test
// test_validate(TEST_ATTEN); // Validate test
float peaklevel = 0.0;
for (int n = 50 ; n < sweep_points; n++)
// setting.sweep_time_us = 1000000;
test_acquire(TEST_ATTEN); // Acquire test
// test_validate(TEST_ATTEN); // Validate test
float peaklevel = 0.0;
for (int n = 0 ; n < sweep_points; n++)
peaklevel += actual_t[n];
peaklevel /= (sweep_points - 50);
peaklevel /= (sweep_points - 0);
summed_peak_level += peaklevel;
}
summed_peak_level /= ATTEN_TEST_SWEEPS;
}
summed_peak_level /= ATTEN_TEST_SWEEPS;
if (j == 0)
reference_peak_level = summed_peak_level;
else {
// shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",((float)j)/2.0, summed_peak_level, summed_peak_level - reference_peak_level);
if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",a, summed_peak_level, summed_peak_level - reference_peak_level);
// if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",a, summed_peak_level, summed_peak_level - reference_peak_level);
#define ATTEN_TEST_CRITERIA 1
if (summed_peak_level - reference_peak_level <= -ATTEN_TEST_CRITERIA || summed_peak_level - reference_peak_level >= ATTEN_TEST_CRITERIA) {
status = TS_FAIL;
@ -3816,7 +3833,7 @@ common_silent:
for (int j = 0; j < setting._sweep_points/2 - W2P(test_case[i].width); j++)
stored_t[j] = test_case[i].stop;
for (int j = setting._sweep_points/2 + W2P(test_case[i].width); j < setting._sweep_points; j++)
stored_t[j] = test_case[i].stop;
stored_t[j] = test_case[i].stop - (i == 6?5:0);
for (int j = setting._sweep_points/2 - W2P(test_case[i].width); j < setting._sweep_points/2 + W2P(test_case[i].width); j++)
stored_t[j] = test_case[i].pass;
break;
@ -4136,7 +4153,6 @@ void self_test(int test)
set_sweep_frequency(ST_SPAN, 0);
break;
}
#endif
} else if (test == 6) {
in_selftest = true; // Spur search
reset_settings(M_LOW);
@ -4152,9 +4168,8 @@ void self_test(int test)
test_acquire(TEST_SPUR); // Acquire test
shell_printf("%d: %9.3q\n\r",i, peakFreq);
test_validate(TEST_SPUR); // Validate test
}
#endif
}
show_test_info = FALSE;

@ -315,7 +315,7 @@ void SI4432_Drive(int d)
void SI4432_Transmit(int d)
{
int count = 0;
SI4432_Write_Byte(SI4432_TX_POWER, (uint8_t) (0x18+(d & 7)));
SI4432_Drive(d);
if (( SI4432_Read_Byte(SI4432_DEV_STATUS) & 0x03 ) == 2)
return; // Already in transmit mode
chThdSleepMilliseconds(3);
@ -715,84 +715,40 @@ pureRSSI_t SI4432_RSSI(uint32_t i, int s)
return RSSI_RAW;
}
static uint8_t SI4432_init_script[] =
{
SI4432_INT_ENABLE1, 0x0,
SI4432_INT_ENABLE2, 0x0,
SI4432_CLOCK_RECOVERY_GEARSHIFT, 0x00,
SI4432_AGC_OVERRIDE, 0x60,
SI4432_AFC_LOOP_GEARSHIFT_OVERRIDE, 0x00,
SI4432_AFC_TIMING_CONTROL, 0x02,
SI4432_CLOCK_RECOVERY_GEARSHIFT, 0x03,
SI4432_CLOCK_RECOVERY_OFFSET2, 0x01,
SI4432_CLOCK_RECOVERY_OFFSET1, 0x11,
SI4432_CLOCK_RECOVERY_OFFSET0, 0x11,
SI4432_CLOCK_RECOVERY_TIMING_GAIN1, 0x01,
SI4432_CLOCK_RECOVERY_TIMING_GAIN0, 0x13,
SI4432_AFC_LIMITER, 0xFF,
SI4432_DATAACCESS_CONTROL, 0x61, // Disable all packet handling
SI4432_AGC_OVERRIDE, 0x60, // AGC, no LNA, fast gain increment
SI4432_GPIO0_CONF, 0x12, // Normal
SI4432_GPIO1_CONF, 0x15,
SI4432_GPIO2_CONF, 0x1F
};
void SI4432_Sub_Init(void)
{
SI4432_Reset();
SI4432_Write_Byte(SI4432_AGC_OVERRIDE, 0x60); //AGC override according to WBS3
#if 0 // Not sure if these add any value
//set VCO and PLL Only for SI4432 V2
SI4432_Write_Byte(SI4432_FREQ_DEVIATION, 0x1F); //write 0x1F to the Frequency Deviation register
// VCO tuning registers
SI4432_Write_Byte(SI4432_VCO_CURRENT_TRIM, 0x7F); //write 0x7F to the VCO Current Trimming register
SI4432_Write_Byte(SI4432_CHARGEPUMP_OVERRIDE, 0x80); //write 0xD7 to the ChargepumpCurrentTrimmingOverride register
SI4432_Write_Byte(SI4432_DIVIDER_CURRENT_TRIM, 0x40); //write 0x40 to the Divider Current Trimming register
#endif
#if 0
//set the AGC, BAD FOR PERFORMANCE!!!!!!
SI4432_Write_Byte(0x6A, 0x0B); //write 0x0B to the AGC Override 2 register
//set ADC reference voltage to 0.9V, BAD FOR PERFORMANCE!!!!!!
SI4432_Write_Byte(0x68, 0x04); //write 0x04 to the Deltasigma ADC Tuning 2 register
SI4432_Write_Byte(0x1F, 0x03); //write 0x03 to the Clock Recovery Gearshift Override register
#endif
SI4432_Write_Byte(SI4432_INT_ENABLE1, 0x0);
SI4432_Write_Byte(SI4432_INT_ENABLE2, 0x0);
// Enable receiver chain
// SI4432_Write_Byte(SI4432_STATE, 0x05);
// Clock Recovery Gearshift Value
SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_GEARSHIFT, 0x00);
uint8_t *p = SI4432_init_script;
while (*p) {
uint8_t r = *p++;
uint8_t v = *p++;
SI4432_Write_Byte (r,v);
}
// IF Filter Bandwidth
set_rbw(100) ;
// // Register 0x75 Frequency Band Select
// uint8_t sbsel = 1 ; // recommended setting
// uint8_t hbsel = 0 ; // low bands
// uint8_t fb = 19 ; // 430<33>439.9 MHz
// uint8_t FBS = (sbsel << 6 ) | (hbsel << 5 ) | fb ;
// SI4432_Write_Byte(SI4432_FREQBAND, FBS) ;
// SI4432_Write_Byte(SI4432_FREQBAND, 0x46) ;
// Register 0x76 Nominal Carrier Frequency
// WE USE 433.92 MHz
// Si443x-Register-Settings_RevB1.xls
// SI4432_Write_Byte(SI4432_FREQCARRIER_H, 0x62) ;
// SI4432_Write_Byte(SI4432_FREQCARRIER_H, 0x00) ;
// Register 0x77 Nominal Carrier Frequency
// SI4432_Write_Byte(SI4432_FREQCARRIER_L, 0x00) ;
// RX MODEM SETTINGS
// SI4432_Write_3_Byte(SI4432_IF_FILTER_BW, 0x81, 0x3C, 0x02) ; // <----------
// SI4432_Write_Byte(SI4432_IF_FILTER_BW, 0x81) ; // <----------
SI4432_Write_Byte(SI4432_AFC_LOOP_GEARSHIFT_OVERRIDE, 0x00) ;
SI4432_Write_Byte(SI4432_AFC_TIMING_CONTROL, 0x02) ;
SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_GEARSHIFT, 0x03) ;
// SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_OVERSAMPLING, 0x78) ; // <----------
// SI4432_Write_3_Byte(SI4432_CLOCK_RECOVERY_OFFSET2, 0x01, 0x11, 0x11) ; // <----------
SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_OFFSET2, 0x01) ;
SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_OFFSET1, 0x11) ;
SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_OFFSET0, 0x11) ;
SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_TIMING_GAIN1, 0x01) ;
SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_TIMING_GAIN0, 0x13) ;
SI4432_Write_Byte(SI4432_AFC_LIMITER, 0xFF) ;
// SI4432_Write_3_Byte(0x2C, 0x28, 0x0c, 0x28) ; // <----------
// SI4432_Write_Byte(Si4432_OOK_COUNTER_VALUE_1, 0x28) ;
// SI4432_Write_Byte(Si4432_OOK_COUNTER_VALUE_2, 0x0C) ;
// SI4432_Write_Byte(Si4432_SLICER_PEAK_HOLD, 0x28) ;
SI4432_Write_Byte(SI4432_DATAACCESS_CONTROL, 0x61); // Disable all packet handling
SI4432_Write_Byte(SI4432_AGC_OVERRIDE, 0x60); // AGC, no LNA, fast gain increment
// GPIO automatic antenna switching
SI4432_Write_Byte(SI4432_GPIO0_CONF, 0x12) ; // Normal
SI4432_Write_Byte(SI4432_GPIO1_CONF, 0x15) ;
// set_rbw(100) ;
// SI4432_Receive();
@ -829,24 +785,6 @@ void SI4432_Init()
SI4432_Sel = SI4432_LO;
SI4432_Sub_Init();
//DebugLine("1 init done");
SI4432_Sel = SI4432_RX;
// SI4432_Receive();// Enable receiver chain
// SI4432_Write_Byte(Si4432_CRYSTAL_OSC_LOAD_CAP, V0_XTAL_CAPACITANCE);// Tune the crystal
// SI4432_Set_Frequency(433800000);
SI4432_Write_Byte(SI4432_GPIO2_CONF, 0x1F) ; // Set GPIO2 output to ground
SI4432_Sel = SI4432_LO;
// SI4432_Write_Byte(Si4432_CRYSTAL_OSC_LOAD_CAP, V1_XTAL_CAPACITANCE);// Tune the crystal
// SI4432_Set_Frequency(443800000);
SI4432_Write_Byte(SI4432_GPIO2_CONF, 0x1F) ; // Set GPIO2 output to ground
// SI4432_Write_Byte(SI4432_TX_POWER, 0x1C);//Set low power
// SI4432_Transmit(0);
// SI4432_Write_Byte(SI4432_GPIO2_CONF, 0xC0) ; // Set GPIO2 maximumdrive and clock output
// SI4432_Write_Byte(Si4432_UC_OUTPUT_CLOCK, 0x02) ; // Set 10MHz output
}
void set_calibration_freq(int freq)

23
ui.c

@ -311,6 +311,7 @@ touch_check(void)
last_touch_x = x;
last_touch_y = y;
}
#ifdef __REMOTE_DESKTOP__
mouse_down = false;
}
if (!stat) {
@ -320,7 +321,10 @@ touch_check(void)
last_touch_y = mouse_y;
}
}
#if 0 // Long press detection
#else
}
#endif
#if 0 // Long press detection
systime_t ticks = chVTGetSystemTimeX();
if (stat && !last_touch_status) { // new button, initialize
@ -446,8 +450,13 @@ touch_draw_test(void)
void
touch_position(int *x, int *y)
{
#ifdef __REMOTE_DESKTOP__
*x = (mouse_down ? mouse_x : (last_touch_x - config.touch_cal[0]) * 16 / config.touch_cal[2]);
*y = (mouse_down ? mouse_y : (last_touch_y - config.touch_cal[1]) * 16 / config.touch_cal[3]);
#else
*x = (last_touch_x - config.touch_cal[0]) * 16 / config.touch_cal[2];
*y = (last_touch_y - config.touch_cal[1]) * 16 / config.touch_cal[3];
#endif
}
@ -2955,9 +2964,11 @@ void ui_process_touch(void)
}
static int previous_button_state = 0;
#ifdef __REMOTE_DESKTOP__
static int previous_mouse_state = 0;
static int previous_mouse_x = 0;
static int previous_mouse_y = 0;
#endif
void
ui_process(void)
@ -2971,10 +2982,14 @@ ui_process(void)
ui_process_lever();
previous_button_state = button_state;
operation_requested = OP_NONE;
} else if (operation_requested&OP_TOUCH || previous_mouse_state != mouse_down || previous_mouse_x != mouse_x || previous_mouse_y != mouse_y) {
}
if (operation_requested&OP_TOUCH
#ifdef __REMOTE_DESKTOP__
|| previous_mouse_state != mouse_down || previous_mouse_x != mouse_x || previous_mouse_y != mouse_y
#endif
) {
ui_process_touch();
previous_mouse_state = mouse_down;
operation_requested = OP_NONE;
operation_requested = OP_NONE;
}
}

@ -1430,6 +1430,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_pause_acb)
// draw_cal_status();
}
#ifdef __REMOTE_DESKTOP__
static UI_FUNCTION_ADV_CALLBACK(menu_send_display_acb)
{
(void) data;
@ -1444,7 +1445,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_send_display_acb)
draw_menu();
// draw_cal_status();
}
#endif
static UI_FUNCTION_ADV_CALLBACK(menu_outputmode_acb)
{
@ -1924,7 +1925,7 @@ static const menuitem_t menu_settings[] =
{
{ MT_ADV_CALLBACK | MT_LOW, 0,"LO OUTPUT", menu_lo_output_acb},
{ MT_KEYPAD, KM_ACTUALPOWER, "ACTUAL\nPOWER", NULL},
{ MT_KEYPAD | MT_LOW, KM_IF, "IF FREQ", "Set to zero for auto IF"},
{ MT_KEYPAD | MT_LOW, KM_IF, "IF FREQ", "0=auto IF"},
{ MT_SUBMENU,0, "SCAN SPEED", menu_scanning_speed},
{ MT_KEYPAD, KM_REPEAT, "SAMPLE\nREPEAT", "1..100"},
{ MT_SUBMENU | MT_LOW,0, "MIXER\nDRIVE", menu_mixer_drive},
@ -2041,7 +2042,9 @@ static const menuitem_t menu_display[] = {
{ MT_ADV_CALLBACK,3, "NORMALIZE", menu_storage_acb},
{ MT_ADV_CALLBACK,4, "WATER\nFALL", menu_waterfall_acb},
{ MT_SUBMENU, 0, "SWEEP\nSETTINGS", menu_sweep_speed},
#ifdef __REMOTE_DESKTOP__
{ MT_ADV_CALLBACK,0, "SEND\nDISPLAY", menu_send_display_acb},
#endif
// { MT_KEYPAD, KM_SWEEP_TIME, "SWEEP\nTIME", NULL},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },

Loading…
Cancel
Save

Powered by TurnKey Linux.