diff --git a/.hgsubstate b/.hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,2 +1,2 @@ -a0aa2c6f13574ae69c8645af2a2afa5d448e6c76 LFR_basic-parameters -a8668a35669295aaba22432d247158626f00a52a header/lfr_common_headers +0f2eb26d750be2b6d8a3f5dee479b4575d3b93be LFR_basic-parameters +95a8d83f1d0c59f28a679e66e23464f21c12dd8a header/lfr_common_headers diff --git a/header/fsw_misc.h b/header/fsw_misc.h --- a/header/fsw_misc.h +++ b/header/fsw_misc.h @@ -34,7 +34,8 @@ void increment_seq_counter(unsigned shor void getTime( unsigned char *time); unsigned long long int getTimeAsUnsignedLongLongInt( ); void send_dumb_hk( void ); -void get_v_e1_e2_f3(unsigned char *spacecraft_potential); +void get_v_e1_e2_f3( unsigned char *spacecraft_potential ); +void get_temperatures( unsigned char *temperatures ); void get_cpu_load( unsigned char *resource_statistics ); extern int sched_yield( void ); diff --git a/header/grlib_regs.h b/header/grlib_regs.h --- a/header/grlib_regs.h +++ b/header/grlib_regs.h @@ -45,6 +45,9 @@ typedef struct { volatile int coarse_time_load; volatile int coarse_time; volatile int fine_time; + volatile int temp_scm; + volatile int temp_pcb; + volatile int temp_fpga; } time_management_regs_t; // PDB >= 0.1.28 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 @@ -142,6 +142,10 @@ static inline void SM_average(float *ave static inline void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, ring_node *ring_node_tab[], unsigned int nbAverageNORM, unsigned int nbAverageSBM ); + +void ASM_patch( float *inputASM, float *outputASM ); +void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent ); + static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ); static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, diff --git a/src/fsw_init.c b/src/fsw_init.c --- a/src/fsw_init.c +++ b/src/fsw_init.c @@ -391,7 +391,7 @@ int create_all_tasks( void ) // create a { status = rtems_task_create( Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2, - RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] ); } @@ -407,7 +407,7 @@ int create_all_tasks( void ) // create a { status = rtems_task_create( Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2, - RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] ); } @@ -423,7 +423,7 @@ int create_all_tasks( void ) // create a { status = rtems_task_create( Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2, - RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] ); } diff --git a/src/fsw_misc.c b/src/fsw_misc.c --- a/src/fsw_misc.c +++ b/src/fsw_misc.c @@ -226,6 +226,7 @@ rtems_task hous_task(rtems_task_argument spacewire_update_statistics(); get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); + get_temperatures( housekeeping_packet.hk_lfr_temp_scm); get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); // SEND PACKET @@ -459,6 +460,24 @@ void get_v_e1_e2_f3( unsigned char *spac spacecraft_potential[5] = e2_ptr[3]; } +void get_temperatures( unsigned char *temperatures ) +{ + unsigned char* temp_scm_ptr; + unsigned char* temp_pcb_ptr; + unsigned char* temp_fpga_ptr; + + temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; + temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; + temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; + + temperatures[0] = temp_scm_ptr[2]; + temperatures[1] = temp_scm_ptr[3]; + temperatures[2] = temp_pcb_ptr[2]; + temperatures[3] = temp_pcb_ptr[3]; + temperatures[4] = temp_fpga_ptr[2]; + temperatures[5] = temp_fpga_ptr[3]; +} + void get_cpu_load( unsigned char *resource_statistics ) { unsigned char cpu_load; diff --git a/src/processing/avf0_prc0.c b/src/processing/avf0_prc0.c --- a/src/processing/avf0_prc0.c +++ b/src/processing/avf0_prc0.c @@ -20,7 +20,10 @@ ring_node_asm asm_ring_burst_sbm_f0 [ NB ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ]; int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ]; -float asm_f0_reorganized [ TOTAL_SIZE_SM ]; +float asm_f0_patched_norm [ TOTAL_SIZE_SM ]; +float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ]; +float asm_f0_reorganized [ TOTAL_SIZE_SM ]; + char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0]; float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ]; @@ -259,6 +262,9 @@ rtems_task prc0_task( rtems_task_argumen incomingMsg = (asm_msg*) incomingData; + ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm ); + ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm ); + //**************** //**************** // BURST SBM1 SBM2 @@ -268,12 +274,12 @@ rtems_task prc0_task( rtems_task_argumen { sid = getSID( incomingMsg->event ); // 1) compress the matrix for Basic Parameters calculation - ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0, + ASM_compress_reorganize_and_divide( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0, nb_sm_before_f0.burst_sbm_bp1, NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0, ASM_F0_INDICE_START); // 2) compute the BP1 set - BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data ); +// BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data ); // 3) send the BP1 set set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); @@ -302,12 +308,12 @@ rtems_task prc0_task( rtems_task_argumen if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0) { // 1) compress the matrix for Basic Parameters calculation - ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0, + ASM_compress_reorganize_and_divide( asm_f0_patched_norm, compressed_sm_norm_f0, nb_sm_before_f0.norm_bp1, NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, ASM_F0_INDICE_START ); // 2) compute the BP1 set - BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data ); +// BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data ); // 3) send the BP1 set set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); @@ -330,7 +336,7 @@ rtems_task prc0_task( rtems_task_argumen if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0) { // 1) reorganize the ASM and divide - ASM_reorganize_and_divide( incomingMsg->norm->matrix, + ASM_reorganize_and_divide( asm_f0_patched_norm, asm_f0_reorganized, nb_sm_before_f0.norm_bp1 ); // 2) convert the float array in a char array diff --git a/src/processing/avf1_prc1.c b/src/processing/avf1_prc1.c --- a/src/processing/avf1_prc1.c +++ b/src/processing/avf1_prc1.c @@ -22,7 +22,7 @@ ring_node ring_to_send_asm_f1 [ NB int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ]; float asm_f1_reorganized [ TOTAL_SIZE_SM ]; -char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; +char asm_f1_char [ TOTAL_SIZE_SM * 2 ]; float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1]; float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ]; @@ -302,7 +302,7 @@ rtems_task prc1_task( rtems_task_argumen NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1, ASM_F1_INDICE_START ); // 2) compute the BP1 set - BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data ); +// BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data ); // 3) send the BP1 set set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); diff --git a/src/processing/avf2_prc2.c b/src/processing/avf2_prc2.c --- a/src/processing/avf2_prc2.c +++ b/src/processing/avf2_prc2.c @@ -184,7 +184,7 @@ rtems_task prc2_task( rtems_task_argumen while(1){ status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************ - RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 + RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF2 incomingMsg = (asm_msg*) incomingData; @@ -195,32 +195,34 @@ rtems_task prc2_task( rtems_task_argumen // NORM //***** //***** + // 1) compress the matrix for Basic Parameters calculation + ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2, + nb_sm_before_f2.norm_bp1, + NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2, + ASM_F2_INDICE_START ); + // BP1_F2 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2) { - // 1) compress the matrix for Basic Parameters calculation - ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2, - nb_sm_before_f2.norm_bp1, - NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2, - ASM_F2_INDICE_START ); - // 2) compute the BP1 set - BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data ); - // 3) send the BP1 set + // 1) compute the BP1 set +// BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data ); + // 2) send the BP1 set set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); BP_send( (char *) &packet_norm_bp1, queue_id_send, PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA, SID_NORM_BP1_F2 ); - if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2) - { - // 1) compute the BP2 set using the same ASM as the one used for BP1 - BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data ); - // 2) send the BP2 set - set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); - set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); - BP_send( (char *) &packet_norm_bp2, queue_id_send, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA, - SID_NORM_BP2_F2 ); - } + } + // BP2_F2 + if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2) + { + // 1) compute the BP2 set + BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data ); + // 2) send the BP2 set + set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); + set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); + BP_send( (char *) &packet_norm_bp2, queue_id_send, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA, + SID_NORM_BP2_F2 ); } if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2) 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 @@ -53,13 +53,13 @@ ring_node * getRingNodeForAveraging( uns //*********************************************************** // Interrupt Service Routine for spectral matrices processing -void spectral_matrices_isr_f0( void ) +void spectral_matrices_isr_f0( unsigned char statusReg ) { unsigned char status; rtems_status_code status_code; ring_node *full_ring_node; - status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits + status = statusReg & 0x03; // [0011] get the status_ready_matrix_f0_x bits switch(status) { @@ -111,13 +111,13 @@ void spectral_matrices_isr_f0( void ) } } -void spectral_matrices_isr_f1( void ) +void spectral_matrices_isr_f1( unsigned char statusReg ) { rtems_status_code status_code; unsigned char status; ring_node *full_ring_node; - status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits + status = (statusReg & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits switch(status) { @@ -169,12 +169,12 @@ void spectral_matrices_isr_f1( void ) } } -void spectral_matrices_isr_f2( void ) +void spectral_matrices_isr_f2( unsigned char statusReg ) { unsigned char status; rtems_status_code status_code; - status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits + status = (statusReg & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits switch(status) { @@ -212,11 +212,11 @@ void spectral_matrices_isr_f2( void ) } } -void spectral_matrix_isr_error_handler( void ) +void spectral_matrix_isr_error_handler( unsigned char statusReg ) { rtems_status_code status_code; - if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000] + if (statusReg & 0x7c0) // [0111 1100 0000] { status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); } @@ -232,13 +232,17 @@ rtems_isr spectral_matrices_isr( rtems_v // 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 - spectral_matrices_isr_f0(); + unsigned char statusReg; - spectral_matrices_isr_f1(); + statusReg = spectral_matrix_regs->status; + + spectral_matrices_isr_f0( statusReg ); - spectral_matrices_isr_f2(); + spectral_matrices_isr_f1( statusReg ); - spectral_matrix_isr_error_handler(); + spectral_matrices_isr_f2( statusReg ); + + spectral_matrix_isr_error_handler( statusReg ); } rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) @@ -536,3 +540,47 @@ unsigned char getSID( rtems_event_set ev return sid; } +void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) +{ + unsigned int i; + float re; + float im; + + for (i=0; i