##// END OF EJS Templates
Snapshot resynchro modified
paul -
r267:3616e7d285c0 R3a
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 b0e42058c39c77fc42a5bd3bf529e4547497c4c3 header/lfr_common_headers
2 449d1ebc41af2e62571508883dab8043a33f16df header/lfr_common_headers
@@ -20,7 +20,7 SWVERSION=-1-0
20 DEFINES += SW_VERSION_N1=3 # major
20 DEFINES += SW_VERSION_N1=3 # major
21 DEFINES += SW_VERSION_N2=0 # minor
21 DEFINES += SW_VERSION_N2=0 # minor
22 DEFINES += SW_VERSION_N3=0 # patch
22 DEFINES += SW_VERSION_N3=0 # patch
23 DEFINES += SW_VERSION_N4=16 # internal
23 DEFINES += SW_VERSION_N4=17 # internal
24
24
25 # <GCOV>
25 # <GCOV>
26 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
26 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
@@ -70,7 +70,7 typedef struct{
70 int addr_data_f3_0; // 0x20
70 int addr_data_f3_0; // 0x20
71 int addr_data_f3_1; // 0x24
71 int addr_data_f3_1; // 0x24
72 volatile int status; // 0x28
72 volatile int status; // 0x28
73 int delta_snapshot; // 0x2c
73 volatile int delta_snapshot; // 0x2c
74 int delta_f0; // 0x30
74 int delta_f0; // 0x30
75 int delta_f0_2; // 0x34
75 int delta_f0_2; // 0x34
76 int delta_f1; // 0x38
76 int delta_f1; // 0x38
@@ -273,6 +273,7 rtems_task Init( rtems_task_argument ign
273 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
273 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
274 // if a tickout is generated, the timer is restarted
274 // if a tickout is generated, the timer is restarted
275 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
275 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
276
276 grspw_timecode_callback = &timecode_irq_handler;
277 grspw_timecode_callback = &timecode_irq_handler;
277
278
278 status = rtems_task_delete(RTEMS_SELF);
279 status = rtems_task_delete(RTEMS_SELF);
@@ -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
General Comments 0
You need to be logged in to leave comments. Login now