First experiment with span in output mode

tinySA
erikkaashoek 6 years ago
parent 01a665f306
commit 495063f5bf

@ -1,5 +1,4 @@
/* /*
* Copyright (c) 2016-2017, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com
* All rights reserved. * All rights reserved.
* *
* This is free software; you can redistribute it and/or modify * This is free software; you can redistribute it and/or modify
@ -116,7 +115,7 @@ const char *info_about[]={
"Platform: " PLATFORM_NAME, "Platform: " PLATFORM_NAME,
0 // sentinel 0 // sentinel
}; };
extern int dirty;
static THD_WORKING_AREA(waThread1, 900); static THD_WORKING_AREA(waThread1, 900);
static THD_FUNCTION(Thread1, arg) static THD_FUNCTION(Thread1, arg)
{ {
@ -126,6 +125,7 @@ static THD_FUNCTION(Thread1, arg)
while (1) { while (1) {
bool completed = false; bool completed = false;
if (sweep_mode&(SWEEP_ENABLE|SWEEP_ONCE)) { if (sweep_mode&(SWEEP_ENABLE|SWEEP_ONCE)) {
if (dirty)
completed = sweep(true); completed = sweep(true);
sweep_mode&=~SWEEP_ONCE; sweep_mode&=~SWEEP_ONCE;
} else if (sweep_mode & SWEEP_SELFTEST) { } else if (sweep_mode & SWEEP_SELFTEST) {

@ -444,6 +444,10 @@ void setFreq(int V, unsigned long freq)
{ {
SI4432_Sel = V; SI4432_Sel = V;
if (old_freq[V] != freq) { if (old_freq[V] != freq) {
if (V == 0) {
V = -V;
V = -V;
}
SI4432_Set_Frequency(freq); SI4432_Set_Frequency(freq);
old_freq[V] = freq; old_freq[V] = freq;
} }
@ -685,7 +689,7 @@ float perform(bool break_on_operation, int i, int32_t f, int tracking)
long local_IF; long local_IF;
if (MODE_HIGH(setting_mode)) if (MODE_HIGH(setting_mode))
local_IF = 0; local_IF = 0;
else if (avoid_spur(f)) else if (setting_mode == M_LOW && avoid_spur(f))
local_IF = spur_alternate_IF; local_IF = spur_alternate_IF;
else else
local_IF = frequency_IF; local_IF = frequency_IF;
@ -698,7 +702,7 @@ float perform(bool break_on_operation, int i, int32_t f, int tracking)
if (local_IF) { if (local_IF) {
setFreq (0, local_IF); setFreq (0, local_IF);
} }
if (setting_modulation == MO_AM) { if (MODE_OUTPUT(setting_mode) && setting_modulation == MO_AM) {
int p = setting_attenuate * 2 + modulation_counter; int p = setting_attenuate * 2 + modulation_counter;
PE4302_Write_Byte(p); PE4302_Write_Byte(p);
if (modulation_counter == 3) if (modulation_counter == 3)
@ -706,7 +710,7 @@ float perform(bool break_on_operation, int i, int32_t f, int tracking)
else else
modulation_counter++; modulation_counter++;
chThdSleepMicroseconds(250); chThdSleepMicroseconds(250);
} else if (setting_modulation == MO_NFM || setting_modulation == MO_WFM ) { } else if (MODE_OUTPUT(setting_mode) && (setting_modulation == MO_NFM || setting_modulation == MO_WFM )) {
SI4432_Sel = 1; SI4432_Sel = 1;
SI4432_Write_Byte(0x79, modulation_counter); // Use frequency hopping channel for FM modulation SI4432_Write_Byte(0x79, modulation_counter); // Use frequency hopping channel for FM modulation
if (modulation_counter == 3) if (modulation_counter == 3)
@ -719,16 +723,22 @@ float perform(bool break_on_operation, int i, int32_t f, int tracking)
int t = 0; int t = 0;
do { do {
int lf = (uint32_t)(f + (int)(t * 500 * actual_rbw)); int lf = (uint32_t)(f + (int)(t * 500 * actual_rbw));
if (tracking) if (MODE_INPUT(setting_mode) && tracking)
setFreq (0, local_IF + lf - reffer_freq[setting_refer]); // Offset so fundamental of reffer is visible setFreq (0, local_IF + lf - reffer_freq[setting_refer]); // Offset so fundamental of reffer is visible
#if 0
if (lf >11000000 || lf < 9000000) {
lf = lf;
break;
}
#endif
setFreq (1, local_IF + lf); setFreq (1, local_IF + lf);
if (MODE_OUTPUT(setting_mode)) if (MODE_OUTPUT(setting_mode)) // No substepping in output mode
return(0); return(0);
float subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting_mode))+settingLevelOffset()+setting_attenuate; float subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting_mode))+settingLevelOffset()+setting_attenuate;
if (RSSI < subRSSI) if (RSSI < subRSSI)
RSSI = subRSSI; RSSI = subRSSI;
t++; t++;
if ((operation_requested && break_on_operation ) || (MODE_OUTPUT(setting_mode))) // output modes do not step. if (operation_requested && break_on_operation) // output modes do not step.
break; // abort break; // abort
} while (t < vbwSteps); } while (t < vbwSteps);
return(RSSI); return(RSSI);
@ -754,7 +764,7 @@ static bool sweep(bool break_on_operation)
// back to toplevel to handle ui operation // back to toplevel to handle ui operation
if (operation_requested && break_on_operation) if (operation_requested && break_on_operation)
return false; return false;
if (MODE_INPUT(setting_mode)) {
// if (setting_spur == 1) { // First pass // if (setting_spur == 1) { // First pass
// temp_t[i] = RSSI; // temp_t[i] = RSSI;
// continue; // Skip all other processing // continue; // Skip all other processing
@ -835,6 +845,7 @@ static bool sweep(bool break_on_operation)
downslope = true; downslope = true;
} }
} }
}
#else #else
if (frequencies[i] > 1000000) { if (frequencies[i] > 1000000) {
if (temppeakLevel < actual_t[i]) { if (temppeakLevel < actual_t[i]) {
@ -857,6 +868,7 @@ static bool sweep(bool break_on_operation)
draw_cal_status(); draw_cal_status();
} }
#if 1 #if 1
if (MODE_INPUT(setting_mode)) {
int i = 0; int i = 0;
int m = 0; int m = 0;
while (i < cur_max) { // For all maxima found while (i < cur_max) { // For all maxima found
@ -915,6 +927,7 @@ static bool sweep(bool break_on_operation)
} }
#endif #endif
}
// redraw_marker(peak_marker, FALSE); // redraw_marker(peak_marker, FALSE);
palSetPad(GPIOC, GPIOC_LED); palSetPad(GPIOC, GPIOC_LED);
return true; return true;

@ -131,6 +131,8 @@ byte SI4432_Read_Byte( byte ADR )
void SI4432_Reset(void) void SI4432_Reset(void)
{ {
int count = 0; int count = 0;
SI4432_Read_Byte ( 0x03 ); // Clear pending interrupts
SI4432_Read_Byte ( 0x04 );
// always perform a system reset (don't send 0x87) // always perform a system reset (don't send 0x87)
SI4432_Write_Byte( 0x07, 0x80); SI4432_Write_Byte( 0x07, 0x80);
chThdSleepMilliseconds(50); chThdSleepMilliseconds(50);
@ -225,7 +227,7 @@ void SI4432_Set_Frequency ( long Freq ) {
int N = Freq / 10000000; int N = Freq / 10000000;
Carrier = ( 4 * ( Freq - N * 10000000 )) / 625; Carrier = ( 4 * ( Freq - N * 10000000 )) / 625;
int Freq_Band = ( N - 24 ) | ( hbsel << 5 ) | ( sbsel << 6 ); int Freq_Band = ( N - 24 ) | ( hbsel << 5 ) | ( sbsel << 6 );
#if 0 #if 1
SI4432_Write_Byte ( 0x75, Freq_Band ); SI4432_Write_Byte ( 0x75, Freq_Band );
SI4432_Write_Byte ( 0x76, (Carrier>>8) & 0xFF ); SI4432_Write_Byte ( 0x76, (Carrier>>8) & 0xFF );
SI4432_Write_Byte ( 0x77, Carrier & 0xFF ); SI4432_Write_Byte ( 0x77, Carrier & 0xFF );
@ -266,6 +268,20 @@ float SI4432_RSSI(uint32_t i, int s)
void SI4432_Sub_Init(void) void SI4432_Sub_Init(void)
{ {
SI4432_Reset(); SI4432_Reset();
//set VCO and PLL Only for SI4432 V2
SI4432_Write_Byte(0x72, 0x1F); //write 0x1F to the Frequency Deviation register
SI4432_Write_Byte(0x5A, 0x7F); //write 0x7F to the VCO Current Trimming register
SI4432_Write_Byte(0x58, 0x80); //write 0xD7 to the ChargepumpCurrentTrimmingOverride register
SI4432_Write_Byte(0x59, 0x40); //write 0x40 to the Divider Current Trimming register
//set the AGC
SI4432_Write_Byte(0x6A, 0x0B); //write 0x0B to the AGC Override 2 register
//set ADC reference voltage to 0.9V
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
SI4432_Write_Byte(0x05, 0x0); SI4432_Write_Byte(0x05, 0x0);
SI4432_Write_Byte(0x06, 0x0); SI4432_Write_Byte(0x06, 0x0);
// Enable receiver chain // Enable receiver chain

@ -570,6 +570,7 @@ const menuitem_t menu_lowoutputmode[] = {
{ MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", NULL}, { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", NULL},
{ MT_FORM | MT_KEYPAD, KM_LOWOUTLEVEL, "LEVEL: %s", NULL}, { MT_FORM | MT_KEYPAD, KM_LOWOUTLEVEL, "LEVEL: %s", NULL},
{ MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation}, { MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation},
{ MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", NULL},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
}; };
@ -579,6 +580,7 @@ const menuitem_t menu_highoutputmode[] = {
{ MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", NULL}, { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", NULL},
{ MT_FORM | MT_SUBMENU, 0, "LEVEL: %s", menu_drive_wide}, { MT_FORM | MT_SUBMENU, 0, "LEVEL: %s", menu_drive_wide},
{ MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation}, { MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation},
{ MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", NULL},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL }, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
}; };

Loading…
Cancel
Save

Powered by TurnKey Linux.