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