@@ -0,0 +1,39 | |||||
|
1 | #ifndef FSW_RTEMS_H_INCLUDED | |||
|
2 | #define FSW_RTEMS_H_INCLUDED | |||
|
3 | ||||
|
4 | #include <errno.h> | |||
|
5 | #include <fcntl.h> | |||
|
6 | #include <stdio.h> | |||
|
7 | #include <stdlib.h> | |||
|
8 | ||||
|
9 | #include <grspw.h> | |||
|
10 | #include <apbuart.h> | |||
|
11 | ||||
|
12 | #include <fsw_params.h> | |||
|
13 | #include <fsw_misc.h> | |||
|
14 | #include <fsw_processing.h> | |||
|
15 | #include <tc_handler.h> | |||
|
16 | #include <wf_handler.h> | |||
|
17 | #include <grlib_regs.h> | |||
|
18 | ||||
|
19 | extern int sched_yield(); | |||
|
20 | extern int errno; | |||
|
21 | ||||
|
22 | // RTEMS TASKS | |||
|
23 | rtems_task Init( rtems_task_argument argument); /* forward declaration needed */ | |||
|
24 | rtems_task spw_recv_task(rtems_task_argument argument); | |||
|
25 | rtems_task spw_spiq_task(rtems_task_argument argument); | |||
|
26 | rtems_task spw_stat_task(rtems_task_argument argument); | |||
|
27 | rtems_task spw_wfrm_task(rtems_task_argument argument); | |||
|
28 | int create_all_tasks(); | |||
|
29 | int start_all_tasks(); | |||
|
30 | ||||
|
31 | // OTHER functions | |||
|
32 | int configure_spw_link(); | |||
|
33 | int send_console_outputs_on_serial_port(); | |||
|
34 | extern int rtems_cpu_usage_report(); | |||
|
35 | extern int rtems_cpu_usage_reset(); | |||
|
36 | void print_statistics(spw_stats *); | |||
|
37 | rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send); | |||
|
38 | ||||
|
39 | #endif // FSW_RTEMS_CONFIG_H_INCLUDED |
@@ -0,0 +1,19 | |||||
|
1 | #ifndef FSW_MISC_H_INCLUDED | |||
|
2 | #define FSW_MISC_H_INCLUDED | |||
|
3 | ||||
|
4 | #include <rtems.h> | |||
|
5 | #include <stdio.h> | |||
|
6 | ||||
|
7 | #include <fsw_init.h> | |||
|
8 | #include <fsw_params.h> | |||
|
9 | #include <grlib_regs.h> | |||
|
10 | #include <grspw.h> | |||
|
11 | #include <ccsds_types.h> | |||
|
12 | ||||
|
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)() ); | |||
|
15 | void print_statistics(spw_stats *stats); | |||
|
16 | int send_console_outputs_on_serial_port(); | |||
|
17 | rtems_task spw_stat_task(rtems_task_argument argument); | |||
|
18 | ||||
|
19 | #endif // FSW_MISC_H_INCLUDED |
@@ -0,0 +1,51 | |||||
|
1 | #ifndef FSW_RTEMS_CONFIG_H_INCLUDED | |||
|
2 | #define FSW_RTEMS_CONFIG_H_INCLUDED | |||
|
3 | ||||
|
4 | #define GRSPW_DEVICE_NAME "/dev/grspw0" | |||
|
5 | #define UART_DEVICE_NAME "/dev/console" | |||
|
6 | ||||
|
7 | #define REGS_ADDR_APBUART 0x80000100 | |||
|
8 | #define REGS_ADDR_GPTIMER 0x80000300 | |||
|
9 | #define REGS_ADDR_GRSPW 0x80000500 | |||
|
10 | #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700 | |||
|
11 | ||||
|
12 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff | |||
|
13 | ||||
|
14 | #define IRQ_SM 9 | |||
|
15 | #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels | |||
|
16 | #define IRQ_WF 10 | |||
|
17 | #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels | |||
|
18 | ||||
|
19 | #define CLKDIV_SM_SIMULATOR 9999 | |||
|
20 | #define CLKDIV_WF_SIMULATOR 9999999 | |||
|
21 | #define TIMER_SM_SIMULATOR 1 | |||
|
22 | #define TIMER_WF_SIMULATOR 2 | |||
|
23 | ||||
|
24 | #define TASKID_RECV 1 | |||
|
25 | #define TASKID_SPIQ 3 | |||
|
26 | #define TASKID_SMIQ 4 | |||
|
27 | #define TASKID_STAT 5 | |||
|
28 | #define TASKID_AVF0 6 | |||
|
29 | #define TASKID_BPF0 7 | |||
|
30 | #define TASKID_WFRM 8 | |||
|
31 | ||||
|
32 | #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions | |||
|
33 | #ifdef PRINT_MESSAGES_ON_CONSOLE | |||
|
34 | #define PRINTF(x) printf(x); | |||
|
35 | #define PRINTF1(x,y) printf(x,y); | |||
|
36 | #define PRINTF2(x,y,z) printf(x,y,z); | |||
|
37 | #else | |||
|
38 | #define PRINTF(x) ; | |||
|
39 | #define PRINTF1(x,y) ; | |||
|
40 | #define PRINTF2(x,y,z) ; | |||
|
41 | #endif | |||
|
42 | ||||
|
43 | #define NB_SAMPLES_PER_SNAPSHOT 2048 | |||
|
44 | #define NB_BYTES_SWF_BLK 2 * 6 | |||
|
45 | ||||
|
46 | extern volatile int wf_snap_f0[ ]; // 24576 bytes | |||
|
47 | extern volatile int wf_snap_f1[ ]; // 24576 bytes | |||
|
48 | extern volatile int wf_snap_f2[ ]; // 24576 bytes | |||
|
49 | extern volatile int wf_cont_f3[ ]; // 24576 bytes | |||
|
50 | ||||
|
51 | #endif // FSW_RTEMS_CONFIG_H_INCLUDED |
@@ -0,0 +1,44 | |||||
|
1 | #ifndef FSW_RTEMS_PROCESSING_H_INCLUDED | |||
|
2 | #define FSW_RTEMS_PROCESSING_H_INCLUDED | |||
|
3 | ||||
|
4 | #define NB_BINS_spec_mat 128 | |||
|
5 | #define NB_VALUES_PER_spec_mat 25 | |||
|
6 | #define TOTAL_SIZE_SPEC_MAT NB_BINS_spec_mat * NB_VALUES_PER_spec_mat | |||
|
7 | #define NB_BINS_COMPRESSED_MATRIX_f0 11 | |||
|
8 | #define SIZE_COMPRESSED_spec_mat_f1 13 | |||
|
9 | #define SIZE_COMPRESSED_spec_mat_f2 12 | |||
|
10 | #define TOTAL_SIZE_COMPRESSED_MATRIX_f0 NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_spec_mat | |||
|
11 | #define NB_AVERAGE_NORMAL_f0 96*4 | |||
|
12 | #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8 | |||
|
13 | ||||
|
14 | #include <rtems.h> | |||
|
15 | #include <grlib_regs.h> | |||
|
16 | #include <fsw_params.h> | |||
|
17 | ||||
|
18 | struct BP1_str{ | |||
|
19 | volatile unsigned char PE[2]; | |||
|
20 | volatile unsigned char PB[2]; | |||
|
21 | volatile unsigned char V0; | |||
|
22 | volatile unsigned char V1; | |||
|
23 | volatile unsigned char V2_ELLIP_DOP; | |||
|
24 | volatile unsigned char SZ; | |||
|
25 | volatile unsigned char VPHI; | |||
|
26 | }; | |||
|
27 | typedef struct BP1_str BP1_t; | |||
|
28 | ||||
|
29 | // ISR | |||
|
30 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); | |||
|
31 | // RTEMS TASKS | |||
|
32 | rtems_task spw_bppr_task(rtems_task_argument argument); | |||
|
33 | rtems_task spw_avf0_task(rtems_task_argument argument); | |||
|
34 | rtems_task spw_bpf0_task(rtems_task_argument argument); | |||
|
35 | rtems_task spw_smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator | |||
|
36 | // | |||
|
37 | rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument); | |||
|
38 | void matrix_average(volatile int *spec_mat, float *averaged_spec_mat); | |||
|
39 | void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat); | |||
|
40 | void matrix_reset(float *averaged_spec_mat); | |||
|
41 | void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1); | |||
|
42 | void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat); | |||
|
43 | ||||
|
44 | #endif // FSW_RTEMS_PROCESSING_H_INCLUDED |
@@ -0,0 +1,40 | |||||
|
1 | #ifndef GRLIBREGS_H_INCLUDED | |||
|
2 | #define GRLIBREGS_H_INCLUDED | |||
|
3 | ||||
|
4 | #define NB_GPTIMER 3 | |||
|
5 | ||||
|
6 | struct apbuart_regs_str{ | |||
|
7 | volatile unsigned int data; | |||
|
8 | volatile unsigned int status; | |||
|
9 | volatile unsigned int ctrl; | |||
|
10 | volatile unsigned int scaler; | |||
|
11 | volatile unsigned int fifoDebug; | |||
|
12 | }; | |||
|
13 | ||||
|
14 | struct timer_regs_str | |||
|
15 | { | |||
|
16 | volatile unsigned int counter; | |||
|
17 | volatile unsigned int reload; | |||
|
18 | volatile unsigned int ctrl; | |||
|
19 | volatile unsigned int unused; | |||
|
20 | }; | |||
|
21 | typedef struct timer_regs_str timer_regs_t; | |||
|
22 | ||||
|
23 | struct gptimer_regs_str | |||
|
24 | { | |||
|
25 | volatile unsigned int scaler_value; | |||
|
26 | volatile unsigned int scaler_reload; | |||
|
27 | volatile unsigned int conf; | |||
|
28 | volatile unsigned int unused0; | |||
|
29 | timer_regs_t timer[NB_GPTIMER]; | |||
|
30 | }; | |||
|
31 | typedef struct gptimer_regs_str gptimer_regs_t; | |||
|
32 | ||||
|
33 | struct spectral_matrices_regs_str{ | |||
|
34 | volatile int ctrl; | |||
|
35 | volatile int address0; | |||
|
36 | volatile int address1; | |||
|
37 | }; | |||
|
38 | typedef struct spectral_matrices_regs_str spectral_matrices_regs_t; | |||
|
39 | ||||
|
40 | #endif // GRLIBREGS_H_INCLUDED |
@@ -0,0 +1,36 | |||||
|
1 | #ifndef TC_HANDLER_H_INCLUDED | |||
|
2 | #define TC_HANDLER_H_INCLUDED | |||
|
3 | ||||
|
4 | #include <rtems.h> | |||
|
5 | #include <stdio.h> | |||
|
6 | #include <unistd.h> // for the read call | |||
|
7 | #include <sys/ioctl.h> // for the ioctl call | |||
|
8 | #include <ccsds_types.h> | |||
|
9 | #include <grspw.h> | |||
|
10 | ||||
|
11 | extern int fdSPW; | |||
|
12 | extern rtems_id Task_id[ ]; /* array of task ids */ | |||
|
13 | ||||
|
14 | unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field | |||
|
15 | unsigned char currentTC_COMPUTED_CRC[2]; | |||
|
16 | unsigned int currentTC_LEN_RCV_AsUnsignedInt; | |||
|
17 | unsigned int currentTM_length; | |||
|
18 | unsigned char currentTC_processedFlag; | |||
|
19 | ||||
|
20 | unsigned int lookUpTableForCRC[256]; | |||
|
21 | void InitLookUpTableForCRC(); | |||
|
22 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData); | |||
|
23 | ||||
|
24 | // ACCEPTANCE FUNCTIONS | |||
|
25 | unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV); | |||
|
26 | ||||
|
27 | unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength, | |||
|
28 | unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader); | |||
|
29 | unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC); | |||
|
30 | unsigned int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV, | |||
|
31 | TMHeader_t *TM_Header, unsigned int *hlen, char *data); | |||
|
32 | ||||
|
33 | // RTEMS TASK | |||
|
34 | rtems_task spw_recv_task( rtems_task_argument unused ); | |||
|
35 | ||||
|
36 | #endif // TC_HANDLER_H_INCLUDED |
@@ -0,0 +1,20 | |||||
|
1 | #ifndef WF_HANDLER_H_INCLUDED | |||
|
2 | #define WF_HANDLER_H_INCLUDED | |||
|
3 | ||||
|
4 | #include <rtems.h> | |||
|
5 | #include <fsw_params.h> | |||
|
6 | #include <grspw.h> | |||
|
7 | #include <grlib_regs.h> | |||
|
8 | #include <ccsds_types.h> | |||
|
9 | #include <stdio.h> | |||
|
10 | #include <fsw_init.h> | |||
|
11 | ||||
|
12 | //#include <sys/ioctl.h> | |||
|
13 | ||||
|
14 | extern rtems_id Task_id[]; /* array of task ids */ | |||
|
15 | extern int fdSPW; | |||
|
16 | ||||
|
17 | rtems_isr waveforms_isr( rtems_vector_number vector ); | |||
|
18 | rtems_task spw_wfrm_task(rtems_task_argument argument); | |||
|
19 | ||||
|
20 | #endif // WF_HANDLER_H_INCLUDED |
@@ -0,0 +1,53 | |||||
|
1 | #include <drvmgr/ambapp_bus.h> | |||
|
2 | ||||
|
3 | // GRSPW0 resources | |||
|
4 | struct drvmgr_key grlib_grspw_0n1_res[] = { | |||
|
5 | {"txBdCnt", KEY_TYPE_INT, {(unsigned int)10}}, | |||
|
6 | {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}}, | |||
|
7 | {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}}, | |||
|
8 | {"txHdrSize", KEY_TYPE_INT, {(unsigned int)20+6}}, // 6 is for the auxiliary header, when needed | |||
|
9 | {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}}, | |||
|
10 | KEY_EMPTY | |||
|
11 | }; | |||
|
12 | ||||
|
13 | #if 0 | |||
|
14 | /* APBUART0 */ | |||
|
15 | struct drvmgr_key grlib_drv_res_apbuart0[] = | |||
|
16 | { | |||
|
17 | {"mode", KEY_TYPE_INT, {(unsigned int)1}}, | |||
|
18 | {"syscon", KEY_TYPE_INT, {(unsigned int)1}}, | |||
|
19 | KEY_EMPTY | |||
|
20 | }; | |||
|
21 | /* APBUART1 */ | |||
|
22 | struct drvmgr_key grlib_drv_res_apbuart1[] = | |||
|
23 | { | |||
|
24 | {"mode", KEY_TYPE_INT, {(unsigned int)1}}, | |||
|
25 | {"syscon", KEY_TYPE_INT, {(unsigned int)0}}, | |||
|
26 | KEY_EMPTY | |||
|
27 | }; | |||
|
28 | /* LEON3 System with driver configuration for 2 APBUARTs, the | |||
|
29 | * the rest of the AMBA device drivers use their defaults. | |||
|
30 | */ | |||
|
31 | ||||
|
32 | /* Override default debug UART assignment. | |||
|
33 | * 0 = Default APBUART. APBUART[0], but on MP system CPU0=APBUART0, | |||
|
34 | * CPU1=APBUART1... | |||
|
35 | * 1 = APBUART[0] | |||
|
36 | * 2 = APBUART[1] | |||
|
37 | * 3 = APBUART[2] | |||
|
38 | * ... | |||
|
39 | */ | |||
|
40 | //int debug_uart_index = 2; /* second UART -- APBUART[1] */ | |||
|
41 | #endif | |||
|
42 | ||||
|
43 | // If RTEMS_DRVMGR_STARTUP is defined we override the "weak defaults" that is defined by the LEON3 BSP. | |||
|
44 | ||||
|
45 | struct drvmgr_bus_res grlib_drv_resources = { | |||
|
46 | .next = NULL, | |||
|
47 | .resource = { | |||
|
48 | {DRIVER_AMBAPP_GAISLER_GRSPW_ID, 0, &grlib_grspw_0n1_res[0]}, | |||
|
49 | // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 0, &grlib_drv_res_apbuart0[0]}, | |||
|
50 | // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 1, &grlib_drv_res_apbuart1[0]}, | |||
|
51 | RES_EMPTY /* Mark end of device resource array */ | |||
|
52 | } | |||
|
53 | }; |
@@ -0,0 +1,25 | |||||
|
1 | #include <fsw_processing.h> | |||
|
2 | ||||
|
3 | // WAVEFORMS GLOBAL VARIABLES | |||
|
4 | volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes | |||
|
5 | volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes | |||
|
6 | volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes | |||
|
7 | volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes | |||
|
8 | ||||
|
9 | // SPECTRAL MATRICES GLOBAL VARIABLES | |||
|
10 | volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ]; | |||
|
11 | volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ]; | |||
|
12 | volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ]; | |||
|
13 | volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ]; | |||
|
14 | volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ]; | |||
|
15 | volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ]; | |||
|
16 | volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ]; | |||
|
17 | volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ]; | |||
|
18 | // | |||
|
19 | float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ]; | |||
|
20 | float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ]; | |||
|
21 | ||||
|
22 | // BASIC PARAMETERS GLOBAL VAIRABLES | |||
|
23 | unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ]; | |||
|
24 | ||||
|
25 | BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ]; |
@@ -0,0 +1,250 | |||||
|
1 | //************************* | |||
|
2 | // GPL reminder to be added | |||
|
3 | //************************* | |||
|
4 | ||||
|
5 | #include <rtems.h> | |||
|
6 | ||||
|
7 | /* configuration information */ | |||
|
8 | ||||
|
9 | #define CONFIGURE_INIT | |||
|
10 | ||||
|
11 | #include <bsp.h> /* for device driver prototypes */ | |||
|
12 | ||||
|
13 | /* configuration information */ | |||
|
14 | ||||
|
15 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |||
|
16 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |||
|
17 | ||||
|
18 | #define CONFIGURE_MAXIMUM_TASKS 10 | |||
|
19 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE | |||
|
20 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) | |||
|
21 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 | |||
|
22 | #define CONFIGURE_INIT_TASK_PRIORITY 100 | |||
|
23 | #define CONFIGURE_MAXIMUM_DRIVERS 16 | |||
|
24 | #define CONFIGURE_MAXIMUM_PERIODS 1 | |||
|
25 | ||||
|
26 | #include <rtems/confdefs.h> | |||
|
27 | ||||
|
28 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ | |||
|
29 | #ifdef RTEMS_DRVMGR_STARTUP | |||
|
30 | #ifdef LEON3 | |||
|
31 | /* Add Timer and UART Driver */ | |||
|
32 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |||
|
33 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER | |||
|
34 | #endif | |||
|
35 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |||
|
36 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART | |||
|
37 | #endif | |||
|
38 | #endif | |||
|
39 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ | |||
|
40 | #include <drvmgr/drvmgr_confdefs.h> | |||
|
41 | #endif | |||
|
42 | ||||
|
43 | #include <fsw_init.h> | |||
|
44 | #include <fsw_config.c> | |||
|
45 | ||||
|
46 | int fdSPW; | |||
|
47 | int fdUART; | |||
|
48 | ||||
|
49 | char *link_status(int status); | |||
|
50 | ||||
|
51 | char *lstates[6] = {"Error-reset", | |||
|
52 | "Error-wait", | |||
|
53 | "Ready", | |||
|
54 | "Started", | |||
|
55 | "Connecting", | |||
|
56 | "Run" | |||
|
57 | }; | |||
|
58 | ||||
|
59 | rtems_id Task_id[10]; /* array of task ids */ | |||
|
60 | rtems_name Task_name[10]; /* array of task names */ | |||
|
61 | ||||
|
62 | rtems_task Init( rtems_task_argument ignored ) | |||
|
63 | { | |||
|
64 | rtems_status_code status; | |||
|
65 | ||||
|
66 | //send_console_outputs_on_serial_port(); | |||
|
67 | ||||
|
68 | InitLookUpTableForCRC(); // in tc_handler.h | |||
|
69 | ||||
|
70 | create_all_tasks(); | |||
|
71 | start_all_tasks(); | |||
|
72 | ||||
|
73 | configure_spw_link(); | |||
|
74 | // configure timer for spectral matrices simulation | |||
|
75 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, | |||
|
76 | IRQ_SPARC_SM, spectral_matrices_isr ); | |||
|
77 | // configure timer for waveforms simulation | |||
|
78 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR, | |||
|
79 | IRQ_SPARC_WF, waveforms_isr ); | |||
|
80 | ||||
|
81 | LEON_Unmask_interrupt( IRQ_SM ); | |||
|
82 | LEON_Unmask_interrupt( IRQ_WF ); | |||
|
83 | ||||
|
84 | status = rtems_task_delete(RTEMS_SELF); | |||
|
85 | } | |||
|
86 | ||||
|
87 | rtems_task spw_spiq_task(rtems_task_argument unused) | |||
|
88 | { | |||
|
89 | rtems_event_set event_out; | |||
|
90 | struct grspw_regs_str *grspw_regs; | |||
|
91 | grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW; | |||
|
92 | ||||
|
93 | while(1){ | |||
|
94 | PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n") | |||
|
95 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT | |||
|
96 | ||||
|
97 | if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task | |||
|
98 | PRINTF("In SPIQ *** Error suspending RECV Task\n") | |||
|
99 | ||||
|
100 | configure_spw_link(); | |||
|
101 | ||||
|
102 | if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task | |||
|
103 | PRINTF("In SPIQ *** Error resume RECV Task\n") | |||
|
104 | } | |||
|
105 | } | |||
|
106 | ||||
|
107 | int create_all_tasks() | |||
|
108 | { | |||
|
109 | rtems_status_code status; | |||
|
110 | ||||
|
111 | Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' ); | |||
|
112 | Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' ); | |||
|
113 | Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' ); | |||
|
114 | Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' ); | |||
|
115 | Task_name[6] = rtems_build_name( 'A', 'V', 'F', '0' ); | |||
|
116 | Task_name[7] = rtems_build_name( 'B', 'P', 'F', '0' ); | |||
|
117 | Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |||
|
118 | ||||
|
119 | // RECV | |||
|
120 | status = rtems_task_create( | |||
|
121 | Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2, | |||
|
122 | RTEMS_DEFAULT_MODES, | |||
|
123 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1] | |||
|
124 | ); | |||
|
125 | // SPIQ | |||
|
126 | status = rtems_task_create( | |||
|
127 | Task_name[3], 50, RTEMS_MINIMUM_STACK_SIZE * 2, | |||
|
128 | RTEMS_DEFAULT_MODES, | |||
|
129 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[3] | |||
|
130 | ); | |||
|
131 | // SMIQ | |||
|
132 | status = rtems_task_create( | |||
|
133 | Task_name[4], 10, RTEMS_MINIMUM_STACK_SIZE * 2, | |||
|
134 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |||
|
135 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[4] | |||
|
136 | ); | |||
|
137 | // STAT | |||
|
138 | status = rtems_task_create( | |||
|
139 | Task_name[5], 200, RTEMS_MINIMUM_STACK_SIZE * 2, | |||
|
140 | RTEMS_DEFAULT_MODES, | |||
|
141 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[5] | |||
|
142 | ); | |||
|
143 | // AVF0 | |||
|
144 | status = rtems_task_create( | |||
|
145 | Task_name[6], 50, RTEMS_MINIMUM_STACK_SIZE * 2, | |||
|
146 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |||
|
147 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[6] | |||
|
148 | ); | |||
|
149 | // BPF0 | |||
|
150 | status = rtems_task_create( | |||
|
151 | Task_name[7], 50, RTEMS_MINIMUM_STACK_SIZE * 2, | |||
|
152 | RTEMS_DEFAULT_MODES, | |||
|
153 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[7] | |||
|
154 | ); | |||
|
155 | // WFRM | |||
|
156 | status = rtems_task_create( | |||
|
157 | Task_name[8], 100, RTEMS_MINIMUM_STACK_SIZE * 2, | |||
|
158 | RTEMS_DEFAULT_MODES, | |||
|
159 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[8] | |||
|
160 | ); | |||
|
161 | ||||
|
162 | return 0; | |||
|
163 | } | |||
|
164 | ||||
|
165 | int start_all_tasks() | |||
|
166 | { | |||
|
167 | rtems_status_code status; | |||
|
168 | ||||
|
169 | status = rtems_task_start( Task_id[3], spw_spiq_task, 1 ); | |||
|
170 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n") | |||
|
171 | ||||
|
172 | status = rtems_task_start( Task_id[1], spw_recv_task, 1 ); | |||
|
173 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n") | |||
|
174 | ||||
|
175 | //status = rtems_task_start( Task_id[4], spw_bppr_task_rate_monotonic, 1 ); | |||
|
176 | status = rtems_task_start( Task_id[4], spw_smiq_task, 1 ); | |||
|
177 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n") | |||
|
178 | ||||
|
179 | status = rtems_task_start( Task_id[5], spw_stat_task, 1 ); | |||
|
180 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n") | |||
|
181 | ||||
|
182 | status = rtems_task_start( Task_id[6], spw_avf0_task, 1 ); | |||
|
183 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n") | |||
|
184 | ||||
|
185 | status = rtems_task_start( Task_id[7], spw_bpf0_task, 1 ); | |||
|
186 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n") | |||
|
187 | ||||
|
188 | status = rtems_task_start( Task_id[8], spw_wfrm_task, 1 ); | |||
|
189 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n") | |||
|
190 | ||||
|
191 | return 0; | |||
|
192 | } | |||
|
193 | ||||
|
194 | int configure_spw_link() | |||
|
195 | { | |||
|
196 | rtems_status_code status; | |||
|
197 | ||||
|
198 | close(fdSPW); // close the device if it is already open | |||
|
199 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware | |||
|
200 | if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n") | |||
|
201 | while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){ | |||
|
202 | PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n") | |||
|
203 | close(fdSPW); // close the device | |||
|
204 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware | |||
|
205 | if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n") | |||
|
206 | rtems_task_wake_after(100); | |||
|
207 | } | |||
|
208 | ||||
|
209 | PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n") | |||
|
210 | ||||
|
211 | // sets a few parameters of the link | |||
|
212 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit | |||
|
213 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n") | |||
|
214 | // | |||
|
215 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception | |||
|
216 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |||
|
217 | // | |||
|
218 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[3]); // sets the task ID to which an event is sent when a | |||
|
219 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |||
|
220 | // | |||
|
221 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts | |||
|
222 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |||
|
223 | // | |||
|
224 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit | |||
|
225 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |||
|
226 | ||||
|
227 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit | |||
|
228 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |||
|
229 | // | |||
|
230 | //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key | |||
|
231 | //if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |||
|
232 | // | |||
|
233 | PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n") | |||
|
234 | ||||
|
235 | return RTEMS_SUCCESSFUL; | |||
|
236 | } | |||
|
237 | ||||
|
238 | char *link_status(int status){ | |||
|
239 | return lstates[status]; | |||
|
240 | } | |||
|
241 | ||||
|
242 | rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send) | |||
|
243 | { | |||
|
244 | rtems_status_code status; | |||
|
245 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); | |||
|
246 | if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n"); | |||
|
247 | return status; | |||
|
248 | } | |||
|
249 | ||||
|
250 |
@@ -0,0 +1,73 | |||||
|
1 | #include <fsw_misc.h> | |||
|
2 | #include <fsw_params.h> | |||
|
3 | ||||
|
4 | extern rtems_id Task_id[]; /* array of task ids */ | |||
|
5 | extern int fdSPW; | |||
|
6 | ||||
|
7 | int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, | |||
|
8 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) | |||
|
9 | { // configure the timer for the waveforms simulation | |||
|
10 | rtems_status_code status; | |||
|
11 | rtems_isr_entry old_isr_handler; | |||
|
12 | ||||
|
13 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels | |||
|
14 | //if (status==RTEMS_SUCCESSFUL) PRINTF("In configure_timer_for_wf_simulation *** rtems_interrupt_catch successfullly configured\n") | |||
|
15 | ||||
|
16 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz | |||
|
17 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any | |||
|
18 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register | |||
|
19 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer | |||
|
20 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart | |||
|
21 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable | |||
|
22 | ||||
|
23 | return 1; | |||
|
24 | } | |||
|
25 | ||||
|
26 | void print_statistics(spw_stats *stats) | |||
|
27 | { | |||
|
28 | //printf(" ******** STATISTICS ******** \n"); | |||
|
29 | printf("Transmit link errors: %i\n", stats->tx_link_err); | |||
|
30 | printf("Receiver RMAP header CRC errors: %i\n", stats->rx_rmap_header_crc_err); | |||
|
31 | printf("Receiver RMAP data CRC errors: %i\n", stats->rx_rmap_data_crc_err); | |||
|
32 | printf("Receiver EEP errors: %i\n", stats->rx_eep_err); | |||
|
33 | printf("Receiver truncation errors: %i\n", stats->rx_truncated); | |||
|
34 | printf("Parity errors: %i\n", stats->parity_err); | |||
|
35 | printf("Escape errors: %i\n", stats->escape_err); | |||
|
36 | printf("Credit errors: %i\n", stats->credit_err); | |||
|
37 | printf("Disconnect errors: %i\n", stats->disconnect_err); | |||
|
38 | printf("Write synchronization errors: %i\n", stats->write_sync_err); | |||
|
39 | printf("Early EOP/EEP: %i\n", stats->early_ep); | |||
|
40 | printf("Invalid Node Address: %i\n", stats->invalid_address); | |||
|
41 | printf("Packets transmitted: %i\n", stats->packets_sent); | |||
|
42 | printf("Packets received: %i\n", stats->packets_received); | |||
|
43 | } | |||
|
44 | ||||
|
45 | int send_console_outputs_on_serial_port() // Send the console outputs on the serial port | |||
|
46 | { | |||
|
47 | struct apbuart_regs_str *apbuart_regs; | |||
|
48 | ||||
|
49 | apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |||
|
50 | apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB; | |||
|
51 | PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") | |||
|
52 | ||||
|
53 | return 0; | |||
|
54 | } | |||
|
55 | ||||
|
56 | rtems_task spw_stat_task(rtems_task_argument argument) | |||
|
57 | { | |||
|
58 | int i; | |||
|
59 | i = 0; | |||
|
60 | PRINTF("In STAT *** \n") | |||
|
61 | while(1){ | |||
|
62 | rtems_task_wake_after(1000); | |||
|
63 | PRINTF1("%d\n", i) | |||
|
64 | if (i == 2) { | |||
|
65 | rtems_cpu_usage_report(); | |||
|
66 | rtems_cpu_usage_reset(); | |||
|
67 | i = 0; | |||
|
68 | } | |||
|
69 | else i++; | |||
|
70 | } | |||
|
71 | } | |||
|
72 | ||||
|
73 |
@@ -0,0 +1,423 | |||||
|
1 | #include <fsw_processing.h> | |||
|
2 | #include <math.h> | |||
|
3 | #include <stdio.h> | |||
|
4 | #include <leon.h> | |||
|
5 | ||||
|
6 | float k14_re = 1; | |||
|
7 | float k14_im = 1; | |||
|
8 | float k14_bis_re = 1; | |||
|
9 | float k14_bis_im = 1; | |||
|
10 | float k14_tris_re = 1; | |||
|
11 | float k14_tris_im = 1; | |||
|
12 | float k15_re = 1; | |||
|
13 | float k15_im = 1; | |||
|
14 | float k15_bis_re = 1; | |||
|
15 | float k15_bis_im = 1; | |||
|
16 | float k24_re = 1; | |||
|
17 | float k24_im = 1; | |||
|
18 | float k24_bis_re = 1; | |||
|
19 | float k24_bis_im = 1; | |||
|
20 | float k24_tris_re = 1; | |||
|
21 | float k24_tris_im = 1; | |||
|
22 | float k25_re = 1; | |||
|
23 | float k25_im = 1; | |||
|
24 | float k25_bis_re = 1; | |||
|
25 | float k25_bis_im = 1; | |||
|
26 | float k34_re = 1; | |||
|
27 | float k34_im = 1; | |||
|
28 | float k44 = 1; | |||
|
29 | float k55 = 1; | |||
|
30 | float k45_re = 1; | |||
|
31 | float k45_im = 1; | |||
|
32 | float alpha_M = M_PI/4; | |||
|
33 | ||||
|
34 | extern volatile int spec_mat_f0_a[ ]; | |||
|
35 | extern volatile int spec_mat_f0_b[ ]; | |||
|
36 | extern volatile int spec_mat_f0_c[ ]; | |||
|
37 | extern volatile int spec_mat_f0_d[ ]; | |||
|
38 | extern volatile int spec_mat_f0_e[ ]; | |||
|
39 | extern volatile int spec_mat_f0_f[ ]; | |||
|
40 | extern volatile int spec_mat_f0_g[ ]; | |||
|
41 | extern volatile int spec_mat_f0_h[ ]; | |||
|
42 | extern float averaged_spec_mat_f0[ ]; | |||
|
43 | extern float compressed_spec_mat_f0[ ]; | |||
|
44 | extern unsigned char LFR_BP1_F0[ ]; | |||
|
45 | ||||
|
46 | extern BP1_t data_BP1[ ]; | |||
|
47 | ||||
|
48 | extern rtems_id Task_id[ ]; /* array of task ids */ | |||
|
49 | ||||
|
50 | spectral_matrices_regs_t *spectral_matrices_regs; | |||
|
51 | ||||
|
52 | // Interrupt Service Routine for spectral matrices processing | |||
|
53 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) | |||
|
54 | { | |||
|
55 | if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |||
|
56 | printf("In spectral_matrices_isr *** Error sending event to AVF0\n"); | |||
|
57 | } | |||
|
58 | ||||
|
59 | rtems_task spw_smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ | |||
|
60 | { | |||
|
61 | rtems_event_set event_out; | |||
|
62 | gptimer_regs_t *gptimer_regs; | |||
|
63 | gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; | |||
|
64 | unsigned char nb_interrupt_f0 = 0; | |||
|
65 | ||||
|
66 | while(1){ | |||
|
67 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |||
|
68 | nb_interrupt_f0 = nb_interrupt_f0 + 1; | |||
|
69 | if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){ | |||
|
70 | if (rtems_event_send( Task_id[6], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |||
|
71 | printf("In spw_smiq_task *** Error sending event to AVF0\n"); | |||
|
72 | nb_interrupt_f0 = 0; | |||
|
73 | } | |||
|
74 | gptimer_regs->timer[1].ctrl = gptimer_regs->timer[1].ctrl | 0x00000010; | |||
|
75 | } | |||
|
76 | } | |||
|
77 | ||||
|
78 | rtems_task spw_bppr_task(rtems_task_argument argument) | |||
|
79 | { | |||
|
80 | rtems_status_code status; | |||
|
81 | rtems_event_set event_out; | |||
|
82 | static int nb_average_f0 = 0; | |||
|
83 | //static int nb_average_f1 = 0; | |||
|
84 | //static int nb_average_f2 = 0; | |||
|
85 | ||||
|
86 | while(1) | |||
|
87 | ||||
|
88 | spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES; | |||
|
89 | spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a; | |||
|
90 | spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b; | |||
|
91 | ||||
|
92 | printf("In BPPR ***\n"); | |||
|
93 | ||||
|
94 | while(1){ // wait for an event to begin with the processing | |||
|
95 | status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); | |||
|
96 | if (status == RTEMS_SUCCESSFUL){ | |||
|
97 | if ((spectral_matrices_regs->ctrl & 0x00000001)==1){ | |||
|
98 | matrix_average(spec_mat_f0_a, averaged_spec_mat_f0); | |||
|
99 | spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; | |||
|
100 | //printf("f0_a\n"); | |||
|
101 | nb_average_f0++; | |||
|
102 | } | |||
|
103 | if (((spectral_matrices_regs->ctrl>>1) & 0x00000001)==1){ | |||
|
104 | matrix_average(spec_mat_f0_b, compressed_spec_mat_f0); | |||
|
105 | spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffd; | |||
|
106 | //printf("f0_b\n"); | |||
|
107 | nb_average_f0++; | |||
|
108 | } | |||
|
109 | if (nb_average_f0 == NB_AVERAGE_NORMAL_f0){ | |||
|
110 | matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0); | |||
|
111 | //printf("f0 compressed\n"); | |||
|
112 | nb_average_f0 = 0; | |||
|
113 | matrix_reset(averaged_spec_mat_f0); | |||
|
114 | } | |||
|
115 | } | |||
|
116 | } | |||
|
117 | } | |||
|
118 | ||||
|
119 | void matrix_average(volatile int *spec_mat, float *averaged_spec_mat) | |||
|
120 | { | |||
|
121 | int i; | |||
|
122 | for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){ | |||
|
123 | averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_a[i] | |||
|
124 | + spec_mat_f0_b[i] | |||
|
125 | + spec_mat_f0_c[i] | |||
|
126 | + spec_mat_f0_d[i] | |||
|
127 | + spec_mat_f0_e[i] | |||
|
128 | + spec_mat_f0_f[i] | |||
|
129 | + spec_mat_f0_g[i] | |||
|
130 | + spec_mat_f0_h[i]; | |||
|
131 | } | |||
|
132 | } | |||
|
133 | ||||
|
134 | void matrix_reset(float *averaged_spec_mat) | |||
|
135 | { | |||
|
136 | int i; | |||
|
137 | for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){ | |||
|
138 | averaged_spec_mat_f0[i] = 0; | |||
|
139 | } | |||
|
140 | } | |||
|
141 | ||||
|
142 | void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat) | |||
|
143 | { | |||
|
144 | int i, j; | |||
|
145 | switch (fChannel){ | |||
|
146 | case 0: | |||
|
147 | for(i=0;i<NB_BINS_COMPRESSED_MATRIX_f0;i++){ | |||
|
148 | j = 17 + i * 8; | |||
|
149 | compressed_spec_mat[i] = (averaged_spec_mat[j] | |||
|
150 | + averaged_spec_mat[j+1] | |||
|
151 | + averaged_spec_mat[j+2] | |||
|
152 | + averaged_spec_mat[j+3] | |||
|
153 | + averaged_spec_mat[j+4] | |||
|
154 | + averaged_spec_mat[j+5] | |||
|
155 | + averaged_spec_mat[j+6] | |||
|
156 | + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0); | |||
|
157 | } | |||
|
158 | break; | |||
|
159 | case 1: | |||
|
160 | // case fChannel = f1 tp be completed later | |||
|
161 | break; | |||
|
162 | case 2: | |||
|
163 | // case fChannel = f1 tp be completed later | |||
|
164 | break; | |||
|
165 | default: | |||
|
166 | break; | |||
|
167 | } | |||
|
168 | } | |||
|
169 | ||||
|
170 | void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){ | |||
|
171 | int i, j; | |||
|
172 | unsigned char tmp_u_char; | |||
|
173 | unsigned char * pt_char; | |||
|
174 | float PSDB, PSDE; | |||
|
175 | float NVEC_V0, NVEC_V1, NVEC_V2; | |||
|
176 | float significand; | |||
|
177 | int exponent; | |||
|
178 | float aux, tr_SB_SB, tmp; | |||
|
179 | float e_cross_b_re, e_cross_b_im; | |||
|
180 | float n_cross_e_scal_b_re = 0, n_cross_e_scal_b_im = 0; | |||
|
181 | float nx = 0, ny = 0; | |||
|
182 | float bz_bz_star = 0; | |||
|
183 | for(i=0; i<nb_bins_compressed_spec_mat; i++){ | |||
|
184 | //============================================== | |||
|
185 | // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits | |||
|
186 | PSDB = compressed_spec_mat[i*30] // S11 | |||
|
187 | + compressed_spec_mat[i*30+10] // S22 | |||
|
188 | + compressed_spec_mat[i*30+18]; // S33 | |||
|
189 | significand = frexp(PSDB, &exponent); | |||
|
190 | pt_char = (unsigned char*) &PSDB; | |||
|
191 | LFR_BP1[i*9+8] = pt_char[0]; // bits 31 downto 24 of the float | |||
|
192 | LFR_BP1[i*9+7] = pt_char[1]; // bits 23 downto 16 of the float | |||
|
193 | //============================================== | |||
|
194 | // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits | |||
|
195 | PSDE = compressed_spec_mat[i*30+24] * k44 // S44 | |||
|
196 | + compressed_spec_mat[i*30+28] * k55 // S55 | |||
|
197 | + compressed_spec_mat[i*30+26] * k45_re // S45 | |||
|
198 | - compressed_spec_mat[i*30+27] * k45_im; // S45 | |||
|
199 | pt_char = (unsigned char*) &PSDE; | |||
|
200 | LFR_BP1[i*9+6] = pt_char[0]; // bits 31 downto 24 of the float | |||
|
201 | LFR_BP1[i*9+5] = pt_char[1]; // bits 23 downto 16 of the float | |||
|
202 | //============================================================================== | |||
|
203 | // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits | |||
|
204 | // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits | |||
|
205 | // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits | |||
|
206 | tmp = sqrt( | |||
|
207 | compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3] //Im S12 | |||
|
208 | +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5] //Im S13 | |||
|
209 | +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+13] //Im S23 | |||
|
210 | ); | |||
|
211 | NVEC_V0 = compressed_spec_mat[i*30+13] / tmp; // Im S23 | |||
|
212 | NVEC_V1 = -compressed_spec_mat[i*30+5] / tmp; // Im S13 | |||
|
213 | NVEC_V2 = compressed_spec_mat[i*30+1] / tmp; // Im S12 | |||
|
214 | LFR_BP1[i*9+4] = (char) (NVEC_V0*256); | |||
|
215 | LFR_BP1[i*9+3] = (char) (NVEC_V1*256); | |||
|
216 | pt_char = (unsigned char*) &NVEC_V2; | |||
|
217 | LFR_BP1[i*9+2] = pt_char[0] & 0x80; // extract the sign of NVEC_V2 | |||
|
218 | //======================================================= | |||
|
219 | // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits | |||
|
220 | aux = 2*tmp / PSDB; // compute the ellipticity | |||
|
221 | tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity | |||
|
222 | LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char | |||
|
223 | //============================================================== | |||
|
224 | // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits | |||
|
225 | for(j = 0; j<NB_VALUES_PER_spec_mat;j++){ | |||
|
226 | tr_SB_SB = compressed_spec_mat[i*30]*compressed_spec_mat[i*30] | |||
|
227 | + compressed_spec_mat[i*30+10]*compressed_spec_mat[i*30+10] | |||
|
228 | + compressed_spec_mat[i*30+18]*compressed_spec_mat[i*30+18] | |||
|
229 | + 2 * compressed_spec_mat[i*30+2]*compressed_spec_mat[i*30+2] | |||
|
230 | + 2 * compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3] | |||
|
231 | + 2 * compressed_spec_mat[i*30+4]*compressed_spec_mat[i*30+4] | |||
|
232 | + 2 * compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5] | |||
|
233 | + 2 * compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+12] | |||
|
234 | + 2 * compressed_spec_mat[i*30+13]*compressed_spec_mat[i*30+13]; | |||
|
235 | } | |||
|
236 | aux = PSDB*PSDB; | |||
|
237 | tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); | |||
|
238 | tmp_u_char = (unsigned char) (NVEC_V0*(8-1)); | |||
|
239 | LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x07)); // keeps 3 bits of the resulting unsigned char | |||
|
240 | //======================================================================================= | |||
|
241 | // BP1 z-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1) | |||
|
242 | e_cross_b_re = compressed_spec_mat[i*30+20]*k34_re | |||
|
243 | + compressed_spec_mat[i*30+6]*k14_re | |||
|
244 | + compressed_spec_mat[i*30+8]*k15_re | |||
|
245 | + compressed_spec_mat[i*30+14]*k24_re | |||
|
246 | + compressed_spec_mat[i*30+16]*k25_re; | |||
|
247 | e_cross_b_im = compressed_spec_mat[i*30+21]*k34_im | |||
|
248 | + compressed_spec_mat[i*30+7]*k14_im | |||
|
249 | + compressed_spec_mat[i*30+9]*k15_im | |||
|
250 | + compressed_spec_mat[i*30+15]*k24_im | |||
|
251 | + compressed_spec_mat[i*30+17]*k25_im; | |||
|
252 | tmp = e_cross_b_re / PSDE; // compute ReaSz | |||
|
253 | LFR_BP1[i*9+1] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive? | |||
|
254 | tmp = e_cross_b_re * e_cross_b_im; | |||
|
255 | pt_char = (unsigned char*) &tmp; | |||
|
256 | LFR_BP1[i*9+1] = LFR_BP1[i*9+1] | (pt_char[0] & 0x80); // extract the sign of ArgSz | |||
|
257 | //====================================================================== | |||
|
258 | // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1) | |||
|
259 | nx = -sin(alpha_M)*NVEC_V0 - cos(alpha_M)*NVEC_V1; | |||
|
260 | ny = NVEC_V2; | |||
|
261 | bz_bz_star = cos(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30] // re S11 | |||
|
262 | + sin(alpha_M) * sin(alpha_M) * compressed_spec_mat[i*30+10] // re S22 | |||
|
263 | - 2 * sin(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30+2]; // re S12 | |||
|
264 | n_cross_e_scal_b_re = nx * (compressed_spec_mat[i*30+8]*k15_bis_re | |||
|
265 | +compressed_spec_mat[i*30+6]*k14_bis_re | |||
|
266 | +compressed_spec_mat[i*30+16]*k25_bis_re | |||
|
267 | +compressed_spec_mat[i*30+14]*k24_bis_re) | |||
|
268 | + ny * (compressed_spec_mat[i*30+6]*k14_tris_re | |||
|
269 | +compressed_spec_mat[i*30+14]*k24_tris_re); | |||
|
270 | n_cross_e_scal_b_im = nx * (compressed_spec_mat[i*30+8]*k15_bis_im | |||
|
271 | +compressed_spec_mat[i*30+6]*k14_bis_im | |||
|
272 | +compressed_spec_mat[i*30+16]*k25_bis_im | |||
|
273 | +compressed_spec_mat[i*30+14]*k24_bis_im) | |||
|
274 | + ny * (compressed_spec_mat[i*30+6]*k14_tris_im | |||
|
275 | +compressed_spec_mat[i*30+14]*k24_tris_im); | |||
|
276 | tmp = n_cross_e_scal_b_re / bz_bz_star; | |||
|
277 | LFR_BP1[i*9+0] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive? | |||
|
278 | tmp = n_cross_e_scal_b_re * n_cross_e_scal_b_im; | |||
|
279 | pt_char = (unsigned char*) &tmp; | |||
|
280 | LFR_BP1[i*9+1] = LFR_BP1[i*9+0] | (pt_char[0] & 0x80); // extract the sign of ArgV | |||
|
281 | } | |||
|
282 | ||||
|
283 | } | |||
|
284 | ||||
|
285 | void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){ | |||
|
286 | // BP2 autocorrelation | |||
|
287 | int i, aux = 0; | |||
|
288 | for(i = 0; i<nb_bins_compressed_spec_mat; i++){ | |||
|
289 | // S12 | |||
|
290 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+10]); | |||
|
291 | compressed_spec_mat[i*30+2] = compressed_spec_mat[i*30+2] / aux; | |||
|
292 | compressed_spec_mat[i*30+3] = compressed_spec_mat[i*30+3] / aux; | |||
|
293 | // S13 | |||
|
294 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+18]); | |||
|
295 | compressed_spec_mat[i*30+4] = compressed_spec_mat[i*30+4] / aux; | |||
|
296 | compressed_spec_mat[i*30+5] = compressed_spec_mat[i*30+5] / aux; | |||
|
297 | // S23 | |||
|
298 | aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+18]); | |||
|
299 | compressed_spec_mat[i*30+12] = compressed_spec_mat[i*30+12] / aux; | |||
|
300 | compressed_spec_mat[i*30+13] = compressed_spec_mat[i*30+13] / aux; | |||
|
301 | // S45 | |||
|
302 | aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[i*30+28]); | |||
|
303 | compressed_spec_mat[i*30+26] = compressed_spec_mat[i*30+26] / aux; | |||
|
304 | compressed_spec_mat[i*30+27] = compressed_spec_mat[i*30+27] / aux; | |||
|
305 | // S14 | |||
|
306 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+24]); | |||
|
307 | compressed_spec_mat[i*30+6] = compressed_spec_mat[i*30+6] / aux; | |||
|
308 | compressed_spec_mat[i*30+7] = compressed_spec_mat[i*30+7] / aux; | |||
|
309 | // S15 | |||
|
310 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+28]); | |||
|
311 | compressed_spec_mat[i*30+8] = compressed_spec_mat[i*30+8] / aux; | |||
|
312 | compressed_spec_mat[i*30+9] = compressed_spec_mat[i*30+9] / aux; | |||
|
313 | // S24 | |||
|
314 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+24]); | |||
|
315 | compressed_spec_mat[i*30+14] = compressed_spec_mat[i*30+14] / aux; | |||
|
316 | compressed_spec_mat[i*30+15] = compressed_spec_mat[i*30+15] / aux; | |||
|
317 | // S25 | |||
|
318 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+28]); | |||
|
319 | compressed_spec_mat[i*30+16] = compressed_spec_mat[i*30+16] / aux; | |||
|
320 | compressed_spec_mat[i*30+17] = compressed_spec_mat[i*30+17] / aux; | |||
|
321 | // S34 | |||
|
322 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+24]); | |||
|
323 | compressed_spec_mat[i*30+20] = compressed_spec_mat[i*30+20] / aux; | |||
|
324 | compressed_spec_mat[i*30+21] = compressed_spec_mat[i*30+21] / aux; | |||
|
325 | // S35 | |||
|
326 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+28]); | |||
|
327 | compressed_spec_mat[i*30+22] = compressed_spec_mat[i*30+22] / aux; | |||
|
328 | compressed_spec_mat[i*30+23] = compressed_spec_mat[i*30+23] / aux; | |||
|
329 | } | |||
|
330 | } | |||
|
331 | ||||
|
332 | rtems_task spw_avf0_task(rtems_task_argument argument){ | |||
|
333 | int i; | |||
|
334 | static int nb_average; | |||
|
335 | rtems_event_set event_out; | |||
|
336 | rtems_status_code status; | |||
|
337 | ||||
|
338 | spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES; | |||
|
339 | spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a; | |||
|
340 | spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b; | |||
|
341 | ||||
|
342 | nb_average = 0; | |||
|
343 | ||||
|
344 | PRINTF("In AVFO *** \n") | |||
|
345 | ||||
|
346 | while(1){ | |||
|
347 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |||
|
348 | for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){ | |||
|
349 | averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i] | |||
|
350 | + spec_mat_f0_b[i] | |||
|
351 | + spec_mat_f0_c[i] | |||
|
352 | + spec_mat_f0_d[i] | |||
|
353 | + spec_mat_f0_e[i] | |||
|
354 | + spec_mat_f0_f[i] | |||
|
355 | + spec_mat_f0_g[i] | |||
|
356 | + spec_mat_f0_h[i]; | |||
|
357 | } | |||
|
358 | spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register | |||
|
359 | nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0; | |||
|
360 | if (nb_average == NB_AVERAGE_NORMAL_f0) { | |||
|
361 | nb_average = 0; | |||
|
362 | status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0 | |||
|
363 | if (status != RTEMS_SUCCESSFUL) printf("IN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status); | |||
|
364 | } | |||
|
365 | } | |||
|
366 | } | |||
|
367 | ||||
|
368 | rtems_task spw_bpf0_task(rtems_task_argument argument){ | |||
|
369 | rtems_event_set event_out; | |||
|
370 | ||||
|
371 | while(1){ | |||
|
372 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |||
|
373 | matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0); | |||
|
374 | BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0); | |||
|
375 | //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n") | |||
|
376 | } | |||
|
377 | } | |||
|
378 | ||||
|
379 | //******* | |||
|
380 | // UNUSED | |||
|
381 | rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument) | |||
|
382 | {/* | |||
|
383 | rtems_status_code status; | |||
|
384 | //static int nb_average_f1 = 0; | |||
|
385 | //static int nb_average_f2 = 0; | |||
|
386 | ||||
|
387 | rtems_name name; | |||
|
388 | rtems_id period; | |||
|
389 | name = rtems_build_name( 'P', 'E', 'R', 'D' ); | |||
|
390 | status = rtems_rate_monotonic_create( name, &period ); | |||
|
391 | if( status != RTEMS_SUCCESSFUL ) { | |||
|
392 | printf( "rtems_rate_monotonic_create failed with status of %d\n", status ); | |||
|
393 | //exit( 1 ); | |||
|
394 | } | |||
|
395 | ||||
|
396 | spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES; | |||
|
397 | spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a; | |||
|
398 | spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b; | |||
|
399 | ||||
|
400 | printf("In BPPR BIS ***\n"); | |||
|
401 | ||||
|
402 | while(1){ // launch the rate monotonic task | |||
|
403 | if ( rtems_rate_monotonic_period( period, 8 ) == RTEMS_TIMEOUT ){ | |||
|
404 | printf("TIMEOUT\n"); | |||
|
405 | //break; | |||
|
406 | } | |||
|
407 | status = rtems_event_send( Task_id[6], RTEMS_EVENT_0 ); // sending an event to the task 6, AVF0 | |||
|
408 | if (status != RTEMS_SUCCESSFUL) printf("IN TASK BPPR BIS *** Error sending RTEMS_EVENT_0 to AVF0, code %d\n", status); | |||
|
409 | } | |||
|
410 | ||||
|
411 | status = rtems_rate_monotonic_delete( period ); | |||
|
412 | if ( status != RTEMS_SUCCESSFUL ) { | |||
|
413 | printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status ); | |||
|
414 | //exit( 1 ); | |||
|
415 | } | |||
|
416 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |||
|
417 | printf( "rtems_task_delete returned with status of %d.\n", status ); | |||
|
418 | //exit( 1 );*/ | |||
|
419 | } | |||
|
420 | ||||
|
421 | ||||
|
422 | ||||
|
423 |
@@ -0,0 +1,319 | |||||
|
1 | #include <tc_handler.h> | |||
|
2 | #include <fsw_params.h> | |||
|
3 | ||||
|
4 | char *errorCCSDSMsg[8] = { "ILLEGAL_APID 0", | |||
|
5 | "WRONG_LEN_PACKET 1", | |||
|
6 | "INCOR_CHECKSUM 2", | |||
|
7 | "ILL_TYPE 3", | |||
|
8 | "ILL_SUBTYPE 4", | |||
|
9 | "WRONG_APP_DATA 5", | |||
|
10 | "WRONG_CMD_CODE 6", | |||
|
11 | "CCSDS_TM_VALID 7" | |||
|
12 | }; | |||
|
13 | ||||
|
14 | unsigned int Crc_opt( unsigned char D, unsigned int Chk) | |||
|
15 | { | |||
|
16 | return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); | |||
|
17 | } | |||
|
18 | ||||
|
19 | void InitLookUpTableForCRC() | |||
|
20 | { | |||
|
21 | unsigned int i, tmp; | |||
|
22 | for (i=0; i<256; i++) | |||
|
23 | { | |||
|
24 | tmp = 0; | |||
|
25 | if((i & 1) != 0) tmp = tmp ^ 0x1021; | |||
|
26 | if((i & 2) != 0) tmp = tmp ^ 0x2042; | |||
|
27 | if((i & 4) != 0) tmp = tmp ^ 0x4084; | |||
|
28 | if((i & 8) != 0) tmp = tmp ^ 0x8108; | |||
|
29 | if((i & 16) != 0) tmp = tmp ^ 0x1231; | |||
|
30 | if((i & 32) != 0) tmp = tmp ^ 0x2462; | |||
|
31 | if((i & 64) != 0) tmp = tmp ^ 0x48c4; | |||
|
32 | if((i & 128) != 0) tmp = tmp ^ 0x9188; | |||
|
33 | lookUpTableForCRC[i] = tmp; | |||
|
34 | } | |||
|
35 | } | |||
|
36 | ||||
|
37 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData) | |||
|
38 | { | |||
|
39 | unsigned int Chk; | |||
|
40 | int j; | |||
|
41 | Chk = 0xffff; // reset the syndrom to all ones | |||
|
42 | for (j=0; j<sizeOfData; j++) { | |||
|
43 | Chk = Crc_opt(data[j], Chk); | |||
|
44 | } | |||
|
45 | crcAsTwoBytes[0] = (unsigned char) (Chk >> 8); | |||
|
46 | crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff); | |||
|
47 | } | |||
|
48 | ||||
|
49 | unsigned int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV, | |||
|
50 | TMHeader_t *TM_Header, unsigned int *hlen, char *data) | |||
|
51 | { | |||
|
52 | unsigned int code = 0; | |||
|
53 | unsigned int data_length = 0; | |||
|
54 | unsigned char computed_CRC[2]; | |||
|
55 | unsigned char subtype = 0; | |||
|
56 | ||||
|
57 | subtype = TC->dataFieldHeader[2]; | |||
|
58 | GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, TC_LEN_RCV + 5 ); | |||
|
59 | code = acceptTM( TC, TC_LEN_RCV ) ; | |||
|
60 | //PRINTF1("in TC_checker *** %s\n", errorCCSDSMsg[code]); | |||
|
61 | if ( (code == 0) | (code == 1) | (code == 2) | |||
|
62 | | (code == 3) | (code == 4) | (code == 5) ) | |||
|
63 | { // generate TM_LFR_TC_EXE_CORRUPTED | |||
|
64 | // BUILD HEADER | |||
|
65 | TM_build_header( TM_LFR_TC_EXE_ERR, SID_EXE_CORR, TM_LEN_EXE_CORR, 0, 0, TM_Header); | |||
|
66 | // BUILD DATA | |||
|
67 | TM_build_data( TC, data, SID_EXE_CORR, computed_CRC); | |||
|
68 | data_length = TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN; | |||
|
69 | } | |||
|
70 | if (subtype == SID_TC_UPDT_TIME){ | |||
|
71 | // BUILD HEADER | |||
|
72 | TM_build_header( TM_LFR_TC_EXE_OK, SID_DEFAULT, TM_LEN_EXE, 0, 0, TM_Header); | |||
|
73 | // BUILD DATA | |||
|
74 | TM_build_data( TC, data, SID_DEFAULT, computed_CRC); | |||
|
75 | data_length = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN; | |||
|
76 | } | |||
|
77 | else { // TM_LFR_TC_EXE_NOT_IMPLEMENTED | |||
|
78 | // BUILD HEADER | |||
|
79 | TM_build_header( TM_LFR_TC_EXE_ERR, SID_NOT_IMP, TM_LEN_NOT_IMP, 0, 0, TM_Header); | |||
|
80 | // BUILD DATA | |||
|
81 | TM_build_data( TC, data, SID_NOT_IMP, computed_CRC); | |||
|
82 | data_length = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN; | |||
|
83 | } | |||
|
84 | ||||
|
85 | return data_length; | |||
|
86 | } | |||
|
87 | ||||
|
88 | unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV) | |||
|
89 | { | |||
|
90 | unsigned char pid = 0; | |||
|
91 | unsigned char category = 0; | |||
|
92 | unsigned int length = 0; | |||
|
93 | unsigned char packetType = 0; | |||
|
94 | unsigned char packetSubtype = 0; | |||
|
95 | unsigned char * CCSDSContent; | |||
|
96 | ||||
|
97 | // APID check *** APID on 2 bytes | |||
|
98 | pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx | |||
|
99 | category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 | |||
|
100 | if (pid!=CCSDS_PROCESS_ID) return ILLEGAL_APID; | |||
|
101 | if (category!=CCSDS_PACKET_CATEGORY) return ILLEGAL_APID; | |||
|
102 | ||||
|
103 | // packet length check | |||
|
104 | length = TMPacket->packetLength[0] * 256 + TMPacket->packetLength[1]; | |||
|
105 | if (length != TC_LEN_RCV ) return WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD | |||
|
106 | if (length >= CCSDS_TC_PKT_MAX_SIZE) return WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size | |||
|
107 | ||||
|
108 | packetType = TMPacket->dataFieldHeader[1]; | |||
|
109 | packetSubtype = TMPacket->dataFieldHeader[2]; | |||
|
110 | // service type, subtype and packet length check | |||
|
111 | if (packetType == 181){ | |||
|
112 | switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61 | |||
|
113 | case 3: | |||
|
114 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
115 | break; | |||
|
116 | case 20: | |||
|
117 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
118 | break; | |||
|
119 | case 21: | |||
|
120 | if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
121 | break; | |||
|
122 | case 24: | |||
|
123 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
124 | break; | |||
|
125 | case 27: | |||
|
126 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
127 | break; | |||
|
128 | case 28: | |||
|
129 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
130 | break; | |||
|
131 | case 30: | |||
|
132 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
133 | break; | |||
|
134 | case 40: | |||
|
135 | if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
136 | break; | |||
|
137 | case 50: | |||
|
138 | if (length!=(50-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
139 | break; | |||
|
140 | case 60: | |||
|
141 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
142 | break; | |||
|
143 | case 61: | |||
|
144 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
145 | break; | |||
|
146 | default: | |||
|
147 | return ILL_SUBTYPE; | |||
|
148 | break; | |||
|
149 | } | |||
|
150 | } | |||
|
151 | else if (packetType == 9){ | |||
|
152 | if (packetSubtype!=129) return ILL_SUBTYPE; | |||
|
153 | if (length!=(18-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; | |||
|
154 | } | |||
|
155 | else return ILL_TYPE; | |||
|
156 | ||||
|
157 | // source ID check // Source ID not documented in the ICD | |||
|
158 | ||||
|
159 | // packet error control, CRC check | |||
|
160 | CCSDSContent = (unsigned char*) TMPacket->packetID; | |||
|
161 | GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC | |||
|
162 | if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) return INCOR_CHECKSUM; | |||
|
163 | if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) return INCOR_CHECKSUM; | |||
|
164 | ||||
|
165 | return CCSDS_TM_VALID; | |||
|
166 | } | |||
|
167 | ||||
|
168 | unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength, | |||
|
169 | unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader) | |||
|
170 | { | |||
|
171 | TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID; | |||
|
172 | TMHeader->protocolIdentifier = 0x02; | |||
|
173 | TMHeader->reserved = 0x00; | |||
|
174 | TMHeader->userApplication = 0x00; | |||
|
175 | TMHeader->packetID[0] = 0x0c; | |||
|
176 | TMHeader->packetSequenceControl[0] = 0xc0; | |||
|
177 | TMHeader->packetSequenceControl[1] = 0x00; | |||
|
178 | TMHeader->packetLength[0] = (unsigned char) (packetLength>>8); | |||
|
179 | TMHeader->packetLength[1] = (unsigned char) packetLength; | |||
|
180 | TMHeader->dataFieldHeader[0] = 0x10; | |||
|
181 | TMHeader->dataFieldHeader[3] = CCSDS_DESTINATION_ID; | |||
|
182 | switch (tm_type){ | |||
|
183 | case(TM_LFR_TC_EXE_OK): | |||
|
184 | TMHeader->packetID[1] = 0xc1; | |||
|
185 | TMHeader->dataFieldHeader[1] = 1; // type | |||
|
186 | TMHeader->dataFieldHeader[2] = 7; // subtype | |||
|
187 | break; | |||
|
188 | case(TM_LFR_TC_EXE_ERR): | |||
|
189 | TMHeader->packetID[1] = 0xc1; | |||
|
190 | TMHeader->dataFieldHeader[1] = 1; // type | |||
|
191 | TMHeader->dataFieldHeader[2] = 8; // subtype | |||
|
192 | break; | |||
|
193 | case(TM_LFR_HK): | |||
|
194 | TMHeader->packetID[1] = 0xc4; | |||
|
195 | TMHeader->dataFieldHeader[1] = 3; // type | |||
|
196 | TMHeader->dataFieldHeader[2] = 25; // subtype | |||
|
197 | break; | |||
|
198 | case(TM_LFR_SCI): | |||
|
199 | TMHeader->packetID[1] = 0xcc; | |||
|
200 | TMHeader->dataFieldHeader[1] = 21; // type | |||
|
201 | TMHeader->dataFieldHeader[2] = 3; // subtype | |||
|
202 | break; | |||
|
203 | case(TM_LFR_SCI_SBM): | |||
|
204 | TMHeader->packetID[1] = 0xfc; | |||
|
205 | TMHeader->dataFieldHeader[1] = 21; // type | |||
|
206 | TMHeader->dataFieldHeader[2] = 3; // subtype | |||
|
207 | break; | |||
|
208 | case(TM_LFR_PAR_DUMP): | |||
|
209 | TMHeader->packetID[1] = 0xc9; | |||
|
210 | TMHeader->dataFieldHeader[1] = 181; // type | |||
|
211 | TMHeader->dataFieldHeader[2] = 31; // subtype | |||
|
212 | break; | |||
|
213 | default: | |||
|
214 | return 0; | |||
|
215 | } | |||
|
216 | /*TMHeader->dataFieldHeader[4] = (unsigned char) (coarseTime>>24); | |||
|
217 | TMHeader->dataFieldHeader[5] = (unsigned char) (coarseTime>>16); | |||
|
218 | TMHeader->dataFieldHeader[6] = (unsigned char) (coarseTime>>8); | |||
|
219 | TMHeader->dataFieldHeader[7] = (unsigned char) (coarseTime); | |||
|
220 | TMHeader->dataFieldHeader[8] = (unsigned char) (fineTime>>8); | |||
|
221 | TMHeader->dataFieldHeader[9] = (unsigned char) (fineTime);*/ | |||
|
222 | TMHeader->dataFieldHeader[4] = 0xaa; | |||
|
223 | TMHeader->dataFieldHeader[5] = 0xbb; | |||
|
224 | TMHeader->dataFieldHeader[6] = 0xcc; | |||
|
225 | TMHeader->dataFieldHeader[7] = 0xdd; | |||
|
226 | TMHeader->dataFieldHeader[8] = 0xee; | |||
|
227 | TMHeader->dataFieldHeader[9] = 0xff; | |||
|
228 | return 1; | |||
|
229 | } | |||
|
230 | ||||
|
231 | unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC) | |||
|
232 | { | |||
|
233 | unsigned int packetLength; | |||
|
234 | packetLength = TC->packetLength[0] * 256 + TC->packetLength[1]; | |||
|
235 | switch (SID){ | |||
|
236 | case (SID_NOT_EXE): | |||
|
237 | break; | |||
|
238 | case (SID_NOT_IMP): | |||
|
239 | data[0] = 0x9c; | |||
|
240 | data[1] = 0x42; | |||
|
241 | data[2] = TC->packetID[0]; | |||
|
242 | data[3] = TC->packetID[1]; | |||
|
243 | data[4] = TC->packetSequenceControl[0]; | |||
|
244 | data[5] = TC->packetSequenceControl[1]; | |||
|
245 | data[6] = TC->dataFieldHeader[1]; // type | |||
|
246 | data[7] = TC->dataFieldHeader[2]; // subtype | |||
|
247 | break; | |||
|
248 | case (SID_EXE_ERR): | |||
|
249 | break; | |||
|
250 | case (SID_EXE_CORR): | |||
|
251 | data[0] = 0x9c; | |||
|
252 | data[1] = 0x45; | |||
|
253 | data[2] = TC->packetID[0]; | |||
|
254 | data[3] = TC->packetID[1]; | |||
|
255 | data[4] = TC->packetSequenceControl[0]; | |||
|
256 | data[5] = TC->packetSequenceControl[1]; | |||
|
257 | data[6] = TC->dataFieldHeader[1]; // type | |||
|
258 | data[7] = TC->dataFieldHeader[2]; // subtype | |||
|
259 | data[8] = currentTC_LEN_RCV[0]; | |||
|
260 | data[9] = currentTC_LEN_RCV[1]; | |||
|
261 | data[10] = TC->packetLength[0]; | |||
|
262 | data[11] = TC->packetLength[1]; | |||
|
263 | data[12] = TC->dataAndCRC[packetLength]; | |||
|
264 | data[13] = TC->dataAndCRC[packetLength+1]; | |||
|
265 | data[14] = computed_CRC[0]; | |||
|
266 | data[15] = computed_CRC[1]; | |||
|
267 | break; | |||
|
268 | default: | |||
|
269 | return 0; | |||
|
270 | } | |||
|
271 | return 1; | |||
|
272 | } | |||
|
273 | ||||
|
274 | rtems_task spw_recv_task( rtems_task_argument unused ) | |||
|
275 | { | |||
|
276 | rtems_status_code status; | |||
|
277 | int len = 0; | |||
|
278 | unsigned int i = 0; | |||
|
279 | unsigned int data_length = 0; | |||
|
280 | ccsdsTelecommandPacket_t currentTC; | |||
|
281 | spw_ioctl_pkt_send spw_ioctl_send; | |||
|
282 | TMHeader_t TM_header; | |||
|
283 | char data[100]; | |||
|
284 | ||||
|
285 | for(i=0; i<100; i++) data[i] = 0; | |||
|
286 | ||||
|
287 | PRINTF("In RECV *** \n") | |||
|
288 | ||||
|
289 | while(1){ | |||
|
290 | len = read(fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking | |||
|
291 | if (len == -1){ // error during the read call | |||
|
292 | PRINTF("In RECV *** last read call returned -1\n") | |||
|
293 | if (rtems_event_send( Task_id[3], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL) | |||
|
294 | PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n") | |||
|
295 | if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL) | |||
|
296 | PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n") | |||
|
297 | } | |||
|
298 | else { | |||
|
299 | //PRINTF1("In RECV *** Got Message of length %d\n", len) | |||
|
300 | currentTC_LEN_RCV[0] = 0x00; | |||
|
301 | currentTC_LEN_RCV[1] = (unsigned char) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // build the corresponding packet size field | |||
|
302 | currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // => -3 is for Prot ID, Reserved and User App bytes | |||
|
303 | // CHECK THE TC AND BUILD THE APPROPRIATE TM | |||
|
304 | data_length = TC_checker(¤tTC, currentTC_LEN_RCV_AsUnsignedInt, | |||
|
305 | &TM_header, &spw_ioctl_send.hlen, data); | |||
|
306 | spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header | |||
|
307 | spw_ioctl_send.hdr = (char*) &TM_header; | |||
|
308 | spw_ioctl_send.dlen = data_length; | |||
|
309 | spw_ioctl_send.data = data; | |||
|
310 | //printf("hlen %d, dlen %d\n", spw_ioctl_send.hlen, spw_ioctl_send.dlen); | |||
|
311 | // SEND PACKET | |||
|
312 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send ); | |||
|
313 | if (status!=RTEMS_SUCCESSFUL) printf("In TC_checker *** Error SPACEWIRE_IOCTRL_SEND\n"); | |||
|
314 | //PRINTF1("In TC_checker *** packet of size %d sent\n", spw_ioctl_send.sent) | |||
|
315 | } | |||
|
316 | } | |||
|
317 | } | |||
|
318 | ||||
|
319 |
@@ -0,0 +1,113 | |||||
|
1 | #include <wf_handler.h> | |||
|
2 | ||||
|
3 | rtems_isr waveforms_isr( rtems_vector_number vector ) | |||
|
4 | { | |||
|
5 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |||
|
6 | printf("In spectral_matrices_isr *** Error sending event to WFRM\n"); | |||
|
7 | } | |||
|
8 | ||||
|
9 | rtems_task spw_wfrm_task(rtems_task_argument argument) | |||
|
10 | { | |||
|
11 | unsigned int length; | |||
|
12 | unsigned int i = 0; | |||
|
13 | spw_ioctl_pkt_send spw_ioctl_send; | |||
|
14 | rtems_event_set event_out; | |||
|
15 | gptimer_regs_t *gptimer_regs; | |||
|
16 | gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; | |||
|
17 | ExtendedTMHeader_t header; | |||
|
18 | ||||
|
19 | header.targetLogicalAddress = CCSDS_DESTINATION_ID; | |||
|
20 | header.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |||
|
21 | header.reserved = 0x00; | |||
|
22 | header.userApplication = CCSDS_USER_APP; | |||
|
23 | header.packetID[0] = 0x0c; | |||
|
24 | header.packetID[1] = 0xcc; | |||
|
25 | header.packetSequenceControl[0] = 0x00; | |||
|
26 | header.packetSequenceControl[1] = 0x00; | |||
|
27 | header.packetLength[0] = 0x00; | |||
|
28 | header.packetLength[1] = 0x00; | |||
|
29 | header.dataFieldHeader[0] = 0x10; | |||
|
30 | header.dataFieldHeader[1] = 0x15; // service type | |||
|
31 | header.dataFieldHeader[2] = 0x03; // service subtype | |||
|
32 | header.dataFieldHeader[3] = CCSDS_DESTINATION_ID; | |||
|
33 | header.dataFieldHeader[4] = 0xaa; | |||
|
34 | header.dataFieldHeader[5] = 0xbb; | |||
|
35 | header.dataFieldHeader[6] = 0xcc; | |||
|
36 | header.dataFieldHeader[7] = 0xdd; | |||
|
37 | header.dataFieldHeader[8] = 0xee; | |||
|
38 | header.dataFieldHeader[9] = 0xff; | |||
|
39 | ||||
|
40 | header.auxiliaryHeader[0] = 0x00; | |||
|
41 | header.auxiliaryHeader[1] = 0x1f; | |||
|
42 | header.auxiliaryHeader[2] = 0x07; // PKT_CNT | |||
|
43 | header.auxiliaryHeader[3] = 0x00; // PKT_NR | |||
|
44 | header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB | |||
|
45 | header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB | |||
|
46 | ||||
|
47 | // BUILD THE PACKET HEADER | |||
|
48 | spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header | |||
|
49 | spw_ioctl_send.hdr = (char*) &header; | |||
|
50 | ||||
|
51 | while(1){ | |||
|
52 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |||
|
53 | for (i=0; i<7; i++) // send F0 | |||
|
54 | { | |||
|
55 | // BUILD THE DATA | |||
|
56 | if (i==6) { | |||
|
57 | spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK; | |||
|
58 | length = TM_LEN_SCI_NORM_SWF_340; | |||
|
59 | } | |||
|
60 | else { | |||
|
61 | spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK; | |||
|
62 | length = TM_LEN_SCI_NORM_SWF_8; | |||
|
63 | } | |||
|
64 | spw_ioctl_send.data = (char*) &wf_snap_f0[i * 340 * NB_BYTES_SWF_BLK]; | |||
|
65 | // BUILD THE HEADER | |||
|
66 | header.packetLength[0] = (unsigned char) (length>>8); | |||
|
67 | header.packetLength[1] = (unsigned char) (length); | |||
|
68 | header.auxiliaryHeader[0] = SID_NORM_SWF_F0; // SID | |||
|
69 | // SEND PACKET | |||
|
70 | write_spw(&spw_ioctl_send); | |||
|
71 | } | |||
|
72 | for (i=0; i<7; i++) // send F1 | |||
|
73 | { | |||
|
74 | // BUILD THE DATA | |||
|
75 | if (i==6) { | |||
|
76 | spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK; | |||
|
77 | length = TM_LEN_SCI_NORM_SWF_340; | |||
|
78 | } | |||
|
79 | else { | |||
|
80 | spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK; | |||
|
81 | length = TM_LEN_SCI_NORM_SWF_8; | |||
|
82 | } | |||
|
83 | spw_ioctl_send.data = (char*) &wf_snap_f1[i * 340 * NB_BYTES_SWF_BLK]; | |||
|
84 | // BUILD THE HEADER | |||
|
85 | header.packetLength[0] = (unsigned char) (length>>8); | |||
|
86 | header.packetLength[1] = (unsigned char) (length); | |||
|
87 | header.auxiliaryHeader[0] = SID_NORM_SWF_F1; // SID | |||
|
88 | // SEND PACKET | |||
|
89 | write_spw(&spw_ioctl_send); | |||
|
90 | } | |||
|
91 | for (i=0; i<7; i++) // send F0 | |||
|
92 | { | |||
|
93 | // BUILD THE DATA | |||
|
94 | if (i==6) { | |||
|
95 | spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK; | |||
|
96 | length = TM_LEN_SCI_NORM_SWF_340; | |||
|
97 | } | |||
|
98 | else { | |||
|
99 | spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK; | |||
|
100 | length = TM_LEN_SCI_NORM_SWF_8; | |||
|
101 | } | |||
|
102 | spw_ioctl_send.data = (char*) &wf_snap_f2[i * 340 * NB_BYTES_SWF_BLK]; | |||
|
103 | // BUILD THE HEADER | |||
|
104 | header.packetLength[0] = (unsigned char) (length>>8); | |||
|
105 | header.packetLength[1] = (unsigned char) (length); | |||
|
106 | header.auxiliaryHeader[0] = SID_NORM_SWF_F2; // SID | |||
|
107 | // SEND PACKET | |||
|
108 | write_spw(&spw_ioctl_send); | |||
|
109 | } | |||
|
110 | // irq processed, reset the related register of the timer unit | |||
|
111 | gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010; | |||
|
112 | } | |||
|
113 | } |
@@ -38,6 +38,7 | |||||
38 | <Unit filename="../header/FSW-config.h" /> |
|
38 | <Unit filename="../header/FSW-config.h" /> | |
39 | <Unit filename="../header/FSW-rtems-processing.h" /> |
|
39 | <Unit filename="../header/FSW-rtems-processing.h" /> | |
40 | <Unit filename="../header/TC_handler.h" /> |
|
40 | <Unit filename="../header/TC_handler.h" /> | |
|
41 | <Unit filename="../header/WF_handler.h" /> | |||
41 | <Unit filename="../header/ccsds_types.h" /> |
|
42 | <Unit filename="../header/ccsds_types.h" /> | |
42 | <Unit filename="../header/grlibregs.h" /> |
|
43 | <Unit filename="../header/grlibregs.h" /> | |
43 | <Unit filename="../src/FSW-config.c"> |
|
44 | <Unit filename="../src/FSW-config.c"> | |
@@ -52,6 +53,9 | |||||
52 | <Unit filename="../src/TC_handler.c"> |
|
53 | <Unit filename="../src/TC_handler.c"> | |
53 | <Option compilerVar="CC" /> |
|
54 | <Option compilerVar="CC" /> | |
54 | </Unit> |
|
55 | </Unit> | |
|
56 | <Unit filename="../src/WF_handler.c"> | |||
|
57 | <Option compilerVar="CC" /> | |||
|
58 | </Unit> | |||
55 | <Extensions> |
|
59 | <Extensions> | |
56 | <code_completion /> |
|
60 | <code_completion /> | |
57 | <debugger /> |
|
61 | <debugger /> |
@@ -41,40 +41,31 1354190602 source:e:\missions\solo\dev_p | |||||
41 | 1354190601 e:\missions\solo\dev_ple\header\fsw-rtems-processing.h |
|
41 | 1354190601 e:\missions\solo\dev_ple\header\fsw-rtems-processing.h | |
42 | <rtems.h> |
|
42 | <rtems.h> | |
43 |
|
43 | |||
44 |
1359 |
|
44 | 1359451040 source:/opt/DEV_PLE/src/FSW-rtems-processing.c | |
45 | <FSW-rtems-processing.h> |
|
45 | <FSW-rtems-processing.h> | |
46 | <math.h> |
|
46 | <math.h> | |
47 | <stdio.h> |
|
47 | <stdio.h> | |
48 | <leon.h> |
|
48 | <leon.h> | |
49 |
|
49 | |||
50 |
1359 |
|
50 | 1359458568 /opt/DEV_PLE/header/FSW-rtems-processing.h | |
51 | <rtems.h> |
|
51 | <rtems.h> | |
52 | <grlibregs.h> |
|
52 | <grlibregs.h> | |
53 |
<FSW- |
|
53 | <FSW-params.h> | |
54 |
|
54 | |||
55 |
1359 |
|
55 | 1359458854 source:/opt/DEV_PLE/src/FSW-rtems.c | |
56 | <rtems.h> |
|
56 | <rtems.h> | |
57 | <bsp.h> |
|
57 | <bsp.h> | |
58 | <rtems/confdefs.h> |
|
58 | <rtems/confdefs.h> | |
59 | <drvmgr/drvmgr_confdefs.h> |
|
59 | <drvmgr/drvmgr_confdefs.h> | |
60 | <rtems.h> |
|
60 | <FSW-rtems.h> | |
61 | <errno.h> |
|
61 | <FSW-config.c> | |
62 | <fcntl.h> |
|
|||
63 | <stdio.h> |
|
|||
64 | <stdlib.h> |
|
|||
65 | <grspw.h> |
|
|||
66 | <apbuart.h> |
|
|||
67 | <FSW-config.h> |
|
|||
68 | <TC_handler.h> |
|
|||
69 | <FSW-rtems-processing.h> |
|
|||
70 | <grlibregs.h> |
|
|||
71 |
|
62 | |||
72 |
135 |
|
63 | 1359365823 /opt/DEV_PLE/src/FSW-config.c | |
73 | <drvmgr/ambapp_bus.h> |
|
64 | <drvmgr/ambapp_bus.h> | |
74 |
|
65 | |||
75 |
1359 |
|
66 | 1359458568 source:/opt/DEV_PLE/src/TC_handler.c | |
76 | <TC_handler.h> |
|
67 | <TC_handler.h> | |
77 |
<FSW- |
|
68 | <FSW-params.h> | |
78 |
|
69 | |||
79 | 1359377846 /opt/DEV_PLE/header/TC_handler.h |
|
70 | 1359377846 /opt/DEV_PLE/header/TC_handler.h | |
80 | <stdio.h> |
|
71 | <stdio.h> | |
@@ -85,7 +76,117 1359372295 /opt/DEV_PLE/header/ccsds_typ | |||||
85 | 1359365823 source:/opt/DEV_PLE/src/FSW-config.c |
|
76 | 1359365823 source:/opt/DEV_PLE/src/FSW-config.c | |
86 | <drvmgr/ambapp_bus.h> |
|
77 | <drvmgr/ambapp_bus.h> | |
87 |
|
78 | |||
88 |
1359 |
|
79 | 1359452642 /opt/DEV_PLE/header/FSW-config.h | |
|
80 | ||||
|
81 | 1359440704 /opt/DEV_PLE/header/grlibregs.h | |||
|
82 | ||||
|
83 | 1359382989 source:/opt/DEV_PLE/src/WF_handler.c | |||
|
84 | ||||
|
85 | 1359459475 source:/opt/DEV_PLE/src/FSW-misc.c | |||
|
86 | <FSW-misc.h> | |||
|
87 | <FSW-params.h> | |||
|
88 | ||||
|
89 | 1359459330 /opt/DEV_PLE/header/FSW-misc.h | |||
|
90 | <rtems.h> | |||
|
91 | <stdio.h> | |||
|
92 | <FSW-rtems.h> | |||
|
93 | <FSW-params.h> | |||
|
94 | <grlibregs.h> | |||
|
95 | <grspw.h> | |||
|
96 | <ccsds_types.h> | |||
|
97 | ||||
|
98 | 1359459364 /opt/DEV_PLE/header/FSW-rtems.h | |||
|
99 | <errno.h> | |||
|
100 | <fcntl.h> | |||
|
101 | <stdio.h> | |||
|
102 | <stdlib.h> | |||
|
103 | <grspw.h> | |||
|
104 | <apbuart.h> | |||
|
105 | <FSW-params.h> | |||
|
106 | <FSW-misc.h> | |||
|
107 | <FSW-rtems-processing.h> | |||
|
108 | <TC_handler.h> | |||
|
109 | <WF_handler.h> | |||
|
110 | <grlibregs.h> | |||
|
111 | ||||
|
112 | 1359458453 /opt/DEV_PLE/header/FSW-params.h | |||
|
113 | ||||
|
114 | 1359459642 /opt/DEV_PLE/header/WF_handler.h | |||
|
115 | <rtems.h> | |||
|
116 | <FSW-params.h> | |||
|
117 | <grspw.h> | |||
|
118 | <grlibregs.h> | |||
|
119 | <ccsds_types.h> | |||
|
120 | <stdio.h> | |||
|
121 | <FSW-rtems.h> | |||
|
122 | ||||
|
123 | 1359464354 source:/opt/DEV_PLE/src/fsw_main.c | |||
|
124 | <rtems.h> | |||
|
125 | <bsp.h> | |||
|
126 | <rtems/confdefs.h> | |||
|
127 | <drvmgr/drvmgr_confdefs.h> | |||
|
128 | <fsw_main.h> | |||
|
129 | <fsw_config.c> | |||
89 |
|
130 | |||
90 |
135 |
|
131 | 1359464346 /opt/DEV_PLE/header/fsw_main.h | |
|
132 | <errno.h> | |||
|
133 | <fcntl.h> | |||
|
134 | <stdio.h> | |||
|
135 | <stdlib.h> | |||
|
136 | <grspw.h> | |||
|
137 | <apbuart.h> | |||
|
138 | <fsw_params.h> | |||
|
139 | <fsw_misc.h> | |||
|
140 | <fsw_processing.h> | |||
|
141 | <tc_handler.h> | |||
|
142 | <wf_handler.h> | |||
|
143 | <grlib_regs.h> | |||
|
144 | ||||
|
145 | 1359464984 /opt/DEV_PLE/header/fsw_params.h | |||
|
146 | ||||
|
147 | 1359464293 /opt/DEV_PLE/header/fsw_misc.h | |||
|
148 | <rtems.h> | |||
|
149 | <stdio.h> | |||
|
150 | <fsw_main.h> | |||
|
151 | <fsw_params.h> | |||
|
152 | <grlib_regs.h> | |||
|
153 | <grspw.h> | |||
|
154 | <ccsds_types.h> | |||
|
155 | ||||
|
156 | 1359440704 /opt/DEV_PLE/header/grlib_regs.h | |||
91 |
|
157 | |||
|
158 | 1359465021 /opt/DEV_PLE/header/fsw_processing.h | |||
|
159 | <rtems.h> | |||
|
160 | <grlib_regs.h> | |||
|
161 | <fsw_params.h> | |||
|
162 | ||||
|
163 | 1359377846 /opt/DEV_PLE/header/tc_handler.h | |||
|
164 | <stdio.h> | |||
|
165 | <ccsds_types.h> | |||
|
166 | ||||
|
167 | 1359464293 /opt/DEV_PLE/header/wf_handler.h | |||
|
168 | <rtems.h> | |||
|
169 | <fsw_params.h> | |||
|
170 | <grspw.h> | |||
|
171 | <grlib_regs.h> | |||
|
172 | <ccsds_types.h> | |||
|
173 | <stdio.h> | |||
|
174 | <fsw_main.h> | |||
|
175 | ||||
|
176 | 1359365823 /opt/DEV_PLE/src/fsw_config.c | |||
|
177 | <drvmgr/ambapp_bus.h> | |||
|
178 | ||||
|
179 | 1359464327 source:/opt/DEV_PLE/src/fsw_misc.c | |||
|
180 | <fsw_misc.h> | |||
|
181 | <fsw_params.h> | |||
|
182 | ||||
|
183 | 1359464327 source:/opt/DEV_PLE/src/tc_handler.c | |||
|
184 | <tc_handler.h> | |||
|
185 | <fsw_params.h> | |||
|
186 | ||||
|
187 | 1359464346 source:/opt/DEV_PLE/src/wf_handler.c | |||
|
188 | <wf_handler.h> | |||
|
189 | ||||
|
190 | 1359465021 source:/opt/DEV_PLE/src/fsw_globals.c | |||
|
191 | <fsw_processing.h> | |||
|
192 |
@@ -2,30 +2,30 | |||||
2 | <CodeBlocks_layout_file> |
|
2 | <CodeBlocks_layout_file> | |
3 | <ActiveTarget name="Debug" /> |
|
3 | <ActiveTarget name="Debug" /> | |
4 | <File name="../header/FSW-config.h" open="0" top="0" tabpos="0"> |
|
4 | <File name="../header/FSW-config.h" open="0" top="0" tabpos="0"> | |
5 |
<Cursor position=" |
|
5 | <Cursor position="581" topLine="0" /> | |
6 | </File> |
|
6 | </File> | |
7 | <File name="../header/FSW-rtems-processing.h" open="0" top="0" tabpos="4"> |
|
7 | <File name="../header/FSW-rtems-processing.h" open="0" top="0" tabpos="4"> | |
8 |
<Cursor position=" |
|
8 | <Cursor position="995" topLine="6" /> | |
9 | </File> |
|
9 | </File> | |
10 |
<File name="../header/TC_handler.h" open=" |
|
10 | <File name="../header/TC_handler.h" open="0" top="0" tabpos="5"> | |
11 |
<Cursor position=" |
|
11 | <Cursor position="963" topLine="0" /> | |
12 | </File> |
|
12 | </File> | |
13 |
<File name="../header/ccsds_types.h" open=" |
|
13 | <File name="../header/ccsds_types.h" open="0" top="0" tabpos="4"> | |
14 |
<Cursor position="1 |
|
14 | <Cursor position="1753" topLine="39" /> | |
15 | </File> |
|
15 | </File> | |
16 | <File name="../header/grlibregs.h" open="0" top="0" tabpos="6"> |
|
16 | <File name="../header/grlibregs.h" open="0" top="0" tabpos="6"> | |
17 |
<Cursor position=" |
|
17 | <Cursor position="915" topLine="1" /> | |
18 | </File> |
|
18 | </File> | |
19 |
<File name="../src/FSW-config.c" open=" |
|
19 | <File name="../src/FSW-config.c" open="0" top="0" tabpos="3"> | |
20 |
<Cursor position="2 |
|
20 | <Cursor position="259" topLine="0" /> | |
21 | </File> |
|
21 | </File> | |
22 | <File name="../src/FSW-rtems-processing.c" open="0" top="0" tabpos="2"> |
|
22 | <File name="../src/FSW-rtems-processing.c" open="0" top="0" tabpos="2"> | |
23 |
<Cursor position=" |
|
23 | <Cursor position="416" topLine="17" /> | |
24 | </File> |
|
24 | </File> | |
25 |
<File name="../src/FSW-rtems.c" open="1" top=" |
|
25 | <File name="../src/FSW-rtems.c" open="1" top="1" tabpos="1"> | |
26 |
<Cursor position=" |
|
26 | <Cursor position="14643" topLine="95" /> | |
27 | </File> |
|
27 | </File> | |
28 |
<File name="../src/TC_handler.c" open=" |
|
28 | <File name="../src/TC_handler.c" open="0" top="0" tabpos="2"> | |
29 |
<Cursor position=" |
|
29 | <Cursor position="2441" topLine="9" /> | |
30 | </File> |
|
30 | </File> | |
31 | </CodeBlocks_layout_file> |
|
31 | </CodeBlocks_layout_file> |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
General Comments 0
You need to be logged in to leave comments.
Login now