##// 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 # Makefile for building: bin/fsw
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 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
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 CC = sparc-rtems-gcc
11 CC = sparc-rtems-gcc
12 CXX = sparc-rtems-g++
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
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 -fprofile-arcs -ftest-coverage -Wall $(DEFINES)
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
17 LINK = sparc-rtems-g++
17 LINK = sparc-rtems-g++
18 LFLAGS =
18 LFLAGS =
19 LIBS = $(SUBLIBS) -lgcov /opt/GCOV/01A/lib/overload.o -lc
19 LIBS = $(SUBLIBS)
20 AR = sparc-rtems-ar rcs
20 AR = sparc-rtems-ar rcs
21 RANLIB =
21 RANLIB =
22 QMAKE = /usr/bin/qmake-qt4
22 QMAKE = /usr/bin/qmake-qt4
@@ -2,7 +2,7 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 # lpp_dpu_destid
4 # lpp_dpu_destid
5 CONFIG += console verbose lpp_dpu_destid
5 CONFIG += console verbose lpp_dpu_destid cpu_usage_report
6 CONFIG -= qt
6 CONFIG -= qt
7
7
8 include(./sparc.pri)
8 include(./sparc.pri)
@@ -15,9 +15,8 DEFINES += SW_VERSION_N3=1 # patch
15 DEFINES += SW_VERSION_N4=1 # internal
15 DEFINES += SW_VERSION_N4=1 # internal
16
16
17 # <GCOV>
17 # <GCOV>
18 QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
19 #QMAKE_LFLAGS_RELEASE +=
19 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
20 LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
21 # </GCOV>
20 # </GCOV>
22
21
23 # <CHANGE BEFORE FLIGHT>
22 # <CHANGE BEFORE FLIGHT>
@@ -1,6 +1,6
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
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 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>EnvironmentId</variable>
6 <variable>EnvironmentId</variable>
@@ -33,13 +33,15 void increment_seq_counter(unsigned shor
33 void getTime( unsigned char *time);
33 void getTime( unsigned char *time);
34 unsigned long long int getTimeAsUnsignedLongLongInt( );
34 unsigned long long int getTimeAsUnsignedLongLongInt( );
35 void send_dumb_hk( void );
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 void get_cpu_load( unsigned char *resource_statistics );
38 void get_cpu_load( unsigned char *resource_statistics );
38
39
39 extern int sched_yield( void );
40 extern int sched_yield( void );
40 extern void rtems_cpu_usage_reset();
41 extern void rtems_cpu_usage_reset();
41 extern ring_node *current_ring_node_f3;
42 extern ring_node *current_ring_node_f3;
42 extern ring_node *ring_node_to_send_cwf_f3;
43 extern ring_node *ring_node_to_send_cwf_f3;
44 extern ring_node waveform_ring_f3[];
43 extern unsigned short sequenceCounterHK;
45 extern unsigned short sequenceCounterHK;
44
46
45 #endif // FSW_MISC_H_INCLUDED
47 #endif // FSW_MISC_H_INCLUDED
@@ -13,11 +13,11
13 typedef struct ring_node
13 typedef struct ring_node
14 {
14 {
15 struct ring_node *previous;
15 struct ring_node *previous;
16 struct ring_node *next;
17 unsigned int coarseTime;
18 unsigned int fineTime;
16 int buffer_address;
19 int buffer_address;
17 struct ring_node *next;
18 unsigned int status;
20 unsigned int status;
19 unsigned coarseTime;
20 unsigned int fineTime;
21 } ring_node;
21 } ring_node;
22
22
23 //************************
23 //************************
@@ -39,7 +39,9 typedef struct {
39 } gptimer_regs_t;
39 } gptimer_regs_t;
40
40
41 typedef struct {
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 volatile int coarse_time_load;
45 volatile int coarse_time_load;
44 volatile int coarse_time;
46 volatile int coarse_time;
45 volatile int fine_time;
47 volatile int fine_time;
@@ -68,24 +70,24 typedef struct{
68 int start_date; // 0x48
70 int start_date; // 0x48
69 //
71 //
70 volatile unsigned int f0_0_coarse_time; // 0x4c
72 volatile unsigned int f0_0_coarse_time; // 0x4c
71 volatile unsigned int f0_0_fine_time; // 0x50
73 volatile unsigned int f0_0_fine_time; // 0x50
72 volatile unsigned int f0_1_coarse_time; // 0x54
74 volatile unsigned int f0_1_coarse_time; // 0x54
73 volatile unsigned int f0_1_fine_time; // 0x58
75 volatile unsigned int f0_1_fine_time; // 0x58
74 //
76 //
75 volatile unsigned int f1_0_coarse_time; // 0x5c
77 volatile unsigned int f1_0_coarse_time; // 0x5c
76 volatile unsigned int f1_0_fine_time; // 0x60
78 volatile unsigned int f1_0_fine_time; // 0x60
77 volatile unsigned int f1_1_coarse_time; // 0x64
79 volatile unsigned int f1_1_coarse_time; // 0x64
78 volatile unsigned int f1_1_fine_time; // 0x68
80 volatile unsigned int f1_1_fine_time; // 0x68
79 //
81 //
80 volatile unsigned int f2_0_coarse_time; // 0x6c
82 volatile unsigned int f2_0_coarse_time; // 0x6c
81 volatile unsigned int f2_0_fine_time; // 0x70
83 volatile unsigned int f2_0_fine_time; // 0x70
82 volatile unsigned int f2_1_coarse_time; // 0x74
84 volatile unsigned int f2_1_coarse_time; // 0x74
83 volatile unsigned int f2_1_fine_time; // 0x78
85 volatile unsigned int f2_1_fine_time; // 0x78
84 //
86 //
85 volatile unsigned int f3_0_coarse_time; // 0x7c
87 volatile unsigned int f3_0_coarse_time; // 0x7c
86 volatile unsigned int f3_0_fine_time; // 0x80
88 volatile unsigned int f3_0_fine_time; // 0x80
87 volatile unsigned int f3_1_coarse_time; // 0x84
89 volatile unsigned int f3_1_coarse_time; // 0x84
88 volatile unsigned int f3_1_fine_time; // 0x88
90 volatile unsigned int f3_1_fine_time; // 0x88
89 //
91 //
90 unsigned int buffer_length; // 0x8c = buffer length in burst 2688 / 16 = 168
92 unsigned int buffer_length; // 0x8c = buffer length in burst 2688 / 16 = 168
91 } waveform_picker_regs_0_1_18_t;
93 } waveform_picker_regs_0_1_18_t;
@@ -96,6 +96,7 void BP_send( char *data,
96
96
97 //******************
97 //******************
98 // general functions
98 // general functions
99 void reset_sm_status( void );
99 void reset_spectral_matrix_regs( void );
100 void reset_spectral_matrix_regs( void );
100 void set_time(unsigned char *time, unsigned char *timeInBuffer );
101 void set_time(unsigned char *time, unsigned char *timeInBuffer );
101 unsigned long long int get_acquisition_time( unsigned char *timePtr );
102 unsigned long long int get_acquisition_time( unsigned char *timePtr );
@@ -39,16 +39,18 int check_mode_transition( unsigned char
39 int check_transition_date( unsigned int transitionCoarseTime );
39 int check_transition_date( unsigned int transitionCoarseTime );
40 int stop_current_mode( void );
40 int stop_current_mode( void );
41 int enter_mode( unsigned char mode , unsigned int transitionCoarseTime );
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 int suspend_science_tasks();
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 void launch_spectral_matrix( void );
45 void launch_spectral_matrix( void );
46 void launch_spectral_matrix_simu( void );
46 void launch_spectral_matrix_simu( void );
47 void set_irq_on_new_ready_matrix(unsigned char value );
47 void set_sm_irq_onNewMatrix( unsigned char value );
48 void set_run_matrix_spectral( unsigned char value );
48 void set_sm_irq_onError( unsigned char value );
49
49
50 // other functions
50 // other functions
51 void updateLFRCurrentMode();
51 void updateLFRCurrentMode();
52 void set_lfr_soft_reset( unsigned char value );
53 void reset_lfr( void );
52 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
54 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
53 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
55 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
54 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
56 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
@@ -59,10 +59,10 int init_header_snapshot_wf_table(
59 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
59 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
60 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
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 );
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( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, 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( volatile int *waveform, 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_waveform_CWF3_light( volatile int *waveform, 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 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
67 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
68 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
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 // wfp registers
75 // wfp registers
76 // RESET
76 // RESET
77 void reset_wfp_burst_enable( void );
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 void reset_waveform_picker_regs( void );
80 void reset_waveform_picker_regs( void );
80 // SET
81 // SET
81 void set_wfp_data_shaping(void);
82 void set_wfp_data_shaping(void);
@@ -73,6 +73,8 rtems_task Init( rtems_task_argument ign
73
73
74 unsigned char *vhdlVersion;
74 unsigned char *vhdlVersion;
75
75
76 reset_lfr();
77
76 reset_local_time();
78 reset_local_time();
77
79
78 rtems_cpu_usage_reset();
80 rtems_cpu_usage_reset();
@@ -245,7 +247,7 void init_local_mode_parameters( void )
245
247
246 void reset_local_time( void )
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 void create_names( void ) // create all names for tasks and queues
253 void create_names( void ) // create all names for tasks and queues
@@ -464,7 +466,7 int create_all_tasks( void ) // create a
464 status = rtems_task_create(
466 status = rtems_task_create(
465 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
467 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
466 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
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 spacewire_update_statistics();
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 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
229 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
230
230
231 // SEND PACKET
231 // SEND PACKET
@@ -484,12 +484,12 void get_v_e1_e2_f3( unsigned char *spac
484 else
484 else
485 {
485 {
486 offset_in_samples = 0;
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 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
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 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
493 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
494 }
494 }
495 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
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 void get_cpu_load( unsigned char *resource_statistics )
610 void get_cpu_load( unsigned char *resource_statistics )
506 {
611 {
507 unsigned char cpu_load;
612 unsigned char cpu_load;
@@ -228,7 +228,7 rtems_task send_task( rtems_task_argumen
228 }
228 }
229 else
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 status = write( fdSPW, incomingData, size );
233 status = write( fdSPW, incomingData, size );
234 if (status == -1){
234 if (status == -1){
@@ -577,6 +577,17 void BP_send(char *data, rtems_id queue_
577 //******************
577 //******************
578 // general functions
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 void reset_spectral_matrix_regs( void )
591 void reset_spectral_matrix_regs( void )
581 {
592 {
582 /** This function resets the spectral matrices module registers.
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;
606 set_sm_irq_onError( 0 );
596 spectral_matrix_regs->status = 0x00;
607
608 set_sm_irq_onNewMatrix( 0 );
609
610 reset_sm_status();
597
611
598 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
612 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
599 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
613 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
@@ -466,19 +466,23 int stop_current_mode( void )
466 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
466 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
467 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
467 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
468
468
469 // (2) clear interruptions
469 // reset lfr VHDL module
470 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
470 reset_lfr();
471 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
472
471
473 // (3) reset waveform picker registers
472 // (2) reset waveform picker registers
474 reset_wfp_burst_enable(); // reset burst and enable bits
473 reset_wfp_burst_enable(); // reset burst and enable bits
475 reset_wfp_status(); // reset all the status bits
474 reset_wfp_status(); // reset all the status bits
476
475
477 // (4) reset spectral matrices registers
476 // (3) reset spectral matrices registers
478 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
477 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
479 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
478 reset_sm_status();
479
480 reset_extractSWF(); // reset the extractSWF flag to false
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 // <Spectral Matrices simulator>
486 // <Spectral Matrices simulator>
483 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
487 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
484 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
488 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
@@ -748,13 +752,14 int suspend_science_tasks()
748 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
752 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
749 {
753 {
750 WFP_reset_current_ring_nodes();
754 WFP_reset_current_ring_nodes();
755
751 reset_waveform_picker_regs();
756 reset_waveform_picker_regs();
757
752 set_wfp_burst_enable_register( mode );
758 set_wfp_burst_enable_register( mode );
753
759
754 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
760 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
755 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
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 if (transitionCoarseTime == 0)
763 if (transitionCoarseTime == 0)
759 {
764 {
760 waveform_picker_regs->start_date = time_management_regs->coarse_time;
765 waveform_picker_regs->start_date = time_management_regs->coarse_time;
@@ -770,17 +775,16 void launch_waveform_picker( unsigned ch
770 void launch_spectral_matrix( void )
775 void launch_spectral_matrix( void )
771 {
776 {
772 SM_reset_current_ring_nodes();
777 SM_reset_current_ring_nodes();
778
773 reset_spectral_matrix_regs();
779 reset_spectral_matrix_regs();
780
774 reset_nb_sm();
781 reset_nb_sm();
775
782
776 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
783 set_sm_irq_onNewMatrix( 1 );
777 grgpio_regs->io_port_direction_register =
784
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 );
781 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
785 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
782 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
786 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
783 set_run_matrix_spectral( 1 );
787
784 }
788 }
785
789
786 void launch_spectral_matrix_simu( void )
790 void launch_spectral_matrix_simu( void )
@@ -795,7 +799,7 void launch_spectral_matrix_simu( void )
795 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
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 if (value == 1)
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 if (value == 1)
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 else
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 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
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 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
24
24
25 //**************
25 //***************
26 // waveform ring
26 // waveform rings
27 // F0
27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
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 ring_node *current_ring_node_f0;
29 ring_node *current_ring_node_f0;
32 ring_node *ring_node_to_send_swf_f0;
30 ring_node *ring_node_to_send_swf_f0;
31 // F1
32 ring_node waveform_ring_f1[NB_RING_NODES_F1];
33 ring_node *current_ring_node_f1;
33 ring_node *current_ring_node_f1;
34 ring_node *ring_node_to_send_swf_f1;
34 ring_node *ring_node_to_send_swf_f1;
35 ring_node *ring_node_to_send_cwf_f1;
35 ring_node *ring_node_to_send_cwf_f1;
36 // F2
37 ring_node waveform_ring_f2[NB_RING_NODES_F2];
36 ring_node *current_ring_node_f2;
38 ring_node *current_ring_node_f2;
37 ring_node *ring_node_to_send_swf_f2;
39 ring_node *ring_node_to_send_swf_f2;
38 ring_node *ring_node_to_send_cwf_f2;
40 ring_node *ring_node_to_send_cwf_f2;
41 // F3
42 ring_node waveform_ring_f3[NB_RING_NODES_F3];
39 ring_node *current_ring_node_f3;
43 ring_node *current_ring_node_f3;
40 ring_node *ring_node_to_send_cwf_f3;
44 ring_node *ring_node_to_send_cwf_f3;
41
45
@@ -44,7 +48,8 bool swf_f0_ready = false;
44 bool swf_f1_ready = false;
48 bool swf_f1_ready = false;
45 bool swf_f2_ready = false;
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 // Interrupt SubRoutine
55 // Interrupt SubRoutine
@@ -57,60 +62,6 void reset_extractSWF( void )
57 swf_f2_ready = false;
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 void waveforms_isr_f3( void )
65 void waveforms_isr_f3( void )
115 {
66 {
116 rtems_status_code spare_status;
67 rtems_status_code spare_status;
@@ -118,29 +69,27 void waveforms_isr_f3( void )
118 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
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 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
70 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
120 { // in modes other than STANDBY and BURST, send the CWF_F3 data
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
72 //***
122 // (1) change the receiving buffer for the waveform picker
73 // F3
123 ring_node_to_send_cwf_f3 = current_ring_node_f3;
74 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
124 current_ring_node_f3 = current_ring_node_f3->next;
75 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
125 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
76 current_ring_node_f3 = current_ring_node_f3->next;
126 // (2) send an event for the waveforms transmission
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 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
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 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
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 rtems_status_code status;
99 rtems_status_code status;
151
100
152 if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits
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
102 && ( (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
103 && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits
155 {
104 {
156 // change F0 ring node
105 //***
157 change_f0_buffer();
106 // F0
158 // change F1 ring node
107 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
159 change_f1_buffer( ring_node_to_send_swf_f1 );
108 current_ring_node_f0 = current_ring_node_f0->next;
160 // change F2 ring node
109 if ( (waveform_picker_regs->status & 0x01) == 0x01)
161 change_f2_buffer( ring_node_to_send_swf_f2 );
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