# HG changeset patch # User paul # Date 2014-03-06 14:58:48 # Node ID ecfd2ffe303348870a3dad678e442f9aa0fd5574 # Parent e5b7ab03049c83fb447fb2e673720bbd61efd7cb snapshot extraction for the waveform ring is operational the SWF_F1 are coarsely synchronized with SWF_F0 and SWF_F2 a dedicated task, SWBD, [S]napshot [W]aveform [B]uil[D] has been created 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.5) on: Tue Mar 4 09:15:37 2014 +# Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Mar 4 13:06: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 @@ -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=2 -DPRINT_MESSAGES_ON_CONSOLE -DDEBUG_MESSAGES +DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=3 -DPRINT_MESSAGES_ON_CONSOLE CFLAGS = -pipe -O3 -Wall $(DEFINES) CXXFLAGS = -pipe -O3 -Wall $(DEFINES) INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../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 -CONFIG += console verbose debug_messages +CONFIG += console verbose CONFIG -= qt include(./sparc.pri) @@ -11,7 +11,7 @@ SWVERSION=-1-0 DEFINES += SW_VERSION_N1=1 # major DEFINES += SW_VERSION_N2=0 # minor DEFINES += SW_VERSION_N3=0 # patch -DEFINES += SW_VERSION_N4=2 # internal +DEFINES += SW_VERSION_N4=3 # internal contains( CONFIG, verbose ) { DEFINES += PRINT_MESSAGES_ON_CONSOLE 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 @@ -144,7 +144,7 @@ typedef struct ring_node #define TASKID_SMIQ 4 #define TASKID_STAT 5 #define TASKID_AVF0 6 -//#define TASKID_BPF0 7 +#define TASKID_SWBD 7 #define TASKID_WFRM 8 #define TASKID_DUMB 9 #define TASKID_HOUS 10 @@ -163,6 +163,7 @@ typedef struct ring_node #define TASK_PRIORITY_CWF2 35 // #define TASK_PRIORITY_WFRM 40 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1 +#define TASK_PRIORITY_SWBD 40 #define TASK_PRIORITY_SEND 45 #define TASK_PRIORITY_RECV 50 #define TASK_PRIORITY_ACTN 50 diff --git a/header/wf_handler.h b/header/wf_handler.h --- a/header/wf_handler.h +++ b/header/wf_handler.h @@ -40,12 +40,17 @@ extern rtems_id Task_id[20]; extern unsigned char lfrCurrentMode; +//********** +// RTEMS_ISR rtems_isr waveforms_isr( rtems_vector_number vector ); -rtems_isr waveforms_isr_alt( rtems_vector_number vector ); + +//*********** +// RTEMS_TASK rtems_task wfrm_task( rtems_task_argument argument ); rtems_task cwf3_task( rtems_task_argument argument ); rtems_task cwf2_task( rtems_task_argument argument ); rtems_task cwf1_task( rtems_task_argument argument ); +rtems_task swbd_task( rtems_task_argument argument ); //****************** // general functions @@ -64,6 +69,7 @@ int send_waveform_CWF3_light( volatile i // void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime, unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime ); +void build_snapshot_from_ring( void ); // rtems_id get_pkts_queue_id( void ); diff --git a/src/fsw_globals.c b/src/fsw_globals.c --- a/src/fsw_globals.c +++ b/src/fsw_globals.c @@ -46,9 +46,9 @@ volatile int wf_cont_f3_b [ (NB_SAMPL char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100))); // SPECTRAL MATRICES GLOBAL VARIABLES -volatile int sm_f0[ NB_RING_NODES_ASM_F0 ][ TIME_OFFSET + TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); -volatile int sm_f1[ NB_RING_NODES_ASM_F1 ][ TIME_OFFSET + TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); -volatile int sm_f2[ NB_RING_NODES_ASM_F2 ][ TIME_OFFSET + TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); +volatile int sm_f0[ NB_RING_NODES_ASM_F0 ][ TIME_OFFSET + TOTAL_SIZE_SM + 62 ] __attribute__((aligned(0x100))); +volatile int sm_f1[ NB_RING_NODES_ASM_F1 ][ TIME_OFFSET + TOTAL_SIZE_SM + 62 ] __attribute__((aligned(0x100))); +volatile int sm_f2[ NB_RING_NODES_ASM_F2 ][ TIME_OFFSET + TOTAL_SIZE_SM + 62 ] __attribute__((aligned(0x100))); // APB CONFIGURATION REGISTERS time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; diff --git a/src/fsw_init.c b/src/fsw_init.c --- a/src/fsw_init.c +++ b/src/fsw_init.c @@ -246,7 +246,7 @@ void create_names( void ) // create all Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); -// Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' ); + Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); @@ -282,13 +282,30 @@ int create_all_tasks( void ) // create a rtems_status_code status; + //********** + // SPACEWIRE // RECV status = rtems_task_create( Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] ); - + if (status == RTEMS_SUCCESSFUL) // SEND + { + status = rtems_task_create( + Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] + ); + } + if (status == RTEMS_SUCCESSFUL) // WTDG + { + status = rtems_task_create( + Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] + ); + } if (status == RTEMS_SUCCESSFUL) // ACTN { status = rtems_task_create( @@ -305,6 +322,9 @@ int create_all_tasks( void ) // create a RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] ); } + + //****************** + // SPECTRAL MATRICES if (status == RTEMS_SUCCESSFUL) // SMIQ { status = rtems_task_create( @@ -313,14 +333,6 @@ int create_all_tasks( void ) // create a RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ] ); } - if (status == RTEMS_SUCCESSFUL) // STAT - { - status = rtems_task_create( - Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] - ); - } if (status == RTEMS_SUCCESSFUL) // AVF0 { status = rtems_task_create( @@ -329,6 +341,17 @@ int create_all_tasks( void ) // create a RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] ); } + if (status == RTEMS_SUCCESSFUL) // MATR + { + status = rtems_task_create( + Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] + ); + } + + //**************** + // WAVEFORM PICKER if (status == RTEMS_SUCCESSFUL) // WFRM { status = rtems_task_create( @@ -337,30 +360,6 @@ int create_all_tasks( void ) // create a RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] ); } - if (status == RTEMS_SUCCESSFUL) // DUMB - { - status = rtems_task_create( - Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] - ); - } - if (status == RTEMS_SUCCESSFUL) // HOUS - { - status = rtems_task_create( - Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, - RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] - ); - } - if (status == RTEMS_SUCCESSFUL) // MATR - { - status = rtems_task_create( - Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] - ); - } if (status == RTEMS_SUCCESSFUL) // CWF3 { status = rtems_task_create( @@ -385,20 +384,39 @@ int create_all_tasks( void ) // create a RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] ); } - if (status == RTEMS_SUCCESSFUL) // SEND + if (status == RTEMS_SUCCESSFUL) // SWBD + { + status = rtems_task_create( + Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] + ); + } + + //***** + // MISC + if (status == RTEMS_SUCCESSFUL) // STAT { status = rtems_task_create( - Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, - RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] + Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] ); } - if (status == RTEMS_SUCCESSFUL) // WTDG + if (status == RTEMS_SUCCESSFUL) // DUMB { status = rtems_task_create( - Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, + Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] + ); + } + if (status == RTEMS_SUCCESSFUL) // HOUS + { + status = rtems_task_create( + Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] ); } @@ -441,6 +459,8 @@ int start_all_tasks( void ) // start all rtems_status_code status; + //********** + // SPACEWIRE status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); if (status!=RTEMS_SUCCESSFUL) { BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") @@ -454,14 +474,6 @@ int start_all_tasks( void ) // start all } } - if (status == RTEMS_SUCCESSFUL) // SMIQ - { - status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); - if (status!=RTEMS_SUCCESSFUL) { - BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") - } - } - if (status == RTEMS_SUCCESSFUL) // ACTN { status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); @@ -470,11 +482,13 @@ int start_all_tasks( void ) // start all } } - if (status == RTEMS_SUCCESSFUL) // STAT + //****************** + // SPECTRAL MATRICES + if (status == RTEMS_SUCCESSFUL) // SMIQ { - status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); + status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); if (status!=RTEMS_SUCCESSFUL) { - BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") + BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") } } @@ -486,6 +500,16 @@ int start_all_tasks( void ) // start all } } + if (status == RTEMS_SUCCESSFUL) // MATR + { + status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); + if (status!=RTEMS_SUCCESSFUL) { + BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") + } + } + + //**************** + // WAVEFORM PICKER if (status == RTEMS_SUCCESSFUL) // WFRM { status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); @@ -494,30 +518,6 @@ int start_all_tasks( void ) // start all } } - if (status == RTEMS_SUCCESSFUL) // DUMB - { - status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); - if (status!=RTEMS_SUCCESSFUL) { - BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") - } - } - - if (status == RTEMS_SUCCESSFUL) // HOUS - { - status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); - if (status!=RTEMS_SUCCESSFUL) { - BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") - } - } - - if (status == RTEMS_SUCCESSFUL) // MATR - { - status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); - if (status!=RTEMS_SUCCESSFUL) { - BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") - } - } - if (status == RTEMS_SUCCESSFUL) // CWF3 { status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); @@ -541,6 +541,41 @@ int start_all_tasks( void ) // start all BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") } } + + if (status == RTEMS_SUCCESSFUL) // SWBD + { + status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); + if (status!=RTEMS_SUCCESSFUL) { + BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") + } + } + + //***** + // MISC + if (status == RTEMS_SUCCESSFUL) // HOUS + { + status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); + if (status!=RTEMS_SUCCESSFUL) { + BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") + } + } + + if (status == RTEMS_SUCCESSFUL) // DUMB + { + status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); + if (status!=RTEMS_SUCCESSFUL) { + BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") + } + } + + if (status == RTEMS_SUCCESSFUL) // STAT + { + status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); + if (status!=RTEMS_SUCCESSFUL) { + BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") + } + } + return status; } diff --git a/src/wf_handler.c b/src/wf_handler.c --- a/src/wf_handler.c +++ b/src/wf_handler.c @@ -36,6 +36,10 @@ ring_node *current_ring_node_f2; ring_node *ring_node_to_send_swf_f2; ring_node *ring_node_to_send_cwf_f2; +bool extractSWF = false; + +int wf_snap_f1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; + rtems_isr waveforms_isr( rtems_vector_number vector ) { /** This is the interrupt sub routine called by the waveform picker core. @@ -135,175 +139,34 @@ rtems_isr waveforms_isr( rtems_vector_nu // SBM1 case(LFR_MODE_SBM1): if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit + // (0) launch snapshot extraction if needed + if (extractSWF == true) + { + ring_node_to_send_swf_f1 = current_ring_node_f1; + if (rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { + rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); + } + extractSWF = false; + } // (1) change the receiving buffer for the waveform picker ring_node_to_send_cwf_f1 = current_ring_node_f1; current_ring_node_f1 = current_ring_node_f1->next; waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; - // (2) send an event for the waveforms transmission + // (2) send an event for the the CWF1 task for transmission if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) { rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); } - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0 - } - if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit - ring_node_to_send_swf_f1 = current_ring_node_f1->previous; - } - if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit - if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); - } - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0 - } - break; - - //***** - // SBM2 - case(LFR_MODE_SBM2): - if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit - // (1) change the receiving buffer for the waveform picker - ring_node_to_send_cwf_f2 = current_ring_node_f2; - current_ring_node_f2 = current_ring_node_f2->next; - waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; - // (2) send an event for the waveforms transmission - if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); - } - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 + waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0 } if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit - ring_node_to_send_swf_f2 = current_ring_node_f2->previous; - } - if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit - if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); - } - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0 + extractSWF = true; + waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0 } - break; - - //******** - // DEFAULT - default: - break; - } -} - -rtems_isr waveforms_isr_alt( rtems_vector_number vector ) -{ - /** This is the interrupt sub routine called by the waveform picker core. - * - * This ISR launch different actions depending mainly on two pieces of information: - * 1. the values read in the registers of the waveform picker. - * 2. the current LFR mode. - * - */ - - if ( (lfrCurrentMode == LFR_MODE_NORMAL) - || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) - { // in modes other than STANDBY and BURST, send the CWF_F3 data - if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full - // (1) change the receiving buffer for the waveform picker - if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { - waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b); - } - else { - waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); - } - // (2) send an event for the waveforms transmission - if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { + if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit + if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) { rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); } - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] - } - } - - switch(lfrCurrentMode) - { - //******** - // STANDBY - case(LFR_MODE_STANDBY): - break; - - //****** - // NORMAL - case(LFR_MODE_NORMAL): - if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits - { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); - } - if ( (waveform_picker_regs->status & 0x01) == 0x01) // [0001] check the f0 full bit - { - // change F0 ring node - ring_node_to_send_swf_f0 = current_ring_node_f0; - current_ring_node_f0 = current_ring_node_f0->next; - waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1110 1110 1110] - if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL_SWF_F0 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); - } - } - if ( (waveform_picker_regs->status & 0x02) == 0x02) // [0010] check the f1 full bit - { - // change F1 ring node - ring_node_to_send_swf_f1 = current_ring_node_f1; - current_ring_node_f1 = current_ring_node_f1->next; - waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1101 1101 1101] - if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL_SWF_F1 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); - } - } - if ( (waveform_picker_regs->status & 0x04) == 0x04) // [0100] check the f2 full bit - { - // change F2 ring node - ring_node_to_send_swf_f2 = current_ring_node_f2; - current_ring_node_f2 = current_ring_node_f2->next; - waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1011 1011 1011] - if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL_SWF_F2 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); - } - } - break; - - //****** - // BURST - case(LFR_MODE_BURST): - if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit - // (1) change the receiving buffer for the waveform picker - ring_node_to_send_cwf_f2 = current_ring_node_f2; - current_ring_node_f2 = current_ring_node_f2->next; - waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; - // (2) send an event for the waveforms transmission - if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); - } - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 - } - break; - - //***** - // SBM1 - case(LFR_MODE_SBM1): - if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit - // (1) change the receiving buffer for the waveform picker - ring_node_to_send_cwf_f1 = current_ring_node_f1; - current_ring_node_f1 = current_ring_node_f1->next; - waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; - // (2) send an event for the waveforms transmission - if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); - } - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0 - } - if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit - ring_node_to_send_swf_f1 = current_ring_node_f1->previous; - } - if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit - if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { - rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); - } - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0 + waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0 } break; @@ -373,27 +236,20 @@ rtems_task wfrm_task(rtems_task_argument while(1){ // wait for an RTEMS_EVENT rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 - | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM - | RTEMS_EVENT_MODE_NORMAL_SWF_F0 - | RTEMS_EVENT_MODE_NORMAL_SWF_F1 - | RTEMS_EVENT_MODE_NORMAL_SWF_F2, + | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); if (event_out == RTEMS_EVENT_MODE_NORMAL) { + PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); } - if ( (event_out & RTEMS_EVENT_MODE_NORMAL_SWF_F0) == RTEMS_EVENT_MODE_NORMAL_SWF_F0) + if (event_out == RTEMS_EVENT_MODE_SBM1) { + PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); - } - if ( (event_out & RTEMS_EVENT_MODE_NORMAL_SWF_F1) == RTEMS_EVENT_MODE_NORMAL_SWF_F1) - { - send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); - } - if ( (event_out & RTEMS_EVENT_MODE_NORMAL_SWF_F2) == RTEMS_EVENT_MODE_NORMAL_SWF_F2) - { + send_waveform_SWF((volatile int*) wf_snap_f1_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id); send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); } } @@ -537,6 +393,26 @@ rtems_task cwf1_task(rtems_task_argument } } +rtems_task swbd_task(rtems_task_argument argument) +{ + /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. + * + * @param unused is the starting argument of the RTEMS task + * + */ + + rtems_event_set event_out; + + BOOT_PRINTF("in SWBD ***\n") + + while(1){ + // wait for an RTEMS_EVENT + rtems_event_receive( RTEMS_EVENT_0, + RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); + build_snapshot_from_ring(); + } +} + //****************** // general functions void init_waveforms( void ) @@ -990,7 +866,9 @@ void compute_acquisition_time( unsigned { unsigned long long int acquisitionTimeAsLong; unsigned char localAcquisitionTime[6]; - double deltaT = 0.; + double deltaT; + + deltaT = 0.; localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 ); localAcquisitionTime[1] = (unsigned char) ( coarseTime ); @@ -1054,6 +932,59 @@ void compute_acquisition_time( unsigned acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); + +} + +void build_snapshot_from_ring( void ) +{ + unsigned int i; + unsigned long long int centerTime_asLong; + unsigned long long int acquisitionTimeF0_asLong; + unsigned long long int acquisitionTimeF1_asLong; + unsigned char *acquisitionTimeF0; + unsigned char *acquisitionTimeF1; + unsigned char *ptr1; + unsigned char *ptr2; + + unsigned int deltaT; + + deltaT = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; + + acquisitionTimeF0 = (unsigned char*) current_ring_node_f0->buffer_address; + acquisitionTimeF1 = (unsigned char*) ring_node_to_send_cwf_f1->buffer_address; + + acquisitionTimeF0_asLong = 0x00; + acquisitionTimeF1_asLong = 0x00; + acquisitionTimeF0_asLong = ( acquisitionTimeF0[0] << 24 ) + + ( acquisitionTimeF0[1] << 16 ) + + ( (unsigned long long int) acquisitionTimeF0[2] << 40 ) + + ( (unsigned long long int) acquisitionTimeF0[3] << 32 ) + + ( acquisitionTimeF0[4] << 8 ) + + ( acquisitionTimeF0[5] ); + + acquisitionTimeF1_asLong = ( acquisitionTimeF1[0] << 24 ) + + ( acquisitionTimeF1[1] << 16 ) + + ( (unsigned long long int) acquisitionTimeF1[2] << 40 ) + + ( (unsigned long long int) acquisitionTimeF1[3] << 32 ) + + ( acquisitionTimeF1[4] << 8 ) + + ( acquisitionTimeF1[5] ); + + centerTime_asLong = acquisitionTimeF0_asLong + deltaT; + + ptr1 = (unsigned char*) &acquisitionTimeF1_asLong; + ptr2 = (unsigned char*) wf_snap_f1_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 ]; + + for (i=0; i<(NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) + { + wf_snap_f1_extracted[i + TIME_OFFSET] = ((int*)(ring_node_to_send_cwf_f1->buffer_address))[i + TIME_OFFSET]; + } } //**************