##// END OF EJS Templates
The flight software is now compatible with the VHDL 0.1.32...
paul -
r171:13f27d43af32 VHDL_0_1_28
parent child
Show More
@@ -1,6 +1,6
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Fri Oct 24 13:25:08 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Thu Nov 6 16:03:39 2014
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
@@ -10,13 +10,13
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=1 -DLPP_DPU_DESTID -DPRINT_MESSAGES_ON_CONSOLE
14 CFLAGS = -pipe -O3 -fprofile-arcs -ftest-coverage -Wall $(DEFINES)
13 DEFINES = -DSW_VERSION_N1=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=1 -DLPP_DPU_DESTID -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 LIBS = $(SUBLIBS) -lgcov /opt/GCOV/01A/lib/overload.o -lc
19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
@@ -2,7 +2,7 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 4 # lpp_dpu_destid
5 CONFIG += console verbose lpp_dpu_destid
5 CONFIG += console verbose lpp_dpu_destid cpu_usage_report
6 6 CONFIG -= qt
7 7
8 8 include(./sparc.pri)
@@ -15,9 +15,8 DEFINES += SW_VERSION_N3=1 # patch
15 15 DEFINES += SW_VERSION_N4=1 # internal
16 16
17 17 # <GCOV>
18 QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
19 #QMAKE_LFLAGS_RELEASE +=
20 LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
19 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
21 20 # </GCOV>
22 21
23 22 # <CHANGE BEFORE FLIGHT>
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.2.0, 2014-10-22T14:31:55. -->
3 <!-- Written by QtCreator 3.2.1, 2014-11-05T17:29:44. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>EnvironmentId</variable>
@@ -33,13 +33,15 void increment_seq_counter(unsigned shor
33 33 void getTime( unsigned char *time);
34 34 unsigned long long int getTimeAsUnsignedLongLongInt( );
35 35 void send_dumb_hk( void );
36 void get_v_e1_e2_f3 (unsigned char *spacecraft_potential);
36 void get_v_e1_e2_f3(unsigned char *spacecraft_potential);
37 void get_v_e1_e2_f3_alt(unsigned char *spacecraft_potential);
37 38 void get_cpu_load( unsigned char *resource_statistics );
38 39
39 40 extern int sched_yield( void );
40 41 extern void rtems_cpu_usage_reset();
41 42 extern ring_node *current_ring_node_f3;
42 43 extern ring_node *ring_node_to_send_cwf_f3;
44 extern ring_node waveform_ring_f3[];
43 45 extern unsigned short sequenceCounterHK;
44 46
45 47 #endif // FSW_MISC_H_INCLUDED
@@ -13,11 +13,11
13 13 typedef struct ring_node
14 14 {
15 15 struct ring_node *previous;
16 struct ring_node *next;
17 unsigned int coarseTime;
18 unsigned int fineTime;
16 19 int buffer_address;
17 struct ring_node *next;
18 20 unsigned int status;
19 unsigned coarseTime;
20 unsigned int fineTime;
21 21 } ring_node;
22 22
23 23 //************************
@@ -39,7 +39,9 typedef struct {
39 39 } gptimer_regs_t;
40 40
41 41 typedef struct {
42 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
42 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
43 // bit 1 is the soft reset for the time management module
44 // bit 2 is the soft reset for the waveform picker and the spectral matrix modules, set to 1 after HW reset
43 45 volatile int coarse_time_load;
44 46 volatile int coarse_time;
45 47 volatile int fine_time;
@@ -68,24 +70,24 typedef struct{
68 70 int start_date; // 0x48
69 71 //
70 72 volatile unsigned int f0_0_coarse_time; // 0x4c
71 volatile unsigned int f0_0_fine_time; // 0x50
72 volatile unsigned int f0_1_coarse_time; // 0x54
73 volatile unsigned int f0_1_fine_time; // 0x58
73 volatile unsigned int f0_0_fine_time; // 0x50
74 volatile unsigned int f0_1_coarse_time; // 0x54
75 volatile unsigned int f0_1_fine_time; // 0x58
74 76 //
75 volatile unsigned int f1_0_coarse_time; // 0x5c
76 volatile unsigned int f1_0_fine_time; // 0x60
77 volatile unsigned int f1_1_coarse_time; // 0x64
78 volatile unsigned int f1_1_fine_time; // 0x68
77 volatile unsigned int f1_0_coarse_time; // 0x5c
78 volatile unsigned int f1_0_fine_time; // 0x60
79 volatile unsigned int f1_1_coarse_time; // 0x64
80 volatile unsigned int f1_1_fine_time; // 0x68
79 81 //
80 volatile unsigned int f2_0_coarse_time; // 0x6c
81 volatile unsigned int f2_0_fine_time; // 0x70
82 volatile unsigned int f2_1_coarse_time; // 0x74
83 volatile unsigned int f2_1_fine_time; // 0x78
82 volatile unsigned int f2_0_coarse_time; // 0x6c
83 volatile unsigned int f2_0_fine_time; // 0x70
84 volatile unsigned int f2_1_coarse_time; // 0x74
85 volatile unsigned int f2_1_fine_time; // 0x78
84 86 //
85 volatile unsigned int f3_0_coarse_time; // 0x7c
86 volatile unsigned int f3_0_fine_time; // 0x80
87 volatile unsigned int f3_1_coarse_time; // 0x84
88 volatile unsigned int f3_1_fine_time; // 0x88
87 volatile unsigned int f3_0_coarse_time; // 0x7c
88 volatile unsigned int f3_0_fine_time; // 0x80
89 volatile unsigned int f3_1_coarse_time; // 0x84
90 volatile unsigned int f3_1_fine_time; // 0x88
89 91 //
90 92 unsigned int buffer_length; // 0x8c = buffer length in burst 2688 / 16 = 168
91 93 } waveform_picker_regs_0_1_18_t;
@@ -96,6 +96,7 void BP_send( char *data,
96 96
97 97 //******************
98 98 // general functions
99 void reset_sm_status( void );
99 100 void reset_spectral_matrix_regs( void );
100 101 void set_time(unsigned char *time, unsigned char *timeInBuffer );
101 102 unsigned long long int get_acquisition_time( unsigned char *timePtr );
@@ -39,16 +39,18 int check_mode_transition( unsigned char
39 39 int check_transition_date( unsigned int transitionCoarseTime );
40 40 int stop_current_mode( void );
41 41 int enter_mode( unsigned char mode , unsigned int transitionCoarseTime );
42 int restart_science_tasks(unsigned char lfrRequestedMode );
42 int restart_science_tasks( unsigned char lfrRequestedMode );
43 43 int suspend_science_tasks();
44 void launch_waveform_picker(unsigned char mode , unsigned int transitionCoarseTime);
44 void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime );
45 45 void launch_spectral_matrix( void );
46 46 void launch_spectral_matrix_simu( void );
47 void set_irq_on_new_ready_matrix(unsigned char value );
48 void set_run_matrix_spectral( unsigned char value );
47 void set_sm_irq_onNewMatrix( unsigned char value );
48 void set_sm_irq_onError( unsigned char value );
49 49
50 50 // other functions
51 51 void updateLFRCurrentMode();
52 void set_lfr_soft_reset( unsigned char value );
53 void reset_lfr( void );
52 54 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
53 55 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
54 56 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
@@ -59,10 +59,10 int init_header_snapshot_wf_table(
59 59 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
60 60 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
61 61 //
62 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
63 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
65 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
62 int send_waveform_SWF( ring_node *ring_node_to_send, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
63 int send_waveform_CWF( ring_node *ring_node_to_send, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 int send_waveform_CWF3_light( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
65 int send_ring_node_CWF( ring_node *ring_node_to_send );
66 66 //
67 67 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
68 68 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
@@ -75,7 +75,8 rtems_id get_pkts_queue_id( void );
75 75 // wfp registers
76 76 // RESET
77 77 void reset_wfp_burst_enable( void );
78 void reset_wfp_status(void);
78 void reset_wfp_status( void );
79 void reset_wfp_buffer_addresses( void );
79 80 void reset_waveform_picker_regs( void );
80 81 // SET
81 82 void set_wfp_data_shaping(void);
@@ -73,6 +73,8 rtems_task Init( rtems_task_argument ign
73 73
74 74 unsigned char *vhdlVersion;
75 75
76 reset_lfr();
77
76 78 reset_local_time();
77 79
78 80 rtems_cpu_usage_reset();
@@ -245,7 +247,7 void init_local_mode_parameters( void )
245 247
246 248 void reset_local_time( void )
247 249 {
248 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
250 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
249 251 }
250 252
251 253 void create_names( void ) // create all names for tasks and queues
@@ -464,7 +466,7 int create_all_tasks( void ) // create a
464 466 status = rtems_task_create(
465 467 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
466 468 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
467 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
469 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
468 470 );
469 471 }
470 472
@@ -225,7 +225,7 rtems_task hous_task(rtems_task_argument
225 225
226 226 spacewire_update_statistics();
227 227
228 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
228 // get_v_e1_e2_f3_alt( housekeeping_packet.hk_lfr_sc_v_f3 );
229 229 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
230 230
231 231 // SEND PACKET
@@ -484,12 +484,12 void get_v_e1_e2_f3( unsigned char *spac
484 484 else
485 485 {
486 486 offset_in_samples = 0;
487 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
487 // PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
488 488 }
489 489
490 490 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
491 491 {
492 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
492 // PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
493 493 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
494 494 }
495 495 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
@@ -502,6 +502,111 void get_v_e1_e2_f3( unsigned char *spac
502 502 }
503 503 }
504 504
505 void get_v_e1_e2_f3_alt( unsigned char *spacecraft_potential )
506 {
507 unsigned long long int localTime_asLong;
508 unsigned long long int f3_0_AcquisitionTime_asLong;
509 unsigned long long int f3_1_AcquisitionTime_asLong;
510 unsigned long long int deltaT;
511 unsigned long long int deltaT_f3_0;
512 unsigned long long int deltaT_f3_1;
513 unsigned char *bufferPtr;
514
515 unsigned int offset_in_samples;
516 unsigned int offset_in_bytes;
517 unsigned char f3;
518
519 bufferPtr = NULL;
520 deltaT = 0;
521 deltaT_f3_0 = 0xffffffff;
522 deltaT_f3_1 = 0xffffffff;
523 f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
524
525 if (lfrCurrentMode == LFR_MODE_STANDBY)
526 {
527 spacecraft_potential[0] = 0x00;
528 spacecraft_potential[1] = 0x00;
529 spacecraft_potential[2] = 0x00;
530 spacecraft_potential[3] = 0x00;
531 spacecraft_potential[4] = 0x00;
532 spacecraft_potential[5] = 0x00;
533 }
534 else
535 {
536 localTime_asLong = get_acquisition_time( (unsigned char *) &time_management_regs->coarse_time );
537 f3_0_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_0_coarse_time );
538 f3_1_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_1_coarse_time );
539 printf("localTime 0x%llx, f3_0 0x%llx, f3_1 0x%llx\n",
540 localTime_asLong,
541 f3_0_AcquisitionTime_asLong,
542 f3_1_AcquisitionTime_asLong);
543
544 if ( localTime_asLong >= f3_0_AcquisitionTime_asLong )
545 {
546 deltaT_f3_0 = localTime_asLong - f3_0_AcquisitionTime_asLong;
547 }
548
549 if ( localTime_asLong > f3_1_AcquisitionTime_asLong )
550 {
551 deltaT_f3_1 = localTime_asLong - f3_1_AcquisitionTime_asLong;
552 }
553
554 if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
555 {
556 if ( deltaT_f3_0 > deltaT_f3_1 )
557 {
558 deltaT = deltaT_f3_1;
559 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
560 }
561 else
562 {
563 deltaT = deltaT_f3_0;
564 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_0;
565 }
566 }
567 else if ( (deltaT_f3_0 == 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
568 {
569 deltaT = deltaT_f3_1;
570 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
571 }
572 else if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 == 0xffffffff) )
573 {
574 deltaT = deltaT_f3_0;
575 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
576 }
577 else
578 {
579 deltaT = 0xffffffff;
580 }
581
582 if ( deltaT == 0xffffffff )
583 {
584 spacecraft_potential[0] = 0x00;
585 spacecraft_potential[1] = 0x00;
586 spacecraft_potential[2] = 0x00;
587 spacecraft_potential[3] = 0x00;
588 spacecraft_potential[4] = 0x00;
589 spacecraft_potential[5] = 0x00;
590 }
591 else
592 {
593 offset_in_samples = ( (double) deltaT ) / 65536. * f3;
594 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
595 {
596 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
597 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT - 1;
598 }
599 offset_in_bytes = offset_in_samples * NB_WORDS_SWF_BLK * 4;
600 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
601 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
602 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
603 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
604 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
605 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
606 }
607 }
608 }
609
505 610 void get_cpu_load( unsigned char *resource_statistics )
506 611 {
507 612 unsigned char cpu_load;
@@ -228,7 +228,7 rtems_task send_task( rtems_task_argumen
228 228 }
229 229 else
230 230 {
231 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
231 if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet
232 232 {
233 233 status = write( fdSPW, incomingData, size );
234 234 if (status == -1){
@@ -577,6 +577,17 void BP_send(char *data, rtems_id queue_
577 577 //******************
578 578 // general functions
579 579
580 void reset_sm_status( void )
581 {
582 // error
583 // 10 --------------- 9 ---------------- 8 ---------------- 7 ---------
584 // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full
585 // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 --
586 // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0
587
588 spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111]
589 }
590
580 591 void reset_spectral_matrix_regs( void )
581 592 {
582 593 /** This function resets the spectral matrices module registers.
@@ -592,8 +603,11 void reset_spectral_matrix_regs( void )
592 603 *
593 604 */
594 605
595 spectral_matrix_regs->config = 0x00;
596 spectral_matrix_regs->status = 0x00;
606 set_sm_irq_onError( 0 );
607
608 set_sm_irq_onNewMatrix( 0 );
609
610 reset_sm_status();
597 611
598 612 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
599 613 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
@@ -466,19 +466,23 int stop_current_mode( void )
466 466 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
467 467 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
468 468
469 // (2) clear interruptions
470 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
471 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
469 // reset lfr VHDL module
470 reset_lfr();
472 471
473 // (3) reset waveform picker registers
472 // (2) reset waveform picker registers
474 473 reset_wfp_burst_enable(); // reset burst and enable bits
475 474 reset_wfp_status(); // reset all the status bits
476 475
477 // (4) reset spectral matrices registers
478 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
479 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
476 // (3) reset spectral matrices registers
477 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
478 reset_sm_status();
479
480 480 reset_extractSWF(); // reset the extractSWF flag to false
481 481
482 // (4) clear interruptions
483 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
484 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
485
482 486 // <Spectral Matrices simulator>
483 487 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
484 488 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
@@ -748,13 +752,14 int suspend_science_tasks()
748 752 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
749 753 {
750 754 WFP_reset_current_ring_nodes();
755
751 756 reset_waveform_picker_regs();
757
752 758 set_wfp_burst_enable_register( mode );
753 759
754 760 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
755 761 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
756 762
757 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
758 763 if (transitionCoarseTime == 0)
759 764 {
760 765 waveform_picker_regs->start_date = time_management_regs->coarse_time;
@@ -770,17 +775,16 void launch_waveform_picker( unsigned ch
770 775 void launch_spectral_matrix( void )
771 776 {
772 777 SM_reset_current_ring_nodes();
778
773 779 reset_spectral_matrix_regs();
780
774 781 reset_nb_sm();
775 782
776 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
777 grgpio_regs->io_port_direction_register =
778 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
779 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0
780 set_irq_on_new_ready_matrix( 1 );
783 set_sm_irq_onNewMatrix( 1 );
784
781 785 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
782 786 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
783 set_run_matrix_spectral( 1 );
787
784 788 }
785 789
786 790 void launch_spectral_matrix_simu( void )
@@ -795,7 +799,7 void launch_spectral_matrix_simu( void )
795 799 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
796 800 }
797 801
798 void set_irq_on_new_ready_matrix( unsigned char value )
802 void set_sm_irq_onNewMatrix( unsigned char value )
799 803 {
800 804 if (value == 1)
801 805 {
@@ -807,15 +811,15 void set_irq_on_new_ready_matrix( unsign
807 811 }
808 812 }
809 813
810 void set_run_matrix_spectral( unsigned char value )
814 void set_sm_irq_onError( unsigned char value )
811 815 {
812 816 if (value == 1)
813 817 {
814 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
818 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02;
815 819 }
816 820 else
817 821 {
818 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
822 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101
819 823 }
820 824 }
821 825
@@ -947,3 +951,21 void updateLFRCurrentMode()
947 951 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
948 952 }
949 953
954 void set_lfr_soft_reset( unsigned char value )
955 {
956 if (value == 1)
957 {
958 time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100]
959 }
960 else
961 {
962 time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011]
963 }
964 }
965
966 void reset_lfr( void )
967 {
968 set_lfr_soft_reset( 1 );
969
970 set_lfr_soft_reset( 0 );
971 }
This diff has been collapsed as it changes many lines, (540 lines changed) Show them Hide them
@@ -22,20 +22,24 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2
22 22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
23 23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
24 24
25 //**************
26 // waveform ring
25 //***************
26 // waveform rings
27 // F0
27 28 ring_node waveform_ring_f0[NB_RING_NODES_F0];
28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
30 ring_node waveform_ring_f3[NB_RING_NODES_F3];
31 29 ring_node *current_ring_node_f0;
32 30 ring_node *ring_node_to_send_swf_f0;
31 // F1
32 ring_node waveform_ring_f1[NB_RING_NODES_F1];
33 33 ring_node *current_ring_node_f1;
34 34 ring_node *ring_node_to_send_swf_f1;
35 35 ring_node *ring_node_to_send_cwf_f1;
36 // F2
37 ring_node waveform_ring_f2[NB_RING_NODES_F2];
36 38 ring_node *current_ring_node_f2;
37 39 ring_node *ring_node_to_send_swf_f2;
38 40 ring_node *ring_node_to_send_cwf_f2;
41 // F3
42 ring_node waveform_ring_f3[NB_RING_NODES_F3];
39 43 ring_node *current_ring_node_f3;
40 44 ring_node *ring_node_to_send_cwf_f3;
41 45
@@ -44,7 +48,8 bool swf_f0_ready = false;
44 48 bool swf_f1_ready = false;
45 49 bool swf_f2_ready = false;
46 50
47 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
51 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ];
52 ring_node ring_node_wf_snap_extracted;
48 53
49 54 //*********************
50 55 // Interrupt SubRoutine
@@ -57,60 +62,6 void reset_extractSWF( void )
57 62 swf_f2_ready = false;
58 63 }
59 64
60 void change_f0_buffer( void )
61 {
62 ring_node_to_send_swf_f0 = current_ring_node_f0;
63 current_ring_node_f0 = current_ring_node_f0->next;
64 if ( (waveform_picker_regs->status & 0x01) == 0x01)
65 {
66 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
67 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
68 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
69 }
70 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
71 {
72 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
73 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
74 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
75 }
76 }
77
78 void change_f1_buffer( ring_node *ring_node_to_send )
79 {
80 ring_node_to_send = current_ring_node_f1;
81 current_ring_node_f1 = current_ring_node_f1->next;
82 if ( (waveform_picker_regs->status & 0x04) == 0x04)
83 {
84 ring_node_to_send->coarseTime = waveform_picker_regs->f1_0_coarse_time;
85 ring_node_to_send->fineTime = waveform_picker_regs->f1_0_fine_time;
86 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
87 }
88 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
89 {
90 ring_node_to_send->coarseTime = waveform_picker_regs->f1_1_coarse_time;
91 ring_node_to_send->fineTime = waveform_picker_regs->f1_1_fine_time;
92 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
93 }
94 }
95
96 void change_f2_buffer( ring_node *ring_node_to_send )
97 {
98 ring_node_to_send = current_ring_node_f2;
99 current_ring_node_f2 = current_ring_node_f2->next;
100 if ( (waveform_picker_regs->status & 0x10) == 0x10)
101 {
102 ring_node_to_send->coarseTime = waveform_picker_regs->f2_0_coarse_time;
103 ring_node_to_send->fineTime = waveform_picker_regs->f2_0_fine_time;
104 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
105 }
106 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
107 {
108 ring_node_to_send->coarseTime = waveform_picker_regs->f2_1_coarse_time;
109 ring_node_to_send->fineTime = waveform_picker_regs->f2_1_fine_time;
110 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
111 }
112 }
113
114 65 void waveforms_isr_f3( void )
115 66 {
116 67 rtems_status_code spare_status;
@@ -118,29 +69,27 void waveforms_isr_f3( void )
118 69 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet
119 70 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
120 71 { // in modes other than STANDBY and BURST, send the CWF_F3 data
121 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
122 // (1) change the receiving buffer for the waveform picker
123 ring_node_to_send_cwf_f3 = current_ring_node_f3;
124 current_ring_node_f3 = current_ring_node_f3->next;
125 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
126 // (2) send an event for the waveforms transmission
72 //***
73 // F3
74 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
75 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
76 current_ring_node_f3 = current_ring_node_f3->next;
77 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
78 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time;
79 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time;
80 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
81 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000]
82 }
83 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
84 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time;
85 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time;
86 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
87 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000]
88 }
127 89 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
128 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
90 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
129 91 }
130 92 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
131 waveform_picker_regs->status = waveform_picker_regs->status & 0xffff77bf; // reset f3 bits to 0, [0111 0111 1011 1111]
132 }
133 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
134 // (1) change the receiving buffer for the waveform picker
135 ring_node_to_send_cwf_f3 = current_ring_node_f3;
136 current_ring_node_f3 = current_ring_node_f3->next;
137 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
138 // (2) send an event for the waveforms transmission
139 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
140 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
141 }
142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
143 waveform_picker_regs->status = waveform_picker_regs->status & 0xffff777f; // reset f3 bits to 0, [0111 0111 0111 1111]
144 93 }
145 94 }
146 95 }
@@ -150,23 +99,72 void waveforms_isr_normal( void )
150 99 rtems_status_code status;
151 100
152 101 if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits
153 || ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits
154 || ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits
102 && ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits
103 && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits
155 104 {
156 // change F0 ring node
157 change_f0_buffer();
158 // change F1 ring node
159 change_f1_buffer( ring_node_to_send_swf_f1 );
160 // change F2 ring node
161 change_f2_buffer( ring_node_to_send_swf_f2 );
105 //***
106 // F0
107 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
108 current_ring_node_f0 = current_ring_node_f0->next;
109 if ( (waveform_picker_regs->status & 0x01) == 0x01)
110 {
111
112 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
113 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
114 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
115 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
116 }
117 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
118 {
119 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
120 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
121 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
122 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
123 }
124
125 //***
126 // F1
127 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
128 current_ring_node_f1 = current_ring_node_f1->next;
129 if ( (waveform_picker_regs->status & 0x04) == 0x04)
130 {
131 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
132 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
133 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
134 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
135 }
136 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
137 {
138 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
139 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
140 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
141 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
142 }
143
144 //***
145 // F2
146 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
147 current_ring_node_f2 = current_ring_node_f2->next;
148 if ( (waveform_picker_regs->status & 0x10) == 0x10)
149 {
150 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
151 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
152 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
153 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
154 }
155 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
156 {
157 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
158 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
159 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
160 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
161 }
162 162 //
163 163 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
164 164 if ( status != RTEMS_SUCCESSFUL)
165 165 {
166 status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
166 status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
167 167 }
168 // update status bits except f3 bits
169 waveform_picker_regs->status = waveform_picker_regs->status & 0xffff00c0; // [1000 1000 1100 0000]
170 168 }
171 169 }
172 170
@@ -176,13 +174,26 void waveforms_isr_burst( void )
176 174
177 175 if ( (waveform_picker_regs->status & 0x30) != 0 ){ // [0100] check the f2 full bit
178 176 // (1) change the receiving buffer for the waveform picker
179 change_f2_buffer( ring_node_to_send_cwf_f2 );
177 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
178 current_ring_node_f2 = current_ring_node_f2->next;
179 if ( (waveform_picker_regs->status & 0x10) == 0x10)
180 {
181 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
182 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
183 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
184 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
185 }
186 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
187 {
188 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
189 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
190 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
191 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
192 }
180 193 // (2) send an event for the waveforms transmission
181 194 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
182 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
195 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
183 196 }
184 // update f2 status bits only
185 waveform_picker_regs->status = waveform_picker_regs->status & 0xffffbbcf; // [1011 1011 1100 1111] f2 bit = 0
186 197 }
187 198 }
188 199
@@ -193,29 +204,77 void waveforms_isr_sbm1( void )
193 204
194 205 //***
195 206 // F1
196 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
207 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits
197 208 // (1) change the receiving buffer for the waveform picker
198 change_f1_buffer( ring_node_to_send_cwf_f1 );
209 ring_node_to_send_cwf_f1 = current_ring_node_f1->previous;
210 current_ring_node_f1 = current_ring_node_f1->next;
211 if ( (waveform_picker_regs->status & 0x04) == 0x04)
212 {
213 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
214 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
215 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
216 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
217 }
218 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
219 {
220 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
221 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
222 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
223 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
224 }
199 225 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
200 226 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
201 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
202 227 }
203 228
204 229 //***
205 230 // F0
206 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] one f0 buffer is full
231 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bits
207 232 swf_f0_ready = true;
208 change_f0_buffer();
233 // change f0 buffer
234 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
235 current_ring_node_f0 = current_ring_node_f0->next;
236 if ( (waveform_picker_regs->status & 0x01) == 0x01)
237 {
238
239 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
240 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
241 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
242 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
243 }
244 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
245 {
246 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
247 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
248 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
249 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
250 }
209 251 }
210 252
211 253 //***
212 254 // F2
213 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
255 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bits
214 256 swf_f2_ready = true;
215 change_f2_buffer( ring_node_to_send_swf_f2 );
257 // change f2 buffer
258 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
259 current_ring_node_f2 = current_ring_node_f2->next;
260 if ( (waveform_picker_regs->status & 0x10) == 0x10)
261 {
262 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
263 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
264 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
265 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
266 }
267 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
268 {
269 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
270 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
271 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
272 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
273 }
274 // start the snapshots transmission
216 275 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
217 276 {
218 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
277 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
219 278 }
220 279 }
221 280 }
@@ -224,22 +283,74 void waveforms_isr_sbm2( void )
224 283 {
225 284 rtems_status_code status;
226 285
227 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
286 //***
287 // F2
288 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit
228 289 // (1) change the receiving buffer for the waveform picker
229 change_f2_buffer( ring_node_to_send_cwf_f2 );
290 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
291 current_ring_node_f2 = current_ring_node_f2->next;
292 if ( (waveform_picker_regs->status & 0x10) == 0x10)
293 {
294 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
295 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
296 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
297 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
298 }
299 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
300 {
301 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
302 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
303 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
304 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
305 }
230 306 // (2) send an event for the waveforms transmission
231 307 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
232 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
233 308 }
234 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
309
310 //***
311 // F0
312 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bit
235 313 swf_f0_ready = true;
236 change_f0_buffer();
237 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
314 // change f0 buffer
315 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
316 current_ring_node_f0 = current_ring_node_f0->next;
317 if ( (waveform_picker_regs->status & 0x01) == 0x01)
318 {
319
320 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
321 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
322 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
323 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
324 }
325 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
326 {
327 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
328 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
329 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
330 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
331 }
238 332 }
239 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
333
334 //***
335 // F1
336 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bit
240 337 swf_f1_ready = true;
241 change_f1_buffer( ring_node_to_send_swf_f1 );
242 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
338 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
339 current_ring_node_f1 = current_ring_node_f1->next;
340 if ( (waveform_picker_regs->status & 0x04) == 0x04)
341 {
342 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
343 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
344 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
345 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
346 }
347 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
348 {
349 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
350 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
351 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
352 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
353 }
243 354 }
244 355 }
245 356
@@ -266,9 +377,9 rtems_isr waveforms_isr( rtems_vector_nu
266 377
267 378 waveforms_isr_f3();
268 379
269 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
380 if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits
270 381 {
271 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
382 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
272 383 }
273 384
274 385 switch(lfrCurrentMode)
@@ -365,23 +476,23 rtems_task wfrm_task(rtems_task_argument
365 476 if (event_out == RTEMS_EVENT_MODE_NORMAL)
366 477 {
367 478 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
368 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
369 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
370 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
479 send_waveform_SWF( ring_node_to_send_swf_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
480 send_waveform_SWF( ring_node_to_send_swf_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
481 send_waveform_SWF( ring_node_to_send_swf_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
371 482 }
372 483 if (event_out == RTEMS_EVENT_MODE_SBM1)
373 484 {
374 485 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
375 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
376 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
377 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
486 send_waveform_SWF( ring_node_to_send_swf_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
487 send_waveform_SWF( &ring_node_wf_snap_extracted, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
488 send_waveform_SWF( ring_node_to_send_swf_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
378 489 }
379 490 if (event_out == RTEMS_EVENT_MODE_SBM2)
380 491 {
381 492 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
382 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
383 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
384 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
493 send_waveform_SWF( ring_node_to_send_swf_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
494 send_waveform_SWF( ring_node_to_send_swf_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
495 send_waveform_SWF( &ring_node_wf_snap_extracted, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
385 496 }
386 497 }
387 498 }
@@ -422,15 +533,13 rtems_task cwf3_task(rtems_task_argument
422 533 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
423 534 {
424 535 PRINTF("send CWF_LONG_F3\n")
425 send_waveform_CWF(
426 (volatile int*) ring_node_to_send_cwf_f3->buffer_address,
536 send_waveform_CWF( ring_node_to_send_cwf_f3,
427 537 SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
428 538 }
429 539 else
430 540 {
431 541 PRINTF("send CWF_F3 (light)\n")
432 send_waveform_CWF3_light(
433 (volatile int*) ring_node_to_send_cwf_f3->buffer_address,
542 send_waveform_CWF3_light( ring_node_to_send_cwf_f3,
434 543 headerCWF_F3_light, queue_id );
435 544 }
436 545
@@ -475,11 +584,11 rtems_task cwf2_task(rtems_task_argument
475 584 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
476 585 if (event_out == RTEMS_EVENT_MODE_BURST)
477 586 {
478 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
587 send_waveform_CWF( ring_node_to_send_cwf_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
479 588 }
480 589 if (event_out == RTEMS_EVENT_MODE_SBM2)
481 590 {
482 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
591 send_waveform_CWF( ring_node_to_send_cwf_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
483 592 // launch snapshot extraction if needed
484 593 if (extractSWF == true)
485 594 {
@@ -529,7 +638,7 rtems_task cwf1_task(rtems_task_argument
529 638 // wait for an RTEMS_EVENT
530 639 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
531 640 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
532 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
641 send_waveform_CWF( ring_node_to_send_cwf_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
533 642 // launch snapshot extraction if needed
534 643 if (extractSWF == true)
535 644 {
@@ -594,6 +703,8 void WFP_init_rings( void )
594 703 // F3 RING
595 704 init_waveform_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_cont_f3 );
596 705
706 ring_node_wf_snap_extracted.buffer_address = (int) wf_snap_extracted;
707
597 708 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
598 709 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
599 710 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
@@ -622,19 +733,19 void init_waveform_ring(ring_node wavefo
622 733
623 734 void WFP_reset_current_ring_nodes( void )
624 735 {
625 current_ring_node_f0 = waveform_ring_f0;
626 ring_node_to_send_swf_f0 = waveform_ring_f0;
736 current_ring_node_f0 = waveform_ring_f0;
737 ring_node_to_send_swf_f0 = waveform_ring_f0;
627 738
628 current_ring_node_f1 = waveform_ring_f1;
629 ring_node_to_send_cwf_f1 = waveform_ring_f1;
630 ring_node_to_send_swf_f1 = waveform_ring_f1;
739 current_ring_node_f1 = waveform_ring_f1;
740 ring_node_to_send_cwf_f1 = waveform_ring_f1;
741 ring_node_to_send_swf_f1 = waveform_ring_f1;
631 742
632 current_ring_node_f2 = waveform_ring_f2;
633 ring_node_to_send_cwf_f2 = waveform_ring_f2;
634 ring_node_to_send_swf_f2 = waveform_ring_f2;
743 current_ring_node_f2 = waveform_ring_f2;
744 ring_node_to_send_cwf_f2 = waveform_ring_f2;
745 ring_node_to_send_swf_f2 = waveform_ring_f2;
635 746
636 current_ring_node_f3 = waveform_ring_f3;
637 ring_node_to_send_cwf_f3 = waveform_ring_f3;
747 current_ring_node_f3 = waveform_ring_f3;
748 ring_node_to_send_cwf_f3 = waveform_ring_f3;
638 749 }
639 750
640 751 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
@@ -780,7 +891,7 int init_header_continuous_cwf3_light_ta
780 891 return return_value;
781 892 }
782 893
783 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
894 int send_waveform_SWF( ring_node *ring_node_to_send, unsigned int sid,
784 895 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
785 896 {
786 897 /** This function sends SWF CCSDS packets (F2, F1 or F0).
@@ -801,18 +912,20 int send_waveform_SWF( volatile int *wav
801 912 unsigned int fineTime;
802 913 rtems_status_code status;
803 914 spw_ioctl_pkt_send spw_ioctl_send_SWF;
915 int *dataPtr;
804 916
805 917 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
806 918 spw_ioctl_send_SWF.options = 0;
807 919
808 920 ret = LFR_DEFAULT;
809 921
810 coarseTime = waveform[0];
811 fineTime = waveform[1];
922 coarseTime = ring_node_to_send->coarseTime;
923 fineTime = ring_node_to_send->fineTime;
924 dataPtr = (int*) ring_node_to_send->buffer_address;
812 925
813 926 for (i=0; i<7; i++) // send waveform
814 927 {
815 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
928 spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ];
816 929 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
817 930 // BUILD THE DATA
818 931 if (i==6) {
@@ -844,7 +957,7 int send_waveform_SWF( volatile int *wav
844 957 return ret;
845 958 }
846 959
847 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
960 int send_waveform_CWF(ring_node *ring_node_to_send, unsigned int sid,
848 961 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
849 962 {
850 963 /** This function sends CWF CCSDS packets (F2, F1 or F0).
@@ -865,18 +978,20 int send_waveform_CWF(volatile int *wave
865 978 unsigned int fineTime;
866 979 rtems_status_code status;
867 980 spw_ioctl_pkt_send spw_ioctl_send_CWF;
981 int *dataPtr;
868 982
869 983 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
870 984 spw_ioctl_send_CWF.options = 0;
871 985
872 986 ret = LFR_DEFAULT;
873 987
874 coarseTime = waveform[0];
875 fineTime = waveform[1];
988 coarseTime = ring_node_to_send->coarseTime;
989 fineTime = ring_node_to_send->fineTime;
990 dataPtr = (int*) ring_node_to_send->buffer_address;
876 991
877 992 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
878 993 {
879 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
994 spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ];
880 995 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
881 996 // BUILD THE DATA
882 997 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
@@ -914,7 +1029,7 int send_waveform_CWF(volatile int *wave
914 1029 return ret;
915 1030 }
916 1031
917 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
1032 int send_waveform_CWF3_light( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id )
918 1033 {
919 1034 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
920 1035 *
@@ -935,33 +1050,35 int send_waveform_CWF3_light(volatile in
935 1050 rtems_status_code status;
936 1051 spw_ioctl_pkt_send spw_ioctl_send_CWF;
937 1052 char *sample;
1053 int *dataPtr;
938 1054
939 1055 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
940 1056 spw_ioctl_send_CWF.options = 0;
941 1057
942 1058 ret = LFR_DEFAULT;
943 1059
1060 coarseTime = ring_node_to_send->coarseTime;
1061 fineTime = ring_node_to_send->fineTime;
1062 dataPtr = (int*) ring_node_to_send->buffer_address;
1063
944 1064 //**********************
945 1065 // BUILD CWF3_light DATA
946 1066 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
947 1067 {
948 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
949 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
950 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
951 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
952 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
953 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
954 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
1068 sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ];
1069 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
1070 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
1071 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
1072 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
1073 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
1074 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
955 1075 }
956 1076
957 coarseTime = waveform[0];
958 fineTime = waveform[1];
959
960 1077 //*********************
961 1078 // SEND CWF3_light DATA
962 1079 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
963 1080 {
964 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES];
1081 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ];
965 1082 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
966 1083 // BUILD THE DATA
967 1084 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
@@ -988,6 +1105,16 int send_waveform_CWF3_light(volatile in
988 1105 return ret;
989 1106 }
990 1107
1108 int send_ring_node_CWF( ring_node *ring_node_to_send )
1109 {
1110 int status;
1111
1112 status = LFR_SUCCESSFUL;
1113 // status = rtems_message_queue_send( queue_id, ring_node_to_send, 4 );
1114
1115 return status;
1116 }
1117
991 1118 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
992 1119 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
993 1120 {
@@ -1088,7 +1215,7 void build_snapshot_from_ring( ring_node
1088 1215 sampleOffset_asLong = 0x00;
1089 1216
1090 1217 // (1) get the f0 acquisition time
1091 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) current_ring_node_f0->buffer_address );
1218 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime );
1092 1219
1093 1220 // (2) compute the central reference time
1094 1221 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
@@ -1120,7 +1247,7 void build_snapshot_from_ring( ring_node
1120 1247 for (i=0; i<nb_ring_nodes; i++)
1121 1248 {
1122 1249 PRINTF1("%d ... ", i)
1123 bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) ring_node_to_send->buffer_address );
1250 bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) ring_node_to_send->coarseTime );
1124 1251 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1125 1252 {
1126 1253 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
@@ -1140,16 +1267,19 void build_snapshot_from_ring( ring_node
1140 1267
1141 1268 // (7) copy the acquisition time at the beginning of the extrated snapshot
1142 1269 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1143 ptr2 = (unsigned char*) wf_snap_extracted;
1270 // fine time
1271 ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.fineTime;
1272 ptr2[2] = ptr1[ 4 + 2 ];
1273 ptr2[3] = ptr1[ 5 + 2 ];
1274 // coarse time
1275 ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.coarseTime;
1144 1276 ptr2[0] = ptr1[ 0 + 2 ];
1145 1277 ptr2[1] = ptr1[ 1 + 2 ];
1146 1278 ptr2[2] = ptr1[ 2 + 2 ];
1147 1279 ptr2[3] = ptr1[ 3 + 2 ];
1148 ptr2[6] = ptr1[ 4 + 2 ];
1149 ptr2[7] = ptr1[ 5 + 2 ];
1150 1280
1151 1281 // re set the synchronization bit
1152 timeCharPtr = (unsigned char*) ring_node_to_send->buffer_address;
1282 timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime;
1153 1283 ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000]
1154 1284
1155 1285 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
@@ -1159,15 +1289,15 void build_snapshot_from_ring( ring_node
1159 1289 // copy the part 1 of the snapshot in the extracted buffer
1160 1290 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1161 1291 {
1162 wf_snap_extracted[i + TIME_OFFSET] =
1163 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1292 wf_snap_extracted[i] =
1293 ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ];
1164 1294 }
1165 1295 // copy the part 2 of the snapshot in the extracted buffer
1166 1296 ring_node_to_send = ring_node_to_send->next;
1167 1297 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1168 1298 {
1169 wf_snap_extracted[i + TIME_OFFSET] =
1170 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1299 wf_snap_extracted[i] =
1300 ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ];
1171 1301 }
1172 1302 }
1173 1303
@@ -1216,7 +1346,7 void snapshot_resynchronization( unsigne
1216 1346
1217 1347 //**************
1218 1348 // wfp registers
1219 void reset_wfp_burst_enable(void)
1349 void reset_wfp_burst_enable( void )
1220 1350 {
1221 1351 /** This function resets the waveform picker burst_enable register.
1222 1352 *
@@ -1224,7 +1354,8 void reset_wfp_burst_enable(void)
1224 1354 *
1225 1355 */
1226 1356
1227 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1357 // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0
1358 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80;
1228 1359 }
1229 1360
1230 1361 void reset_wfp_status( void )
@@ -1235,10 +1366,30 void reset_wfp_status( void )
1235 1366 *
1236 1367 */
1237 1368
1238 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1369 waveform_picker_regs->status = 0xffff;
1239 1370 }
1240 1371
1241 void reset_waveform_picker_regs(void)
1372 void reset_wfp_buffer_addresses( void )
1373 {
1374 // F0
1375 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; // 0x08
1376 current_ring_node_f0 = current_ring_node_f0->next;
1377 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1378 // F1
1379 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; // 0x10
1380 current_ring_node_f1 = current_ring_node_f1->next;
1381 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1382 // F2
1383 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; // 0x18
1384 current_ring_node_f2 = current_ring_node_f2->next;
1385 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1386 // F3
1387 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; // 0x20
1388 current_ring_node_f3 = current_ring_node_f3->next;
1389 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1390 }
1391
1392 void reset_waveform_picker_regs( void )
1242 1393 {
1243 1394 /** This function resets the waveform picker module registers.
1244 1395 *
@@ -1263,31 +1414,34 void reset_waveform_picker_regs(void)
1263 1414 */
1264 1415
1265 1416 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1417
1266 1418 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1267 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; // 0x08
1268 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1269 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; // 0x10
1270 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1271 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; // 0x18
1272 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1273 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; // 0x20
1274 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1419
1420 reset_wfp_buffer_addresses();
1421
1275 1422 reset_wfp_status(); // 0x18
1276 //
1277 set_wfp_delta_snapshot(); // 0x1c
1423
1424 set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff
1425
1278 1426 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1427
1279 1428 set_wfp_delta_f1(); // 0x28
1429
1280 1430 set_wfp_delta_f2(); // 0x2c
1281 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1282 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1283 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1284 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1285 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1431
1432 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1433 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1434 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1435 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1436 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1286 1437 // 2688 = 8 * 336
1287 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1288 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1289 waveform_picker_regs->start_date = 0x00; // 0x38
1290 waveform_picker_regs->buffer_length = 0x1f8; // buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1438 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1439 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1440 waveform_picker_regs->start_date = 0x7fffffff; // 0x38
1441 //
1442 // coarse time and fine time registers are not initialized, they are volatile
1443 //
1444 waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1291 1445 }
1292 1446
1293 1447 void set_wfp_data_shaping( void )
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.2.0, 2014-09-25T16:02:40. -->
3 <!-- Written by QtCreator 3.2.1, 2014-10-24T14:21:58. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>EnvironmentId</variable>
General Comments 0
You need to be logged in to leave comments. Login now