Commit 702f5511 authored by Jean-Claude BAU's avatar Jean-Claude BAU

WR profile: Restart servo when PLL unlocked

If a PLL unlocked is detected on slave side  when the servo is running,
the PTP state is forced to UNCALIBRATED to restart the WR calibration
(handshake)
parent 59838a0d
......@@ -118,6 +118,7 @@ typedef struct wrh_servo_t {
int missed_iters;
Boolean readyForSync; /* Ready for synchronization */
Boolean doRestart; /* PLL is unlocked: A restart of the calibration is needed */
} wrh_servo_t;
......
......@@ -234,8 +234,9 @@ static int __wrh_servo_update(struct pp_instance *ppi)
if (locking_poll_ret != WRH_SPLL_READY
&& locking_poll_ret != WRH_SPLL_CALIB_NOT_READY) {
pp_diag(ppi, servo, 1, "PLL out of lock\n");
/* TODO check
* DSPOR(ppi)->doRestart = TRUE; */
s->doRestart = TRUE;
return 0;
}
/* After each action on the hardware, we must verify if it is over. */
......
......@@ -183,6 +183,8 @@ static void wr_state_change(struct pp_instance *ppi)
pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
if ( ppi->ext_enabled ) {
// Check leaving state
if ( wrp->wrModeOn &&
((ppi->state == PPS_SLAVE) ||
(ppi->state == PPS_MASTER))) {
......@@ -191,20 +193,21 @@ static void wr_state_change(struct pp_instance *ppi)
if (ppi->state == PPS_SLAVE)
//* We are leaving SLAVE state
WRH_OPER()->locking_reset(ppi);
} else {
switch (ppi->next_state) {
case PPS_MASTER : /* Enter in MASTER_STATE */
wrp->next_state=WRS_IDLE;
wrp->wrMode=WR_MASTER;
break;
case PPS_UNCALIBRATED : /* Enter in UNCALIBRATED state */
wrp->next_state=WRS_PRESENT;
wrp->wrMode=WR_SLAVE;
break;
case PPS_LISTENING : /* Enter in LISTENING state */
wr_reset_process(ppi,WR_ROLE_NONE);
break;
}
}
// Check entering state
switch (ppi->next_state) {
case PPS_MASTER : /* Enter in MASTER_STATE */
wrp->next_state=WRS_IDLE;
wr_reset_process(ppi,WR_MASTER);
break;
case PPS_UNCALIBRATED : /* Enter in UNCALIBRATED state */
wrp->next_state=WRS_PRESENT;
wr_reset_process(ppi,WR_SLAVE);
break;
case PPS_LISTENING : /* Enter in LISTENING state */
wr_reset_process(ppi,WR_ROLE_NONE);
break;
}
if ( ppi->state==PPS_SLAVE && ppi->next_state!=PPS_UNCALIBRATED ) {
......@@ -254,7 +257,6 @@ struct pp_ext_hooks wr_ext_hooks = {
.handle_resp = wr_handle_resp,
.handle_dreq = wr_handle_dreq,
.handle_sync = wr_handle_sync,
// .handle_signaling=wr_handle_signaling,
.handle_followup = wr_handle_followup,
.ready_for_slave = wr_ready_for_slave,
.run_ext_state_machine = wr_run_state_machine,
......
......@@ -24,7 +24,16 @@ int wr_servo_init(struct pp_instance *ppi)
int wr_servo_got_sync(struct pp_instance *ppi) {
/* Re-adjust T1 and T2 */
wr_servo_ext_t *se=WRE_SRV(ppi);
wrh_servo_t *s=WRH_SRV(ppi);
if (s->doRestart) {
// Error detected by the servo.
s->doRestart=FALSE;
if ( ppi->state==PPS_SLAVE ) {
// Restart calibration
ppi->next_state=PPS_UNCALIBRATED;
}
}
pp_time_add(&ppi->t1,&se->delta_txm);
pp_time_sub(&ppi->t2,&se->delta_rxs);
return wrh_servo_got_sync(ppi);
......
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