Output level corrected

Removed_REF_marker
erikkaashoek 5 years ago
parent a1559e77ac
commit cbdb99aa79

@ -71,8 +71,9 @@ checksum(const void *start, size_t len)
uint32_t *tail = (uint32_t*)(start + len); uint32_t *tail = (uint32_t*)(start + len);
uint32_t value = 0; uint32_t value = 0;
while (p < tail) { while (p < tail) {
value = __ROR(value, 31) + *p++; value = __ROR(value, 31) + *p;
// if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf("%x\r\n", value); // if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf("%x, %x\r\n", *p, value);
p++;
} }
return value; return value;
} }
@ -109,6 +110,7 @@ config_recall(void)
if (src->magic != CONFIG_MAGIC) if (src->magic != CONFIG_MAGIC)
return -1; return -1;
// if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf("Checksum %x\r\n", src->checksum);
if (checksum(src, sizeof config - sizeof config.checksum) != src->checksum) if (checksum(src, sizeof config - sizeof config.checksum) != src->checksum)
return -1; return -1;
@ -132,8 +134,9 @@ caldata_save(uint16_t id)
dst = (uint16_t*)(SAVE_PROP_CONFIG_ADDR + id * SAVE_PROP_CONFIG_SIZE); dst = (uint16_t*)(SAVE_PROP_CONFIG_ADDR + id * SAVE_PROP_CONFIG_SIZE);
setting.magic = CONFIG_MAGIC; setting.magic = CONFIG_MAGIC;
setting.checksum = 0x12345678;
setting.checksum = checksum( setting.checksum = checksum(
&setting, sizeof setting - sizeof setting.checksum); &setting, (sizeof (setting)) - sizeof setting.checksum);
flash_unlock(); flash_unlock();
@ -179,7 +182,8 @@ caldata_recall(uint16_t id)
if (src->magic != CONFIG_MAGIC) if (src->magic != CONFIG_MAGIC)
return -1; return -1;
if (checksum(src, sizeof setting - sizeof src->checksum) != src->checksum) // if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf("Checksum %x\r\n", src->checksum);
if (checksum(src, (sizeof (setting)) - sizeof src->checksum) != src->checksum)
return -1; return -1;
/* active configuration points to save data on flash memory */ /* active configuration points to save data on flash memory */

@ -858,6 +858,7 @@ typedef struct setting
uint8_t agc; uint8_t agc;
uint8_t lna; uint8_t lna;
uint8_t auto_reflevel; uint8_t auto_reflevel;
uint8_t dummy2;
int modulation; int modulation;
int show_stored; int show_stored;
int atten_step; int atten_step;
@ -918,8 +919,8 @@ typedef struct setting
int ultra; int ultra;
int R; int R;
#endif #endif
uint32_t dummy; uint16_t dummy;
uint32_t checksum; // must be last uint32_t checksum; // must be last and at 4 byte boundary
}setting_t; }setting_t;
extern setting_t setting; extern setting_t setting;

@ -103,7 +103,7 @@ const int8_t drive_dBm [16] = {-38, -32, -30, -27, -24, -19, -15, -12, -5, -2, 0
#define MAX_DRIVE (setting.mode == M_GENHIGH ? 15 : 11) #define MAX_DRIVE (setting.mode == M_GENHIGH ? 15 : 11)
#define MIN_DRIVE 8 #define MIN_DRIVE 8
#define SL_GENHIGH_LEVEL_MIN -38 #define SL_GENHIGH_LEVEL_MIN -38
#define SL_GENHIGH_LEVEL_RANGE 51 #define SL_GENHIGH_LEVEL_RANGE 54
#define SL_GENLOW_LEVEL_MIN -76 #define SL_GENLOW_LEVEL_MIN -76
#define SL_GENLOW_LEVEL_RANGE 70 #define SL_GENLOW_LEVEL_RANGE 70
#endif #endif
@ -670,8 +670,12 @@ void set_level(float v) // Set the output level in dB in high/low output
// d = 7; // d = 7;
set_lo_drive(d); set_lo_drive(d);
} else { } else {
if (v < SL_GENLOW_LEVEL_MIN)
v = SL_GENLOW_LEVEL_MIN;
if (v > SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE)
v = SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE;
setting.level = v; setting.level = v;
set_attenuation(setting.level - config.low_level_output_offset); // set_attenuation(setting.level - config.low_level_output_offset);
} }
dirty = true; dirty = true;
} }
@ -681,7 +685,7 @@ float get_level(void)
if (setting.mode == M_GENHIGH) { if (setting.mode == M_GENHIGH) {
return drive_dBm[setting.lo_drive] + config.high_level_output_offset; return drive_dBm[setting.lo_drive] + config.high_level_output_offset;
} else { } else {
setting.level = get_attenuation() + config.low_level_output_offset; // setting.level = get_attenuation() + config.low_level_output_offset;
return setting.level; return setting.level;
} }
} }
@ -701,8 +705,9 @@ float get_attenuation(void)
return(actual_attenuation); return(actual_attenuation);
} }
void set_attenuation(float a) // Is used both in low output mode and high/low input mode void set_attenuation(float a) // Is used both only in high/low input mode
{ {
#if 0
if (setting.mode == M_GENLOW) { if (setting.mode == M_GENLOW) {
a = a - level_max(); // Move to zero for max power a = a - level_max(); // Move to zero for max power
if (a > 0) if (a > 0)
@ -719,7 +724,9 @@ void set_attenuation(float a) // Is used both in low output mode and high/
} }
a -= BELOW_MAX_DRIVE(setting.rx_drive); a -= BELOW_MAX_DRIVE(setting.rx_drive);
a = -a; a = -a;
} else { } else
#endif
{
if (setting.mode == M_LOW && a > 31.5) { if (setting.mode == M_LOW && a > 31.5) {
setting.atten_step = 1; setting.atten_step = 1;
a = a - RECEIVE_SWITCH_ATTENUATION; a = a - RECEIVE_SWITCH_ATTENUATION;

@ -404,7 +404,7 @@ static const keypads_t keypads_time[] = {
enum { enum {
KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, // These must be first to share common help text KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, // These must be first to share common help text
KM_REFLEVEL, KM_SCALE, KM_ATTENUATION, KM_REFLEVEL, KM_SCALE, KM_ATTENUATION,
KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE, KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE,
#ifdef TINYSA4 #ifdef TINYSA4
KM_30MHZ, KM_30MHZ,
#else #else
@ -439,7 +439,6 @@ static const struct {
{keypads_plusmin_unit, "ACTUAL\nPOWER"}, // actual power {keypads_plusmin_unit, "ACTUAL\nPOWER"}, // actual power
{keypads_freq , "IF"}, // IF {keypads_freq , "IF"}, // IF
{keypads_positive , "SAMPLE\nDELAY"}, // sample delay {keypads_positive , "SAMPLE\nDELAY"}, // sample delay
{keypads_positive , "DRIVE"}, // KM_DRIVE
{keypads_plusmin , "LEVEL"}, // KM_LOWOUTLEVEL {keypads_plusmin , "LEVEL"}, // KM_LOWOUTLEVEL
{keypads_positive , "DECAY"}, // KM_DECAY {keypads_positive , "DECAY"}, // KM_DECAY
{keypads_positive , "NOISE\nLEVEL"}, // KM_NOISE {keypads_positive , "NOISE\nLEVEL"}, // KM_NOISE
@ -2256,10 +2255,6 @@ static void fetch_numeric_target(void)
uistat.value = setting.repeat; uistat.value = setting.repeat;
plot_printf(uistat.text, sizeof uistat.text, "%2d", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%2d", ((int32_t)uistat.value));
break; break;
case KM_DRIVE:
uistat.value = setting.rx_drive;
plot_printf(uistat.text, sizeof uistat.text, "%3ddB", ((int32_t)uistat.value));
break;
case KM_LOWOUTLEVEL: case KM_LOWOUTLEVEL:
uistat.value = get_level(); // compensation for dB offset during low output mode uistat.value = get_level(); // compensation for dB offset during low output mode
int end_level = ((int32_t)uistat.value)+setting.level_sweep; int end_level = ((int32_t)uistat.value)+setting.level_sweep;
@ -2422,9 +2417,6 @@ set_numeric_value(void)
case KM_REPEAT: case KM_REPEAT:
set_repeat(uistat.value); set_repeat(uistat.value);
break; break;
case KM_DRIVE:
set_rx_drive(uistat.value);
break;
case KM_LOWOUTLEVEL: case KM_LOWOUTLEVEL:
set_level(uistat.value - setting.offset); set_level(uistat.value - setting.offset);
break; break;

Loading…
Cancel
Save

Powered by TurnKey Linux.