Reverted back to old si4468.c code

Removed_REF_marker
erikkaashoek 5 years ago
parent 568cbe17c9
commit 09ab2f583c

@ -76,6 +76,7 @@
#define __LISTEN__
#define __CHANNEL_POWER__
#define __LIMITS__
#define __MCU_CLOCK_SHIFT__
#ifdef TINYSA4
#define __HARMONIC__
#define __VBW__

@ -376,6 +376,23 @@ dBm_to_Watt(const float v)
return logf(v*1000.0)*(10.0/logf(10.0));
}
static float fast_expf(float x)
{
union { float f; int32_t i; } v;
v.i = (int32_t)(12102203.0f*x) + 0x3F800000;
int32_t m = (v.i >> 7) & 0xFFFF; // copy mantissa
#if 1
// cubic spline approximation
// empirical values for small maximum relative error (8.34e-5):
v.i += ((((((((1277*m) >> 14) + 14825)*m) >> 14) - 79749)*m) >> 11) - 626;
#else
// quartic spline approximation
// empirical values for small maximum relative error (1.21e-5):
v.i += (((((((((((3537*m) >> 16) + 13668)*m) >> 18) + 15817)*m) >> 14) - 80470)*m) >> 11);
#endif
return v.f;
}
static void
trace_into_index_x_array(index_x_t *x, uint16_t points){
// Not need update if index calculated for this points count
@ -417,7 +434,7 @@ trace_into_index_y_array(index_y_t *y, float *array, int points)
int max = NGRIDY * GRIDY, i;
for (i=0;i<points;i++){
float value = array[i];
if (mult) value = expf(value*mult);
if (mult) value = fast_expf(value*mult);
value = ref - value * scale;
int v = value;
if (v < 0) v = 0;

@ -2559,11 +2559,15 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
}
if (MODE_INPUT(setting.mode)) {
calculate_static_correction();
#ifdef __MCU_CLOCK_SHIFT__
if (!in_selftest) clock_above_48MHz();
#endif
is_below = false;
correct_RSSI_freq = get_frequency_correction(f); // for i == 0 and freq_step == 0;
} else {
#ifdef __MCU_CLOCK_SHIFT__
clock_at_48MHz();
#endif
}
// if (MODE_OUTPUT(setting.mode) && setting.additional_step_delay_us < 500) // Minimum wait time to prevent LO from lockup during output frequency sweep
// setting.additional_step_delay_us = 500;
@ -3226,7 +3230,7 @@ again: // Spur redu
#endif
}
#if 1
#ifdef __MCU_CLOCK_SHIFT__
if (setting.mode == M_LOW && !in_selftest) { // Avoid 48MHz spur
int set_below = false;
#ifdef TINYSA4
@ -3239,6 +3243,7 @@ again: // Spur redu
#endif
if (lf > 40000000){
uint32_t tf = lf;
while (tf > 240000000) tf -= 240000000; // Wrap between 0-48MHz
while (tf > 48000000) tf -= 48000000; // Wrap between 0-48MHz
if (tf < 20000000 )
set_below = true;

Loading…
Cancel
Save

Powered by TurnKey Linux.