Temperature, speed, size optimizations

Removed_REF_marker
erikkaashoek 5 years ago
parent ba60a0e615
commit b00979a31b

@ -2504,7 +2504,9 @@ static const VNAShellCommand commands[] =
{ "a", cmd_a, CMD_WAIT_MUTEX }, { "a", cmd_a, CMD_WAIT_MUTEX },
{ "b", cmd_b, CMD_WAIT_MUTEX }, { "b", cmd_b, CMD_WAIT_MUTEX },
{ "t", cmd_t, CMD_WAIT_MUTEX }, { "t", cmd_t, CMD_WAIT_MUTEX },
#ifdef TINYSA4
{ "k", cmd_k, CMD_WAIT_MUTEX }, { "k", cmd_k, CMD_WAIT_MUTEX },
#endif
{ "e", cmd_e, CMD_WAIT_MUTEX }, { "e", cmd_e, CMD_WAIT_MUTEX },
{ "s", cmd_s, CMD_WAIT_MUTEX }, { "s", cmd_s, CMD_WAIT_MUTEX },
{ "m", cmd_m, CMD_WAIT_MUTEX }, { "m", cmd_m, CMD_WAIT_MUTEX },

@ -18,7 +18,7 @@
*/ */
#include "ch.h" #include "ch.h"
//#ifdef TINYSA_F303 #ifdef TINYSA_F303
#include "adc_F303.h" #include "adc_F303.h"
#ifdef TINYSA_F072 #ifdef TINYSA_F072
#error "Remove comment for #ifdef TINYSA_F303" #error "Remove comment for #ifdef TINYSA_F303"
@ -27,7 +27,7 @@
#define TINYSA4 #define TINYSA4
#endif #endif
#define TINYSA4_PROTO #define TINYSA4_PROTO
//#endif #endif
#ifdef TINYSA_F072 #ifdef TINYSA_F072
#ifdef TINYSA_F303 #ifdef TINYSA_F303

@ -303,6 +303,29 @@ marker_to_value(const int i)
return(value(ref_marker_levels[markers[i].index])); return(value(ref_marker_levels[markers[i].index]));
} }
#ifdef TINYSA3
float sa_sqrtf(const float x)
{
union
{
int i;
float x;
} u;
u.x = x;
u.i = (1<<29) + (u.i >> 1) - (1<<22);
// Two Babylonian Steps (simplified from:)
// u.x = 0.5f * (u.x + x/u.x);
// u.x = 0.5f * (u.x + x/u.x);
u.x = u.x + x/u.x;
u.x = 0.25f*u.x + x/u.x;
return u.x;
}
#else
#define sa_sqrtf(x) sqrtf(x)
#endif
// Function for convert to different type of values from dBm // Function for convert to different type of values from dBm
// Replaced some equal functions and use recalculated constants: // Replaced some equal functions and use recalculated constants:
// powf(10,x) = expf(x * logf(10)) // powf(10,x) = expf(x * logf(10))
@ -1469,7 +1492,7 @@ static void cell_draw_marker_info(int x0, int y0)
h += marker_to_value(1); h += marker_to_value(1);
h_i++; h_i++;
} }
float thd = 100.0 * sqrtf(h/p); float thd = 100.0 * sa_sqrtf(h/p);
setting.unit = old_unit; setting.unit = old_unit;
ili9341_set_foreground(marker_color(markers[0].mtype)); ili9341_set_foreground(marker_color(markers[0].mtype));
// j = 1; // j = 1;

@ -1073,6 +1073,8 @@ void set_offset_delay(int d) // override RSSI measurement delay
void set_average(int v) void set_average(int v)
{ {
if (setting.average == v)
dirty = true;
setting.average = v; setting.average = v;
trace[TRACE_TEMP].enabled = ((v != 0) trace[TRACE_TEMP].enabled = ((v != 0)
#ifdef __QUASI_PEAK__ #ifdef __QUASI_PEAK__

@ -868,65 +868,65 @@ static uint8_t SI4463_wait_response(void* buff, uint8_t len, uint8_t use_timeout
return 1; return 1;
} }
#define SI_FAST_SPEED SPI_BR_DIV2
void SI4463_do_api(void* data, uint8_t len, void* out, uint8_t outLen) void SI4463_do_api(void* data, uint8_t len, void* out, uint8_t outLen)
{ {
set_SPI_mode(SPI_MODE_SI); set_SPI_mode(SPI_MODE_SI);
SPI_BR_SET(SI4432_SPI, SI4432_SPI_SPEED); SPI_BR_SET(SI4432_SPI, SI_FAST_SPEED);
while (!SI4463_READ_CTS) { my_microsecond_delay(1); } // Wait for CTS #define SHORT_DELAY my_microsecond_delay(1)
//#define SHORT_DELAY
{ while (!SI4463_READ_CTS) {SHORT_DELAY; } // Wait for CTS
// SPI_BR_SET(SI4432_SPI, SPI_BR_DIV8);
__disable_irq(); __disable_irq();
SI_CS_LOW; SI_CS_LOW;
for(uint8_t i=0;i<len;i++) {
for(uint8_t i=0;i<len;i++) {
#if 1 // Inline transfer #if 1 // Inline transfer
while (SPI_TX_IS_NOT_EMPTY(SI4432_SPI)); // while (SPI_TX_IS_NOT_EMPTY(SI4432_SPI));
SPI_WRITE_8BIT(SI4432_SPI, ((uint8_t*)data)[i]); SPI_WRITE_8BIT(SI4432_SPI, ((uint8_t*)data)[i]);
while (SPI_IS_BUSY(SI4432_SPI)) // drop rx and wait tx while (SPI_IS_BUSY(SI4432_SPI)) // drop rx and wait tx
SPI_READ_8BIT(SI4432_SPI); SPI_READ_8BIT(SI4432_SPI);
#else #else
shiftOut(((uint8_t*)data)[i]); // (pgm_read_byte(&((uint8_t*)data)[i])); shiftOut(((uint8_t*)data)[i]); // (pgm_read_byte(&((uint8_t*)data)[i]));
#endif #endif
} }
// SPI_BR_SET(SI4432_SPI, SPI_BR_DIV8); // SPI_BR_SET(SI4432_SPI, SPI_BR_DIV8);
SI_CS_HIGH; SI_CS_HIGH;
__enable_irq(); // __enable_irq();
while (!SI4463_READ_CTS) { my_microsecond_delay(1); } // Wait for CTS
if(out != NULL) { // If we have an output buffer then read command response into it while (!SI4463_READ_CTS) { SHORT_DELAY; } // Wait for CTS
__disable_irq(); if(out != NULL) { // If we have an output buffer then read command response into it
// again: SI_CS_LOW;
SI_CS_LOW; SPI_BR_SET(SI4432_SPI, SI4432_SPI_SPEED);
shiftOut( SI446X_CMD_READ_CMD_BUFF ); #if 1
// uint8_t cts = (shiftIn() == 0xFF); SPI_WRITE_8BIT(SI4432_SPI,SI446X_CMD_READ_CMD_BUFF);
shiftIn(); // Should always be 0xFF while (SPI_IS_BUSY(SI4432_SPI)) // drop rx and wait tx
// uint8_t cts = 0xFF; SPI_READ_8BIT(SI4432_SPI);
// if (cts) SPI_WRITE_8BIT(SI4432_SPI, 0xFF);
{ while (SPI_IS_BUSY(SI4432_SPI)) // drop rx and wait tx
// Get response data SPI_READ_8BIT(SI4432_SPI);
for(uint8_t i=0;i<outLen;i++) { #else
shiftOut( SI446X_CMD_READ_CMD_BUFF );
shiftIn(); // Should always be 0xFF
#endif
// Get response data
for(uint8_t i=0;i<outLen;i++) {
#if 1 // Inline transfer #if 1 // Inline transfer
SPI_WRITE_8BIT(SI4432_SPI, 0xFF); SPI_WRITE_8BIT(SI4432_SPI, 0xFF);
while (SPI_IS_BUSY(SI4432_SPI)) // drop rx and wait tx while (SPI_IS_BUSY(SI4432_SPI)) // drop rx and wait tx
while (SPI_RX_IS_EMPTY(SI4432_SPI)); //wait rx data in buffer while (SPI_RX_IS_EMPTY(SI4432_SPI)); //wait rx data in buffer
((uint8_t*)out)[i] = SPI_READ_8BIT(SI4432_SPI); ((uint8_t*)out)[i] = SPI_READ_8BIT(SI4432_SPI);
#else #else
((uint8_t*)out)[i] = shiftIn(); ((uint8_t*)out)[i] = shiftIn();
#endif #endif
}
}
// else {
// SI_CS_HIGH;
// goto again;
// }
SI_CS_HIGH;
__enable_irq();
} }
SI_CS_HIGH;
} }
__enable_irq();
} }
#ifdef notused #ifdef notused
@ -1210,9 +1210,12 @@ void Si446x_getInfo(si446x_info_t* info)
float Si446x_get_temp(void) float Si446x_get_temp(void)
{ {
uint8_t data[6] = { SI446X_CMD_GET_ADC_READING, 0x10 }; uint8_t data[8] = { SI446X_CMD_GET_ADC_READING, 0x10, 0 };
SI4463_do_api(data, 2, data, 6); SI4463_do_api(data, 3, data, 8);
float t = (data[4] << 8) + data[5]; int i = 4;
if (MODE_OUTPUT(setting.mode))
i = 6;
float t = (data[i] << 8) + data[i+1];
t = (899.0 * t /4096.0) - 293.0; t = (899.0 * t /4096.0) - 293.0;
return t; return t;
} }

@ -570,7 +570,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_curve_acb)
(void)item; (void)item;
int old_m; int old_m;
if (b){ if (b){
plot_printf(uistat.text, sizeof uistat.text, "%.3QHz %+.1fdB", plot_printf(uistat.text, sizeof uistat.text, "%8.3QHz %+4.1fdB",
config.correction_frequency[current_curve][data], config.correction_frequency[current_curve][data],
config.correction_value[current_curve][data]); config.correction_value[current_curve][data]);
b->param_1.text = uistat.text; b->param_1.text = uistat.text;
@ -609,6 +609,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_curve_acb)
common: common:
set_sweep_frequency(ST_SPAN, 1000000); set_sweep_frequency(ST_SPAN, 1000000);
set_sweep_frequency(ST_CENTER, config.correction_frequency[current_curve][data]); set_sweep_frequency(ST_CENTER, config.correction_frequency[current_curve][data]);
setting.step_delay_mode = SD_PRECISE;
current_curve_index = data; current_curve_index = data;
menu_push_submenu(menu_curve_confirm); menu_push_submenu(menu_curve_confirm);
break; break;
@ -1401,7 +1402,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_average_acb)
return; return;
} }
set_average(data); set_average(data);
menu_move_back(true); // menu_move_back(true);
} }
extern const menuitem_t menu_marker_modify[]; extern const menuitem_t menu_marker_modify[];
@ -2395,7 +2396,7 @@ static const menuitem_t menu_actual_power[] =
#ifdef TINYSA4 #ifdef TINYSA4
{ MT_CALLBACK, 0, "INPUT\nCURVE", menu_input_curve_prepare_cb}, { MT_CALLBACK, 0, "INPUT\nCURVE", menu_input_curve_prepare_cb},
{ MT_CALLBACK, 0, "LNA\nCURVE", menu_lna_curve_prepare_cb}, { MT_CALLBACK, 0, "LNA\nCURVE", menu_lna_curve_prepare_cb},
{ MT_SUBMENU | MT_LOW, 0, "OUTPUT\nCURVE", menu_output_curve_prepare_cb}, { MT_CALLBACK, 0, "OUTPUT\nCURVE", menu_output_curve_prepare_cb},
#endif #endif
{ 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

Loading…
Cancel
Save

Powered by TurnKey Linux.