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 },
{ "b", cmd_b, CMD_WAIT_MUTEX },
{ "t", cmd_t, CMD_WAIT_MUTEX },
#ifdef TINYSA4
{ "k", cmd_k, CMD_WAIT_MUTEX },
#endif
{ "e", cmd_e, CMD_WAIT_MUTEX },
{ "s", cmd_s, CMD_WAIT_MUTEX },
{ "m", cmd_m, CMD_WAIT_MUTEX },

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

@ -303,6 +303,29 @@ marker_to_value(const int i)
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
// Replaced some equal functions and use recalculated constants:
// 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_i++;
}
float thd = 100.0 * sqrtf(h/p);
float thd = 100.0 * sa_sqrtf(h/p);
setting.unit = old_unit;
ili9341_set_foreground(marker_color(markers[0].mtype));
// j = 1;

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

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

@ -570,7 +570,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_curve_acb)
(void)item;
int old_m;
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_value[current_curve][data]);
b->param_1.text = uistat.text;
@ -609,6 +609,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_curve_acb)
common:
set_sweep_frequency(ST_SPAN, 1000000);
set_sweep_frequency(ST_CENTER, config.correction_frequency[current_curve][data]);
setting.step_delay_mode = SD_PRECISE;
current_curve_index = data;
menu_push_submenu(menu_curve_confirm);
break;
@ -1401,7 +1402,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_average_acb)
return;
}
set_average(data);
menu_move_back(true);
// menu_move_back(true);
}
extern const menuitem_t menu_marker_modify[];
@ -2395,7 +2396,7 @@ static const menuitem_t menu_actual_power[] =
#ifdef TINYSA4
{ MT_CALLBACK, 0, "INPUT\nCURVE", menu_input_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
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel

Loading…
Cancel
Save

Powered by TurnKey Linux.