Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
96757b24
Commit
96757b24
authored
Jul 15, 2020
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ertm14: removed commented out 'old' RF NCO sync task code
parent
786b8f54
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
210 deletions
+0
-210
board.c
boards/ertm14/board.c
+0
-210
No files found.
boards/ertm14/board.c
View file @
96757b24
...
...
@@ -494,216 +494,6 @@ static void ertm14_align_ref_out_to_pps(void)
}
}
#if 0
#define CLK_PPS_SYNC_MAX_HANDLERS 2
struct ertm14_clk_pps_sync_handler {
void (*func)();
uint8_t once;
uint8_t done;
};
struct ertm14_clk_pps_sync_fsm {
int state;
int prev_mode;
int prev_locked;
struct ertm14_clk_pps_sync_handler handlers[ CLK_PPS_SYNC_MAX_HANDLERS ];
} clk_pps_sync_state;
static void ertm14_clk_pps_sync_restart(void)
{
struct ertm14_clk_pps_sync_fsm* fsm = &clk_pps_sync_state;
fsm->state = CLK_PPS_STATE_START;
}
static void ertm14_clk_pps_sync_add_handler( void (*func)(), int once )
{
int i;
for(i=0; i<CLK_PPS_SYNC_MAX_HANDLERS;i++)
{
if ( !clk_pps_sync_state.handlers[i].func )
{
clk_pps_sync_state.handlers[i].func = func;
clk_pps_sync_state.handlers[i].once = once;
clk_pps_sync_state.handlers[i].done = 0;
return;
}
}
}
static void rf_nco_sync_init()
{
tmo_init( &rf_nco_sync_tmo, 300 );
}
void rf_nco_sync_handle_channel( struct ertm14_dds_state *state, uint32_t ioupdate_channel )
{
int flags = 0;
pp_printf("Sync Source : %d\n",state->sync_source);
if( state->sync_source == ERTM14_SYNC_SOURCE_NONE )
{
fine_pulse_gen_setup_channel ( &board.dds_sync_dev, ioupdate_channel, 1, board.dds_sync_delays[ioupdate_channel], 0 );
state->sync_state = ERTM14_SYNC_STATE_OFF;
return;
}
if( state->sync_source == ERTM14_SYNC_SOURCE_RF_TRIGGER )
flags |= FINE_PULSE_GEN_USE_EXT_TRIGGER;
switch(state->sync_state)
{
case ERTM14_SYNC_STATE_IDLE:
board_dbg("armed DDS channel %x\n", ioupdate_channel );
fine_pulse_gen_setup_channel ( &board.dds_sync_dev, ioupdate_channel, 1, board.dds_sync_delays[ioupdate_channel], flags );
board_dbg("xxxx\n" );
fine_pulse_gen_trigger ( &board.dds_sync_dev, (1<<ioupdate_channel), 0 );
board_dbg("yyyy\n" );
state->sync_state = ERTM14_SYNC_STATE_WAIT_TRIGGER;
break;
case ERTM14_SYNC_STATE_WAIT_TRIGGER:
if( fine_pulse_gen_is_triggered ( &board.dds_sync_dev, (1<<ioupdate_channel) ) )
{
board_dbg("triggered DDS sync channel %x\n", ioupdate_channel );
state->sync_state = ERTM14_SYNC_STATE_DONE;
}
break;
case ERTM14_SYNC_STATE_OFF:
return;
}
}
int ertm14_rf_nco_sync_update()
{
if (tmo_expired(&rf_nco_sync_tmo))
{
tmo_restart(&rf_nco_sync_tmo);
rf_nco_sync_handle_channel( &ertm14_current_state->ref, ERTM14_DDS_IOUPDATE_REF );
rf_nco_sync_handle_channel( &ertm14_current_state->lo, ERTM14_DDS_IOUPDATE_LO );
}
return 0;
}
static void ertm14_clk_pps_sync_init(void)
{
int i;
for(i=0; i<CLK_PPS_SYNC_MAX_HANDLERS;i++)
{
clk_pps_sync_state.handlers[i].func = NULL;
}
rf_nco_sync_init();
ertm14_clk_pps_sync_add_handler( ertm14_align_clocks, 1 );
ertm14_clk_pps_sync_add_handler( ertm14_rf_nco_sync_update, 0 );
ertm14_clk_pps_sync_restart();
}
static void ertm14_clk_pps_sync_task(void)
{
extern struct pp_instance ppi_static;
struct pp_instance *ppi = &ppi_static;
struct ertm14_clk_pps_sync_fsm* fsm = &clk_pps_sync_state;
int mode = wrc_ptp_get_mode();
if( mode != fsm->prev_mode )
{
board_dbg("PTP Mode changed, restarting clock alignment FSM\n");
fsm->state = CLK_PPS_STATE_START;
}
fsm->prev_mode = mode;
switch(fsm->state)
{
case CLK_PPS_STATE_START:
{
fsm->prev_locked = -1;
int mode = wrc_ptp_get_mode();
if( mode == WRC_MODE_MASTER || mode == WRC_MODE_GM )
{
fsm->state = CLK_PPS_STATE_MASTER;
board_dbg("Master mode\n");
} else {
fsm->state = CLK_PPS_STATE_SLAVE;
board_dbg("Slave mode\n");
}
}
break;
case CLK_PPS_STATE_MASTER:
{
if( spll_check_lock(0) )
{
board_dbg("PLL locked\n");
fsm->state = CLK_PPS_STATE_RUN_SYNC;
}
}
break;
case CLK_PPS_STATE_SLAVE:
{
struct wr_servo_state *ss = &((struct wr_data *)ppi->ext_data)->servo_state;
if( ss->state == WR_TRACK_PHASE )
{
board_dbg("Servo tracking phase, proceeding with sync\n");
fsm->state = CLK_PPS_STATE_RUN_SYNC;
}
}
break;
case CLK_PPS_STATE_RUN_SYNC:
{
int i;
for( i = 0; i < CLK_PPS_SYNC_MAX_HANDLERS; i++ )
{
struct ertm14_clk_pps_sync_handler *handler = &fsm->handlers[i];
if(!handler->func)
continue;
if(handler->once && handler->done)
continue;
handler->func();
handler->done = 1;
}
}
break;
default : break;
}
}
#endif
static
int
evth_dds_nco_sync
;
#define DDS_NCO_STATE_WAIT_TIMING 0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment