Use timer macros

Removed_REF_marker
DiSlord 5 years ago
parent b2878e5a9e
commit 41eac5bce7

@ -80,7 +80,7 @@ int16_t adc_vbat_read(void)
// Vbat measure averange count = 2^VBAT_AVERAGE
#define VBAT_AVERAGE 4
// Measure vbat every 5 second
#define VBAT_MEASURE_INTERVAL 50000
#define VBAT_MEASURE_INTERVAL S2ST(5)
static int16_t vbat_raw = 0;
static systime_t vbat_time = -VBAT_MEASURE_INTERVAL-1;

@ -96,7 +96,7 @@ int16_t adc_vbat_read(void)
// Vbat measure averange count = 2^VBAT_AVERAGE
#define VBAT_AVERAGE 4
// Measure vbat every 5 second
#define VBAT_MEASURE_INTERVAL 50000
#define VBAT_MEASURE_INTERVAL S2ST(5)
static int16_t vbat_raw = 0;
static systime_t vbat_time = -VBAT_MEASURE_INTERVAL-1;

@ -1444,6 +1444,8 @@ enum {
T_AUTO, T_NORMAL, T_SINGLE, T_DONE, T_UP, T_DOWN, T_MODE, T_PRE, T_POST, T_MID
};
//!!! Warning can show not correct results on CH_CFG_ST_FREQUENCY not round by 1000 or > 1000000UL
#define sa_ST2US(n) ((n)*(1000000UL/(CH_CFG_ST_FREQUENCY)))
extern const uint8_t SI4432_RBW_count;
extern void SI4432_Listen(int s);

@ -3427,7 +3427,7 @@ again: // Spur redu
// i = 1; // Everything set so skip LO setting
#define MODULATION_CYCLES_TEST 10000
if (in_selftest && modulation_count_iter++ >= 10000) {
start_of_sweep_timestamp = (chVTGetSystemTimeX() - start_of_sweep_timestamp)*MODULATION_STEPS*100/MODULATION_CYCLES_TEST; // uS per cycle
start_of_sweep_timestamp = sa_ST2US(chVTGetSystemTimeX() - start_of_sweep_timestamp)*MODULATION_STEPS/MODULATION_CYCLES_TEST; // uS per cycle
return 0;
}
goto modulation_again; // Keep repeating sweep loop till user aborts by input
@ -3761,7 +3761,7 @@ static bool sweep(bool break_on_operation)
}
}
}
systime_t local_sweep_time = (chVTGetSystemTimeX() - start_of_sweep_timestamp)*100 ;
systime_t local_sweep_time = sa_ST2US(chVTGetSystemTimeX() - start_of_sweep_timestamp);
if (setting.actual_sweep_time_us > ONE_SECOND_TIME)
local_sweep_time = setting.actual_sweep_time_us;
if (show_bar && (( local_sweep_time > ONE_SECOND_TIME && (i & 0x07) == 0) || ( local_sweep_time > ONE_SECOND_TIME*10)) )
@ -4002,7 +4002,7 @@ static bool sweep(bool break_on_operation)
// ---------------------- process measured actual sweep time -----------------
// For CW mode value calculated in SI4432_Fill
if (setting.measure_sweep_time_us == 0)
setting.measure_sweep_time_us = (chVTGetSystemTimeX() - start_of_sweep_timestamp) * 100;
setting.measure_sweep_time_us = sa_ST2US(chVTGetSystemTimeX() - start_of_sweep_timestamp);
// Update actual time on change on status panel
uint32_t delta = abs((int)(setting.actual_sweep_time_us - setting.measure_sweep_time_us));
@ -4104,7 +4104,7 @@ static bool sweep(bool break_on_operation)
} else if (actual_max_level > target_level && setting.attenuate_x2 < 60) {
delta = actual_max_level - target_level;
}
if ((chVTGetSystemTimeX() - sweep_elapsed > 10000 && ( delta < -5 || delta > +5)) || delta > 10 ) {
if ((chVTGetSystemTimeX() - sweep_elapsed > MS2ST(1000) && ( delta < -5 || delta > +5)) || delta > 10 ) {
setting.attenuate_x2 += delta + delta;
if (setting.attenuate_x2 < 0)
setting.attenuate_x2= 0;

@ -593,7 +593,7 @@ void SI4432_trigger_fill(int s, uint8_t trigger_lvl, int up_direction, int trigg
case ST_ARMING:
if (i == sweep_points-1) {
waiting = ST_WAITING;
setting.measure_sweep_time_us = (chVTGetSystemTimeX() - measure)*100;
setting.measure_sweep_time_us = sa_ST2US(chVTGetSystemTimeX() - measure);
}
break;
case ST_WAITING:
@ -674,7 +674,7 @@ void SI4432_Fill(int s, int start)
shiftInBuf(sel, SI4432_REG_RSSI, &age[start], sweep_points - start, t);
#endif
// __enable_irq();
setting.measure_sweep_time_us = (chVTGetSystemTimeX() - measure)*100;
setting.measure_sweep_time_us = sa_ST2US(chVTGetSystemTimeX() - measure);
buf_index = start; // Is used to skip 1st entry during level triggering
buf_end = sweep_points - 1;
buf_read = true;

@ -1276,7 +1276,7 @@ void SI446x_Fill(int s, int start)
} while(1);
__enable_irq();
setting.measure_sweep_time_us = (chVTGetSystemTimeX() - measure)*100;
setting.measure_sweep_time_us = sa_ST2US(chVTGetSystemTimeX() - measure);
buf_index = (start<=0 ? 0 : start); // Is used to skip 1st entry during level triggering
buf_read = true;
}

Loading…
Cancel
Save

Powered by TurnKey Linux.