|
@@
-45,10
+45,8
ring_node ring_node_swf2_extracted;
|
|
45
|
|
|
45
|
|
|
46
|
typedef enum resynchro_state_t
|
|
46
|
typedef enum resynchro_state_t
|
|
47
|
{
|
|
47
|
{
|
|
48
|
MEASURE_0,
|
|
48
|
MEASURE,
|
|
49
|
MEASURE_1,
|
|
49
|
CORRECTION
|
|
50
|
CORRECTION_0,
|
|
|
|
|
51
|
CORRECTION_1
|
|
|
|
|
52
|
} resynchro_state;
|
|
50
|
} resynchro_state;
|
|
53
|
|
|
51
|
|
|
54
|
//*********************
|
|
52
|
//*********************
|
|
@@
-205,6
+203,8
inline void waveform_isr_normal_sbm1_sbm
|
|
205
|
waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
|
|
203
|
waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
|
|
206
|
waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
|
|
204
|
waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
|
|
207
|
}
|
|
205
|
}
|
|
|
|
|
206
|
// send an event to the WFRM task for resynchro activities
|
|
|
|
|
207
|
status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH );
|
|
208
|
}
|
|
208
|
}
|
|
209
|
|
|
209
|
|
|
210
|
//***
|
|
210
|
//***
|
|
@@
-350,11
+350,9
rtems_task wfrm_task(rtems_task_argument
|
|
350
|
|
|
350
|
|
|
351
|
while(1){
|
|
351
|
while(1){
|
|
352
|
// wait for an RTEMS_EVENT
|
|
352
|
// wait for an RTEMS_EVENT
|
|
353
|
rtems_event_receive(RTEMS_EVENT_MODE_NORMAL,
|
|
353
|
rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_SWF_RESYNCH,
|
|
354
|
RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
|
|
354
|
RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
|
|
355
|
|
|
355
|
|
|
356
|
snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
|
|
|
|
|
357
|
|
|
|
|
|
358
|
if (event_out == RTEMS_EVENT_MODE_NORMAL)
|
|
356
|
if (event_out == RTEMS_EVENT_MODE_NORMAL)
|
|
359
|
{
|
|
357
|
{
|
|
360
|
DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n");
|
|
358
|
DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n");
|
|
@@
-365,6
+363,10
rtems_task wfrm_task(rtems_task_argument
|
|
365
|
status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) );
|
|
363
|
status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) );
|
|
366
|
status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) );
|
|
364
|
status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) );
|
|
367
|
}
|
|
365
|
}
|
|
|
|
|
366
|
if (event_out == RTEMS_EVENT_SWF_RESYNCH)
|
|
|
|
|
367
|
{
|
|
|
|
|
368
|
snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
|
|
|
|
|
369
|
}
|
|
368
|
}
|
|
370
|
}
|
|
369
|
}
|
|
371
|
}
|
|
370
|
|
|
372
|
|
|
@@
-461,7
+463,8
rtems_task cwf2_task(rtems_task_argument
|
|
461
|
BOOT_PRINTF("in CWF2 ***\n")
|
|
463
|
BOOT_PRINTF("in CWF2 ***\n")
|
|
462
|
|
|
464
|
|
|
463
|
while(1){
|
|
465
|
while(1){
|
|
464
|
// wait for an RTEMS_EVENT
|
|
466
|
// wait for an RTEMS_EVENT// send the snapshot when built
|
|
|
|
|
467
|
status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
|
|
465
|
rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST,
|
|
468
|
rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST,
|
|
466
|
RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
|
|
469
|
RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
|
|
467
|
ring_node_to_send = getRingNodeToSendCWF( 2 );
|
|
470
|
ring_node_to_send = getRingNodeToSendCWF( 2 );
|
|
@@
-482,10
+485,8
rtems_task cwf2_task(rtems_task_argument
|
|
482
|
// extract the snapshot
|
|
485
|
// extract the snapshot
|
|
483
|
build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong,
|
|
486
|
build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong,
|
|
484
|
&ring_node_swf2_extracted, swf2_extracted );
|
|
487
|
&ring_node_swf2_extracted, swf2_extracted );
|
|
485
|
// send the snapshot when built
|
|
|
|
|
486
|
status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
|
|
|
|
|
487
|
extractSWF2 = false;
|
|
488
|
extractSWF2 = false;
|
|
488
|
swf2_ready = true;
|
|
489
|
swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM
|
|
489
|
}
|
|
490
|
}
|
|
490
|
if (swf0_ready_flag_f2 == true)
|
|
491
|
if (swf0_ready_flag_f2 == true)
|
|
491
|
{
|
|
492
|
{
|
|
@@
-953,7
+954,7
void applyCorrection( double correction
|
|
953
|
void snapshot_resynchronization( unsigned char *timePtr )
|
|
954
|
void snapshot_resynchronization( unsigned char *timePtr )
|
|
954
|
{
|
|
955
|
{
|
|
955
|
static double correction = 0.;
|
|
956
|
static double correction = 0.;
|
|
956
|
static resynchro_state state = MEASURE_0;
|
|
957
|
static resynchro_state state = MEASURE;
|
|
957
|
|
|
958
|
|
|
958
|
int correctionInt;
|
|
959
|
int correctionInt;
|
|
959
|
|
|
960
|
|
|
@@
-962,35
+963,26
void snapshot_resynchronization( unsigne
|
|
962
|
switch (state)
|
|
963
|
switch (state)
|
|
963
|
{
|
|
964
|
{
|
|
964
|
|
|
965
|
|
|
965
|
case MEASURE_0:
|
|
966
|
case MEASURE:
|
|
966
|
// ********
|
|
967
|
// ********
|
|
967
|
PRINTF("MEASURE_0 ===\n");
|
|
968
|
PRINTF("MEASURE ===\n");
|
|
968
|
state = CORRECTION_0;
|
|
969
|
state = CORRECTION;
|
|
969
|
correction = computeCorrection( timePtr );
|
|
970
|
correction = computeCorrection( timePtr );
|
|
970
|
PRINTF1("MEASURE_0 === correction = %.2f\n", correction );
|
|
971
|
PRINTF1("MEASURE === correction = %.2f\n", correction );
|
|
971
|
applyCorrection( correction );
|
|
972
|
applyCorrection( correction );
|
|
972
|
PRINTF1("MEASURE_0 === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
|
|
973
|
PRINTF1("MEASURE === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
|
|
973
|
//****
|
|
974
|
//****
|
|
974
|
break;
|
|
975
|
break;
|
|
975
|
|
|
976
|
|
|
976
|
case CORRECTION_0:
|
|
977
|
case CORRECTION:
|
|
977
|
//************
|
|
978
|
//************
|
|
978
|
PRINTF("CORRECTION_0 ===\n");
|
|
979
|
PRINTF("CORRECTION ===\n");
|
|
979
|
state = CORRECTION_1;
|
|
980
|
state = MEASURE;
|
|
980
|
computeCorrection( timePtr );
|
|
981
|
computeCorrection( timePtr );
|
|
981
|
correction = -correction;
|
|
982
|
correction = -correction;
|
|
982
|
PRINTF1("CORRECTION_0 === correction = %.2f\n", correction );
|
|
983
|
PRINTF1("CORRECTION === correction = %.2f\n", correction );
|
|
983
|
applyCorrection( correction );
|
|
984
|
applyCorrection( correction );
|
|
984
|
PRINTF1("CORRECTION_0 === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
|
|
985
|
PRINTF1("CORRECTION === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
|
|
985
|
//****
|
|
|
|
|
986
|
break;
|
|
|
|
|
987
|
|
|
|
|
|
988
|
case CORRECTION_1:
|
|
|
|
|
989
|
//************
|
|
|
|
|
990
|
PRINTF("CORRECTION_1 ===\n");
|
|
|
|
|
991
|
state = MEASURE_0;
|
|
|
|
|
992
|
computeCorrection( timePtr );
|
|
|
|
|
993
|
PRINTF1("CORRECTION_1 === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
|
|
|
|
|
994
|
//****
|
|
986
|
//****
|
|
995
|
break;
|
|
987
|
break;
|
|
996
|
|
|
988
|
|