##// END OF EJS Templates
fsw-0-2 delivery to LESIA...
paul@pc-solar1.lab-lpp.local -
r16:059e0f45d09b default
parent child
Show More
@@ -1,46 +1,46
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 <CodeBlocks_layout_file>
2 <CodeBlocks_layout_file>
3 <ActiveTarget name="Debug" />
3 <ActiveTarget name="Debug" />
4 <File name="../header/ccsds_types.h" open="0" top="0" tabpos="3">
4 <File name="../header/ccsds_types.h" open="0" top="0" tabpos="3">
5 <Cursor position="417" topLine="3" />
5 <Cursor position="384" topLine="87" />
6 </File>
6 </File>
7 <File name="../header/fsw_init.h" open="0" top="0" tabpos="6">
7 <File name="../header/fsw_init.h" open="0" top="0" tabpos="6">
8 <Cursor position="1629" topLine="27" />
8 <Cursor position="1133" topLine="22" />
9 </File>
9 </File>
10 <File name="../header/fsw_misc.h" open="0" top="0" tabpos="0">
10 <File name="../header/fsw_misc.h" open="0" top="0" tabpos="0">
11 <Cursor position="114" topLine="0" />
11 <Cursor position="545" topLine="0" />
12 </File>
12 </File>
13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="2">
13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="2">
14 <Cursor position="481" topLine="0" />
14 <Cursor position="1157" topLine="0" />
15 </File>
15 </File>
16 <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0">
16 <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0">
17 <Cursor position="628" topLine="7" />
17 <Cursor position="628" topLine="7" />
18 </File>
18 </File>
19 <File name="../header/grlib_regs.h" open="0" top="0" tabpos="4">
19 <File name="../header/grlib_regs.h" open="0" top="0" tabpos="4">
20 <Cursor position="1153" topLine="16" />
20 <Cursor position="1153" topLine="16" />
21 </File>
21 </File>
22 <File name="../header/tc_handler.h" open="0" top="0" tabpos="4">
22 <File name="../header/tc_handler.h" open="0" top="0" tabpos="4">
23 <Cursor position="1380" topLine="35" />
23 <Cursor position="1380" topLine="35" />
24 </File>
24 </File>
25 <File name="../header/wf_handler.h" open="0" top="0" tabpos="0">
25 <File name="../header/wf_handler.h" open="0" top="0" tabpos="0">
26 <Cursor position="341" topLine="0" />
26 <Cursor position="341" topLine="0" />
27 </File>
27 </File>
28 <File name="../src/fsw_globals.c" open="0" top="0" tabpos="5">
28 <File name="../src/fsw_globals.c" open="0" top="0" tabpos="5">
29 <Cursor position="99" topLine="0" />
29 <Cursor position="184" topLine="0" />
30 </File>
30 </File>
31 <File name="../src/fsw_init.c" open="1" top="0" tabpos="1">
31 <File name="../src/fsw_init.c" open="1" top="0" tabpos="1">
32 <Cursor position="12524" topLine="55" />
32 <Cursor position="12072" topLine="91" />
33 </File>
33 </File>
34 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="2">
34 <File name="../src/fsw_misc.c" open="1" top="1" tabpos="2">
35 <Cursor position="2621" topLine="0" />
35 <Cursor position="4309" topLine="44" />
36 </File>
36 </File>
37 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="0">
37 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="0">
38 <Cursor position="1792" topLine="43" />
38 <Cursor position="20570" topLine="67" />
39 </File>
39 </File>
40 <File name="../src/tc_handler.c" open="1" top="1" tabpos="2">
40 <File name="../src/tc_handler.c" open="0" top="0" tabpos="2">
41 <Cursor position="13883" topLine="80" />
41 <Cursor position="15292" topLine="0" />
42 </File>
42 </File>
43 <File name="../src/wf_handler.c" open="0" top="0" tabpos="4">
43 <File name="../src/wf_handler.c" open="0" top="0" tabpos="4">
44 <Cursor position="4576" topLine="83" />
44 <Cursor position="2540" topLine="42" />
45 </File>
45 </File>
46 </CodeBlocks_layout_file>
46 </CodeBlocks_layout_file>
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,19 +1,20
1 #ifndef FSW_MISC_H_INCLUDED
1 #ifndef FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <stdio.h>
5 #include <stdio.h>
6
6
7 #include <fsw_init.h>
7 #include <fsw_init.h>
8 #include <fsw_params.h>
8 #include <fsw_params.h>
9 #include <grlib_regs.h>
9 #include <grlib_regs.h>
10 #include <grspw.h>
10 #include <grspw.h>
11 #include <ccsds_types.h>
11 #include <ccsds_types.h>
12
12
13 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
13 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
14 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
14 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
15 void print_statistics(spw_stats *stats);
15 void print_statistics(spw_stats *stats);
16 int send_console_outputs_on_serial_port();
16 int send_console_outputs_on_serial_port();
17 rtems_task stat_task(rtems_task_argument argument);
17 rtems_task stat_task(rtems_task_argument argument);
18 rtems_task hous_task(rtems_task_argument argument);
18
19
19 #endif // FSW_MISC_H_INCLUDED
20 #endif // FSW_MISC_H_INCLUDED
@@ -1,100 +1,107
1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
2 #define FSW_RTEMS_CONFIG_H_INCLUDED
2 #define FSW_RTEMS_CONFIG_H_INCLUDED
3
3
4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
5 #define UART_DEVICE_NAME "/dev/console"
5 #define UART_DEVICE_NAME "/dev/console"
6
6
7 //**********
7 //**********
8 // LFR MODES
8 // LFR MODES
9 #define LFR_MODE_STANDBY 0
9 #define LFR_MODE_STANDBY 0
10 #define LFR_MODE_NORMAL 1
10 #define LFR_MODE_NORMAL 1
11 #define LFR_MODE_BURST 2
11 #define LFR_MODE_BURST 2
12 #define LFR_MODE_SBM1 3
12 #define LFR_MODE_SBM1 3
13 #define LFR_MODE_SBM2 4
13 #define LFR_MODE_SBM2 4
14
14
15 //*****************************
15 //*****************************
16 // APB REGISTERS BASE ADDRESSES
16 // APB REGISTERS BASE ADDRESSES
17 #define REGS_ADDR_APBUART 0x80000100
17 #define REGS_ADDR_APBUART 0x80000100
18 #define REGS_ADDR_GPTIMER 0x80000300
18 #define REGS_ADDR_GPTIMER 0x80000300
19 #define REGS_ADDR_GRSPW 0x80000500
19 #define REGS_ADDR_GRSPW 0x80000500
20 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
20 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
21 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
21 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
22
22
23 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
23 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
24
24
25 //**********
25 //**********
26 // IRQ LINES
26 // IRQ LINES
27 #define IRQ_SM 9
27 #define IRQ_SM 9
28 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
28 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
29 #define IRQ_WF 10
29 #define IRQ_WF 10
30 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
30 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
31 #define IRQ_TIME1 12
31 #define IRQ_TIME1 12
32 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
32 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
33 #define IRQ_TIME2 13
33 #define IRQ_TIME2 13
34 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
34 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
35
35
36 //*****
37 // TIME
36 #define CLKDIV_SM_SIMULATOR 9999
38 #define CLKDIV_SM_SIMULATOR 9999
37 #define CLKDIV_WF_SIMULATOR 9999999
39 #define CLKDIV_WF_SIMULATOR 9999999
38 #define TIMER_SM_SIMULATOR 1
40 #define TIMER_SM_SIMULATOR 1
39 #define TIMER_WF_SIMULATOR 2
41 #define TIMER_WF_SIMULATOR 2
42 #define HK_PERIOD 100 // 100 * 10ms => 1sec
40
43
41 //******
44 //******
42 // RTEMS
45 // RTEMS
43 #define TASKID_RECV 1
46 #define TASKID_RECV 1
44 #define TASKID_ACTN 1
47 #define TASKID_ACTN 2
45 #define TASKID_SPIQ 3
48 #define TASKID_SPIQ 3
46 #define TASKID_SMIQ 4
49 #define TASKID_SMIQ 4
47 #define TASKID_STAT 5
50 #define TASKID_STAT 5
48 #define TASKID_AVF0 6
51 #define TASKID_AVF0 6
49 #define TASKID_BPF0 7
52 #define TASKID_BPF0 7
50 #define TASKID_WFRM 8
53 #define TASKID_WFRM 8
51 #define TASKID_DUMB 9
54 #define TASKID_DUMB 9
55 #define TASKID_HOUS 10
52
56
53 #define ACTION_MSG_QUEUE_COUNT 10
57 #define ACTION_MSG_QUEUE_COUNT 10
54
58
59 // LENGTH (BYTES)
60 #define LENGTH_TM_LFR_HK 126
61
55 //*******
62 //*******
56 // MACROS
63 // MACROS
57 //#define PRINT_TASK_STATISTICS
64 //#define PRINT_TASK_STATISTICS
58 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
65 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
59 #ifdef PRINT_MESSAGES_ON_CONSOLE
66 #ifdef PRINT_MESSAGES_ON_CONSOLE
60 #define PRINTF(x) printf(x);
67 #define PRINTF(x) printf(x);
61 #define PRINTF1(x,y) printf(x,y);
68 #define PRINTF1(x,y) printf(x,y);
62 #define PRINTF2(x,y,z) printf(x,y,z);
69 #define PRINTF2(x,y,z) printf(x,y,z);
63 #else
70 #else
64 #define PRINTF(x) ;
71 #define PRINTF(x) ;
65 #define PRINTF1(x,y) ;
72 #define PRINTF1(x,y) ;
66 #define PRINTF2(x,y,z) ;
73 #define PRINTF2(x,y,z) ;
67 #endif
74 #endif
68
75
69 #define NB_SAMPLES_PER_SNAPSHOT 2048
76 #define NB_SAMPLES_PER_SNAPSHOT 2048
70 #define NB_BYTES_SWF_BLK 2 * 6
77 #define NB_BYTES_SWF_BLK 2 * 6
71
78
72 struct param_norm_str{
79 struct param_norm_str{
73 unsigned int sy_lfr_n_swf_l; // length of the snapshots
80 unsigned int sy_lfr_n_swf_l; // length of the snapshots
74 unsigned int sy_lfr_n_swf_p; // time between two snapshots
81 unsigned int sy_lfr_n_swf_p; // time between two snapshots
75 unsigned int sy_lfr_n_asm_p; // time between two asm
82 unsigned int sy_lfr_n_asm_p; // time between two asm
76 unsigned char sy_lfr_n_bp_p0; // timebetween two products BP1 set
83 unsigned char sy_lfr_n_bp_p0; // timebetween two products BP1 set
77 unsigned char sy_lfr_n_bp_p1; // time between two products BP2 set
84 unsigned char sy_lfr_n_bp_p1; // time between two products BP2 set
78 };
85 };
79
86
80 struct param_burst_str{
87 struct param_burst_str{
81 unsigned char sy_lfr_b_bp_p0; // timebetween two products BP1 set
88 unsigned char sy_lfr_b_bp_p0; // timebetween two products BP1 set
82 unsigned char sy_lfr_b_bp_p1; // time between two products BP2 set
89 unsigned char sy_lfr_b_bp_p1; // time between two products BP2 set
83 };
90 };
84
91
85 struct param_sbm1_str{
92 struct param_sbm1_str{
86 unsigned char sy_lfr_s1_bp_p0; // timebetween two products BP1 set
93 unsigned char sy_lfr_s1_bp_p0; // timebetween two products BP1 set
87 unsigned char sy_lfr_s1_bp_p1; // time between two products BP2 set
94 unsigned char sy_lfr_s1_bp_p1; // time between two products BP2 set
88 };
95 };
89
96
90 struct param_sbm2_str{
97 struct param_sbm2_str{
91 unsigned char sy_lfr_s2_bp_p0; // timebetween two products BP1 set
98 unsigned char sy_lfr_s2_bp_p0; // timebetween two products BP1 set
92 unsigned char sy_lfr_s2_bp_p1; // time between two products BP2 set
99 unsigned char sy_lfr_s2_bp_p1; // time between two products BP2 set
93 };
100 };
94
101
95 extern volatile int wf_snap_f0[ ]; // 24576 bytes
102 extern volatile int wf_snap_f0[ ]; // 24576 bytes
96 extern volatile int wf_snap_f1[ ]; // 24576 bytes
103 extern volatile int wf_snap_f1[ ]; // 24576 bytes
97 extern volatile int wf_snap_f2[ ]; // 24576 bytes
104 extern volatile int wf_snap_f2[ ]; // 24576 bytes
98 extern volatile int wf_cont_f3[ ]; // 24576 bytes
105 extern volatile int wf_cont_f3[ ]; // 24576 bytes
99
106
100 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
107 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,45 +1,49
1 #include <fsw_processing.h>
1 #include <fsw_processing.h>
2 #include <rtems.h>
2 #include <rtems.h>
3 #include <ccsds_types.h>
3
4
4 // RTEMS GLOBAL VARIABLES
5 // RTEMS GLOBAL VARIABLES
5 rtems_name misc_name[5];
6 rtems_name misc_name[5];
6 rtems_name misc_id[5];
7 rtems_name misc_id[5];
7 rtems_id Task_id[10]; /* array of task ids */
8 rtems_id Task_id[15]; /* array of task ids */
8 rtems_name Task_name[10]; /* array of task names */
9 rtems_name Task_name[15]; /* array of task names */
9 int fdSPW;
10 int fdSPW;
10 int fdUART;
11 int fdUART;
11
12
12 // APB CONFIGURATION REGISTERS
13 // APB CONFIGURATION REGISTERS
13 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
14 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
14
15
15 // WAVEFORMS GLOBAL VARIABLES
16 // WAVEFORMS GLOBAL VARIABLES
16 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
17 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
17 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
18 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
18 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
19 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
19 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
20 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
20
21
21 // SPECTRAL MATRICES GLOBAL VARIABLES
22 // SPECTRAL MATRICES GLOBAL VARIABLES
22 volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ];
23 volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ];
23 volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ];
24 volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ];
24 volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ];
25 volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ];
25 volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ];
26 volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ];
26 volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ];
27 volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ];
27 volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ];
28 volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ];
28 volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ];
29 volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ];
29 volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ];
30 volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ];
30 //
31 //
31 float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ];
32 float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ];
32 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
33 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
33
34
34 // MODE PARAMETERS
35 // MODE PARAMETERS
35 struct param_norm_str param_norm;
36 struct param_norm_str param_norm;
36 struct param_burst_str param_burst;
37 struct param_burst_str param_burst;
37 struct param_sbm1_str param_sbm1;
38 struct param_sbm1_str param_sbm1;
38 struct param_sbm2_str param_sbm2;
39 struct param_sbm2_str param_sbm2;
39 unsigned char param_common[2];
40 unsigned char param_common[2];
40
41
42 // HK PACKETS
43 TMHeader_t housekeeping_header;
44 char housekeeping_data[LENGTH_TM_LFR_HK - 10 + 1];
45
41 // BASIC PARAMETERS GLOBAL VARIABLES
46 // BASIC PARAMETERS GLOBAL VARIABLES
42 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
47 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
43
44 BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ];
48 BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ];
45
49
@@ -1,345 +1,361
1 //*************************
1 //*************************
2 // GPL reminder to be added
2 // GPL reminder to be added
3 //*************************
3 //*************************
4
4
5 #include <rtems.h>
5 #include <rtems.h>
6
6
7 /* configuration information */
7 /* configuration information */
8
8
9 #define CONFIGURE_INIT
9 #define CONFIGURE_INIT
10
10
11 #include <bsp.h> /* for device driver prototypes */
11 #include <bsp.h> /* for device driver prototypes */
12
12
13 /* configuration information */
13 /* configuration information */
14
14
15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
17
17
18 #define CONFIGURE_MAXIMUM_TASKS 10
18 #define CONFIGURE_MAXIMUM_TASKS 15
19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 #define CONFIGURE_MAXIMUM_PERIODS 1
24 #define CONFIGURE_MAXIMUM_PERIODS 1
25 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
25 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
26
26
27 #include <rtems/confdefs.h>
27 #include <rtems/confdefs.h>
28
28
29 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
29 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
30 #ifdef RTEMS_DRVMGR_STARTUP
30 #ifdef RTEMS_DRVMGR_STARTUP
31 #ifdef LEON3
31 #ifdef LEON3
32 /* Add Timer and UART Driver */
32 /* Add Timer and UART Driver */
33 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
33 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
34 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
34 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
35 #endif
35 #endif
36 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
36 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
37 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
37 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
38 #endif
38 #endif
39 #endif
39 #endif
40 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
40 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
41 #include <drvmgr/drvmgr_confdefs.h>
41 #include <drvmgr/drvmgr_confdefs.h>
42 #endif
42 #endif
43
43
44 #include <fsw_init.h>
44 #include <fsw_init.h>
45 #include <fsw_config.c>
45 #include <fsw_config.c>
46
46
47 char *link_status(int status);
47 char *link_status(int status);
48
48
49 char *lstates[6] = {"Error-reset",
49 char *lstates[6] = {"Error-reset",
50 "Error-wait",
50 "Error-wait",
51 "Ready",
51 "Ready",
52 "Started",
52 "Started",
53 "Connecting",
53 "Connecting",
54 "Run"
54 "Run"
55 };
55 };
56
56
57 rtems_task Init( rtems_task_argument ignored )
57 rtems_task Init( rtems_task_argument ignored )
58 {
58 {
59 rtems_status_code status;
59 rtems_status_code status;
60 rtems_isr_entry old_isr_handler;
60 rtems_isr_entry old_isr_handler;
61
61
62 //send_console_outputs_on_serial_port();
62 //send_console_outputs_on_serial_port();
63
63
64 initLookUpTableForCRC(); // in tc_handler.h
64 initLookUpTableForCRC(); // in tc_handler.h
65 init_default_mode_parameters();
65 init_default_mode_parameters();
66 create_message_queue();
66 create_message_queue();
67 create_all_tasks();
67 create_all_tasks();
68 start_all_tasks();
68 start_all_tasks();
69
69
70 grspw_timecode_callback = &timecode_irq_handler;
70 grspw_timecode_callback = &timecode_irq_handler;
71
71
72 configure_spw_link();
72 configure_spw_link();
73
73 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
74 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
74 IRQ_SPARC_SM, spectral_matrices_isr );
75 IRQ_SPARC_SM, spectral_matrices_isr );
75 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
76 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
76 IRQ_SPARC_WF, waveforms_isr );
77 IRQ_SPARC_WF, waveforms_isr );
77
78
78 // irq handling of the time management unit
79 // irq handling of the time management unit
79 status = rtems_interrupt_catch( commutation_isr1,
80 status = rtems_interrupt_catch( commutation_isr1,
80 IRQ_SPARC_TIME1,
81 IRQ_SPARC_TIME1,
81 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
82 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
82 if (status==RTEMS_SUCCESSFUL)
83 if (status==RTEMS_SUCCESSFUL)
83 PRINTF("commutation_isr1 *** rtems_interrupt_catch successfullly configured\n")
84 PRINTF("commutation_isr1 *** rtems_interrupt_catch successfullly configured\n")
84
85
85 status = rtems_interrupt_catch( commutation_isr2,
86 status = rtems_interrupt_catch( commutation_isr2,
86 IRQ_SPARC_TIME2,
87 IRQ_SPARC_TIME2,
87 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
88 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
88 if (status==RTEMS_SUCCESSFUL)
89 if (status==RTEMS_SUCCESSFUL)
89 PRINTF("commutation_isr2 *** rtems_interrupt_catch successfullly configured\n")
90 PRINTF("commutation_isr2 *** rtems_interrupt_catch successfullly configured\n")
90
91
91 LEON_Unmask_interrupt( IRQ_TIME1 );
92 LEON_Unmask_interrupt( IRQ_TIME1 );
92 LEON_Unmask_interrupt( IRQ_TIME2 );
93 LEON_Unmask_interrupt( IRQ_TIME2 );
93
94
94 status = rtems_task_delete(RTEMS_SELF);
95 status = rtems_task_delete(RTEMS_SELF);
95 }
96 }
96
97
97 rtems_task spiq_task(rtems_task_argument unused)
98 rtems_task spiq_task(rtems_task_argument unused)
98 {
99 {
99 rtems_event_set event_out;
100 rtems_event_set event_out;
100 struct grspw_regs_str *grspw_regs;
101 struct grspw_regs_str *grspw_regs;
101 grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW;
102 grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW;
102
103
103 while(1){
104 while(1){
104 PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
105 PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
105 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
106 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
106
107
107 if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task
108 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) // suspend RECV task
108 PRINTF("In SPIQ *** Error suspending RECV Task\n")
109 PRINTF("In SPIQ *** Error suspending RECV Task\n")
110 if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) // suspend HOUS task
111 PRINTF("In SPIQ *** Error suspending HOUS Task\n")
109
112
110 configure_spw_link();
113 configure_spw_link();
111
114
112 if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
115 if (rtems_task_restart(Task_id[TASKID_RECV], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
113 PRINTF("In SPIQ *** Error resume RECV Task\n")
116 PRINTF("In SPIQ *** Error resume RECV Task\n")
117 if (rtems_task_restart(Task_id[TASKID_HOUS], 1)!=RTEMS_SUCCESSFUL) // restart HOUS task
118 PRINTF("In SPIQ *** Error resume HOUS Task\n")
119
114 }
120 }
115 }
121 }
116
122
117 void init_default_mode_parameters()
123 void init_default_mode_parameters()
118 {
124 {
119 // COMMON PARAMETERS
125 // COMMON PARAMETERS
120 param_common[0] = 0x00;
126 param_common[0] = 0x00;
121 param_common[1] = 0x10; // default value 0 0 0 1 0 0 0 0
127 param_common[1] = 0x10; // default value 0 0 0 1 0 0 0 0
122 // NORMAL MODE
128 // NORMAL MODE
123 param_norm.sy_lfr_n_swf_l = 2048; // nb sample
129 param_norm.sy_lfr_n_swf_l = 2048; // nb sample
124 param_norm.sy_lfr_n_swf_p = 300; // sec
130 param_norm.sy_lfr_n_swf_p = 300; // sec
125 param_norm.sy_lfr_n_asm_p = 3600; // sec
131 param_norm.sy_lfr_n_asm_p = 3600; // sec
126 param_norm.sy_lfr_n_bp_p0 = 4; // sec
132 param_norm.sy_lfr_n_bp_p0 = 4; // sec
127 param_norm.sy_lfr_n_bp_p1 = 20; // sec
133 param_norm.sy_lfr_n_bp_p1 = 20; // sec
128 // BURST MODE
134 // BURST MODE
129 param_burst.sy_lfr_b_bp_p0 = 1; // sec
135 param_burst.sy_lfr_b_bp_p0 = 1; // sec
130 param_burst.sy_lfr_b_bp_p1 = 5; // sec
136 param_burst.sy_lfr_b_bp_p1 = 5; // sec
131 // SBM1 MODE
137 // SBM1 MODE
132 param_sbm1.sy_lfr_s1_bp_p0 = 1; // sec
138 param_sbm1.sy_lfr_s1_bp_p0 = 1; // sec
133 param_sbm1.sy_lfr_s1_bp_p1 = 1; // sec
139 param_sbm1.sy_lfr_s1_bp_p1 = 1; // sec
134 // SBM2 MODE
140 // SBM2 MODE
135 param_sbm2.sy_lfr_s2_bp_p0 = 1; // sec
141 param_sbm2.sy_lfr_s2_bp_p0 = 1; // sec
136 param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec
142 param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec
137 }
143 }
138
144
139 int create_all_tasks()
145 int create_all_tasks()
140 {
146 {
141 rtems_status_code status;
147 rtems_status_code status;
142
148
143 Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' );
149 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
144 Task_name[2] = rtems_build_name( 'A', 'C', 'T', 'N' );
150 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
145 Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' );
151 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
146 Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' );
152 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
147 Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' );
153 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
148 Task_name[6] = rtems_build_name( 'A', 'V', 'F', '0' );
154 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
149 Task_name[7] = rtems_build_name( 'B', 'P', 'F', '0' );
155 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
150 Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' );
156 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
151 Task_name[9] = rtems_build_name( 'D', 'U', 'M', 'B' );
157 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
158 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
152
159
153 // RECV
160 // RECV
154 status = rtems_task_create(
161 status = rtems_task_create(
155 Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
162 Task_name[TASKID_RECV], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
156 RTEMS_DEFAULT_MODES,
163 RTEMS_DEFAULT_MODES,
157 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1]
164 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
158 );
165 );
159 // ACTN
166 // ACTN
160 status = rtems_task_create(
167 status = rtems_task_create(
161 Task_name[2], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
168 Task_name[TASKID_ACTN], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
162 RTEMS_DEFAULT_MODES,
169 RTEMS_DEFAULT_MODES,
163 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[2]
170 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_ACTN]
164 );
171 );
165 // SPIQ
172 // SPIQ
166 status = rtems_task_create(
173 status = rtems_task_create(
167 Task_name[3], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
174 Task_name[TASKID_SPIQ], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
168 RTEMS_DEFAULT_MODES,
175 RTEMS_DEFAULT_MODES,
169 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[3]
176 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
170 );
177 );
171 // SMIQ
178 // SMIQ
172 status = rtems_task_create(
179 status = rtems_task_create(
173 Task_name[4], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
180 Task_name[TASKID_SMIQ], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
174 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
181 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
175 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[4]
182 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
176 );
183 );
177 // STAT
184 // STAT
178 status = rtems_task_create(
185 status = rtems_task_create(
179 Task_name[5], 150, RTEMS_MINIMUM_STACK_SIZE * 2,
186 Task_name[TASKID_STAT], 150, RTEMS_MINIMUM_STACK_SIZE * 2,
180 RTEMS_DEFAULT_MODES,
187 RTEMS_DEFAULT_MODES,
181 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[5]
188 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
182 );
189 );
183 // AVF0
190 // AVF0
184 status = rtems_task_create(
191 status = rtems_task_create(
185 Task_name[6], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
192 Task_name[TASKID_AVF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
186 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
193 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
187 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[6]
194 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
188 );
195 );
189 // BPF0
196 // BPF0
190 status = rtems_task_create(
197 status = rtems_task_create(
191 Task_name[7], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
198 Task_name[TASKID_BPF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
192 RTEMS_DEFAULT_MODES,
199 RTEMS_DEFAULT_MODES,
193 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[7]
200 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
194 );
201 );
195 // WFRM
202 // WFRM
196 status = rtems_task_create(
203 status = rtems_task_create(
197 Task_name[8], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
204 Task_name[TASKID_WFRM], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
198 RTEMS_DEFAULT_MODES,
205 RTEMS_DEFAULT_MODES,
199 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[8]
206 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
200 );
207 );
201 // DUMB
208 // DUMB
202 status = rtems_task_create(
209 status = rtems_task_create(
203 Task_name[9], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
210 Task_name[TASKID_DUMB], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
204 RTEMS_DEFAULT_MODES,
211 RTEMS_DEFAULT_MODES,
205 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[9]
212 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
213 );
214 // HOUS
215 status = rtems_task_create(
216 Task_name[TASKID_HOUS], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
217 RTEMS_DEFAULT_MODES,
218 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
206 );
219 );
207
220
208 return 0;
221 return 0;
209 }
222 }
210
223
211 int start_all_tasks()
224 int start_all_tasks()
212 {
225 {
213 rtems_status_code status;
226 rtems_status_code status;
214
227
215 status = rtems_task_start( Task_id[3], spiq_task, 1 );
228 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
216 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
229 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
217
230
218 status = rtems_task_start( Task_id[1], recv_task, 1 );
231 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
219 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
232 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
220
233
221 status = rtems_task_start( Task_id[2], actn_task, 1 );
234 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
222 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n")
235 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n")
223
236
224 status = rtems_task_start( Task_id[4], smiq_task, 1 );
237 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
225 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
238 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
226
239
227 status = rtems_task_start( Task_id[5], stat_task, 1 );
240 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
228 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
241 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
229
242
230 status = rtems_task_start( Task_id[6], avf0_task, 1 );
243 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
231 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
244 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
232
245
233 status = rtems_task_start( Task_id[7], bpf0_task, 1 );
246 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
234 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
247 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
235
248
236 status = rtems_task_start( Task_id[8], wfrm_task, 1 );
249 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
237 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
250 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
238
251
239 status = rtems_task_start( Task_id[9], dumb_task, 1 );
252 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
240 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_DUMB\n")
253 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_DUMB\n")
241
254
255 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
256 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_HOUS\n")
257
242 return 0;
258 return 0;
243 }
259 }
244
260
245 int configure_spw_link()
261 int configure_spw_link()
246 {
262 {
247 rtems_status_code status;
263 rtems_status_code status;
248
264
249 close(fdSPW); // close the device if it is already open
265 close(fdSPW); // close the device if it is already open
250 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
266 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
251 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
267 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
252 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
268 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
253 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n")
269 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n")
254 close(fdSPW); // close the device
270 close(fdSPW); // close the device
255 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
271 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
256 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
272 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
257 rtems_task_wake_after(100);
273 rtems_task_wake_after(100);
258 }
274 }
259
275
260 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
276 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
261
277
262 // sets a few parameters of the link
278 // sets a few parameters of the link
263 //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit
279 //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit
264 //if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n")
280 //if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n")
265
281
266 configure_spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force
282 configure_spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force
267 configure_spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration
283 configure_spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration
268
284
269 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
285 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
270 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
286 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
271 //
287 //
272 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[3]); // sets the task ID to which an event is sent when a
288 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
273 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
289 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
274 //
290 //
275 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
291 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
276 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
292 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
277 //
293 //
278 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
294 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
279 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
295 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
280 //
296 //
281 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit
297 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit
282 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
298 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
283 //
299 //
284 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key
300 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key
285 PRINTF1("destination address set to: %d\n", CCSDS_DESTINATION_ID)
301 PRINTF1("destination address set to: %d\n", CCSDS_DESTINATION_ID)
286 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DESTKEY\n")
302 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DESTKEY\n")
287 //
303 //
288 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_NODEADDR, CCSDS_NODE_ADDRESS); // sets the node address
304 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_NODEADDR, CCSDS_NODE_ADDRESS); // sets the node address
289 PRINTF1("node address set to: %d\n", CCSDS_NODE_ADDRESS)
305 PRINTF1("node address set to: %d\n", CCSDS_NODE_ADDRESS)
290 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_NODEADDR\n")
306 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_NODEADDR\n")
291 //
307 //
292 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909);
308 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909);
293 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
309 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
294
310
295 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
311 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
296
312
297 return RTEMS_SUCCESSFUL;
313 return RTEMS_SUCCESSFUL;
298 }
314 }
299
315
300 void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr) // No Port force
316 void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr) // No Port force
301 {
317 {
302 unsigned int *spwptr;
318 unsigned int *spwptr;
303 spwptr = (unsigned int*) regAddr;
319 spwptr = (unsigned int*) regAddr;
304 if (val == 1)
320 if (val == 1)
305 {
321 {
306 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
322 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
307 }
323 }
308 if (val== 0)
324 if (val== 0)
309 {
325 {
310 *spwptr = *spwptr & 0xffdfffff;
326 *spwptr = *spwptr & 0xffdfffff;
311 }
327 }
312 }
328 }
313
329
314 void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr) // RMAP Enable
330 void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr) // RMAP Enable
315 {
331 {
316 unsigned int *spwptr;
332 unsigned int *spwptr;
317 spwptr = (unsigned int*) regAddr;
333 spwptr = (unsigned int*) regAddr;
318 if (val == 1)
334 if (val == 1)
319 {
335 {
320 *spwptr = *spwptr | 0x00010000; // [NP] set the No port force bit
336 *spwptr = *spwptr | 0x00010000; // [NP] set the No port force bit
321 }
337 }
322 if (val== 0)
338 if (val== 0)
323 {
339 {
324 *spwptr = *spwptr & 0xfffdffff;
340 *spwptr = *spwptr & 0xfffdffff;
325 }
341 }
326 }
342 }
327
343
328 char *link_status(int status){
344 char *link_status(int status){
329 return lstates[status];
345 return lstates[status];
330 }
346 }
331
347
332 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
348 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
333 {
349 {
334 rtems_status_code status;
350 rtems_status_code status;
335 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
351 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
336 if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n");
352 if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n");
337 return status;
353 return status;
338 }
354 }
339
355
340 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc)
356 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc)
341 {
357 {
342 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
358 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
343 printf("In timecode_irq_handler *** Error sending event to DUMB\n");
359 printf("In timecode_irq_handler *** Error sending event to DUMB\n");
344 }
360 }
345
361
@@ -1,75 +1,138
1 #include <fsw_misc.h>
1 #include <fsw_misc.h>
2 #include <fsw_params.h>
2 #include <fsw_params.h>
3
3
4 extern rtems_id Task_id[]; /* array of task ids */
4 extern rtems_id Task_id[]; /* array of task ids */
5 extern int fdSPW;
5 extern int fdSPW;
6 extern TMHeader_t housekeeping_header;
7 extern char housekeeping_data[];
6
8
7 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
9 int configure_timer(