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: Mon May 26 15:36:46 2014 +# Generated by qmake (2.01a) (Qt 4.8.6) on: Thu May 29 09:32:56 2014 # Project: fsw-qt.pro # Template: app # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro @@ -10,7 +10,7 @@ CC = sparc-rtems-gcc CXX = sparc-rtems-g++ -DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=7 -DPRINT_MESSAGES_ON_CONSOLE +DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=8 -DPRINT_MESSAGES_ON_CONSOLE -DDEBUG_MESSAGES CFLAGS = -pipe -O3 -Wall $(DEFINES) CXXFLAGS = -pipe -O3 -Wall $(DEFINES) INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters diff --git a/FSW-qt/fsw-qt.pro b/FSW-qt/fsw-qt.pro --- a/FSW-qt/fsw-qt.pro +++ b/FSW-qt/fsw-qt.pro @@ -1,7 +1,7 @@ TEMPLATE = app # CONFIG += console v8 sim # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch -CONFIG += console verbose +CONFIG += console verbose debug_messages CONFIG -= qt include(./sparc.pri) diff --git a/FSW-qt/fsw-qt.pro.user b/FSW-qt/fsw-qt.pro.user --- a/FSW-qt/fsw-qt.pro.user +++ b/FSW-qt/fsw-qt.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/header/fsw_params.h b/header/fsw_params.h --- a/header/fsw_params.h +++ b/header/fsw_params.h @@ -118,7 +118,7 @@ typedef struct ring_node #define REGS_ADDR_GRGPIO 0x80000b00 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 -#define REGS_ADDR_WAVEFORM_PICKER 0x80000f40 +#define REGS_ADDR_WAVEFORM_PICKER 0x80000f50 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff #define APBUART_CTRL_REG_MASK_TE 0x00000002 diff --git a/header/grlib_regs.h b/header/grlib_regs.h --- a/header/grlib_regs.h +++ b/header/grlib_regs.h @@ -82,19 +82,28 @@ typedef struct{ typedef struct { volatile int config; // 0x00 volatile int status; // 0x04 - volatile int matrixF0_Address0; // 0x08 - volatile int matrixFO_Address1; // 0x0C - volatile int matrixF1_Address; // 0x10 - volatile int matrixF2_Address; // 0x14 - volatile int coarse_time_F0_0; // 0x18 - volatile int coarse_time_F0_1; // 0x1C - volatile int coarse_time_F1; // 0x20 - volatile int coarse_time_F2; // 0x24 - volatile int fine_time_FO_0; // 0x28 - volatile int fine_time_F0_1; // 0x2C - volatile int fine_time_F1; // 0x30 - volatile int fine_time_F2; // 0x34 - volatile int debug; // 0x38 + volatile int f0_0_address; // 0x08 + volatile int f0_1_address; // 0x0C + // + volatile int f1_0_address; // 0x10 + volatile int f1_1_address; // 0x14 + volatile int f2_0_address; // 0x18 + volatile int f2_1_address; // 0x1C + // + volatile int f0_0_coarse_time; // 0x20 + volatile int f0_0_fine_time; // 0x24 + volatile int f0_1_coarse_time; // 0x28 + volatile int f0_1_fine_time; // 0x2C + // + volatile int f1_0_coarse_time; // 0x30 + volatile int f1_0_fine_time; // 0x34 + volatile int f1_1_coarse_time; // 0x38 + volatile int f1_1_time_time; // 0x3C + // + volatile int f2_0_coarse_time; // 0x40 + volatile int f2_0_fine_time; // 0x44 + volatile int f2_1_coarse_time; // 0x48 + volatile int f2_1_time_time; // 0x4C } spectral_matrix_regs_t; #endif // GRLIB_REGS_H_INCLUDED diff --git a/header/processing/fsw_processing.h b/header/processing/fsw_processing.h --- a/header/processing/fsw_processing.h +++ b/header/processing/fsw_processing.h @@ -98,6 +98,9 @@ void BP_send( char *data, // general functions void reset_spectral_matrix_regs( void ); void set_time(unsigned char *time, unsigned char *timeInBuffer ); +unsigned long long int get_acquisition_time( unsigned char *timePtr ); +void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id, + ring_node_sm *node_for_averaging, ring_node_sm *ringNode); extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); diff --git a/header/wf_handler.h b/header/wf_handler.h --- a/header/wf_handler.h +++ b/header/wf_handler.h @@ -51,9 +51,9 @@ rtems_task swbd_task( rtems_task_argumen //****************** // general functions -void init_waveform_rings( void ); +void WFP_init_rings( void ); void init_waveform_ring( ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] ); -void reset_current_ring_nodes( void ); +void WFP_reset_current_ring_nodes( void ); // int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF ); int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); diff --git a/src/fsw_init.c b/src/fsw_init.c --- a/src/fsw_init.c +++ b/src/fsw_init.c @@ -32,6 +32,7 @@ #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) +#define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) #define CONFIGURE_MAXIMUM_DRIVERS 16 #define CONFIGURE_MAXIMUM_PERIODS 5 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) @@ -98,12 +99,15 @@ rtems_task Init( rtems_task_argument ign init_local_mode_parameters(); init_housekeeping_parameters(); - init_waveform_rings(); // initialize the waveform rings - SM_init_rings(); // initialize spectral matrices rings + // waveform picker initialization + WFP_init_rings(); // initialize the waveform rings + WFP_reset_current_ring_nodes(); + reset_waveform_picker_regs(); - reset_wfp_burst_enable(); - reset_wfp_status(); - set_wfp_data_shaping(); + // spectral matrices initialization + SM_init_rings(); // initialize spectral matrices rings + SM_reset_current_ring_nodes(); + reset_spectral_matrix_regs(); updateLFRCurrentMode(); 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 @@ -32,58 +32,92 @@ ring_node_sm *ring_node_for_averaging_sm rtems_isr spectral_matrices_isr( rtems_vector_number vector ) { + 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 - if ( (spectral_matrix_regs->status & 0x1) == 0x01) // check the status_ready_matrix_f0 bit + status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits + switch(status) { - nb_sm_f0 = nb_sm_f0 + 1; - if (nb_sm_f0 == NB_SM_BEFORE_AVF0 ) + case 0: + break; + case 3: + time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_0_coarse_time ); + time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_1_coarse_time ); + if ( time_0 < time_1 ) { - ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; + 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; + 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->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address; - if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) - { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); - } - nb_sm_f0 = 0; + spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; + } + else + { + 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; + 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 & 0xfffffffc; // [1100] + 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] + 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] + 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->matrixF1_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 ( (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 +// } //*** // F2 - if ( (spectral_matrix_regs->status & 0x8) == 0x08) // check the status_ready_matrix_f2 bit - { +// if ( (spectral_matrix_regs->status & 0x8) == 0x08) // check the status_ready_matrix_f2 bit +// { - 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->matrixF2_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 - } +// 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 +// } //************************ // reset status error bits @@ -219,8 +253,8 @@ void SM_init_rings( void ) DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) - spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address; - DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0) + spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address; + DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address) } void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] ) @@ -266,9 +300,9 @@ void ASM_generic_init_ring( ring_node_as void SM_reset_current_ring_nodes( void ) { - current_ring_node_sm_f0 = sm_ring_f0; - current_ring_node_sm_f1 = sm_ring_f1; - current_ring_node_sm_f2 = sm_ring_f2; + current_ring_node_sm_f0 = sm_ring_f0[0].next; + current_ring_node_sm_f1 = sm_ring_f1[0].next; + current_ring_node_sm_f2 = sm_ring_f2[0].next; ring_node_for_averaging_sm_f0 = sm_ring_f0; ring_node_for_averaging_sm_f1 = sm_ring_f1; @@ -488,10 +522,12 @@ void reset_spectral_matrix_regs( void ) spectral_matrix_regs->config = 0x00; spectral_matrix_regs->status = 0x00; - spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address; - spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address; - spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address; - spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address; + spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address; + spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; + spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address; + spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; + spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address; + spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; } void set_time( unsigned char *time, unsigned char * timeInBuffer ) @@ -510,3 +546,33 @@ void set_time( unsigned char *time, unsi time[4] = timeInBuffer[6]; time[5] = timeInBuffer[7]; } + +unsigned long long int get_acquisition_time( unsigned char *timePtr ) +{ + unsigned long long int acquisitionTimeAslong; + acquisitionTimeAslong = 0x00; + acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit + + ( (unsigned long long int) timePtr[1] << 32 ) + + ( timePtr[2] << 24 ) + + ( timePtr[3] << 16 ) + + ( timePtr[4] << 8 ) + + ( timePtr[5] ); + return acquisitionTimeAslong; +} + +void close_matrix_actions( unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id, + ring_node_sm *node_for_averaging, ring_node_sm *ringNode ) +{ + *nb_sm = *nb_sm + 1; + if (*nb_sm == nb_sm_before_avf) + { + node_for_averaging = ringNode; + if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) + { + rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + } + *nb_sm = 0; + } +} + + diff --git a/src/tc_handler.c b/src/tc_handler.c --- a/src/tc_handler.c +++ b/src/tc_handler.c @@ -532,8 +532,8 @@ int enter_mode( unsigned char mode, unsi #endif status = restart_science_tasks( mode ); launch_waveform_picker( mode, transitionCoarseTime ); - //launch_spectral_matrix( ); - launch_spectral_matrix_simu( ); + launch_spectral_matrix( ); +// launch_spectral_matrix_simu( ); } else if ( mode == LFR_MODE_STANDBY ) { @@ -748,7 +748,7 @@ int suspend_science_tasks() void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) { - reset_current_ring_nodes(); + WFP_reset_current_ring_nodes(); reset_waveform_picker_regs(); set_wfp_burst_enable_register( mode ); diff --git a/src/wf_handler.c b/src/wf_handler.c --- a/src/wf_handler.c +++ b/src/wf_handler.c @@ -448,7 +448,7 @@ rtems_task swbd_task(rtems_task_argument //****************** // general functions -void init_waveform_rings( void ) +void WFP_init_rings( void ) { // F0 RING init_waveform_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_snap_f0 ); @@ -485,7 +485,7 @@ void init_waveform_ring(ring_node wavefo } } -void reset_current_ring_nodes( void ) +void WFP_reset_current_ring_nodes( void ) { current_ring_node_f0 = waveform_ring_f0; ring_node_to_send_swf_f0 = waveform_ring_f0;