@@ -1,2 +1,2 | |||
|
1 | 1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
2 | 80d727bb9d808ae67c801c4c6101811d68b94af6 header/lfr_common_headers | |
|
2 | 4ffa7549495b4d1e5ddbda520569468a5e3b8779 header/lfr_common_headers |
@@ -61,6 +61,8 void compute_acquisition_time(unsigned i | |||
|
61 | 61 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime ); |
|
62 | 62 | void build_snapshot_from_ring(ring_node *ring_node_to_send, unsigned char frequencyChannel , |
|
63 | 63 | unsigned long long acquisitionTimeF0_asLong, ring_node *ring_node_swf_extracted, int *swf_extracted); |
|
64 | double computeCorrection( unsigned char *timePtr ); | |
|
65 | void applyCorrection( double correction ); | |
|
64 | 66 | void snapshot_resynchronization( unsigned char *timePtr ); |
|
65 | 67 | // |
|
66 | 68 | rtems_id get_pkts_queue_id( void ); |
@@ -268,6 +268,9 rtems_task Init( rtems_task_argument ign | |||
|
268 | 268 | |
|
269 | 269 | set_hk_lfr_sc_potential_flag( true ); |
|
270 | 270 | |
|
271 | // start the timer used for the detection of missing parameters (started also by the timecode_irq_handler ISR) | |
|
272 | status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT, timecode_timer_routine, NULL ); | |
|
273 | ||
|
271 | 274 | status = rtems_task_delete(RTEMS_SELF); |
|
272 | 275 | |
|
273 | 276 | } |
@@ -444,8 +444,16 int check_mode_transition( unsigned char | |||
|
444 | 444 | |
|
445 | 445 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ) |
|
446 | 446 | { |
|
447 |
|
|
|
448 | PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime); | |
|
447 | if (transitionCoarseTime == 0) | |
|
448 | { | |
|
449 | lastValidEnterModeTime = time_management_regs->coarse_time + 1; | |
|
450 | PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", transitionCoarseTime); | |
|
451 | } | |
|
452 | else | |
|
453 | { | |
|
454 | lastValidEnterModeTime = transitionCoarseTime; | |
|
455 | PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime); | |
|
456 | } | |
|
449 | 457 | } |
|
450 | 458 | |
|
451 | 459 | int check_transition_date( unsigned int transitionCoarseTime ) |
@@ -1243,6 +1251,7 int suspend_asm_tasks( void ) | |||
|
1243 | 1251 | |
|
1244 | 1252 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
1245 | 1253 | { |
|
1254 | ||
|
1246 | 1255 | WFP_reset_current_ring_nodes(); |
|
1247 | 1256 | |
|
1248 | 1257 | reset_waveform_picker_regs(); |
@@ -1263,6 +1272,8 void launch_waveform_picker( unsigned ch | |||
|
1263 | 1272 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
1264 | 1273 | } |
|
1265 | 1274 | |
|
1275 | update_last_valid_transition_date(waveform_picker_regs->start_date); | |
|
1276 | ||
|
1266 | 1277 | } |
|
1267 | 1278 | |
|
1268 | 1279 | void launch_spectral_matrix( void ) |
@@ -45,9 +45,10 ring_node ring_node_swf2_extracted; | |||
|
45 | 45 | |
|
46 | 46 | typedef enum resynchro_state_t |
|
47 | 47 | { |
|
48 | IDLE, | |
|
49 |
MEASURE_ |
|
|
50 | MEASURE_K_PLUS_1, | |
|
48 | MEASURE_0, | |
|
49 | MEASURE_1, | |
|
50 | CORRECTION_0, | |
|
51 | CORRECTION_1 | |
|
51 | 52 | } resynchro_state; |
|
52 | 53 | |
|
53 | 54 | //********************* |
@@ -868,7 +869,7 void build_snapshot_from_ring( ring_node | |||
|
868 | 869 | } |
|
869 | 870 | } |
|
870 | 871 | |
|
871 |
|
|
|
872 | double computeCorrection( unsigned char *timePtr ) | |
|
872 | 873 | { |
|
873 | 874 | unsigned long long int acquisitionTime; |
|
874 | 875 | unsigned long long int centerTime; |
@@ -876,63 +877,110 void snapshot_resynchronization( unsigne | |||
|
876 | 877 | unsigned long long int nextTick; |
|
877 | 878 | unsigned long long int deltaPreviousTick; |
|
878 | 879 | unsigned long long int deltaNextTick; |
|
879 | int deltaTickInF2; | |
|
880 | 880 | double deltaPrevious_ms; |
|
881 | 881 | double deltaNext_ms; |
|
882 | 882 | double correctionInF2; |
|
883 | double center_k = 0.; | |
|
884 | double cnter_k_plus_1 = 0.; | |
|
885 | static resynchro_state state = IDLE; | |
|
886 | static unsigned char resynchroEngaged = 0; | |
|
883 | ||
|
884 | // get acquisition time in fine time ticks | |
|
885 | acquisitionTime = get_acquisition_time( timePtr ); | |
|
887 | 886 | |
|
888 | if (resynchroEngaged == 0) | |
|
889 | { | |
|
890 | resynchroEngaged = 1; | |
|
891 | // get acquisition time in fine time ticks | |
|
892 | acquisitionTime = get_acquisition_time( timePtr ); | |
|
887 | // compute center time | |
|
888 | centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
|
889 | previousTick = centerTime - (centerTime & 0xffff); | |
|
890 | nextTick = previousTick + 65536; | |
|
893 | 891 | |
|
894 | // compute center time | |
|
895 | centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
|
896 | previousTick = centerTime - (centerTime & 0xffff); | |
|
897 | nextTick = previousTick + 65536; | |
|
892 | deltaPreviousTick = centerTime - previousTick; | |
|
893 | deltaNextTick = nextTick - centerTime; | |
|
898 | 894 | |
|
899 | deltaPreviousTick = centerTime - previousTick; | |
|
900 | deltaNextTick = nextTick - centerTime; | |
|
895 | deltaPrevious_ms = ((double) deltaPreviousTick) / 65536. * 1000.; | |
|
896 | deltaNext_ms = ((double) deltaNextTick) / 65536. * 1000.; | |
|
901 | 897 | |
|
902 | deltaPrevious_ms = ((double) deltaPreviousTick) / 65536. * 1000.; | |
|
903 | deltaNext_ms = ((double) deltaNextTick) / 65536. * 1000.; | |
|
898 | PRINTF2(" delta previous = %.3f ms, delta next = %.2f ms\n", deltaPrevious_ms, deltaNext_ms); | |
|
899 | // PRINTF2(" delta previous = %llu fine time ticks, delta next = %llu fine time ticks\n", | |
|
900 | // deltaPreviousTick, deltaNextTick); | |
|
904 | 901 | |
|
905 | PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious_ms, deltaNext_ms); | |
|
906 | PRINTF2("delta previous = %llu fine time ticks, delta next = %llu fine time ticks\n", deltaPreviousTick, deltaNextTick); | |
|
902 | // which tick is the closest? | |
|
903 | if (deltaPreviousTick > deltaNextTick) | |
|
904 | { | |
|
905 | // the snapshot center is just before the second => increase delta_snapshot | |
|
906 | correctionInF2 = + (deltaNext_ms * 256. / 1000. ); | |
|
907 | } | |
|
908 | else | |
|
909 | { | |
|
910 | // the snapshot center is just after the second => decrease delta_snapshot | |
|
911 | correctionInF2 = - (deltaPrevious_ms * 256. / 1000. ); | |
|
912 | } | |
|
907 | 913 | |
|
908 | // which tick is the closest? | |
|
909 | if (deltaPreviousTick > deltaNextTick) | |
|
910 | { | |
|
911 | // the snapshot center is just before the second => increase delta_snapshot | |
|
912 | correctionInF2 = + (deltaNext_ms * 256. / 1000. ); | |
|
913 | } | |
|
914 | else | |
|
915 | { | |
|
916 | // the snapshot center is just after the second => decrease delta_snapshot | |
|
917 | correctionInF2 = - (deltaPrevious_ms * 256. / 1000. ); | |
|
918 | } | |
|
914 | PRINTF1(" correctionInF2 = %.2f\n", correctionInF2); | |
|
915 | ||
|
916 | return correctionInF2; | |
|
917 | } | |
|
919 | 918 | |
|
920 | if (correctionInF2 >=0 ) | |
|
921 | { | |
|
922 | deltaTickInF2 = ceil( correctionInF2 ); | |
|
923 | } | |
|
924 | else | |
|
925 |
|
|
|
926 | deltaTickInF2 = floor( correctionInF2 ); | |
|
927 | } | |
|
928 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2; | |
|
929 | set_wfp_delta_f0_f0_2(); // this is necessary to reset the value of delta_f0 as delta_snapshot has been changed | |
|
930 | PRINTF2("Correction of = %d, delta_snapshot = %d\n\n", deltaTickInF2, waveform_picker_regs->delta_snapshot); | |
|
919 | void applyCorrection( double correction ) | |
|
920 | { | |
|
921 | int correctionInt; | |
|
922 | ||
|
923 | if (correction>=0) | |
|
924 | { | |
|
925 | correctionInt = floor(correction); | |
|
931 | 926 | } |
|
932 | 927 | else |
|
933 | 928 | { |
|
934 | PRINTF1("No resynchro, delta_snapshot = %d\n\n", waveform_picker_regs->delta_snapshot); | |
|
935 | resynchroEngaged = 0; | |
|
929 | correctionInt = ceil(correction); | |
|
930 | } | |
|
931 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt; | |
|
932 | //set_wfp_delta_f0_f0_2(); | |
|
933 | } | |
|
934 | ||
|
935 | void snapshot_resynchronization( unsigned char *timePtr ) | |
|
936 | { | |
|
937 | static double correction = 0.; | |
|
938 | static double delay_0 = 0.; | |
|
939 | static resynchro_state state = MEASURE_0; | |
|
940 | ||
|
941 | int correctionInt; | |
|
942 | ||
|
943 | correctionInt = 0; | |
|
944 | ||
|
945 | switch (state) | |
|
946 | { | |
|
947 | ||
|
948 | case MEASURE_0: | |
|
949 | // ******** | |
|
950 | PRINTF("MEASURE_0 ===\n"); | |
|
951 | state = CORRECTION_0; | |
|
952 | delay_0 = computeCorrection( timePtr ); | |
|
953 | correction = delay_0; | |
|
954 | PRINTF1("MEASURE_0 === correction = %.2f\n", correction ); | |
|
955 | applyCorrection( correction ); | |
|
956 | PRINTF1("MEASURE_0 === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); | |
|
957 | //**** | |
|
958 | break; | |
|
959 | ||
|
960 | case CORRECTION_0: | |
|
961 | //************ | |
|
962 | PRINTF("CORRECTION_0 ===\n"); | |
|
963 | state = CORRECTION_1; | |
|
964 | computeCorrection( timePtr ); | |
|
965 | correction = -correction; | |
|
966 | PRINTF1("CORRECTION_0 === correction = %.2f\n", correction ); | |
|
967 | applyCorrection( correction ); | |
|
968 | PRINTF1("CORRECTION_0 === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); | |
|
969 | //**** | |
|
970 | break; | |
|
971 | ||
|
972 | case CORRECTION_1: | |
|
973 | //************ | |
|
974 | PRINTF("CORRECTION_1 ===\n"); | |
|
975 | state = MEASURE_0; | |
|
976 | computeCorrection( timePtr ); | |
|
977 | PRINTF1("CORRECTION_1 === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); | |
|
978 | //**** | |
|
979 | break; | |
|
980 | ||
|
981 | default: | |
|
982 | break; | |
|
983 | ||
|
936 | 984 | } |
|
937 | 985 | } |
|
938 | 986 |
General Comments 0
You need to be logged in to leave comments.
Login now