Merge branch 'master' into tinySA-V4-SI4463

Removed_REF_marker
erikkaashoek 5 years ago
commit 65f269059b

@ -2091,19 +2091,22 @@ sweep_again: // stay in sweep loop when output mo
// -------------------------- auto attenuate ---------------------------------- // -------------------------- auto attenuate ----------------------------------
#define AUTO_TARGET_LEVEL -30 #define AUTO_TARGET_LEVEL -25
#define AUTO_TARGET_WINDOW 2
if (!in_selftest && setting.mode == M_LOW && setting.auto_attenuation && max_index[0] > 0) { // calculate and apply auto attenuate if (!in_selftest && setting.mode == M_LOW && setting.auto_attenuation && max_index[0] > 0) { // calculate and apply auto attenuate
setting.atten_step = false; // No step attenuate in low mode auto attenuate setting.atten_step = false; // No step attenuate in low mode auto attenuate
int changed = false; int changed = false;
float actual_max_level = actual_t[max_index[0]] - get_attenuation(); int actual_max_level = (int) (actual_t[max_index[0]] - get_attenuation());
if (actual_max_level < AUTO_TARGET_LEVEL - 11 && setting.attenuate >= 10) { if (actual_max_level < AUTO_TARGET_LEVEL && setting.attenuate > 0) {
setting.attenuate -= 10.0; setting.attenuate -= AUTO_TARGET_LEVEL - actual_max_level;
if (setting.attenuate < 0)
setting.attenuate= 0;
changed = true; changed = true;
} else if (actual_max_level < AUTO_TARGET_LEVEL - 6 && setting.attenuate >= 5) { } else if (actual_max_level > AUTO_TARGET_LEVEL && setting.attenuate < 30) {
setting.attenuate -= 5.0; setting.attenuate += actual_max_level - AUTO_TARGET_LEVEL;
changed = true; if (setting.attenuate > 30)
} else if (actual_max_level > AUTO_TARGET_LEVEL + 2 && setting.attenuate <= 20) { setting.attenuate = 30;
setting.attenuate += 10.0;
changed = true; changed = true;
} }
@ -3277,13 +3280,7 @@ void self_test(int test)
int i = 15; // calibrate low mode power on 30 MHz; int i = 15; // calibrate low mode power on 30 MHz;
test_prepare(i); test_prepare(i);
setting.step_delay = 8000; setting.step_delay = 8000;
#ifdef __SI4432__ for (int j= 0; j < SI4432_RBW_count; j++ ) {
#define RBW_COUNT 57
#endif
#ifdef __SI4463__
#define RBW_COUNT 7
#endif
for (int j= 0; j < RBW_COUNT; j++ ) {
if (setting.test_argument != 0) if (setting.test_argument != 0)
j = setting.test_argument; j = setting.test_argument;
// do_again: // do_again:

@ -349,11 +349,10 @@ typedef struct {
int8_t RSSI_correction_x_10; // Correction * 10 int8_t RSSI_correction_x_10; // Correction * 10
uint16_t RBWx10; // RBW * 10 in kHz uint16_t RBWx10; // RBW * 10 in kHz
}RBW_t; // sizeof(RBW_t) = 4 bytes }RBW_t; // sizeof(RBW_t) = 4 bytes
RBW_t RBW_choices[] = {
static RBW_t RBW_choices[] = {
// BW register corr freq // BW register corr freq
{IF_BW(0,5,1),0,26}, // {IF_BW(0,5,1),0,26},
{IF_BW(0,5,2),0,28}, // {IF_BW(0,5,2),0,28},
{IF_BW(0,5,3),3,31}, {IF_BW(0,5,3),3,31},
{IF_BW(0,5,4),-3,32}, {IF_BW(0,5,4),-3,32},
{IF_BW(0,5,5),6,37}, {IF_BW(0,5,5),6,37},
@ -413,6 +412,8 @@ static RBW_t RBW_choices[] = {
}; };
const int SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t)));
static pureRSSI_t SI4432_RSSI_correction = float_TO_PURE_RSSI(-120); static pureRSSI_t SI4432_RSSI_correction = float_TO_PURE_RSSI(-120);
uint16_t SI4432_force_RBW(int i) uint16_t SI4432_force_RBW(int i)
@ -425,7 +426,7 @@ uint16_t SI4432_force_RBW(int i)
uint16_t SI4432_SET_RBW(uint16_t WISH) { uint16_t SI4432_SET_RBW(uint16_t WISH) {
int i; int i;
for (i=0; i < (int)(sizeof(RBW_choices)/sizeof(RBW_t)) - 1; i++) for (i=0; i < SI4432_RBW_count - 1; i++)
if (WISH <= RBW_choices[i].RBWx10) if (WISH <= RBW_choices[i].RBWx10)
break; break;
return SI4432_force_RBW(i); return SI4432_force_RBW(i);

@ -136,6 +136,7 @@ void SI4432_Set_Frequency ( uint32_t Freq );
uint16_t SI4432_force_RBW(int i); uint16_t SI4432_force_RBW(int i);
uint16_t SI4432_SET_RBW(uint16_t WISH); uint16_t SI4432_SET_RBW(uint16_t WISH);
extern const int SI4432_RBW_count;
void SI4432_SetReference(int freq); void SI4432_SetReference(int freq);
#ifdef __FAST_SWEEP__ #ifdef __FAST_SWEEP__
void SI4432_Fill(int s, int start); void SI4432_Fill(int s, int start);

Loading…
Cancel
Save

Powered by TurnKey Linux.