Commit d18dde7b authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

ljd: check only once whether it is present

parent c0b241ea
......@@ -7,4 +7,6 @@
#define GPIO_EXT_OSC_FRED_D1 7
#define GPIO_EXT_OSC_FRED_D2 8
extern int ljd_present;
#endif
......@@ -29,7 +29,7 @@ void external_init(volatile struct spll_external_state *s, int ext_ref,
{
int idx = spll_n_chan_ref + spll_n_chan_out;
if (gpio_in(GPIO_EXT_BOARD_DETECT))
if (ljd_present)
idx++;
helper_init(s->helper, idx);
......@@ -55,12 +55,12 @@ int external_locked(volatile struct spll_external_state *s)
if (!s->helper->ld.locked || !s->main->ld.locked)
return 0;
if (!gpio_in(GPIO_EXT_BOARD_DETECT) && (!(SPLL->ECCR & SPLL_ECCR_EXT_REF_LOCKED) || // ext PLL became unlocked
if (!ljd_present && (!(SPLL->ECCR & SPLL_ECCR_EXT_REF_LOCKED) || // ext PLL became unlocked
(SPLL->ECCR & SPLL_ECCR_EXT_REF_STOPPED))) // 10MHz unplugged (only SPEC)
return 0;
//FIXME A bug prevents the correct locking if the external lock check is executed
// Correct way to solve it: export the LOCK signal from the gateware and check it
// if (gpio_in(GPIO_EXT_BOARD_DETECT) && ext_ad9516_locked())
// if (ljd_present && ext_ad9516_locked())
// return 1;
switch(s->align_state) {
......@@ -102,13 +102,13 @@ int external_align_fsm(volatile struct spll_external_state *s)
break;
case ALIGN_STATE_WAIT_CLKIN:
if(!gpio_in(GPIO_EXT_BOARD_DETECT) && !(SPLL->ECCR & SPLL_ECCR_EXT_REF_STOPPED) ) {
if(!ljd_present && !(SPLL->ECCR & SPLL_ECCR_EXT_REF_STOPPED) ) {
SPLL->ECCR |= SPLL_ECCR_EXT_REF_PLLRST;
s->align_state = ALIGN_STATE_WAIT_PLOCK;
done_sth++;
}
f_ext = spll_measure_frequency(SPLL_OSC_EXT);
if (gpio_in(GPIO_EXT_BOARD_DETECT) && (f_ext > 9999000) && (f_ext < 10001000))
if (ljd_present && (f_ext > 9999000) && (f_ext < 10001000))
if (!ext_ad9516_init()) {
s->align_state = ALIGN_STATE_WAIT_PLOCK;
pp_printf("External AD9516 locked\n");
......@@ -118,10 +118,10 @@ int external_align_fsm(volatile struct spll_external_state *s)
case ALIGN_STATE_WAIT_PLOCK:
SPLL->ECCR &= (~SPLL_ECCR_EXT_REF_PLLRST);
if(!gpio_in(GPIO_EXT_BOARD_DETECT) && SPLL->ECCR & SPLL_ECCR_EXT_REF_STOPPED )
if(!ljd_present && SPLL->ECCR & SPLL_ECCR_EXT_REF_STOPPED )
s->align_state = ALIGN_STATE_WAIT_CLKIN;
else if((!gpio_in(GPIO_EXT_BOARD_DETECT) && SPLL->ECCR & SPLL_ECCR_EXT_REF_LOCKED ) ||
gpio_in(GPIO_EXT_BOARD_DETECT) && ext_ad9516_locked())
else if((!ljd_present && SPLL->ECCR & SPLL_ECCR_EXT_REF_LOCKED ) ||
ljd_present && ext_ad9516_locked())
s->align_state = ALIGN_STATE_START;
done_sth++;
break;
......
......@@ -18,6 +18,7 @@
int scb_ver = 33; /* SCB version */
int ljd_present = 0; /* Low-jitter Daughterboard presence indicator */
extern struct spll_stats stats;
......@@ -42,7 +43,9 @@ int main(void)
build_revision, build_date, build_time);
pp_printf("SCB version: %d. %s\n", scb_ver,(scb_ver>=34)?"10 MHz SMC Output.":"" );
pp_printf("Start counter %d\n", stats.start_cnt);
if (gpio_in(GPIO_EXT_BOARD_DETECT))
/* Low-jitter Daughterboard detection */
ljd_present = gpio_in(GPIO_EXT_BOARD_DETECT);
if (ljd_present)
pp_printf("\n--- WRS Low jitter board detected. ---\nAllow 1 hour of warming \
up before starting measurements\n");
pp_printf("--\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment