# HG changeset patch # User paul # Date 2014-06-12 15:02:27 # Node ID 8abc460aa11b70e25290ad28b1972567f68baa25 # Parent 7dc1808bbf1e44c1e3b36d8166bf386298f9f455 Sync diff --git a/FSW-qt/Makefile b/FSW-qt/Makefile --- a/FSW-qt/Makefile +++ b/FSW-qt/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: bin/fsw -# Generated by qmake (2.01a) (Qt 4.8.6) on: Thu Jun 12 08:10:29 2014 +# Generated by qmake (2.01a) (Qt 4.8.6) on: Thu Jun 12 15:33:39 2014 # Project: fsw-qt.pro # Template: app # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro diff --git a/src/processing/fsw_processing.c b/src/processing/fsw_processing.c --- a/src/processing/fsw_processing.c +++ b/src/processing/fsw_processing.c @@ -30,20 +30,14 @@ ring_node_sm *ring_node_for_averaging_sm //*********************************************************** // Interrupt Service Routine for spectral matrices processing -rtems_isr spectral_matrices_isr( rtems_vector_number vector ) +void spectral_matrices_isr_f0( void ) { unsigned char status; unsigned long long int time_0; unsigned long long int time_1; - // STATUS REGISTER - // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) - // 10 9 8 - // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 - // 7 6 5 4 3 2 1 0 - //*** - // F0 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits + switch(status) { case 0: @@ -69,64 +63,124 @@ rtems_isr spectral_matrices_isr( rtems_v current_ring_node_sm_f0 = current_ring_node_sm_f0->next; spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; } - spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffc; // [1100] + spectral_matrix_regs->status = spectral_matrix_regs->status & 0x03; // [0011] break; case 1: close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous); current_ring_node_sm_f0 = current_ring_node_sm_f0->next; spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; - spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // [1110] + spectral_matrix_regs->status = spectral_matrix_regs->status & 0x01; // [0001] break; case 2: close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous); current_ring_node_sm_f0 = current_ring_node_sm_f0->next; spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; - spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // [1101] + spectral_matrix_regs->status = spectral_matrix_regs->status & 0x02; // [0010] + break; + } +} + +void spectral_matrices_isr_f1( void ) +{ + unsigned char status; + unsigned long long int time_0; + unsigned long long int time_1; + + status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits + + switch(status) + { + case 0: + break; + case 3: + time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_0_coarse_time ); + time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_1_coarse_time ); + if ( time_0 < time_1 ) + { + close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous); + current_ring_node_sm_f1 = current_ring_node_sm_f1->next; + spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; + close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous); + current_ring_node_sm_f1 = current_ring_node_sm_f1->next; + spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; + } + else + { + close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous); + current_ring_node_sm_f1 = current_ring_node_sm_f1->next; + spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; + close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous); + current_ring_node_sm_f1 = current_ring_node_sm_f1->next; + spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; + } + spectral_matrix_regs->status = spectral_matrix_regs->status & 0x0c; // [1100] + break; + case 1: + close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous); + current_ring_node_sm_f1 = current_ring_node_sm_f1->next; + spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; + spectral_matrix_regs->status = spectral_matrix_regs->status & 0x07; // [0100] + break; + case 2: + close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous); + current_ring_node_sm_f1 = current_ring_node_sm_f1->next; + spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; + spectral_matrix_regs->status = spectral_matrix_regs->status & 0x08; // [1000] + break; + } +} + +void spectral_matrices_isr_f2( void ) +{ + unsigned char status; + + status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits + + ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; + + current_ring_node_sm_f2 = current_ring_node_sm_f2->next; + + switch(status) + { + case 0: + case 3: + break; + case 1: + spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; + spectral_matrix_regs->status = spectral_matrix_regs->status & 0x10; // [0001 0000] + break; + case 2: + spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; + spectral_matrix_regs->status = spectral_matrix_regs->status & 0x20; // [0010 0000] break; } - //*** - // F1 -// if ( (spectral_matrix_regs->status & 0x4) == 0x04) // check the status_ready_matrix_f1 bit -// { -// nb_sm_f1 = nb_sm_f1 + 1; -// if (nb_sm_f1 == NB_SM_BEFORE_AVF1 ) -// { -// ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1; -// current_ring_node_sm_f1 = current_ring_node_sm_f1->next; -// spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; -// if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) -// { -// rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); -// } -// nb_sm_f1 = 0; -// } -// spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffb; // 1011 -// } + if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) + { + rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + } +} + +void spectral_matrix_isr_error_handler( void ) +{ + spectral_matrix_regs->status = 0x7c0; // [0111 1100 0000] +} - //*** - // F2 -// if ( (spectral_matrix_regs->status & 0x8) == 0x08) // check the status_ready_matrix_f2 bit -// { +rtems_isr spectral_matrices_isr( rtems_vector_number vector ) +{ + // STATUS REGISTER + // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) + // 10 9 8 + // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 + // 7 6 5 4 3 2 1 0 -// ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; -// current_ring_node_sm_f2 = current_ring_node_sm_f2->next; -// spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; -// if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) -// { -// rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); -// } -// spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff7; // 0111 -// } + spectral_matrices_isr_f0(); + + spectral_matrices_isr_f1(); - //************************ - // reset status error bits -// if ( (spectral_matrix_regs->status & 0x3e0) != 0x00) // [0011 1110 0000] check the status bits -// { -// rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); -// spectral_matrix_regs->status = spectral_matrix_regs->status | 0xfffffc1f; // [1100 0001 1111] -// } + spectral_matrices_isr_f2(); + spectral_matrix_isr_error_handler(); } rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) diff --git a/src/tc_handler.c b/src/tc_handler.c --- a/src/tc_handler.c +++ b/src/tc_handler.c @@ -533,7 +533,7 @@ int enter_mode( unsigned char mode, unsi status = restart_science_tasks( mode ); launch_waveform_picker( mode, transitionCoarseTime ); // launch_spectral_matrix( ); - launch_spectral_matrix_simu( ); +// launch_spectral_matrix_simu( ); } else if ( mode == LFR_MODE_STANDBY ) { diff --git a/src/wf_handler.c b/src/wf_handler.c --- a/src/wf_handler.c +++ b/src/wf_handler.c @@ -928,8 +928,8 @@ void compute_acquisition_time( unsigned localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); localAcquisitionTime[3] = (unsigned char) ( coarseTime ); - localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 ); - localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 ); + localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); + localAcquisitionTime[5] = (unsigned char) ( fineTime ); acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) @@ -998,6 +998,7 @@ void build_snapshot_from_ring( ring_node unsigned long long int bufferAcquisitionTime_asLong; unsigned char *ptr1; unsigned char *ptr2; + unsigned char *timeCharPtr; unsigned char nb_ring_nodes; unsigned long long int frequency_asLong; unsigned long long int nbTicksPerSample_asLong; @@ -1058,7 +1059,7 @@ void build_snapshot_from_ring( ring_node // (5) compute the number of samples to take in the current buffer sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; - PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong) + PRINTF2("sampleOffset_asLong = %llx, nbSamplesPart1_asLong = %llx\n", sampleOffset_asLong, nbSamplesPart1_asLong) // (6) compute the final acquisition time acquisitionTime_asLong = bufferAcquisitionTime_asLong + @@ -1067,16 +1068,21 @@ void build_snapshot_from_ring( ring_node // (7) copy the acquisition time at the beginning of the extrated snapshot ptr1 = (unsigned char*) &acquisitionTime_asLong; ptr2 = (unsigned char*) wf_snap_extracted; - ptr2[0] = ptr1[ 2 + 2 ]; - ptr2[1] = ptr1[ 3 + 2 ]; - ptr2[2] = ptr1[ 0 + 2 ]; - ptr2[3] = ptr1[ 1 + 2 ]; - ptr2[4] = ptr1[ 4 + 2 ]; - ptr2[5] = ptr1[ 5 + 2 ]; + ptr2[0] = ptr1[ 0 + 2 ]; + ptr2[1] = ptr1[ 1 + 2 ]; + ptr2[2] = ptr1[ 2 + 2 ]; + ptr2[3] = ptr1[ 3 + 2 ]; + ptr2[6] = ptr1[ 4 + 2 ]; + ptr2[7] = ptr1[ 5 + 2 ]; // re set the synchronization bit + timeCharPtr = (unsigned char*) ring_node_to_send->buffer_address; + ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] - + if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) + { + nbSamplesPart1_asLong = 0; + } // copy the part 1 of the snapshot in the extracted buffer for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) { @@ -1118,8 +1124,8 @@ void build_acquisition_time( unsigned lo + ( (unsigned long long int) acquisitionTimeCharPtr[1] << 32 ) + ( acquisitionTimeCharPtr[2] << 24 ) + ( acquisitionTimeCharPtr[3] << 16 ) - + ( acquisitionTimeCharPtr[4] << 8 ) - + ( acquisitionTimeCharPtr[5] ); + + ( acquisitionTimeCharPtr[6] << 8 ) + + ( acquisitionTimeCharPtr[7] ); } //**************