icE1usb fw/gpsdo: Export accumulated error
This is a pretty usefu stat as this is what actually matters
Note that structure is just extended so any call with a wLength
shorter will just get the beginning of the struct (usb stack
limits response to wLength) and thus is fully backward compatible.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I0aa919d4870ca7e1b653b82ac4f76ed26b5e3b08
diff --git a/firmware/ice40-riscv/icE1usb/gpsdo.c b/firmware/ice40-riscv/icE1usb/gpsdo.c
index c1df4b0..477d2e7 100644
--- a/firmware/ice40-riscv/icE1usb/gpsdo.c
+++ b/firmware/ice40-riscv/icE1usb/gpsdo.c
@@ -102,6 +102,7 @@
status->tune.coarse = g_gpsdo.tune.coarse;
status->tune.fine = g_gpsdo.tune.fine;
status->freq_est = g_gpsdo.meas.last;
+ status->err_acc = (g_gpsdo.state == STATE_TUNE_FINE) ? g_gpsdo.fine.acc : 0;
}
void
diff --git a/firmware/ice40-riscv/icE1usb/ice1usb_proto.h b/firmware/ice40-riscv/icE1usb/ice1usb_proto.h
index 3170d55..38cb23b 100644
--- a/firmware/ice40-riscv/icE1usb/ice1usb_proto.h
+++ b/firmware/ice40-riscv/icE1usb/ice1usb_proto.h
@@ -65,6 +65,7 @@
uint8_t mode; /*!< Current configured operating mode */
struct e1usb_gpsdo_tune tune; /*!< Current VCXO tuning values */
uint32_t freq_est; /*!< Latest frequency estimate measurement */
+ int16_t err_acc; /*!< Accumulated error */
} __attribute__((packed));