mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
Merge branch 'bandwidth'
This commit is contained in:
commit
5a10105b1a
16
dsp.c
16
dsp.c
|
|
@ -41,10 +41,10 @@ const int16_t sincos_tbl[48][2] = {
|
||||||
{-24636, -21605 }, {-32698, -2143 }, {-27246, 18205 }, {-10533, 31029 }
|
{-24636, -21605 }, {-32698, -2143 }, {-27246, 18205 }, {-10533, 31029 }
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t acc_samp_s;
|
float acc_samp_s;
|
||||||
int32_t acc_samp_c;
|
float acc_samp_c;
|
||||||
int32_t acc_ref_s;
|
float acc_ref_s;
|
||||||
int32_t acc_ref_c;
|
float acc_ref_c;
|
||||||
|
|
||||||
void
|
void
|
||||||
dsp_process(int16_t *capture, size_t length)
|
dsp_process(int16_t *capture, size_t length)
|
||||||
|
|
@ -79,10 +79,10 @@ dsp_process(int16_t *capture, size_t length)
|
||||||
ref_c = __SMLATT(sr, sc, ref_c);
|
ref_c = __SMLATT(sr, sc, ref_c);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
acc_samp_s = samp_s;
|
acc_samp_s += samp_s;
|
||||||
acc_samp_c = samp_c;
|
acc_samp_c += samp_c;
|
||||||
acc_ref_s = ref_s;
|
acc_ref_s += ref_s;
|
||||||
acc_ref_c = ref_c;
|
acc_ref_c += ref_c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
46
main.c
46
main.c
|
|
@ -584,10 +584,34 @@ int16_t dump_buffer[AUDIO_BUFFER_LEN];
|
||||||
int16_t dump_selection = 0;
|
int16_t dump_selection = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
volatile int16_t wait_count = 0;
|
volatile uint8_t wait_count = 0;
|
||||||
|
volatile uint8_t accumerate_count = 0;
|
||||||
|
|
||||||
|
const int8_t bandwidth_accumerate_count[] = {
|
||||||
|
1, // 1kHz
|
||||||
|
3, // 300Hz
|
||||||
|
10, // 100Hz
|
||||||
|
33, // 30Hz
|
||||||
|
100 // 10Hz
|
||||||
|
};
|
||||||
|
|
||||||
float measured[2][POINTS_COUNT][2];
|
float measured[2][POINTS_COUNT][2];
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
dsp_start(int count)
|
||||||
|
{
|
||||||
|
wait_count = count;
|
||||||
|
accumerate_count = bandwidth_accumerate_count[bandwidth];
|
||||||
|
reset_dsp_accumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
dsp_wait(void)
|
||||||
|
{
|
||||||
|
while (accumerate_count > 0)
|
||||||
|
__WFI();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLED_DUMP
|
#ifdef ENABLED_DUMP
|
||||||
static void
|
static void
|
||||||
duplicate_buffer_to_dump(int16_t *p)
|
duplicate_buffer_to_dump(int16_t *p)
|
||||||
|
|
@ -610,13 +634,16 @@ void i2s_end_callback(I2SDriver *i2sp, size_t offset, size_t n)
|
||||||
(void)i2sp;
|
(void)i2sp;
|
||||||
(void)n;
|
(void)n;
|
||||||
|
|
||||||
if (wait_count > 0) {
|
if (wait_count > 1) {
|
||||||
if (wait_count == 1)
|
--wait_count;
|
||||||
|
} else if (wait_count > 0) {
|
||||||
|
if (accumerate_count > 0) {
|
||||||
dsp_process(p, n);
|
dsp_process(p, n);
|
||||||
|
accumerate_count--;
|
||||||
|
}
|
||||||
#ifdef ENABLED_DUMP
|
#ifdef ENABLED_DUMP
|
||||||
duplicate_buffer_to_dump(p);
|
duplicate_buffer_to_dump(p);
|
||||||
#endif
|
#endif
|
||||||
--wait_count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PORT_SUPPORTS_RT
|
#if PORT_SUPPORTS_RT
|
||||||
|
|
@ -808,9 +835,6 @@ ensure_edit_config(void)
|
||||||
cal_status = 0;
|
cal_status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DSP_START(delay) wait_count = delay;
|
|
||||||
#define DSP_WAIT_READY while (wait_count) __WFI();
|
|
||||||
|
|
||||||
#define DELAY_CHANNEL_CHANGE 2
|
#define DELAY_CHANNEL_CHANGE 2
|
||||||
|
|
||||||
// main loop for measurement
|
// main loop for measurement
|
||||||
|
|
@ -824,20 +848,20 @@ bool sweep(bool break_on_operation)
|
||||||
if (frequencies[i] == 0) break;
|
if (frequencies[i] == 0) break;
|
||||||
delay = set_frequency(frequencies[i]); // 700
|
delay = set_frequency(frequencies[i]); // 700
|
||||||
tlv320aic3204_select(0); // 60 CH0:REFLECT, reset and begin measure
|
tlv320aic3204_select(0); // 60 CH0:REFLECT, reset and begin measure
|
||||||
DSP_START(delay + ((i == 0) ? 1 : 0)); // 1900
|
dsp_start(delay + ((i == 0) ? 1 : 0)); // 1900
|
||||||
//================================================
|
//================================================
|
||||||
// Place some code thats need execute while delay
|
// Place some code thats need execute while delay
|
||||||
//================================================
|
//================================================
|
||||||
DSP_WAIT_READY;
|
dsp_wait();
|
||||||
// calculate reflection coefficient
|
// calculate reflection coefficient
|
||||||
(*sample_func)(measured[0][i]); // 60
|
(*sample_func)(measured[0][i]); // 60
|
||||||
|
|
||||||
tlv320aic3204_select(1); // 60 CH1:TRANSMISSION, reset and begin measure
|
tlv320aic3204_select(1); // 60 CH1:TRANSMISSION, reset and begin measure
|
||||||
DSP_START(DELAY_CHANNEL_CHANGE); // 1700
|
dsp_start(DELAY_CHANNEL_CHANGE); // 1700
|
||||||
//================================================
|
//================================================
|
||||||
// Place some code thats need execute while delay
|
// Place some code thats need execute while delay
|
||||||
//================================================
|
//================================================
|
||||||
DSP_WAIT_READY;
|
dsp_wait();
|
||||||
// calculate transmission coefficient
|
// calculate transmission coefficient
|
||||||
(*sample_func)(measured[1][i]); // 60
|
(*sample_func)(measured[1][i]); // 60
|
||||||
// ======== 170 ===========
|
// ======== 170 ===========
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,7 @@ typedef struct properties {
|
||||||
int8_t _active_marker;
|
int8_t _active_marker;
|
||||||
uint8_t _domain_mode; /* 0bxxxxxffm : where ff: TD_FUNC m: DOMAIN_MODE */
|
uint8_t _domain_mode; /* 0bxxxxxffm : where ff: TD_FUNC m: DOMAIN_MODE */
|
||||||
uint8_t _marker_smith_format;
|
uint8_t _marker_smith_format;
|
||||||
|
uint8_t _bandwidth;
|
||||||
uint8_t _reserved[50];
|
uint8_t _reserved[50];
|
||||||
uint32_t checksum;
|
uint32_t checksum;
|
||||||
} properties_t;
|
} properties_t;
|
||||||
|
|
@ -405,6 +406,7 @@ extern properties_t current_props;
|
||||||
#define domain_mode current_props._domain_mode
|
#define domain_mode current_props._domain_mode
|
||||||
#define velocity_factor current_props._velocity_factor
|
#define velocity_factor current_props._velocity_factor
|
||||||
#define marker_smith_format current_props._marker_smith_format
|
#define marker_smith_format current_props._marker_smith_format
|
||||||
|
#define bandwidth current_props._bandwidth
|
||||||
|
|
||||||
#define FREQ_IS_STARTSTOP() (!(config.freq_mode&FREQ_MODE_CENTER_SPAN))
|
#define FREQ_IS_STARTSTOP() (!(config.freq_mode&FREQ_MODE_CENTER_SPAN))
|
||||||
#define FREQ_IS_CENTERSPAN() (config.freq_mode&FREQ_MODE_CENTER_SPAN)
|
#define FREQ_IS_CENTERSPAN() (config.freq_mode&FREQ_MODE_CENTER_SPAN)
|
||||||
|
|
|
||||||
23
ui.c
23
ui.c
|
|
@ -631,6 +631,13 @@ menu_transform_filter_cb(int item, uint8_t data)
|
||||||
ui_mode_normal();
|
ui_mode_normal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
menu_bandwidth_cb(int item)
|
||||||
|
{
|
||||||
|
bandwidth = item;
|
||||||
|
draw_menu();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
choose_active_marker(void)
|
choose_active_marker(void)
|
||||||
{
|
{
|
||||||
|
|
@ -928,12 +935,23 @@ const menuitem_t menu_transform[] = {
|
||||||
{ MT_NONE, 0, NULL, NULL } // sentinel
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const menuitem_t menu_bandwidth[] = {
|
||||||
|
{ MT_CALLBACK, 0, "1 kHz", menu_bandwidth_cb },
|
||||||
|
{ MT_CALLBACK, 0, "300 Hz", menu_bandwidth_cb },
|
||||||
|
{ MT_CALLBACK, 0, "100 Hz", menu_bandwidth_cb },
|
||||||
|
{ MT_CALLBACK, 0, "30 Hz", menu_bandwidth_cb },
|
||||||
|
{ MT_CALLBACK, 0, "10 Hz", menu_bandwidth_cb },
|
||||||
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
||||||
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
||||||
|
};
|
||||||
|
|
||||||
const menuitem_t menu_display[] = {
|
const menuitem_t menu_display[] = {
|
||||||
{ MT_SUBMENU, 0, "TRACE", menu_trace },
|
{ MT_SUBMENU, 0, "TRACE", menu_trace },
|
||||||
{ MT_SUBMENU, 0, "FORMAT", menu_format },
|
{ MT_SUBMENU, 0, "FORMAT", menu_format },
|
||||||
{ MT_SUBMENU, 0, "SCALE", menu_scale },
|
{ MT_SUBMENU, 0, "SCALE", menu_scale },
|
||||||
{ MT_SUBMENU, 0, "CHANNEL", menu_channel },
|
{ MT_SUBMENU, 0, "CHANNEL", menu_channel },
|
||||||
{ MT_SUBMENU, 0, "TRANSFORM", menu_transform },
|
{ MT_SUBMENU, 0, "TRANSFORM", menu_transform },
|
||||||
|
{ MT_SUBMENU, 0, "BANDWIDTH", menu_bandwidth },
|
||||||
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
||||||
{ MT_NONE, 0, NULL, NULL } // sentinel
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
||||||
};
|
};
|
||||||
|
|
@ -1365,6 +1383,11 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
|
||||||
*bg = DEFAULT_MENU_TEXT_COLOR;
|
*bg = DEFAULT_MENU_TEXT_COLOR;
|
||||||
*fg = config.menu_normal_color;
|
*fg = config.menu_normal_color;
|
||||||
}
|
}
|
||||||
|
} else if (menu == menu_bandwidth) {
|
||||||
|
if (item == bandwidth) {
|
||||||
|
*bg = 0x0000;
|
||||||
|
*fg = 0xffff;
|
||||||
|
}
|
||||||
} else if (menu == menu_transform) {
|
} else if (menu == menu_transform) {
|
||||||
if ((item == 0 && (domain_mode & DOMAIN_MODE) == DOMAIN_TIME)
|
if ((item == 0 && (domain_mode & DOMAIN_MODE) == DOMAIN_TIME)
|
||||||
|| (item == 1 && (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_IMPULSE)
|
|| (item == 1 && (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_IMPULSE)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue