stored trace now also saved to flash

tinySA-v0.2
erikkaashoek 6 years ago
parent 27b183ccb1
commit 10d77ee691

@ -166,6 +166,14 @@ caldata_save(int id)
dst++; dst++;
} }
// Flash stored trace
count = sizeof(stored_t) / sizeof(uint16_t);
src = (uint16_t*)&stored_t[0];
while (count-- > 0) {
flash_program_half_word((uint32_t)dst, *src++);
dst++;
}
/* after saving data, make active configuration points to flash */ /* after saving data, make active configuration points to flash */
// active_props = (setting_t*)saveareas[id]; // active_props = (setting_t*)saveareas[id];
lastsaveid = id; lastsaveid = id;
@ -187,7 +195,7 @@ caldata_recall(int id)
if (src->magic != CONFIG_MAGIC) if (src->magic != CONFIG_MAGIC)
return -1; return -1;
if (checksum(src, sizeof *src - sizeof src->checksum) != 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 */
@ -196,6 +204,9 @@ caldata_recall(int id)
/* duplicated saved data onto sram to be able to modify marker/trace */ /* duplicated saved data onto sram to be able to modify marker/trace */
memcpy(dst, src, sizeof(setting_t)); memcpy(dst, src, sizeof(setting_t));
// Restore stored trace
memcpy(stored_t, &src[1], sizeof(stored_t));
update_frequencies(); update_frequencies();
set_scale(setting.scale); set_scale(setting.scale);
set_reflevel(setting.reflevel); set_reflevel(setting.reflevel);

@ -563,8 +563,8 @@ typedef struct setting
marker_t _markers[MARKERS_MAX]; marker_t _markers[MARKERS_MAX];
int8_t _active_marker; int8_t _active_marker;
int8_t unit; int8_t unit;
uint32_t checksum;
float offset; float offset;
uint32_t checksum;
}setting_t; }setting_t;
extern setting_t setting; extern setting_t setting;

@ -484,7 +484,7 @@ void set_mode(int m)
void apply_settings(void) void apply_settings(void)
{ {
if (setting.mode == M_HIGH) if (setting.mode == M_HIGH)
PE4302_Write_Byte(40); PE4302_Write_Byte(40); // Ensure defined input impedance of low port when using high input mode (power calibration)
else else
PE4302_Write_Byte(setting.attenuate * 2); PE4302_Write_Byte(setting.attenuate * 2);
#if 0 #if 0

Loading…
Cancel
Save

Powered by TurnKey Linux.