Add LISTEN function

Removed_REF_marker
erikkaashoek 5 years ago
parent aab365f67d
commit 680967e6f7

@ -68,6 +68,7 @@
#define __NICE_BIG_FONT__ // Add not scaled big font for menus
#define __QUASI_PEAK__ // Add quasi peak average option
#define __REMOTE_DESKTOP__ // Add remote desktop option
#define __LISTEN__
#ifdef TINYSA4
#define __HARMONIC__
#endif
@ -234,6 +235,8 @@ enum {
#define MODE_LOW(x) ((x) == M_LOW || (x) == M_GENLOW )
#ifdef __SI4432__
#define SI4432_RX 0
#define SI4432_LO 1
#define MODE_SELECT(x) (MODE_HIGH(x) ? SI4432_LO : SI4432_RX)
#endif
#ifdef __SI4468__
@ -1287,6 +1290,10 @@ enum {
T_AUTO, T_NORMAL, T_SINGLE, T_DONE, T_UP, T_DOWN, T_MODE, T_PRE, T_POST, T_MID
};
extern const int SI4432_RBW_count;
extern void SI4432_Listen(int s);
#ifdef TINYSA4
// si4432.c

@ -4502,6 +4502,7 @@ void self_test(int test)
}
#endif
reset_settings(M_LOW);
#endif
} else if (test == 3) { // RBW step time search
in_selftest = true;
ui_mode_normal();
@ -4556,7 +4557,7 @@ void self_test(int test)
// return;
// }
shell_printf("Start level = %f, ",peakLevel);
#if 1 // Enable for step delay tuning
#if 0 // Enable for step delay tuning
while (setting.step_delay > 10 && test_value != 0 && test_value > saved_peakLevel - 1.5) {
test_prepare(TEST_RBW);
setting.spur_removal = S_OFF;
@ -4583,7 +4584,7 @@ void self_test(int test)
#else
setting.offset_delay = 1600;
#endif
#if 1 // Enable for offset tuning stepping
#if 0 // Enable for offset tuning stepping
test_value = saved_peakLevel;
if ((uint32_t)(setting.rbw_x10 * 1000) / (sweep_points) < 8000) { // fast mode possible
while (setting.offset_delay > 0 && test_value != 0 && test_value > saved_peakLevel - 1.5) {
@ -4602,15 +4603,16 @@ void self_test(int test)
}
setting.offset_delay = setting.offset_delay * 5 / 4; // back one level
}
shell_printf("---------------------------------------------\n\r");
#endif
shell_printf("End level = %f, step time = %d, fast delay = %d\n\r",peakLevel, setting.step_delay, setting.offset_delay);
shell_printf("---------------------------------------------\n\r");
if (setting.test_argument != 0)
break;
}
reset_settings(M_LOW);
setting.step_delay_mode = SD_NORMAL;
setting.step_delay = 0;
#ifdef DOESNOTFIT
} else if (test == 4) {
reset_settings(M_LOW);
set_mode(M_GENLOW);

@ -325,10 +325,12 @@ typedef struct {
int8_t RSSI_correction_x_10; // Correction * 10
uint16_t RBWx10; // RBW * 10 in kHz
}RBW_t; // sizeof(RBW_t) = 4 bytes
static const RBW_t RBW_choices[] = {
static const RBW_t RBW_choices[] =
{
// BW register corr freq
// {IF_BW(0,5,1),0,26},
// {IF_BW(0,5,2),0,28},
#if 0
{IF_BW(0,5,3),3,31},
{IF_BW(0,5,4),-3,32},
{IF_BW(0,5,5),6,37},
@ -384,10 +386,69 @@ static const RBW_t RBW_choices[] = {
{IF_BW(1,0,12),-20,5188},
{IF_BW(1,0,13),-14,5770},
{IF_BW(1,0,14),-9,6207},
#else
{IF_BW(0,5,3),1,31},
{IF_BW(0,5,4),-4,32},
{IF_BW(0,5,5),1,37},
{IF_BW(0,5,6),-3,42},
{IF_BW(0,5,7),-3,45},
{IF_BW(0,4,1),-4,49},
{IF_BW(0,4,2),-4,54},
{IF_BW(0,4,3),-3,59},
{IF_BW(0,4,4),-4,61},
{IF_BW(0,4,5),1,72},
{IF_BW(0,4,6),1,82},
{IF_BW(0,4,7),1,88},
{IF_BW(0,3,1),-4,95},
{IF_BW(0,3,2),-4,106},
{IF_BW(0,3,3),-3,115},
{IF_BW(0,3,4),-8,121},
{IF_BW(0,3,5),1,142},
{IF_BW(0,3,6),1,162},
{IF_BW(0,3,7),1,175},
{IF_BW(0,2,1),-4,189},
{IF_BW(0,2,2),-4,210},
{IF_BW(0,2,3),1,227},
{IF_BW(0,2,4),-4,240},
{IF_BW(0,2,5),1,282},
{IF_BW(0,2,6),1,322},
{IF_BW(0,2,7),1,347},
{IF_BW(0,1,1),-4,377},
{IF_BW(0,1,2),-4,417},
{IF_BW(0,1,3),-3,452},
{IF_BW(0,1,4),-4,479},
{IF_BW(0,1,5),1,562},
{IF_BW(0,1,6),1,641},
{IF_BW(0,1,7),1,692},
{IF_BW(0,0,1),-4,752},
{IF_BW(0,0,2),-4,832},
{IF_BW(0,0,3),-3,900},
{IF_BW(0,0,4),-4,953},
{IF_BW(0,0,5),6,1121},
{IF_BW(0,0,6),1,1279},
{IF_BW(0,0,7),1,1379},
{IF_BW(1,1,4),16,1428},
{IF_BW(1,1,5),22,1678},
{IF_BW(1,1,9),-53,1811},
{IF_BW(1,0,15),-104,1915},
{IF_BW(1,0,1),16,2251},
{IF_BW(1,0,2),21,2488},
{IF_BW(1,0,3),17,2693},
{IF_BW(1,0,4),11,2849},
{IF_BW(1,0,8),-19,3355},
{IF_BW(1,0,9),-54,3618},
{IF_BW(1,0,10),-14,4202},
{IF_BW(1,0,11),-14,4684},
{IF_BW(1,0,12),-23,5188},
{IF_BW(1,0,13),-14,5770},
{IF_BW(1,0,14),-9,6207},
#endif
};
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 force_rbw(int i)
@ -620,6 +681,71 @@ void SI4432_Fill(int s, int start)
}
#endif
#ifdef __LISTEN__
const uint8_t dBm_to_volt [] =
{
255,
225,
198,
175,
154,
136,
120,
106,
93,
82,
72,
64,
56,
50,
44,
39,
34,
30,
26,
23,
21,
18,
16,
14,
12,
11,
10,
8,
7,
7,
6,
5,
5,
};
void SI4432_Listen(int s)
{
SI4432_Sel = s;
uint16_t sel = SI_nSEL[SI4432_Sel];
uint8_t max = 0;
uint16_t count = 0;
do {
uint8_t v;
palClearPad(GPIOC, sel);
shiftOut(SI4432_REG_RSSI);
v = shiftIn();
palSetPad(GPIOC, sel);
if (max < v) // Peak
max = v;
if (count > 1000) { // Decay
max -= 1;
count = 0;
} else
count++;
v = max - v;
dacPutChannelX(&DACD2, 0, dBm_to_volt[v] << 4);
} while((operation_requested & OP_LEVER) != OP_LEVER);
count = 0;
dacPutChannelX(&DACD2, 0, 0);
}
#endif
#define MINIMUM_WAIT_FOR_RSSI 280
uint32_t SI4432_offset_delay = 300;

@ -28,9 +28,6 @@ extern uint32_t SI4432_offset_delay;
//
#define MAX_SI4432 2
#define SI4432_RX 0
#define SI4432_LO 1
// #define SI4432_DUMMY 2 // never used
#define SI4432_DEV_TYPE 0x00
@ -188,7 +185,7 @@ int16_t Si446x_RSSI(void);
uint8_t getFRR(uint8_t reg);
si446x_state_t getState(void);
void setState(si446x_state_t newState);
extern const int SI4432_RBW_count;
extern si446x_info_t SI4463_info;
pureRSSI_t getSI4463_RSSI_correction(void);
void Si446x_getInfo(si446x_info_t* info);

@ -678,6 +678,14 @@ static UI_FUNCTION_CALLBACK(menu_dfu_cb)
enter_dfu();
}
#ifdef __LISTEN__
static UI_FUNCTION_CALLBACK(menu_listen_cb)
{
(void)data;
(void)item;
SI4432_Listen(MODE_SELECT(setting.mode));
}
#endif
// const int menu_modulation_value[]={MO_NONE,MO_AM, MO_NFM, MO_WFM, MO_EXTERNAL};
const char *menu_modulation_text[]={"None", "AM", "NFM", "WFM", "External"};
@ -2098,6 +2106,9 @@ static const menuitem_t menu_level[] = {
{ MT_ADV_CALLBACK | MT_LOW ,0,"LNA", menu_extra_lna_acb},
#endif
{ MT_SUBMENU, 0, "TRIGGER", menu_trigger},
#ifdef __LISTEN__
{ MT_CALLBACK, 0, "LISTEN", menu_listen_cb},
#endif
{ MT_CANCEL, 0, S_LARROW" BACK",NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};

Loading…
Cancel
Save

Powered by TurnKey Linux.