Commit 5ee623ef authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

Merge branch 'v3-switch-for-wrpc-tom' into v3-switch_for_wrpc

Conflicts:
	dev/softpll_ng.c
	wrc_main.c
parents 135809f9 57b66dfc
......@@ -535,8 +535,9 @@ int spll_update_aux_clocks()
break;
case AUX_READY:
if(!softpll.mpll.ld.locked)
if(!softpll.mpll.ld.locked || !softpll.aux[i].ld.locked)
{
TRACE("[aux] aux channel or mpll lost lock\n");
SPLL->OCCR &= ~ (SPLL_OCCR_OUT_LOCK_W((1<<(i+1))));
s->state = AUX_DISABLED;
}
......@@ -557,3 +558,14 @@ int spll_get_aux_status(int channel)
return rval;
}
int spll_get_dac(int index)
{
if(index < 0)
return softpll.helper.pi.y;
else if (index == 0)
return softpll.mpll.pi.y;
else if (index > 0)
return softpll.aux[index-1].pi.y;
return 0;
}
......@@ -108,3 +108,45 @@ int wrc_mon_gui(void)
return 0;
}
int wrc_log_stats(void)
{
static char* slave_states[] = {"Uninitialized", "SYNC_UTC", "SYNC_NSEC", "SYNC_PHASE", "TRACK_PHASE"};
static uint32_t last = 0;
hexp_port_state_t ps;
int tx, rx;
int aux_stat;
if(timer_get_tics() - last < 1000)
return 0;
last = timer_get_tics();
halexp_get_port_state(&ps, NULL);
minic_get_stats(&tx, &rx);
mprintf("-->STAT Link:%d rx:%d tx:%d ", ps.up, rx, tx);
mprintf("Lock:%d ", ps.is_locked?1:0);
mprintf("ServoValid:%d ", cur_servo_state.valid?1:0);
mprintf("ServoState:'%s' ", cur_servo_state.slave_servo_state);
aux_stat = spll_get_aux_status(0);
mprintf("aux:%x ", aux_stat);
mprintf("mu:%d ", cur_servo_state.mu);
mprintf("dms:%d ", cur_servo_state.delay_ms);
mprintf("dtxm:%d drxm:%d ", (int32_t)cur_servo_state.delta_tx_m, (int32_t)cur_servo_state.delta_rx_m);
mprintf("dtxs:%d drxs:%d ", (int32_t)cur_servo_state.delta_tx_s, (int32_t)cur_servo_state.delta_rx_s);
mprintf("asym:%d ", (int32_t)(cur_servo_state.total_asymmetry));
mprintf("cable_rtt:%d ",
(int32_t)(cur_servo_state.mu) - (int32_t)cur_servo_state.delta_tx_m - (int32_t)cur_servo_state.delta_rx_m -
(int32_t)cur_servo_state.delta_tx_s - (int32_t)cur_servo_state.delta_rx_s);
mprintf("ckoffs:%d ", (int32_t)(cur_servo_state.cur_offset));
mprintf("setpoint:%d ", (int32_t)(cur_servo_state.cur_setpoint));
mprintf("HDAC:%d MDAC:%d ADAC:%d ",
spll_get_dac(-1),
spll_get_dac(0),
spll_get_dac(1)
);
mprintf("\n");
return 0;
}
......@@ -207,11 +207,10 @@ void wrc_initialize()
uart_init();
timer_init(1);
// uart_write_string(__FILE__ " is up (compiled on "
// __DATE__ " " __TIME__ ")\n");
mprintf("wr_core: starting up (press G to launch the GUI and D for extra debug messages)....\n");
uart_write_string(__FILE__ " is up (compiled on "
__DATE__ " " __TIME__ ")\n");
mprintf("wr_core: starting up (press G to launch the GUI and D for extra debug messages)....\n");
//SFP
#if 1
if( get_sfp_id(sfp_pn) >= 0)
......@@ -298,8 +297,8 @@ int wrc_check_link()
return rv;
}
int wrc_extra_debug = 1;
int wrc_gui_mode = 0;
int wrc_extra_debug = 0;
int wrc_gui_mode = 1;
void wrc_debug_printf(int subsys, const char *fmt, ...)
{
......@@ -361,18 +360,22 @@ void wrc_handle_input()
extern volatile int irq_cnt;
int main(void)
{
wrc_initialize();
wrc_extra_debug = 1;
wrc_gui_mode = 0;
spll_init(SPLL_MODE_FREE_RUNNING_MASTER, 0, 1);
for(;;)
{
wrc_handle_input();
if(wrc_gui_mode)
wrc_mon_gui();
for(;;)
{
wrc_handle_input();
if(wrc_gui_mode)
wrc_mon_gui();
else
wrc_log_stats();
int l_status = wrc_check_link();
......
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