tnt has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/29608 )
Change subject: icE1usb fw/gpsdo: Use a struct for VCTXO dependent params ...................................................................... icE1usb fw/gpsdo: Use a struct for VCTXO dependent params Not that useful for now, but prep for PID loop Signed-off-by: Sylvain Munaut <[email protected]> Change-Id: Iffea8992130eccd98a2952b08277e3d0d2568a1f --- M firmware/ice40-riscv/icE1usb/gpsdo.c 1 file changed, 23 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/08/29608/1 diff --git a/firmware/ice40-riscv/icE1usb/gpsdo.c b/firmware/ice40-riscv/icE1usb/gpsdo.c index 477d2e7..5975100 100644 --- a/firmware/ice40-riscv/icE1usb/gpsdo.c +++ b/firmware/ice40-riscv/icE1usb/gpsdo.c @@ -17,6 +17,9 @@ struct { + /* Configuration */ + enum gpsdo_vctxo_model vctxo; + /* Current tuning */ struct { uint16_t coarse; @@ -41,7 +44,6 @@ /* Coarse tuning */ struct { - int vctxo_sensitivity; int step; } coarse; @@ -54,19 +56,25 @@ } g_gpsdo; -/* VCXTO sensitivity vs 'coarse' count for fast initial acquisition */ - /* - * Note that the spec if often a guaranteed minimum range and goes - * from ~0.1V to 3.2V instead of 0-3.3V so actual sensitivity is - * higher than the "theoritical value". We boost it by ~ 10% here. - */ -static const int -vctxo_sensitivity[] = { - /* +- 50 ppm pull range => ~ 0.75 Hz / hi-count (set to 0.85) */ - [VCTXO_TAITIEN_VT40] = 300, +/* + * VCXTO parameters + * + * - iKv is reciprocal sensitivity vs 'coarse' count for fast initial acquisition + * + * Note that the spec if often a guaranteed minimum range and goes + * from ~0.1V to 3.2V instead of 0-3.3V so actual sensitivity is + * higher than the "theoritical value". We boost it by ~ 10% here. + */ +static const struct { + int iKv; /* hi-count / Hz (.8 fixed point) */ +} vctxo_params[] = { + [VCTXO_TAITIEN_VT40] = { + .iKv = 300, /* +- 50 ppm pull range => ~ 0.75 Hz / hi-count (set to 0.85) */ + }, - /* +- 100 ppm pull range => ~ 1.50 Hz / hi-count (set to 1.6) */ - [VCTXO_SITIME_SIT3808_E] = 160, + [VCTXO_SITIME_SIT3808_E] = { + .iKv = 160, /* +- 100 ppm pull range => ~ 1.50 Hz / hi-count (set to 1.6) */ + }, }; /* Tuning params */ @@ -195,7 +203,7 @@ } /* Estimate correction and apply it */ - g_gpsdo.tune.coarse -= (freq_diff * g_gpsdo.coarse.vctxo_sensitivity) >> 8; + g_gpsdo.tune.coarse -= (freq_diff * vctxo_params[g_gpsdo.vctxo].iKv) >> 8; pdm_set(PDM_CLK_HI, true, g_gpsdo.tune.coarse, false); /* Skip next measurement */ @@ -357,5 +365,5 @@ /* Initial state and config */ g_gpsdo.state = STATE_HOLD_OVER; - g_gpsdo.coarse.vctxo_sensitivity = vctxo_sensitivity[vctxo]; + g_gpsdo.vctxo = vctxo; } -- To view, visit https://gerrit.osmocom.org/c/osmo-e1-hardware/+/29608 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1-hardware Gerrit-Branch: master Gerrit-Change-Id: Iffea8992130eccd98a2952b08277e3d0d2568a1f Gerrit-Change-Number: 29608 Gerrit-PatchSet: 1 Gerrit-Owner: tnt <[email protected]> Gerrit-MessageType: newchange
