power on/off restore

Speed-test
erikkaashoek 4 years ago
parent 8d3c9d2c2d
commit 06392925f6

@ -131,17 +131,27 @@ static THD_FUNCTION(Thread1, arg)
while (1) {
// START_PROFILE
if (sweep_mode&(SWEEP_ENABLE|SWEEP_ONCE)) {
backup.frequency0 = setting.frequency0;
backup.frequency1 = setting.frequency1;
backup_t b;
b.frequency0 = setting.frequency0;
b.frequency1 = setting.frequency1;
if (setting.auto_attenuation)
backup.attenuation = 0;
b.attenuation = 0;
else
backup.attenuation = setting.attenuate_x2+1;
b.attenuation = setting.attenuate_x2+1;
if (setting.auto_reflevel || setting.unit != U_DBM)
backup.reflevel = 0;
b.reflevel = 0;
else
b.reflevel = setting.reflevel + 140;
if (setting.rbw_x10 == 0)
b.RBW = 0;
else
backup.reflevel = setting.reflevel + 140;
b.RBW = SI4463_rbw_selected+1;
b.mode = setting.mode;
uint32_t *f = (uint32_t *)&b;
uint32_t *t = &backup;
int i = 5;
while (i--)
*t++ = *f++;
completed = sweep(true);
sweep_mode&=~SWEEP_ONCE;
@ -2467,27 +2477,58 @@ int main(void)
if (caldata_recall(0) == -1) {
load_LCD_properties();
}
{backup_t b = backup;
if (backup.frequency0 != 0 || backup.frequency1 != 0) {
setting.frequency0 = backup.frequency0;
setting.frequency1 = backup.frequency1;
update_frequencies();
if (backup.attenuation == 0)
ui_mode_normal();
{
backup_t b;
uint32_t *f = &backup;
uint32_t *t = (uint32_t *)&b;
int i = 5;
while (i--)
*t++ = *f++;
set_mode(b.mode);
switch (b.mode) {
case M_LOW:
case M_HIGH:
break;
case M_GENLOW:
menu_push_submenu(menu_lowoutputmode);
break;
case M_GENHIGH:
menu_push_submenu(menu_highoutputmode);
break;
}
if (b.frequency0 != 0 || b.frequency1 != 0) {
if (b.mode <= M_HIGH){
setting.frequency0 = b.frequency0;
setting.frequency1 = b.frequency1;
update_frequencies();
} else {
set_sweep_frequency(ST_CW, (b.frequency0 + b.frequency1)/2);
set_sweep_frequency(ST_SPAN, (b.frequency1 - b.frequency0));
ui_mode_menu();
}
if (b.attenuation == 0)
set_auto_attenuation();
else {
set_attenuation((backup.attenuation - 1)/2.0);
set_attenuation((b.attenuation - 1)/2.0);
}
if (backup.reflevel == 0)
if (b.reflevel == 0)
set_auto_reflevel(true);
else {
set_auto_reflevel(false);
user_set_reflevel(((float)backup.reflevel)-140.0);
user_set_reflevel((float)(b.reflevel-140));
}
if (b.RBW == 0)
setting.rbw_x10 = 0;
else {
set_RBW(force_rbw(b.RBW-1));
}
}
}
set_refer_output(-1);
// ui_mode_menu(); // Show menu when autostarting mode
ui_mode_normal();
/*
* Set LCD display brightness (use DAC2 for control)

@ -18,7 +18,7 @@
*/
#include "ch.h"
#ifdef TINYSA_F303
//#ifdef TINYSA_F303
#ifdef TINYSA_F072
#error "Remove comment for #ifdef TINYSA_F303"
#endif
@ -26,7 +26,7 @@
#define TINYSA4
#endif
#define TINYSA4_PROTO
#endif
//#endif
#ifdef TINYSA_F072
#ifdef TINYSA_F303
@ -455,20 +455,6 @@ extern void tlv320aic3204_select(int channel);
#endif
#pragma pack(push)
#pragma pack(1)
typedef struct {
uint32_t frequency0, frequency1;
uint32_t attenuation;
int32_t reflevel;
// uint8_t RBW;
// uint8_t mode;
} backup_t;
#pragma pack(pop)
#define backup (*(backup_t *)0x40002850) // backup registers 5 * 32 bits
/*
* plot.c
*/
@ -1307,6 +1293,18 @@ void clear_all_config_prop_data(void);
/*
* ui.c
*/
// Set structure align as WORD (save flash memory)
#pragma pack(push, 2)
typedef struct {
uint8_t type;
uint8_t data;
char *label;
const void *reference;
} menuitem_t;
#pragma pack(pop)
extern void ui_init(void);
extern void ui_process(void);
int current_menu_is_form(void);
@ -1468,6 +1466,29 @@ void testLog(void); // debug log
void sd_card_load_config(char *filename);
#endif
/*
* Backup
*/
#pragma pack(push)
#pragma pack(1)
extern uint8_t SI4463_rbw_selected;
extern const menuitem_t menu_lowoutputmode[];
extern const menuitem_t menu_highoutputmode[];
extern void menu_push_submenu(const menuitem_t *submenu);
typedef struct {
uint32_t frequency0, frequency1;
uint8_t attenuation;
uint8_t reflevel;
uint8_t RBW;
uint8_t mode;
} backup_t;
#pragma pack(pop)
#define backup (*(uint32_t *)0x40002850) // backup registers 5 * 32 bits
/*
* misclinous
*/

@ -835,7 +835,7 @@ float high_out_offset()
static pureRSSI_t get_signal_path_loss(void){
#ifdef TINYSA4
if (setting.mode == M_LOW)
return float_TO_PURE_RSSI(+3); // Loss in dB, -9.5 for v0.1, -12.5 for v0.2
return float_TO_PURE_RSSI(+9.3); // Loss in dB, -9.5 for v0.1, -12.5 for v0.2
return float_TO_PURE_RSSI(+29); // Loss in dB (+ is gain)
#else
if (setting.mode == M_LOW)
@ -4126,6 +4126,15 @@ static bool sweep(bool break_on_operation)
ili9341_fill(OFFSETX, CHART_BOTTOM+1, pos, 1); // update sweep progress bar
ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(OFFSETX+pos, CHART_BOTTOM+1, WIDTH-pos, 1);
if (local_sweep_time > 10 * ONE_SECOND_TIME) {
plot_into_index(measured);
redraw_request |= REDRAW_CELLS | REDRAW_BATTERY;
// plot trace and other indications as raster
draw_all(true); // flush markmap only if scan completed to prevent
}
#ifdef __SWEEP_RESTART__
if (MODE_OUTPUT(setting.mode) && (setting.level_sweep != 0 || get_sweep_frequency(ST_SPAN) != 0))
refresh_sweep_menu(i);
@ -5111,7 +5120,7 @@ enum {
#ifdef TINYSA4
//#define CAL_LEVEL -23.5
#define CAL_LEVEL -23.1
#define CAL_LEVEL -24.2
#else
#define CAL_LEVEL (has_esd ? -26.2 : -25)
#endif
@ -6236,7 +6245,9 @@ again:
reset_settings(M_LOW);
set_refer_output(0);
set_attenuation(10);
set_sweep_frequency(ST_STOP, 60000000);
set_sweep_frequency(ST_CENTER, 30000000);
set_sweep_frequency(ST_SPAN, 5000000);
setting.rbw_x10 = 3000;
int test_case = TEST_POWER;
#ifdef TINYSA4
set_extra_lna(calibrate_lna);

@ -616,6 +616,7 @@ void ADF4351_enable_out(int s)
bool SI4463_frequency_changed = false;
bool SI4463_offset_changed = false;
int SI4463_offset_value = 0;
uint8_t SI4463_rbw_selected = 0;
static int SI4463_band = -1;
//static freq_t SI4463_prev_freq = 0;
@ -1601,8 +1602,8 @@ static const RBW_t RBW_choices[] =
{SI4463_RBW_30kHz, 12,300, 10},
{SI4463_RBW_100kHz, 2,1000, 17},
{SI4463_RBW_300kHz, 4,3000, 10},
{SI4463_RBW_600kHz, 10,6000, 8},
{SI4463_RBW_850kHz, 15,8500, 8},
{SI4463_RBW_600kHz, -10,6000, 8},
{SI4463_RBW_850kHz, -9,8500, 8},
};
const uint8_t SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t)));
@ -1623,7 +1624,7 @@ void switch_SI4463_RSSI_correction(bool enabled){
uint16_t force_rbw(int f)
{
if (SI4463_in_tx_mode)
if (SI4463_in_tx_mode || f >= (int)(sizeof(RBW_choices)/sizeof(RBW_t)))
return(0);
SI4463_set_state(SI446X_STATE_READY);
const uint8_t *config = RBW_choices[f].reg;
@ -1640,6 +1641,7 @@ uint16_t force_rbw(int f)
// prev_band = -1;
SI4463_RSSI_correction = ( SI4463_RSSI_correction_enabled ? float_TO_PURE_RSSI(RBW_choices[f].RSSI_correction_x_10 - 1200)/10 : float_TO_PURE_RSSI(-120) ) ; // Set RSSI correction
SI4463_noise_correction_x10 = RBW_choices[f].noise_correction_x10;
SI4463_rbw_selected = f;
return RBW_choices[f].RBWx10; // RBW achieved by SI4463 in kHz * 10
}

13
ui.c

@ -121,16 +121,6 @@ static const uint8_t slider_bitmap[]=
#define BUTTON_BORDER_RISE (BUTTON_BORDER_TOP|BUTTON_BORDER_RIGHT)
#define BUTTON_BORDER_FALLING (BUTTON_BORDER_BOTTOM|BUTTON_BORDER_LEFT)
// Set structure align as WORD (save flash memory)
#pragma pack(push, 2)
typedef struct {
uint8_t type;
uint8_t data;
char *label;
const void *reference;
} menuitem_t;
#pragma pack(pop)
// Touch screen
#define EVT_TOUCH_NONE 0
#define EVT_TOUCH_DOWN 1
@ -154,7 +144,6 @@ static void erase_menu_buttons(void);
static void ui_process_keypad(void);
static void choose_active_marker(void);
static void menu_move_back(bool leave_ui);
static void menu_push_submenu(const menuitem_t *submenu);
//static const menuitem_t menu_marker_type[];
static int btn_check(void)
@ -873,7 +862,7 @@ menu_move_back(bool leave_ui)
ui_mode_menu();
}
static void
void
menu_push_submenu(const menuitem_t *submenu)
{
erase_menu_buttons();

@ -525,8 +525,8 @@ ui_slider_t ui_sliders [] =
// ===[MENU CALLBACKS]=========================================================
static const menuitem_t menu_lowoutputmode[];
static const menuitem_t menu_highoutputmode[];
const menuitem_t menu_lowoutputmode[];
const menuitem_t menu_highoutputmode[];
static const menuitem_t menu_modulation[];
static const menuitem_t menu_top[];
static const menuitem_t menu_trace[];
@ -2394,7 +2394,7 @@ static const menuitem_t menu_sweep[] = {
char low_level_help_text[12] = "-76..-6";
char center_text[18] = "FREQ: %s";
static const menuitem_t menu_lowoutputmode[] = {
const menuitem_t menu_lowoutputmode[] = {
{ MT_FORM | MT_ADV_CALLBACK, 0, "LOW OUTPUT %s", menu_outputmode_acb},
// { MT_FORM | MT_ADV_CALLBACK, 0, "MOD: %s", menu_smodulation_acb},
{ MT_FORM | MT_KEYPAD, KM_CENTER, center_text, VARIANT("10kHz..350MHz","10kHz..850MHz")},
@ -2412,7 +2412,7 @@ static const menuitem_t menu_lowoutputmode[] = {
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_highoutputmode[] = {
const menuitem_t menu_highoutputmode[] = {
{ MT_FORM | MT_ADV_CALLBACK, 0, "HIGH OUTPUT %s", menu_outputmode_acb},
{ MT_FORM | MT_KEYPAD, KM_CENTER, center_text, VARIANT("240MHz..960MHz",range_text)},
{ MT_FORM | MT_KEYPAD, KM_HIGHOUTLEVEL, "LEVEL: %s", low_level_help_text /* "-76..-6" */},

Loading…
Cancel
Save

Powered by TurnKey Linux.