@@ -1,111 +1,115 | |||||
1 | #ifndef TC_HANDLER_H_INCLUDED |
|
1 | #ifndef TC_HANDLER_H_INCLUDED | |
2 | #define TC_HANDLER_H_INCLUDED |
|
2 | #define TC_HANDLER_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <leon.h> |
|
5 | #include <leon.h> | |
6 |
|
6 | |||
7 | #include "tc_load_dump_parameters.h" |
|
7 | #include "tc_load_dump_parameters.h" | |
8 | #include "tc_acceptance.h" |
|
8 | #include "tc_acceptance.h" | |
9 | #include "tm_lfr_tc_exe.h" |
|
9 | #include "tm_lfr_tc_exe.h" | |
10 | #include "wf_handler.h" |
|
10 | #include "wf_handler.h" | |
11 | #include "fsw_processing.h" |
|
11 | #include "fsw_processing.h" | |
12 |
|
12 | |||
13 | #include "lfr_cpu_usage_report.h" |
|
13 | #include "lfr_cpu_usage_report.h" | |
14 |
|
14 | |||
15 | #define MAX_DELTA_COARSE_TIME 3 |
|
15 | #define MAX_DELTA_COARSE_TIME 3 | |
16 | #define NB_SCIENCE_TASKS 10 |
|
16 | #define NB_SCIENCE_TASKS 10 | |
17 | #define NB_ASM_TASKS 6 |
|
17 | #define NB_ASM_TASKS 6 | |
18 | #define STATUS_0 0 |
|
18 | #define STATUS_0 0 | |
19 | #define STATUS_1 1 |
|
19 | #define STATUS_1 1 | |
20 | #define STATUS_2 2 |
|
20 | #define STATUS_2 2 | |
21 | #define STATUS_3 3 |
|
21 | #define STATUS_3 3 | |
22 | #define STATUS_4 4 |
|
22 | #define STATUS_4 4 | |
23 | #define STATUS_5 5 |
|
23 | #define STATUS_5 5 | |
24 | #define STATUS_6 6 |
|
24 | #define STATUS_6 6 | |
25 | #define STATUS_7 7 |
|
25 | #define STATUS_7 7 | |
26 | #define STATUS_8 8 |
|
26 | #define STATUS_8 8 | |
27 | #define STATUS_9 9 |
|
27 | #define STATUS_9 9 | |
28 |
|
28 | |||
29 | #define CAL_F0 625 |
|
29 | #define CAL_F0 625. | |
30 | #define CAL_F1 10000 |
|
30 | #define CAL_F1 10000. | |
|
31 | #define CAL_W0 (2. * pi * CAL_F0) | |||
|
32 | #define CAL_W1 (2. * pi * CAL_F1) | |||
|
33 | #define CAL_A0 1. | |||
|
34 | #define CAL_A1 2. | |||
31 | #define CAL_FS 160256.410 |
|
35 | #define CAL_FS 160256.410 | |
32 | #define CAL_SCALE_FACTOR (0.250 / 0.000654) // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV |
|
36 | #define CAL_SCALE_FACTOR (0.250 / 0.000654) // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV | |
33 | #define CAL_NB_PTS 256 |
|
37 | #define CAL_NB_PTS 256 | |
34 | #define CAL_DATA_MASK 0xfff |
|
38 | #define CAL_DATA_MASK 0xfff | |
35 | #define CAL_F_DIVISOR 38 // 25 MHz => 160 256 (39 - 1) |
|
39 | #define CAL_F_DIVISOR 38 // 25 MHz => 160 256 (39 - 1) | |
36 | // INTERLEAVED MODE |
|
40 | // INTERLEAVED MODE | |
37 | #define CAL_FS_INTER 240384.615 |
|
41 | #define CAL_FS_INTER 240384.615 | |
38 | #define CAL_NB_PTS_INTER 384 |
|
42 | #define CAL_NB_PTS_INTER 384 | |
39 | #define CAL_DATA_MASK_INTER 0x3f |
|
43 | #define CAL_DATA_MASK_INTER 0x3f | |
40 | #define CAL_DATA_SHIFT_INTER 12 |
|
44 | #define CAL_DATA_SHIFT_INTER 12 | |
41 | #define BYTES_FOR_2_SAMPLES 3 // one need 3 bytes = 24 bits to store 3 samples of 12 bits in interleaved mode |
|
45 | #define BYTES_FOR_2_SAMPLES 3 // one need 3 bytes = 24 bits to store 3 samples of 12 bits in interleaved mode | |
42 | #define STEPS_FOR_STORAGE_INTER 128 |
|
46 | #define STEPS_FOR_STORAGE_INTER 128 | |
43 | #define CAL_F_DIVISOR_INTER 26 // 25 MHz => 240 384 |
|
47 | #define CAL_F_DIVISOR_INTER 26 // 25 MHz => 240 384 | |
44 |
|
48 | |||
45 | extern unsigned int lastValidEnterModeTime; |
|
49 | extern unsigned int lastValidEnterModeTime; | |
46 | extern unsigned char oneTcLfrUpdateTimeReceived; |
|
50 | extern unsigned char oneTcLfrUpdateTimeReceived; | |
47 |
|
51 | |||
48 | //**** |
|
52 | //**** | |
49 | // ISR |
|
53 | // ISR | |
50 | rtems_isr commutation_isr1( rtems_vector_number vector ); |
|
54 | rtems_isr commutation_isr1( rtems_vector_number vector ); | |
51 | rtems_isr commutation_isr2( rtems_vector_number vector ); |
|
55 | rtems_isr commutation_isr2( rtems_vector_number vector ); | |
52 |
|
56 | |||
53 | //*********** |
|
57 | //*********** | |
54 | // RTEMS TASK |
|
58 | // RTEMS TASK | |
55 | rtems_task actn_task( rtems_task_argument unused ); |
|
59 | rtems_task actn_task( rtems_task_argument unused ); | |
56 |
|
60 | |||
57 | //*********** |
|
61 | //*********** | |
58 | // TC ACTIONS |
|
62 | // TC ACTIONS | |
59 | int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
63 | int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); | |
60 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
64 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
61 | int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
65 | int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
62 | int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
66 | int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); | |
63 | int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
67 | int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); | |
64 | int action_update_time( ccsdsTelecommandPacket_t *TC); |
|
68 | int action_update_time( ccsdsTelecommandPacket_t *TC); | |
65 |
|
69 | |||
66 | // mode transition |
|
70 | // mode transition | |
67 | int check_mode_value( unsigned char requestedMode ); |
|
71 | int check_mode_value( unsigned char requestedMode ); | |
68 | int check_mode_transition( unsigned char requestedMode ); |
|
72 | int check_mode_transition( unsigned char requestedMode ); | |
69 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ); |
|
73 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ); | |
70 | int check_transition_date( unsigned int transitionCoarseTime ); |
|
74 | int check_transition_date( unsigned int transitionCoarseTime ); | |
71 | int stop_spectral_matrices( void ); |
|
75 | int stop_spectral_matrices( void ); | |
72 | int stop_current_mode( void ); |
|
76 | int stop_current_mode( void ); | |
73 | int enter_mode_standby(void ); |
|
77 | int enter_mode_standby(void ); | |
74 | int enter_mode_normal( unsigned int transitionCoarseTime ); |
|
78 | int enter_mode_normal( unsigned int transitionCoarseTime ); | |
75 | int enter_mode_burst( unsigned int transitionCoarseTime ); |
|
79 | int enter_mode_burst( unsigned int transitionCoarseTime ); | |
76 | int enter_mode_sbm1( unsigned int transitionCoarseTime ); |
|
80 | int enter_mode_sbm1( unsigned int transitionCoarseTime ); | |
77 | int enter_mode_sbm2( unsigned int transitionCoarseTime ); |
|
81 | int enter_mode_sbm2( unsigned int transitionCoarseTime ); | |
78 | int restart_science_tasks( unsigned char lfrRequestedMode ); |
|
82 | int restart_science_tasks( unsigned char lfrRequestedMode ); | |
79 | int restart_asm_tasks(unsigned char lfrRequestedMode ); |
|
83 | int restart_asm_tasks(unsigned char lfrRequestedMode ); | |
80 | int suspend_science_tasks(void); |
|
84 | int suspend_science_tasks(void); | |
81 | int suspend_asm_tasks( void ); |
|
85 | int suspend_asm_tasks( void ); | |
82 | void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime ); |
|
86 | void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime ); | |
83 | void launch_spectral_matrix( void ); |
|
87 | void launch_spectral_matrix( void ); | |
84 | void set_sm_irq_onNewMatrix( unsigned char value ); |
|
88 | void set_sm_irq_onNewMatrix( unsigned char value ); | |
85 | void set_sm_irq_onError( unsigned char value ); |
|
89 | void set_sm_irq_onError( unsigned char value ); | |
86 |
|
90 | |||
87 | // other functions |
|
91 | // other functions | |
88 | void updateLFRCurrentMode(unsigned char requestedMode); |
|
92 | void updateLFRCurrentMode(unsigned char requestedMode); | |
89 | void set_lfr_soft_reset( unsigned char value ); |
|
93 | void set_lfr_soft_reset( unsigned char value ); | |
90 | void reset_lfr( void ); |
|
94 | void reset_lfr( void ); | |
91 | // CALIBRATION |
|
95 | // CALIBRATION | |
92 | void setCalibrationPrescaler( unsigned int prescaler ); |
|
96 | void setCalibrationPrescaler( unsigned int prescaler ); | |
93 | void setCalibrationDivisor( unsigned int divisionFactor ); |
|
97 | void setCalibrationDivisor( unsigned int divisionFactor ); | |
94 | void setCalibrationData( void ); |
|
98 | void setCalibrationData( void ); | |
95 | void setCalibrationReload( bool state); |
|
99 | void setCalibrationReload( bool state); | |
96 | void setCalibrationEnable( bool state ); |
|
100 | void setCalibrationEnable( bool state ); | |
97 | void setCalibrationInterleaved( bool state ); |
|
101 | void setCalibrationInterleaved( bool state ); | |
98 | void setCalibration( bool state ); |
|
102 | void setCalibration( bool state ); | |
99 | void configureCalibration( bool interleaved ); |
|
103 | void configureCalibration( bool interleaved ); | |
100 | // |
|
104 | // | |
101 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time ); |
|
105 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time ); | |
102 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time ); |
|
106 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time ); | |
103 | void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ); |
|
107 | void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ); | |
104 |
|
108 | |||
105 | extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
109 | extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); | |
106 | extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
110 | extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); | |
107 |
|
111 | |||
108 | #endif // TC_HANDLER_H_INCLUDED |
|
112 | #endif // TC_HANDLER_H_INCLUDED | |
109 |
|
113 | |||
110 |
|
114 | |||
111 |
|
115 |
@@ -1,1670 +1,1669 | |||||
1 | /** Functions and tasks related to TeleCommand handling. |
|
1 | /** Functions and tasks related to TeleCommand handling. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TeleCommands:\n |
|
6 | * A group of functions to handle TeleCommands:\n | |
7 | * action launching\n |
|
7 | * action launching\n | |
8 | * TC parsing\n |
|
8 | * TC parsing\n | |
9 | * ... |
|
9 | * ... | |
10 | * |
|
10 | * | |
11 | */ |
|
11 | */ | |
12 |
|
12 | |||
13 | #include "tc_handler.h" |
|
13 | #include "tc_handler.h" | |
14 | #include "math.h" |
|
14 | #include "math.h" | |
15 |
|
15 | |||
16 | //*********** |
|
16 | //*********** | |
17 | // RTEMS TASK |
|
17 | // RTEMS TASK | |
18 |
|
18 | |||
19 | rtems_task actn_task( rtems_task_argument unused ) |
|
19 | rtems_task actn_task( rtems_task_argument unused ) | |
20 | { |
|
20 | { | |
21 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
21 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. | |
22 | * |
|
22 | * | |
23 | * @param unused is the starting argument of the RTEMS task |
|
23 | * @param unused is the starting argument of the RTEMS task | |
24 | * |
|
24 | * | |
25 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
25 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending | |
26 | * on the incoming TeleCommand. |
|
26 | * on the incoming TeleCommand. | |
27 | * |
|
27 | * | |
28 | */ |
|
28 | */ | |
29 |
|
29 | |||
30 | int result; |
|
30 | int result; | |
31 | rtems_status_code status; // RTEMS status code |
|
31 | rtems_status_code status; // RTEMS status code | |
32 | ccsdsTelecommandPacket_t __attribute__((aligned(4))) TC; // TC sent to the ACTN task |
|
32 | ccsdsTelecommandPacket_t __attribute__((aligned(4))) TC; // TC sent to the ACTN task | |
33 | size_t size; // size of the incoming TC packet |
|
33 | size_t size; // size of the incoming TC packet | |
34 | unsigned char subtype; // subtype of the current TC packet |
|
34 | unsigned char subtype; // subtype of the current TC packet | |
35 | unsigned char time[BYTES_PER_TIME]; |
|
35 | unsigned char time[BYTES_PER_TIME]; | |
36 | rtems_id queue_rcv_id; |
|
36 | rtems_id queue_rcv_id; | |
37 | rtems_id queue_snd_id; |
|
37 | rtems_id queue_snd_id; | |
38 |
|
38 | |||
39 | memset(&TC, 0, sizeof(ccsdsTelecommandPacket_t)); |
|
39 | memset(&TC, 0, sizeof(ccsdsTelecommandPacket_t)); | |
40 | size = 0; |
|
40 | size = 0; | |
41 | queue_rcv_id = RTEMS_ID_NONE; |
|
41 | queue_rcv_id = RTEMS_ID_NONE; | |
42 | queue_snd_id = RTEMS_ID_NONE; |
|
42 | queue_snd_id = RTEMS_ID_NONE; | |
43 |
|
43 | |||
44 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
44 | status = get_message_queue_id_recv( &queue_rcv_id ); | |
45 | if (status != RTEMS_SUCCESSFUL) |
|
45 | if (status != RTEMS_SUCCESSFUL) | |
46 | { |
|
46 | { | |
47 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
47 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | status = get_message_queue_id_send( &queue_snd_id ); |
|
50 | status = get_message_queue_id_send( &queue_snd_id ); | |
51 | if (status != RTEMS_SUCCESSFUL) |
|
51 | if (status != RTEMS_SUCCESSFUL) | |
52 | { |
|
52 | { | |
53 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
53 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 | result = LFR_SUCCESSFUL; |
|
56 | result = LFR_SUCCESSFUL; | |
57 | subtype = 0; // subtype of the current TC packet |
|
57 | subtype = 0; // subtype of the current TC packet | |
58 |
|
58 | |||
59 | BOOT_PRINTF("in ACTN *** \n"); |
|
59 | BOOT_PRINTF("in ACTN *** \n"); | |
60 |
|
60 | |||
61 | while(1) |
|
61 | while(1) | |
62 | { |
|
62 | { | |
63 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
63 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, | |
64 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
64 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); | |
65 | getTime( time ); // set time to the current time |
|
65 | getTime( time ); // set time to the current time | |
66 | if (status!=RTEMS_SUCCESSFUL) |
|
66 | if (status!=RTEMS_SUCCESSFUL) | |
67 | { |
|
67 | { | |
68 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
68 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) | |
69 | } |
|
69 | } | |
70 | else |
|
70 | else | |
71 | { |
|
71 | { | |
72 | subtype = TC.serviceSubType; |
|
72 | subtype = TC.serviceSubType; | |
73 | switch(subtype) |
|
73 | switch(subtype) | |
74 | { |
|
74 | { | |
75 | case TC_SUBTYPE_RESET: |
|
75 | case TC_SUBTYPE_RESET: | |
76 | result = action_reset( &TC, queue_snd_id, time ); |
|
76 | result = action_reset( &TC, queue_snd_id, time ); | |
77 | close_action( &TC, result, queue_snd_id ); |
|
77 | close_action( &TC, result, queue_snd_id ); | |
78 | break; |
|
78 | break; | |
79 | case TC_SUBTYPE_LOAD_COMM: |
|
79 | case TC_SUBTYPE_LOAD_COMM: | |
80 | result = action_load_common_par( &TC ); |
|
80 | result = action_load_common_par( &TC ); | |
81 | close_action( &TC, result, queue_snd_id ); |
|
81 | close_action( &TC, result, queue_snd_id ); | |
82 | break; |
|
82 | break; | |
83 | case TC_SUBTYPE_LOAD_NORM: |
|
83 | case TC_SUBTYPE_LOAD_NORM: | |
84 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
84 | result = action_load_normal_par( &TC, queue_snd_id, time ); | |
85 | close_action( &TC, result, queue_snd_id ); |
|
85 | close_action( &TC, result, queue_snd_id ); | |
86 | break; |
|
86 | break; | |
87 | case TC_SUBTYPE_LOAD_BURST: |
|
87 | case TC_SUBTYPE_LOAD_BURST: | |
88 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
88 | result = action_load_burst_par( &TC, queue_snd_id, time ); | |
89 | close_action( &TC, result, queue_snd_id ); |
|
89 | close_action( &TC, result, queue_snd_id ); | |
90 | break; |
|
90 | break; | |
91 | case TC_SUBTYPE_LOAD_SBM1: |
|
91 | case TC_SUBTYPE_LOAD_SBM1: | |
92 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
92 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); | |
93 | close_action( &TC, result, queue_snd_id ); |
|
93 | close_action( &TC, result, queue_snd_id ); | |
94 | break; |
|
94 | break; | |
95 | case TC_SUBTYPE_LOAD_SBM2: |
|
95 | case TC_SUBTYPE_LOAD_SBM2: | |
96 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
96 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); | |
97 | close_action( &TC, result, queue_snd_id ); |
|
97 | close_action( &TC, result, queue_snd_id ); | |
98 | break; |
|
98 | break; | |
99 | case TC_SUBTYPE_DUMP: |
|
99 | case TC_SUBTYPE_DUMP: | |
100 | result = action_dump_par( &TC, queue_snd_id ); |
|
100 | result = action_dump_par( &TC, queue_snd_id ); | |
101 | close_action( &TC, result, queue_snd_id ); |
|
101 | close_action( &TC, result, queue_snd_id ); | |
102 | break; |
|
102 | break; | |
103 | case TC_SUBTYPE_ENTER: |
|
103 | case TC_SUBTYPE_ENTER: | |
104 | result = action_enter_mode( &TC, queue_snd_id ); |
|
104 | result = action_enter_mode( &TC, queue_snd_id ); | |
105 | close_action( &TC, result, queue_snd_id ); |
|
105 | close_action( &TC, result, queue_snd_id ); | |
106 | break; |
|
106 | break; | |
107 | case TC_SUBTYPE_UPDT_INFO: |
|
107 | case TC_SUBTYPE_UPDT_INFO: | |
108 | result = action_update_info( &TC, queue_snd_id ); |
|
108 | result = action_update_info( &TC, queue_snd_id ); | |
109 | close_action( &TC, result, queue_snd_id ); |
|
109 | close_action( &TC, result, queue_snd_id ); | |
110 | break; |
|
110 | break; | |
111 | case TC_SUBTYPE_EN_CAL: |
|
111 | case TC_SUBTYPE_EN_CAL: | |
112 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
112 | result = action_enable_calibration( &TC, queue_snd_id, time ); | |
113 | close_action( &TC, result, queue_snd_id ); |
|
113 | close_action( &TC, result, queue_snd_id ); | |
114 | break; |
|
114 | break; | |
115 | case TC_SUBTYPE_DIS_CAL: |
|
115 | case TC_SUBTYPE_DIS_CAL: | |
116 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
116 | result = action_disable_calibration( &TC, queue_snd_id, time ); | |
117 | close_action( &TC, result, queue_snd_id ); |
|
117 | close_action( &TC, result, queue_snd_id ); | |
118 | break; |
|
118 | break; | |
119 | case TC_SUBTYPE_LOAD_K: |
|
119 | case TC_SUBTYPE_LOAD_K: | |
120 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); |
|
120 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); | |
121 | close_action( &TC, result, queue_snd_id ); |
|
121 | close_action( &TC, result, queue_snd_id ); | |
122 | break; |
|
122 | break; | |
123 | case TC_SUBTYPE_DUMP_K: |
|
123 | case TC_SUBTYPE_DUMP_K: | |
124 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); |
|
124 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); | |
125 | close_action( &TC, result, queue_snd_id ); |
|
125 | close_action( &TC, result, queue_snd_id ); | |
126 | break; |
|
126 | break; | |
127 | case TC_SUBTYPE_LOAD_FBINS: |
|
127 | case TC_SUBTYPE_LOAD_FBINS: | |
128 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); |
|
128 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); | |
129 | close_action( &TC, result, queue_snd_id ); |
|
129 | close_action( &TC, result, queue_snd_id ); | |
130 | break; |
|
130 | break; | |
131 | case TC_SUBTYPE_LOAD_FILTER_PAR: |
|
131 | case TC_SUBTYPE_LOAD_FILTER_PAR: | |
132 | result = action_load_filter_par( &TC, queue_snd_id, time ); |
|
132 | result = action_load_filter_par( &TC, queue_snd_id, time ); | |
133 | close_action( &TC, result, queue_snd_id ); |
|
133 | close_action( &TC, result, queue_snd_id ); | |
134 | break; |
|
134 | break; | |
135 | case TC_SUBTYPE_UPDT_TIME: |
|
135 | case TC_SUBTYPE_UPDT_TIME: | |
136 | result = action_update_time( &TC ); |
|
136 | result = action_update_time( &TC ); | |
137 | close_action( &TC, result, queue_snd_id ); |
|
137 | close_action( &TC, result, queue_snd_id ); | |
138 | break; |
|
138 | break; | |
139 | default: |
|
139 | default: | |
140 | break; |
|
140 | break; | |
141 | } |
|
141 | } | |
142 | } |
|
142 | } | |
143 | } |
|
143 | } | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | //*********** |
|
146 | //*********** | |
147 | // TC ACTIONS |
|
147 | // TC ACTIONS | |
148 |
|
148 | |||
149 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
149 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
150 | { |
|
150 | { | |
151 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
151 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. | |
152 | * |
|
152 | * | |
153 | * @param TC points to the TeleCommand packet that is being processed |
|
153 | * @param TC points to the TeleCommand packet that is being processed | |
154 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
154 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
155 | * |
|
155 | * | |
156 | */ |
|
156 | */ | |
157 |
|
157 | |||
158 | PRINTF("this is the end!!!\n"); |
|
158 | PRINTF("this is the end!!!\n"); | |
159 | exit(0); |
|
159 | exit(0); | |
160 |
|
160 | |||
161 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
161 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
162 |
|
162 | |||
163 | return LFR_DEFAULT; |
|
163 | return LFR_DEFAULT; | |
164 | } |
|
164 | } | |
165 |
|
165 | |||
166 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
166 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
167 | { |
|
167 | { | |
168 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
168 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. | |
169 | * |
|
169 | * | |
170 | * @param TC points to the TeleCommand packet that is being processed |
|
170 | * @param TC points to the TeleCommand packet that is being processed | |
171 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
171 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
172 | * |
|
172 | * | |
173 | */ |
|
173 | */ | |
174 |
|
174 | |||
175 | rtems_status_code status; |
|
175 | rtems_status_code status; | |
176 | unsigned char requestedMode; |
|
176 | unsigned char requestedMode; | |
177 | unsigned int *transitionCoarseTime_ptr; |
|
|||
178 | unsigned int transitionCoarseTime; |
|
177 | unsigned int transitionCoarseTime; | |
179 | unsigned char * bytePosPtr; |
|
178 | unsigned char * bytePosPtr; | |
180 |
|
179 | |||
181 | printf("(0)\n"); |
|
180 | printf("(0)\n"); | |
182 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
181 | bytePosPtr = (unsigned char *) &TC->packetID; | |
183 | printf("(1)\n"); |
|
182 | printf("(1)\n"); | |
184 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
183 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; | |
185 | printf("(2)\n"); |
|
184 | printf("(2)\n"); | |
186 | copyInt32ByChar( &transitionCoarseTime, &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); |
|
185 | copyInt32ByChar( (char*) &transitionCoarseTime, &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); | |
187 | printf("(3)\n"); |
|
186 | printf("(3)\n"); | |
188 | transitionCoarseTime = transitionCoarseTime & COARSE_TIME_MASK; |
|
187 | transitionCoarseTime = transitionCoarseTime & COARSE_TIME_MASK; | |
189 | printf("(4)\n"); |
|
188 | printf("(4)\n"); | |
190 | status = check_mode_value( requestedMode ); |
|
189 | status = check_mode_value( requestedMode ); | |
191 | printf("(5)\n"); |
|
190 | printf("(5)\n"); | |
192 |
|
191 | |||
193 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
192 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent | |
194 | { |
|
193 | { | |
195 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); |
|
194 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); | |
196 | } |
|
195 | } | |
197 |
|
196 | |||
198 | else // the mode value is valid, check the transition |
|
197 | else // the mode value is valid, check the transition | |
199 | { |
|
198 | { | |
200 | status = check_mode_transition(requestedMode); |
|
199 | status = check_mode_transition(requestedMode); | |
201 | if (status != LFR_SUCCESSFUL) |
|
200 | if (status != LFR_SUCCESSFUL) | |
202 | { |
|
201 | { | |
203 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
202 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") | |
204 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
203 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
205 | } |
|
204 | } | |
206 | } |
|
205 | } | |
207 |
|
206 | |||
208 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date |
|
207 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date | |
209 | { |
|
208 | { | |
210 | status = check_transition_date( transitionCoarseTime ); |
|
209 | status = check_transition_date( transitionCoarseTime ); | |
211 | if (status != LFR_SUCCESSFUL) |
|
210 | if (status != LFR_SUCCESSFUL) | |
212 | { |
|
211 | { | |
213 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n"); |
|
212 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n"); | |
214 | send_tm_lfr_tc_exe_not_executable(TC, queue_id ); |
|
213 | send_tm_lfr_tc_exe_not_executable(TC, queue_id ); | |
215 | } |
|
214 | } | |
216 | } |
|
215 | } | |
217 |
|
216 | |||
218 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
217 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode | |
219 | { |
|
218 | { | |
220 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
219 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); | |
221 |
|
220 | |||
222 | switch(requestedMode) |
|
221 | switch(requestedMode) | |
223 | { |
|
222 | { | |
224 | case LFR_MODE_STANDBY: |
|
223 | case LFR_MODE_STANDBY: | |
225 | status = enter_mode_standby(); |
|
224 | status = enter_mode_standby(); | |
226 | break; |
|
225 | break; | |
227 | case LFR_MODE_NORMAL: |
|
226 | case LFR_MODE_NORMAL: | |
228 | status = enter_mode_normal( transitionCoarseTime ); |
|
227 | status = enter_mode_normal( transitionCoarseTime ); | |
229 | break; |
|
228 | break; | |
230 | case LFR_MODE_BURST: |
|
229 | case LFR_MODE_BURST: | |
231 | status = enter_mode_burst( transitionCoarseTime ); |
|
230 | status = enter_mode_burst( transitionCoarseTime ); | |
232 | break; |
|
231 | break; | |
233 | case LFR_MODE_SBM1: |
|
232 | case LFR_MODE_SBM1: | |
234 | status = enter_mode_sbm1( transitionCoarseTime ); |
|
233 | status = enter_mode_sbm1( transitionCoarseTime ); | |
235 | break; |
|
234 | break; | |
236 | case LFR_MODE_SBM2: |
|
235 | case LFR_MODE_SBM2: | |
237 | status = enter_mode_sbm2( transitionCoarseTime ); |
|
236 | status = enter_mode_sbm2( transitionCoarseTime ); | |
238 | break; |
|
237 | break; | |
239 | default: |
|
238 | default: | |
240 | break; |
|
239 | break; | |
241 | } |
|
240 | } | |
242 |
|
241 | |||
243 | if (status != RTEMS_SUCCESSFUL) |
|
242 | if (status != RTEMS_SUCCESSFUL) | |
244 | { |
|
243 | { | |
245 | status = LFR_EXE_ERROR; |
|
244 | status = LFR_EXE_ERROR; | |
246 | } |
|
245 | } | |
247 | } |
|
246 | } | |
248 |
|
247 | |||
249 | return status; |
|
248 | return status; | |
250 | } |
|
249 | } | |
251 |
|
250 | |||
252 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
251 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
253 | { |
|
252 | { | |
254 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
253 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
255 | * |
|
254 | * | |
256 | * @param TC points to the TeleCommand packet that is being processed |
|
255 | * @param TC points to the TeleCommand packet that is being processed | |
257 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
256 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
258 | * |
|
257 | * | |
259 | * @return LFR directive status code: |
|
258 | * @return LFR directive status code: | |
260 | * - LFR_DEFAULT |
|
259 | * - LFR_DEFAULT | |
261 | * - LFR_SUCCESSFUL |
|
260 | * - LFR_SUCCESSFUL | |
262 | * |
|
261 | * | |
263 | */ |
|
262 | */ | |
264 |
|
263 | |||
265 | unsigned int val; |
|
264 | unsigned int val; | |
266 | int result; |
|
265 | int result; | |
267 | unsigned int status; |
|
266 | unsigned int status; | |
268 | unsigned char mode; |
|
267 | unsigned char mode; | |
269 | unsigned char * bytePosPtr; |
|
268 | unsigned char * bytePosPtr; | |
270 |
|
269 | |||
271 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
270 | bytePosPtr = (unsigned char *) &TC->packetID; | |
272 |
|
271 | |||
273 | // check LFR mode |
|
272 | // check LFR mode | |
274 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & BITS_LFR_MODE) >> SHIFT_LFR_MODE; |
|
273 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & BITS_LFR_MODE) >> SHIFT_LFR_MODE; | |
275 | status = check_update_info_hk_lfr_mode( mode ); |
|
274 | status = check_update_info_hk_lfr_mode( mode ); | |
276 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
275 | if (status == LFR_SUCCESSFUL) // check TDS mode | |
277 | { |
|
276 | { | |
278 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_TDS_MODE) >> SHIFT_TDS_MODE; |
|
277 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_TDS_MODE) >> SHIFT_TDS_MODE; | |
279 | status = check_update_info_hk_tds_mode( mode ); |
|
278 | status = check_update_info_hk_tds_mode( mode ); | |
280 | } |
|
279 | } | |
281 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
280 | if (status == LFR_SUCCESSFUL) // check THR mode | |
282 | { |
|
281 | { | |
283 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_THR_MODE); |
|
282 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_THR_MODE); | |
284 | status = check_update_info_hk_thr_mode( mode ); |
|
283 | status = check_update_info_hk_thr_mode( mode ); | |
285 | } |
|
284 | } | |
286 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
285 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful | |
287 | { |
|
286 | { | |
288 | val = (housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * CONST_256) |
|
287 | val = (housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * CONST_256) | |
289 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
288 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
290 | val++; |
|
289 | val++; | |
291 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); |
|
290 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); | |
292 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
291 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
293 | } |
|
292 | } | |
294 |
|
293 | |||
295 | // pa_bia_status_info |
|
294 | // pa_bia_status_info | |
296 | // => pa_bia_mode_mux_set 3 bits |
|
295 | // => pa_bia_mode_mux_set 3 bits | |
297 | // => pa_bia_mode_hv_enabled 1 bit |
|
296 | // => pa_bia_mode_hv_enabled 1 bit | |
298 | // => pa_bia_mode_bias1_enabled 1 bit |
|
297 | // => pa_bia_mode_bias1_enabled 1 bit | |
299 | // => pa_bia_mode_bias2_enabled 1 bit |
|
298 | // => pa_bia_mode_bias2_enabled 1 bit | |
300 | // => pa_bia_mode_bias3_enabled 1 bit |
|
299 | // => pa_bia_mode_bias3_enabled 1 bit | |
301 | // => pa_bia_on_off (cp_dpu_bias_on_off) |
|
300 | // => pa_bia_on_off (cp_dpu_bias_on_off) | |
302 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & BITS_BIA; // [1111 1110] |
|
301 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & BITS_BIA; // [1111 1110] | |
303 | pa_bia_status_info = pa_bia_status_info |
|
302 | pa_bia_status_info = pa_bia_status_info | |
304 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 1); |
|
303 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 1); | |
305 |
|
304 | |||
306 | // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets) |
|
305 | // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets) | |
307 |
|
306 | |||
308 | //cp_rpw_sc_rw_f_flags = bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW_F_FLAGS ]; |
|
307 | //cp_rpw_sc_rw_f_flags = bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW_F_FLAGS ]; | |
309 | getReactionWheelsFrequencies( TC ); |
|
308 | getReactionWheelsFrequencies( TC ); | |
310 | set_hk_lfr_sc_rw_f_flags(); |
|
309 | set_hk_lfr_sc_rw_f_flags(); | |
311 | build_sy_lfr_rw_masks(); |
|
310 | build_sy_lfr_rw_masks(); | |
312 |
|
311 | |||
313 | // once the masks are built, they have to be merged with the fbins_mask |
|
312 | // once the masks are built, they have to be merged with the fbins_mask | |
314 | merge_fbins_masks(); |
|
313 | merge_fbins_masks(); | |
315 |
|
314 | |||
316 | result = status; |
|
315 | result = status; | |
317 |
|
316 | |||
318 | return result; |
|
317 | return result; | |
319 | } |
|
318 | } | |
320 |
|
319 | |||
321 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
320 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
322 | { |
|
321 | { | |
323 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
322 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
324 | * |
|
323 | * | |
325 | * @param TC points to the TeleCommand packet that is being processed |
|
324 | * @param TC points to the TeleCommand packet that is being processed | |
326 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
325 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
327 | * |
|
326 | * | |
328 | */ |
|
327 | */ | |
329 |
|
328 | |||
330 | int result; |
|
329 | int result; | |
331 |
|
330 | |||
332 | result = LFR_DEFAULT; |
|
331 | result = LFR_DEFAULT; | |
333 |
|
332 | |||
334 | setCalibration( true ); |
|
333 | setCalibration( true ); | |
335 |
|
334 | |||
336 | result = LFR_SUCCESSFUL; |
|
335 | result = LFR_SUCCESSFUL; | |
337 |
|
336 | |||
338 | return result; |
|
337 | return result; | |
339 | } |
|
338 | } | |
340 |
|
339 | |||
341 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
340 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
342 | { |
|
341 | { | |
343 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
342 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
344 | * |
|
343 | * | |
345 | * @param TC points to the TeleCommand packet that is being processed |
|
344 | * @param TC points to the TeleCommand packet that is being processed | |
346 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
345 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
347 | * |
|
346 | * | |
348 | */ |
|
347 | */ | |
349 |
|
348 | |||
350 | int result; |
|
349 | int result; | |
351 |
|
350 | |||
352 | result = LFR_DEFAULT; |
|
351 | result = LFR_DEFAULT; | |
353 |
|
352 | |||
354 | setCalibration( false ); |
|
353 | setCalibration( false ); | |
355 |
|
354 | |||
356 | result = LFR_SUCCESSFUL; |
|
355 | result = LFR_SUCCESSFUL; | |
357 |
|
356 | |||
358 | return result; |
|
357 | return result; | |
359 | } |
|
358 | } | |
360 |
|
359 | |||
361 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
360 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
362 | { |
|
361 | { | |
363 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
362 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
364 | * |
|
363 | * | |
365 | * @param TC points to the TeleCommand packet that is being processed |
|
364 | * @param TC points to the TeleCommand packet that is being processed | |
366 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
365 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
367 | * |
|
366 | * | |
368 | * @return LFR_SUCCESSFUL |
|
367 | * @return LFR_SUCCESSFUL | |
369 | * |
|
368 | * | |
370 | */ |
|
369 | */ | |
371 |
|
370 | |||
372 | unsigned int val; |
|
371 | unsigned int val; | |
373 |
|
372 | |||
374 | time_management_regs->coarse_time_load = (TC->dataAndCRC[BYTE_0] << SHIFT_3_BYTES) |
|
373 | time_management_regs->coarse_time_load = (TC->dataAndCRC[BYTE_0] << SHIFT_3_BYTES) | |
375 | + (TC->dataAndCRC[BYTE_1] << SHIFT_2_BYTES) |
|
374 | + (TC->dataAndCRC[BYTE_1] << SHIFT_2_BYTES) | |
376 | + (TC->dataAndCRC[BYTE_2] << SHIFT_1_BYTE) |
|
375 | + (TC->dataAndCRC[BYTE_2] << SHIFT_1_BYTE) | |
377 | + TC->dataAndCRC[BYTE_3]; |
|
376 | + TC->dataAndCRC[BYTE_3]; | |
378 |
|
377 | |||
379 | val = (housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * CONST_256) |
|
378 | val = (housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * CONST_256) | |
380 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
379 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
381 | val++; |
|
380 | val++; | |
382 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); |
|
381 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); | |
383 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
382 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
384 |
|
383 | |||
385 | oneTcLfrUpdateTimeReceived = 1; |
|
384 | oneTcLfrUpdateTimeReceived = 1; | |
386 |
|
385 | |||
387 | return LFR_SUCCESSFUL; |
|
386 | return LFR_SUCCESSFUL; | |
388 | } |
|
387 | } | |
389 |
|
388 | |||
390 | //******************* |
|
389 | //******************* | |
391 | // ENTERING THE MODES |
|
390 | // ENTERING THE MODES | |
392 | int check_mode_value( unsigned char requestedMode ) |
|
391 | int check_mode_value( unsigned char requestedMode ) | |
393 | { |
|
392 | { | |
394 | int status; |
|
393 | int status; | |
395 |
|
394 | |||
396 | status = LFR_DEFAULT; |
|
395 | status = LFR_DEFAULT; | |
397 |
|
396 | |||
398 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
397 | if ( (requestedMode != LFR_MODE_STANDBY) | |
399 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
398 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
400 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
399 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
401 | { |
|
400 | { | |
402 | status = LFR_DEFAULT; |
|
401 | status = LFR_DEFAULT; | |
403 | } |
|
402 | } | |
404 | else |
|
403 | else | |
405 | { |
|
404 | { | |
406 | status = LFR_SUCCESSFUL; |
|
405 | status = LFR_SUCCESSFUL; | |
407 | } |
|
406 | } | |
408 |
|
407 | |||
409 | return status; |
|
408 | return status; | |
410 | } |
|
409 | } | |
411 |
|
410 | |||
412 | int check_mode_transition( unsigned char requestedMode ) |
|
411 | int check_mode_transition( unsigned char requestedMode ) | |
413 | { |
|
412 | { | |
414 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
413 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
415 | * |
|
414 | * | |
416 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
415 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
417 | * |
|
416 | * | |
418 | * @return LFR directive status codes: |
|
417 | * @return LFR directive status codes: | |
419 | * - LFR_SUCCESSFUL - the transition is authorized |
|
418 | * - LFR_SUCCESSFUL - the transition is authorized | |
420 | * - LFR_DEFAULT - the transition is not authorized |
|
419 | * - LFR_DEFAULT - the transition is not authorized | |
421 | * |
|
420 | * | |
422 | */ |
|
421 | */ | |
423 |
|
422 | |||
424 | int status; |
|
423 | int status; | |
425 |
|
424 | |||
426 | switch (requestedMode) |
|
425 | switch (requestedMode) | |
427 | { |
|
426 | { | |
428 | case LFR_MODE_STANDBY: |
|
427 | case LFR_MODE_STANDBY: | |
429 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
428 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
430 | status = LFR_DEFAULT; |
|
429 | status = LFR_DEFAULT; | |
431 | } |
|
430 | } | |
432 | else |
|
431 | else | |
433 | { |
|
432 | { | |
434 | status = LFR_SUCCESSFUL; |
|
433 | status = LFR_SUCCESSFUL; | |
435 | } |
|
434 | } | |
436 | break; |
|
435 | break; | |
437 | case LFR_MODE_NORMAL: |
|
436 | case LFR_MODE_NORMAL: | |
438 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
437 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
439 | status = LFR_DEFAULT; |
|
438 | status = LFR_DEFAULT; | |
440 | } |
|
439 | } | |
441 | else { |
|
440 | else { | |
442 | status = LFR_SUCCESSFUL; |
|
441 | status = LFR_SUCCESSFUL; | |
443 | } |
|
442 | } | |
444 | break; |
|
443 | break; | |
445 | case LFR_MODE_BURST: |
|
444 | case LFR_MODE_BURST: | |
446 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
445 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
447 | status = LFR_DEFAULT; |
|
446 | status = LFR_DEFAULT; | |
448 | } |
|
447 | } | |
449 | else { |
|
448 | else { | |
450 | status = LFR_SUCCESSFUL; |
|
449 | status = LFR_SUCCESSFUL; | |
451 | } |
|
450 | } | |
452 | break; |
|
451 | break; | |
453 | case LFR_MODE_SBM1: |
|
452 | case LFR_MODE_SBM1: | |
454 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
453 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
455 | status = LFR_DEFAULT; |
|
454 | status = LFR_DEFAULT; | |
456 | } |
|
455 | } | |
457 | else { |
|
456 | else { | |
458 | status = LFR_SUCCESSFUL; |
|
457 | status = LFR_SUCCESSFUL; | |
459 | } |
|
458 | } | |
460 | break; |
|
459 | break; | |
461 | case LFR_MODE_SBM2: |
|
460 | case LFR_MODE_SBM2: | |
462 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
461 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
463 | status = LFR_DEFAULT; |
|
462 | status = LFR_DEFAULT; | |
464 | } |
|
463 | } | |
465 | else { |
|
464 | else { | |
466 | status = LFR_SUCCESSFUL; |
|
465 | status = LFR_SUCCESSFUL; | |
467 | } |
|
466 | } | |
468 | break; |
|
467 | break; | |
469 | default: |
|
468 | default: | |
470 | status = LFR_DEFAULT; |
|
469 | status = LFR_DEFAULT; | |
471 | break; |
|
470 | break; | |
472 | } |
|
471 | } | |
473 |
|
472 | |||
474 | return status; |
|
473 | return status; | |
475 | } |
|
474 | } | |
476 |
|
475 | |||
477 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ) |
|
476 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ) | |
478 | { |
|
477 | { | |
479 | if (transitionCoarseTime == 0) |
|
478 | if (transitionCoarseTime == 0) | |
480 | { |
|
479 | { | |
481 | lastValidEnterModeTime = time_management_regs->coarse_time + 1; |
|
480 | lastValidEnterModeTime = time_management_regs->coarse_time + 1; | |
482 | PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime); |
|
481 | PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime); | |
483 | } |
|
482 | } | |
484 | else |
|
483 | else | |
485 | { |
|
484 | { | |
486 | lastValidEnterModeTime = transitionCoarseTime; |
|
485 | lastValidEnterModeTime = transitionCoarseTime; | |
487 | PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime); |
|
486 | PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime); | |
488 | } |
|
487 | } | |
489 | } |
|
488 | } | |
490 |
|
489 | |||
491 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
490 | int check_transition_date( unsigned int transitionCoarseTime ) | |
492 | { |
|
491 | { | |
493 | int status; |
|
492 | int status; | |
494 | unsigned int localCoarseTime; |
|
493 | unsigned int localCoarseTime; | |
495 | unsigned int deltaCoarseTime; |
|
494 | unsigned int deltaCoarseTime; | |
496 |
|
495 | |||
497 | status = LFR_SUCCESSFUL; |
|
496 | status = LFR_SUCCESSFUL; | |
498 |
|
497 | |||
499 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
498 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition | |
500 | { |
|
499 | { | |
501 | status = LFR_SUCCESSFUL; |
|
500 | status = LFR_SUCCESSFUL; | |
502 | } |
|
501 | } | |
503 | else |
|
502 | else | |
504 | { |
|
503 | { | |
505 | localCoarseTime = time_management_regs->coarse_time & COARSE_TIME_MASK; |
|
504 | localCoarseTime = time_management_regs->coarse_time & COARSE_TIME_MASK; | |
506 |
|
505 | |||
507 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime); |
|
506 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime); | |
508 |
|
507 | |||
509 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
508 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 | |
510 | { |
|
509 | { | |
511 | status = LFR_DEFAULT; |
|
510 | status = LFR_DEFAULT; | |
512 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n"); |
|
511 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n"); | |
513 | } |
|
512 | } | |
514 |
|
513 | |||
515 | if (status == LFR_SUCCESSFUL) |
|
514 | if (status == LFR_SUCCESSFUL) | |
516 | { |
|
515 | { | |
517 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
516 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; | |
518 | if ( deltaCoarseTime > MAX_DELTA_COARSE_TIME ) // SSS-CP-EQS-323 |
|
517 | if ( deltaCoarseTime > MAX_DELTA_COARSE_TIME ) // SSS-CP-EQS-323 | |
519 | { |
|
518 | { | |
520 | status = LFR_DEFAULT; |
|
519 | status = LFR_DEFAULT; | |
521 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
520 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) | |
522 | } |
|
521 | } | |
523 | } |
|
522 | } | |
524 | } |
|
523 | } | |
525 |
|
524 | |||
526 | return status; |
|
525 | return status; | |
527 | } |
|
526 | } | |
528 |
|
527 | |||
529 | int restart_asm_activities( unsigned char lfrRequestedMode ) |
|
528 | int restart_asm_activities( unsigned char lfrRequestedMode ) | |
530 | { |
|
529 | { | |
531 | rtems_status_code status; |
|
530 | rtems_status_code status; | |
532 |
|
531 | |||
533 | status = stop_spectral_matrices(); |
|
532 | status = stop_spectral_matrices(); | |
534 |
|
533 | |||
535 | thisIsAnASMRestart = 1; |
|
534 | thisIsAnASMRestart = 1; | |
536 |
|
535 | |||
537 | status = restart_asm_tasks( lfrRequestedMode ); |
|
536 | status = restart_asm_tasks( lfrRequestedMode ); | |
538 |
|
537 | |||
539 | launch_spectral_matrix(); |
|
538 | launch_spectral_matrix(); | |
540 |
|
539 | |||
541 | return status; |
|
540 | return status; | |
542 | } |
|
541 | } | |
543 |
|
542 | |||
544 | int stop_spectral_matrices( void ) |
|
543 | int stop_spectral_matrices( void ) | |
545 | { |
|
544 | { | |
546 | /** This function stops and restarts the current mode average spectral matrices activities. |
|
545 | /** This function stops and restarts the current mode average spectral matrices activities. | |
547 | * |
|
546 | * | |
548 | * @return RTEMS directive status codes: |
|
547 | * @return RTEMS directive status codes: | |
549 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
548 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
550 | * - RTEMS_INVALID_ID - task id invalid |
|
549 | * - RTEMS_INVALID_ID - task id invalid | |
551 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
550 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
552 | * |
|
551 | * | |
553 | */ |
|
552 | */ | |
554 |
|
553 | |||
555 | rtems_status_code status; |
|
554 | rtems_status_code status; | |
556 |
|
555 | |||
557 | status = RTEMS_SUCCESSFUL; |
|
556 | status = RTEMS_SUCCESSFUL; | |
558 |
|
557 | |||
559 | // (1) mask interruptions |
|
558 | // (1) mask interruptions | |
560 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt |
|
559 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt | |
561 |
|
560 | |||
562 | // (2) reset spectral matrices registers |
|
561 | // (2) reset spectral matrices registers | |
563 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
562 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
564 | reset_sm_status(); |
|
563 | reset_sm_status(); | |
565 |
|
564 | |||
566 | // (3) clear interruptions |
|
565 | // (3) clear interruptions | |
567 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
566 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
568 |
|
567 | |||
569 | // suspend several tasks |
|
568 | // suspend several tasks | |
570 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
569 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
571 | status = suspend_asm_tasks(); |
|
570 | status = suspend_asm_tasks(); | |
572 | } |
|
571 | } | |
573 |
|
572 | |||
574 | if (status != RTEMS_SUCCESSFUL) |
|
573 | if (status != RTEMS_SUCCESSFUL) | |
575 | { |
|
574 | { | |
576 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
575 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
577 | } |
|
576 | } | |
578 |
|
577 | |||
579 | return status; |
|
578 | return status; | |
580 | } |
|
579 | } | |
581 |
|
580 | |||
582 | int stop_current_mode( void ) |
|
581 | int stop_current_mode( void ) | |
583 | { |
|
582 | { | |
584 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
583 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
585 | * |
|
584 | * | |
586 | * @return RTEMS directive status codes: |
|
585 | * @return RTEMS directive status codes: | |
587 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
586 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
588 | * - RTEMS_INVALID_ID - task id invalid |
|
587 | * - RTEMS_INVALID_ID - task id invalid | |
589 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
588 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
590 | * |
|
589 | * | |
591 | */ |
|
590 | */ | |
592 |
|
591 | |||
593 | rtems_status_code status; |
|
592 | rtems_status_code status; | |
594 |
|
593 | |||
595 | status = RTEMS_SUCCESSFUL; |
|
594 | status = RTEMS_SUCCESSFUL; | |
596 |
|
595 | |||
597 | // (1) mask interruptions |
|
596 | // (1) mask interruptions | |
598 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
597 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
599 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
598 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
600 |
|
599 | |||
601 | // (2) reset waveform picker registers |
|
600 | // (2) reset waveform picker registers | |
602 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
601 | reset_wfp_burst_enable(); // reset burst and enable bits | |
603 | reset_wfp_status(); // reset all the status bits |
|
602 | reset_wfp_status(); // reset all the status bits | |
604 |
|
603 | |||
605 | // (3) reset spectral matrices registers |
|
604 | // (3) reset spectral matrices registers | |
606 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
605 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
607 | reset_sm_status(); |
|
606 | reset_sm_status(); | |
608 |
|
607 | |||
609 | // reset lfr VHDL module |
|
608 | // reset lfr VHDL module | |
610 | reset_lfr(); |
|
609 | reset_lfr(); | |
611 |
|
610 | |||
612 | reset_extractSWF(); // reset the extractSWF flag to false |
|
611 | reset_extractSWF(); // reset the extractSWF flag to false | |
613 |
|
612 | |||
614 | // (4) clear interruptions |
|
613 | // (4) clear interruptions | |
615 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
614 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
616 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
615 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
617 |
|
616 | |||
618 | // suspend several tasks |
|
617 | // suspend several tasks | |
619 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
618 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
620 | status = suspend_science_tasks(); |
|
619 | status = suspend_science_tasks(); | |
621 | } |
|
620 | } | |
622 |
|
621 | |||
623 | if (status != RTEMS_SUCCESSFUL) |
|
622 | if (status != RTEMS_SUCCESSFUL) | |
624 | { |
|
623 | { | |
625 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
624 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
626 | } |
|
625 | } | |
627 |
|
626 | |||
628 | return status; |
|
627 | return status; | |
629 | } |
|
628 | } | |
630 |
|
629 | |||
631 | int enter_mode_standby( void ) |
|
630 | int enter_mode_standby( void ) | |
632 | { |
|
631 | { | |
633 | /** This function is used to put LFR in the STANDBY mode. |
|
632 | /** This function is used to put LFR in the STANDBY mode. | |
634 | * |
|
633 | * | |
635 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
634 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
636 | * |
|
635 | * | |
637 | * @return RTEMS directive status codes: |
|
636 | * @return RTEMS directive status codes: | |
638 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
637 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
639 | * - RTEMS_INVALID_ID - task id invalid |
|
638 | * - RTEMS_INVALID_ID - task id invalid | |
640 | * - RTEMS_INCORRECT_STATE - task never started |
|
639 | * - RTEMS_INCORRECT_STATE - task never started | |
641 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
640 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
642 | * |
|
641 | * | |
643 | * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE |
|
642 | * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE | |
644 | * is immediate. |
|
643 | * is immediate. | |
645 | * |
|
644 | * | |
646 | */ |
|
645 | */ | |
647 |
|
646 | |||
648 | int status; |
|
647 | int status; | |
649 |
|
648 | |||
650 | status = stop_current_mode(); // STOP THE CURRENT MODE |
|
649 | status = stop_current_mode(); // STOP THE CURRENT MODE | |
651 |
|
650 | |||
652 | #ifdef PRINT_TASK_STATISTICS |
|
651 | #ifdef PRINT_TASK_STATISTICS | |
653 | rtems_cpu_usage_report(); |
|
652 | rtems_cpu_usage_report(); | |
654 | #endif |
|
653 | #endif | |
655 |
|
654 | |||
656 | #ifdef PRINT_STACK_REPORT |
|
655 | #ifdef PRINT_STACK_REPORT | |
657 | PRINTF("stack report selected\n") |
|
656 | PRINTF("stack report selected\n") | |
658 | rtems_stack_checker_report_usage(); |
|
657 | rtems_stack_checker_report_usage(); | |
659 | #endif |
|
658 | #endif | |
660 |
|
659 | |||
661 | return status; |
|
660 | return status; | |
662 | } |
|
661 | } | |
663 |
|
662 | |||
664 | int enter_mode_normal( unsigned int transitionCoarseTime ) |
|
663 | int enter_mode_normal( unsigned int transitionCoarseTime ) | |
665 | { |
|
664 | { | |
666 | /** This function is used to start the NORMAL mode. |
|
665 | /** This function is used to start the NORMAL mode. | |
667 | * |
|
666 | * | |
668 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
667 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
669 | * |
|
668 | * | |
670 | * @return RTEMS directive status codes: |
|
669 | * @return RTEMS directive status codes: | |
671 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
670 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
672 | * - RTEMS_INVALID_ID - task id invalid |
|
671 | * - RTEMS_INVALID_ID - task id invalid | |
673 | * - RTEMS_INCORRECT_STATE - task never started |
|
672 | * - RTEMS_INCORRECT_STATE - task never started | |
674 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
673 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
675 | * |
|
674 | * | |
676 | * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2, |
|
675 | * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2, | |
677 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. |
|
676 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. | |
678 | * |
|
677 | * | |
679 | */ |
|
678 | */ | |
680 |
|
679 | |||
681 | int status; |
|
680 | int status; | |
682 |
|
681 | |||
683 | #ifdef PRINT_TASK_STATISTICS |
|
682 | #ifdef PRINT_TASK_STATISTICS | |
684 | rtems_cpu_usage_reset(); |
|
683 | rtems_cpu_usage_reset(); | |
685 | #endif |
|
684 | #endif | |
686 |
|
685 | |||
687 | status = RTEMS_UNSATISFIED; |
|
686 | status = RTEMS_UNSATISFIED; | |
688 |
|
687 | |||
689 | printf("hop\n"); |
|
688 | printf("hop\n"); | |
690 |
|
689 | |||
691 | switch( lfrCurrentMode ) |
|
690 | switch( lfrCurrentMode ) | |
692 | { |
|
691 | { | |
693 | case LFR_MODE_STANDBY: |
|
692 | case LFR_MODE_STANDBY: | |
694 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks |
|
693 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks | |
695 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
694 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
696 | { |
|
695 | { | |
697 | launch_spectral_matrix( ); |
|
696 | launch_spectral_matrix( ); | |
698 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
697 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
699 | } |
|
698 | } | |
700 | break; |
|
699 | break; | |
701 | case LFR_MODE_BURST: |
|
700 | case LFR_MODE_BURST: | |
702 | status = stop_current_mode(); // stop the current mode |
|
701 | status = stop_current_mode(); // stop the current mode | |
703 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks |
|
702 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks | |
704 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
703 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
705 | { |
|
704 | { | |
706 | launch_spectral_matrix( ); |
|
705 | launch_spectral_matrix( ); | |
707 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
706 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
708 | } |
|
707 | } | |
709 | break; |
|
708 | break; | |
710 | case LFR_MODE_SBM1: |
|
709 | case LFR_MODE_SBM1: | |
711 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters |
|
710 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters | |
712 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
711 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
713 | update_last_valid_transition_date( transitionCoarseTime ); |
|
712 | update_last_valid_transition_date( transitionCoarseTime ); | |
714 | break; |
|
713 | break; | |
715 | case LFR_MODE_SBM2: |
|
714 | case LFR_MODE_SBM2: | |
716 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters |
|
715 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters | |
717 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
716 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
718 | update_last_valid_transition_date( transitionCoarseTime ); |
|
717 | update_last_valid_transition_date( transitionCoarseTime ); | |
719 | break; |
|
718 | break; | |
720 | default: |
|
719 | default: | |
721 | break; |
|
720 | break; | |
722 | } |
|
721 | } | |
723 |
|
722 | |||
724 | if (status != RTEMS_SUCCESSFUL) |
|
723 | if (status != RTEMS_SUCCESSFUL) | |
725 | { |
|
724 | { | |
726 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) |
|
725 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) | |
727 | status = RTEMS_UNSATISFIED; |
|
726 | status = RTEMS_UNSATISFIED; | |
728 | } |
|
727 | } | |
729 |
|
728 | |||
730 | return status; |
|
729 | return status; | |
731 | } |
|
730 | } | |
732 |
|
731 | |||
733 | int enter_mode_burst( unsigned int transitionCoarseTime ) |
|
732 | int enter_mode_burst( unsigned int transitionCoarseTime ) | |
734 | { |
|
733 | { | |
735 | /** This function is used to start the BURST mode. |
|
734 | /** This function is used to start the BURST mode. | |
736 | * |
|
735 | * | |
737 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
736 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
738 | * |
|
737 | * | |
739 | * @return RTEMS directive status codes: |
|
738 | * @return RTEMS directive status codes: | |
740 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
739 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
741 | * - RTEMS_INVALID_ID - task id invalid |
|
740 | * - RTEMS_INVALID_ID - task id invalid | |
742 | * - RTEMS_INCORRECT_STATE - task never started |
|
741 | * - RTEMS_INCORRECT_STATE - task never started | |
743 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
742 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
744 | * |
|
743 | * | |
745 | * The way the BURST mode is started does not depend on the LFR current mode. |
|
744 | * The way the BURST mode is started does not depend on the LFR current mode. | |
746 | * |
|
745 | * | |
747 | */ |
|
746 | */ | |
748 |
|
747 | |||
749 |
|
748 | |||
750 | int status; |
|
749 | int status; | |
751 |
|
750 | |||
752 | #ifdef PRINT_TASK_STATISTICS |
|
751 | #ifdef PRINT_TASK_STATISTICS | |
753 | rtems_cpu_usage_reset(); |
|
752 | rtems_cpu_usage_reset(); | |
754 | #endif |
|
753 | #endif | |
755 |
|
754 | |||
756 | status = stop_current_mode(); // stop the current mode |
|
755 | status = stop_current_mode(); // stop the current mode | |
757 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks |
|
756 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks | |
758 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
757 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
759 | { |
|
758 | { | |
760 | launch_spectral_matrix( ); |
|
759 | launch_spectral_matrix( ); | |
761 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); |
|
760 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); | |
762 | } |
|
761 | } | |
763 |
|
762 | |||
764 | if (status != RTEMS_SUCCESSFUL) |
|
763 | if (status != RTEMS_SUCCESSFUL) | |
765 | { |
|
764 | { | |
766 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) |
|
765 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) | |
767 | status = RTEMS_UNSATISFIED; |
|
766 | status = RTEMS_UNSATISFIED; | |
768 | } |
|
767 | } | |
769 |
|
768 | |||
770 | return status; |
|
769 | return status; | |
771 | } |
|
770 | } | |
772 |
|
771 | |||
773 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) |
|
772 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) | |
774 | { |
|
773 | { | |
775 | /** This function is used to start the SBM1 mode. |
|
774 | /** This function is used to start the SBM1 mode. | |
776 | * |
|
775 | * | |
777 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
776 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
778 | * |
|
777 | * | |
779 | * @return RTEMS directive status codes: |
|
778 | * @return RTEMS directive status codes: | |
780 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
779 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
781 | * - RTEMS_INVALID_ID - task id invalid |
|
780 | * - RTEMS_INVALID_ID - task id invalid | |
782 | * - RTEMS_INCORRECT_STATE - task never started |
|
781 | * - RTEMS_INCORRECT_STATE - task never started | |
783 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
782 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
784 | * |
|
783 | * | |
785 | * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2, |
|
784 | * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2, | |
786 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other |
|
785 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other | |
787 | * cases, the acquisition is completely restarted. |
|
786 | * cases, the acquisition is completely restarted. | |
788 | * |
|
787 | * | |
789 | */ |
|
788 | */ | |
790 |
|
789 | |||
791 | int status; |
|
790 | int status; | |
792 |
|
791 | |||
793 | #ifdef PRINT_TASK_STATISTICS |
|
792 | #ifdef PRINT_TASK_STATISTICS | |
794 | rtems_cpu_usage_reset(); |
|
793 | rtems_cpu_usage_reset(); | |
795 | #endif |
|
794 | #endif | |
796 |
|
795 | |||
797 | status = RTEMS_UNSATISFIED; |
|
796 | status = RTEMS_UNSATISFIED; | |
798 |
|
797 | |||
799 | switch( lfrCurrentMode ) |
|
798 | switch( lfrCurrentMode ) | |
800 | { |
|
799 | { | |
801 | case LFR_MODE_STANDBY: |
|
800 | case LFR_MODE_STANDBY: | |
802 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks |
|
801 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks | |
803 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
802 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
804 | { |
|
803 | { | |
805 | launch_spectral_matrix( ); |
|
804 | launch_spectral_matrix( ); | |
806 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
805 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
807 | } |
|
806 | } | |
808 | break; |
|
807 | break; | |
809 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action |
|
808 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action | |
810 | status = restart_asm_activities( LFR_MODE_SBM1 ); |
|
809 | status = restart_asm_activities( LFR_MODE_SBM1 ); | |
811 | status = LFR_SUCCESSFUL; |
|
810 | status = LFR_SUCCESSFUL; | |
812 | update_last_valid_transition_date( transitionCoarseTime ); |
|
811 | update_last_valid_transition_date( transitionCoarseTime ); | |
813 | break; |
|
812 | break; | |
814 | case LFR_MODE_BURST: |
|
813 | case LFR_MODE_BURST: | |
815 | status = stop_current_mode(); // stop the current mode |
|
814 | status = stop_current_mode(); // stop the current mode | |
816 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks |
|
815 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks | |
817 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
816 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
818 | { |
|
817 | { | |
819 | launch_spectral_matrix( ); |
|
818 | launch_spectral_matrix( ); | |
820 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
819 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
821 | } |
|
820 | } | |
822 | break; |
|
821 | break; | |
823 | case LFR_MODE_SBM2: |
|
822 | case LFR_MODE_SBM2: | |
824 | status = restart_asm_activities( LFR_MODE_SBM1 ); |
|
823 | status = restart_asm_activities( LFR_MODE_SBM1 ); | |
825 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
824 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
826 | update_last_valid_transition_date( transitionCoarseTime ); |
|
825 | update_last_valid_transition_date( transitionCoarseTime ); | |
827 | break; |
|
826 | break; | |
828 | default: |
|
827 | default: | |
829 | break; |
|
828 | break; | |
830 | } |
|
829 | } | |
831 |
|
830 | |||
832 | if (status != RTEMS_SUCCESSFUL) |
|
831 | if (status != RTEMS_SUCCESSFUL) | |
833 | { |
|
832 | { | |
834 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status); |
|
833 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status); | |
835 | status = RTEMS_UNSATISFIED; |
|
834 | status = RTEMS_UNSATISFIED; | |
836 | } |
|
835 | } | |
837 |
|
836 | |||
838 | return status; |
|
837 | return status; | |
839 | } |
|
838 | } | |
840 |
|
839 | |||
841 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) |
|
840 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) | |
842 | { |
|
841 | { | |
843 | /** This function is used to start the SBM2 mode. |
|
842 | /** This function is used to start the SBM2 mode. | |
844 | * |
|
843 | * | |
845 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
844 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
846 | * |
|
845 | * | |
847 | * @return RTEMS directive status codes: |
|
846 | * @return RTEMS directive status codes: | |
848 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
847 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
849 | * - RTEMS_INVALID_ID - task id invalid |
|
848 | * - RTEMS_INVALID_ID - task id invalid | |
850 | * - RTEMS_INCORRECT_STATE - task never started |
|
849 | * - RTEMS_INCORRECT_STATE - task never started | |
851 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
850 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
852 | * |
|
851 | * | |
853 | * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1, |
|
852 | * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1, | |
854 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other |
|
853 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other | |
855 | * cases, the acquisition is completely restarted. |
|
854 | * cases, the acquisition is completely restarted. | |
856 | * |
|
855 | * | |
857 | */ |
|
856 | */ | |
858 |
|
857 | |||
859 | int status; |
|
858 | int status; | |
860 |
|
859 | |||
861 | #ifdef PRINT_TASK_STATISTICS |
|
860 | #ifdef PRINT_TASK_STATISTICS | |
862 | rtems_cpu_usage_reset(); |
|
861 | rtems_cpu_usage_reset(); | |
863 | #endif |
|
862 | #endif | |
864 |
|
863 | |||
865 | status = RTEMS_UNSATISFIED; |
|
864 | status = RTEMS_UNSATISFIED; | |
866 |
|
865 | |||
867 | switch( lfrCurrentMode ) |
|
866 | switch( lfrCurrentMode ) | |
868 | { |
|
867 | { | |
869 | case LFR_MODE_STANDBY: |
|
868 | case LFR_MODE_STANDBY: | |
870 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks |
|
869 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks | |
871 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
870 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
872 | { |
|
871 | { | |
873 | launch_spectral_matrix( ); |
|
872 | launch_spectral_matrix( ); | |
874 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
873 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
875 | } |
|
874 | } | |
876 | break; |
|
875 | break; | |
877 | case LFR_MODE_NORMAL: |
|
876 | case LFR_MODE_NORMAL: | |
878 | status = restart_asm_activities( LFR_MODE_SBM2 ); |
|
877 | status = restart_asm_activities( LFR_MODE_SBM2 ); | |
879 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
878 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
880 | update_last_valid_transition_date( transitionCoarseTime ); |
|
879 | update_last_valid_transition_date( transitionCoarseTime ); | |
881 | break; |
|
880 | break; | |
882 | case LFR_MODE_BURST: |
|
881 | case LFR_MODE_BURST: | |
883 | status = stop_current_mode(); // stop the current mode |
|
882 | status = stop_current_mode(); // stop the current mode | |
884 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks |
|
883 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks | |
885 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
884 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
886 | { |
|
885 | { | |
887 | launch_spectral_matrix( ); |
|
886 | launch_spectral_matrix( ); | |
888 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
887 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
889 | } |
|
888 | } | |
890 | break; |
|
889 | break; | |
891 | case LFR_MODE_SBM1: |
|
890 | case LFR_MODE_SBM1: | |
892 | status = restart_asm_activities( LFR_MODE_SBM2 ); |
|
891 | status = restart_asm_activities( LFR_MODE_SBM2 ); | |
893 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
892 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
894 | update_last_valid_transition_date( transitionCoarseTime ); |
|
893 | update_last_valid_transition_date( transitionCoarseTime ); | |
895 | break; |
|
894 | break; | |
896 | default: |
|
895 | default: | |
897 | break; |
|
896 | break; | |
898 | } |
|
897 | } | |
899 |
|
898 | |||
900 | if (status != RTEMS_SUCCESSFUL) |
|
899 | if (status != RTEMS_SUCCESSFUL) | |
901 | { |
|
900 | { | |
902 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) |
|
901 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) | |
903 | status = RTEMS_UNSATISFIED; |
|
902 | status = RTEMS_UNSATISFIED; | |
904 | } |
|
903 | } | |
905 |
|
904 | |||
906 | return status; |
|
905 | return status; | |
907 | } |
|
906 | } | |
908 |
|
907 | |||
909 | int restart_science_tasks( unsigned char lfrRequestedMode ) |
|
908 | int restart_science_tasks( unsigned char lfrRequestedMode ) | |
910 | { |
|
909 | { | |
911 | /** This function is used to restart all science tasks. |
|
910 | /** This function is used to restart all science tasks. | |
912 | * |
|
911 | * | |
913 | * @return RTEMS directive status codes: |
|
912 | * @return RTEMS directive status codes: | |
914 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
913 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
915 | * - RTEMS_INVALID_ID - task id invalid |
|
914 | * - RTEMS_INVALID_ID - task id invalid | |
916 | * - RTEMS_INCORRECT_STATE - task never started |
|
915 | * - RTEMS_INCORRECT_STATE - task never started | |
917 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
916 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
918 | * |
|
917 | * | |
919 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
918 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 | |
920 | * |
|
919 | * | |
921 | */ |
|
920 | */ | |
922 |
|
921 | |||
923 | rtems_status_code status[NB_SCIENCE_TASKS]; |
|
922 | rtems_status_code status[NB_SCIENCE_TASKS]; | |
924 | rtems_status_code ret; |
|
923 | rtems_status_code ret; | |
925 |
|
924 | |||
926 | ret = RTEMS_SUCCESSFUL; |
|
925 | ret = RTEMS_SUCCESSFUL; | |
927 |
|
926 | |||
928 | status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
927 | status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
929 | if (status[STATUS_0] != RTEMS_SUCCESSFUL) |
|
928 | if (status[STATUS_0] != RTEMS_SUCCESSFUL) | |
930 | { |
|
929 | { | |
931 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0]) |
|
930 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0]) | |
932 | } |
|
931 | } | |
933 |
|
932 | |||
934 | status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
933 | status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
935 | if (status[STATUS_1] != RTEMS_SUCCESSFUL) |
|
934 | if (status[STATUS_1] != RTEMS_SUCCESSFUL) | |
936 | { |
|
935 | { | |
937 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1]) |
|
936 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1]) | |
938 | } |
|
937 | } | |
939 |
|
938 | |||
940 | status[STATUS_2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
939 | status[STATUS_2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
941 | if (status[STATUS_2] != RTEMS_SUCCESSFUL) |
|
940 | if (status[STATUS_2] != RTEMS_SUCCESSFUL) | |
942 | { |
|
941 | { | |
943 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[STATUS_2]) |
|
942 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[STATUS_2]) | |
944 | } |
|
943 | } | |
945 |
|
944 | |||
946 | status[STATUS_3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
945 | status[STATUS_3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
947 | if (status[STATUS_3] != RTEMS_SUCCESSFUL) |
|
946 | if (status[STATUS_3] != RTEMS_SUCCESSFUL) | |
948 | { |
|
947 | { | |
949 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[STATUS_3]) |
|
948 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[STATUS_3]) | |
950 | } |
|
949 | } | |
951 |
|
950 | |||
952 | status[STATUS_4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
951 | status[STATUS_4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
953 | if (status[STATUS_4] != RTEMS_SUCCESSFUL) |
|
952 | if (status[STATUS_4] != RTEMS_SUCCESSFUL) | |
954 | { |
|
953 | { | |
955 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[STATUS_4]) |
|
954 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[STATUS_4]) | |
956 | } |
|
955 | } | |
957 |
|
956 | |||
958 | status[STATUS_5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
957 | status[STATUS_5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
959 | if (status[STATUS_5] != RTEMS_SUCCESSFUL) |
|
958 | if (status[STATUS_5] != RTEMS_SUCCESSFUL) | |
960 | { |
|
959 | { | |
961 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[STATUS_5]) |
|
960 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[STATUS_5]) | |
962 | } |
|
961 | } | |
963 |
|
962 | |||
964 | status[STATUS_6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
963 | status[STATUS_6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
965 | if (status[STATUS_6] != RTEMS_SUCCESSFUL) |
|
964 | if (status[STATUS_6] != RTEMS_SUCCESSFUL) | |
966 | { |
|
965 | { | |
967 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_6]) |
|
966 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_6]) | |
968 | } |
|
967 | } | |
969 |
|
968 | |||
970 | status[STATUS_7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
969 | status[STATUS_7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
971 | if (status[STATUS_7] != RTEMS_SUCCESSFUL) |
|
970 | if (status[STATUS_7] != RTEMS_SUCCESSFUL) | |
972 | { |
|
971 | { | |
973 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_7]) |
|
972 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_7]) | |
974 | } |
|
973 | } | |
975 |
|
974 | |||
976 | status[STATUS_8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
975 | status[STATUS_8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
977 | if (status[STATUS_8] != RTEMS_SUCCESSFUL) |
|
976 | if (status[STATUS_8] != RTEMS_SUCCESSFUL) | |
978 | { |
|
977 | { | |
979 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_8]) |
|
978 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_8]) | |
980 | } |
|
979 | } | |
981 |
|
980 | |||
982 | status[STATUS_9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
981 | status[STATUS_9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
983 | if (status[STATUS_9] != RTEMS_SUCCESSFUL) |
|
982 | if (status[STATUS_9] != RTEMS_SUCCESSFUL) | |
984 | { |
|
983 | { | |
985 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_9]) |
|
984 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_9]) | |
986 | } |
|
985 | } | |
987 |
|
986 | |||
988 | if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) || |
|
987 | if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) || | |
989 | (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) || |
|
988 | (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) || | |
990 | (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) || |
|
989 | (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) || | |
991 | (status[STATUS_6] != RTEMS_SUCCESSFUL) || (status[STATUS_7] != RTEMS_SUCCESSFUL) || |
|
990 | (status[STATUS_6] != RTEMS_SUCCESSFUL) || (status[STATUS_7] != RTEMS_SUCCESSFUL) || | |
992 | (status[STATUS_8] != RTEMS_SUCCESSFUL) || (status[STATUS_9] != RTEMS_SUCCESSFUL) ) |
|
991 | (status[STATUS_8] != RTEMS_SUCCESSFUL) || (status[STATUS_9] != RTEMS_SUCCESSFUL) ) | |
993 | { |
|
992 | { | |
994 | ret = RTEMS_UNSATISFIED; |
|
993 | ret = RTEMS_UNSATISFIED; | |
995 | } |
|
994 | } | |
996 |
|
995 | |||
997 | return ret; |
|
996 | return ret; | |
998 | } |
|
997 | } | |
999 |
|
998 | |||
1000 | int restart_asm_tasks( unsigned char lfrRequestedMode ) |
|
999 | int restart_asm_tasks( unsigned char lfrRequestedMode ) | |
1001 | { |
|
1000 | { | |
1002 | /** This function is used to restart average spectral matrices tasks. |
|
1001 | /** This function is used to restart average spectral matrices tasks. | |
1003 | * |
|
1002 | * | |
1004 | * @return RTEMS directive status codes: |
|
1003 | * @return RTEMS directive status codes: | |
1005 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1004 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1006 | * - RTEMS_INVALID_ID - task id invalid |
|
1005 | * - RTEMS_INVALID_ID - task id invalid | |
1007 | * - RTEMS_INCORRECT_STATE - task never started |
|
1006 | * - RTEMS_INCORRECT_STATE - task never started | |
1008 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
1007 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
1009 | * |
|
1008 | * | |
1010 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 |
|
1009 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 | |
1011 | * |
|
1010 | * | |
1012 | */ |
|
1011 | */ | |
1013 |
|
1012 | |||
1014 | rtems_status_code status[NB_ASM_TASKS]; |
|
1013 | rtems_status_code status[NB_ASM_TASKS]; | |
1015 | rtems_status_code ret; |
|
1014 | rtems_status_code ret; | |
1016 |
|
1015 | |||
1017 | ret = RTEMS_SUCCESSFUL; |
|
1016 | ret = RTEMS_SUCCESSFUL; | |
1018 |
|
1017 | |||
1019 | status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
1018 | status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
1020 | if (status[STATUS_0] != RTEMS_SUCCESSFUL) |
|
1019 | if (status[STATUS_0] != RTEMS_SUCCESSFUL) | |
1021 | { |
|
1020 | { | |
1022 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0]) |
|
1021 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0]) | |
1023 | } |
|
1022 | } | |
1024 |
|
1023 | |||
1025 | status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
1024 | status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
1026 | if (status[STATUS_1] != RTEMS_SUCCESSFUL) |
|
1025 | if (status[STATUS_1] != RTEMS_SUCCESSFUL) | |
1027 | { |
|
1026 | { | |
1028 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1]) |
|
1027 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1]) | |
1029 | } |
|
1028 | } | |
1030 |
|
1029 | |||
1031 | status[STATUS_2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
1030 | status[STATUS_2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
1032 | if (status[STATUS_2] != RTEMS_SUCCESSFUL) |
|
1031 | if (status[STATUS_2] != RTEMS_SUCCESSFUL) | |
1033 | { |
|
1032 | { | |
1034 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_2]) |
|
1033 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_2]) | |
1035 | } |
|
1034 | } | |
1036 |
|
1035 | |||
1037 | status[STATUS_3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
1036 | status[STATUS_3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
1038 | if (status[STATUS_3] != RTEMS_SUCCESSFUL) |
|
1037 | if (status[STATUS_3] != RTEMS_SUCCESSFUL) | |
1039 | { |
|
1038 | { | |
1040 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_3]) |
|
1039 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_3]) | |
1041 | } |
|
1040 | } | |
1042 |
|
1041 | |||
1043 | status[STATUS_4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
1042 | status[STATUS_4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
1044 | if (status[STATUS_4] != RTEMS_SUCCESSFUL) |
|
1043 | if (status[STATUS_4] != RTEMS_SUCCESSFUL) | |
1045 | { |
|
1044 | { | |
1046 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_4]) |
|
1045 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_4]) | |
1047 | } |
|
1046 | } | |
1048 |
|
1047 | |||
1049 | status[STATUS_5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
1048 | status[STATUS_5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
1050 | if (status[STATUS_5] != RTEMS_SUCCESSFUL) |
|
1049 | if (status[STATUS_5] != RTEMS_SUCCESSFUL) | |
1051 | { |
|
1050 | { | |
1052 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_5]) |
|
1051 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_5]) | |
1053 | } |
|
1052 | } | |
1054 |
|
1053 | |||
1055 | if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) || |
|
1054 | if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) || | |
1056 | (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) || |
|
1055 | (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) || | |
1057 | (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) ) |
|
1056 | (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) ) | |
1058 | { |
|
1057 | { | |
1059 | ret = RTEMS_UNSATISFIED; |
|
1058 | ret = RTEMS_UNSATISFIED; | |
1060 | } |
|
1059 | } | |
1061 |
|
1060 | |||
1062 | return ret; |
|
1061 | return ret; | |
1063 | } |
|
1062 | } | |
1064 |
|
1063 | |||
1065 | int suspend_science_tasks( void ) |
|
1064 | int suspend_science_tasks( void ) | |
1066 | { |
|
1065 | { | |
1067 | /** This function suspends the science tasks. |
|
1066 | /** This function suspends the science tasks. | |
1068 | * |
|
1067 | * | |
1069 | * @return RTEMS directive status codes: |
|
1068 | * @return RTEMS directive status codes: | |
1070 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1069 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1071 | * - RTEMS_INVALID_ID - task id invalid |
|
1070 | * - RTEMS_INVALID_ID - task id invalid | |
1072 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1071 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
1073 | * |
|
1072 | * | |
1074 | */ |
|
1073 | */ | |
1075 |
|
1074 | |||
1076 | rtems_status_code status; |
|
1075 | rtems_status_code status; | |
1077 |
|
1076 | |||
1078 | PRINTF("in suspend_science_tasks\n") |
|
1077 | PRINTF("in suspend_science_tasks\n") | |
1079 |
|
1078 | |||
1080 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
1079 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
1081 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1080 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1082 | { |
|
1081 | { | |
1083 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1082 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
1084 | } |
|
1083 | } | |
1085 | else |
|
1084 | else | |
1086 | { |
|
1085 | { | |
1087 | status = RTEMS_SUCCESSFUL; |
|
1086 | status = RTEMS_SUCCESSFUL; | |
1088 | } |
|
1087 | } | |
1089 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
1088 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
1090 | { |
|
1089 | { | |
1091 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
1090 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
1092 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1091 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1093 | { |
|
1092 | { | |
1094 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
1093 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
1095 | } |
|
1094 | } | |
1096 | else |
|
1095 | else | |
1097 | { |
|
1096 | { | |
1098 | status = RTEMS_SUCCESSFUL; |
|
1097 | status = RTEMS_SUCCESSFUL; | |
1099 | } |
|
1098 | } | |
1100 | } |
|
1099 | } | |
1101 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
1100 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
1102 | { |
|
1101 | { | |
1103 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
1102 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
1104 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1103 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1105 | { |
|
1104 | { | |
1106 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
1105 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
1107 | } |
|
1106 | } | |
1108 | else |
|
1107 | else | |
1109 | { |
|
1108 | { | |
1110 | status = RTEMS_SUCCESSFUL; |
|
1109 | status = RTEMS_SUCCESSFUL; | |
1111 | } |
|
1110 | } | |
1112 | } |
|
1111 | } | |
1113 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
1112 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
1114 | { |
|
1113 | { | |
1115 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
1114 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
1116 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1115 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1117 | { |
|
1116 | { | |
1118 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
1117 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
1119 | } |
|
1118 | } | |
1120 | else |
|
1119 | else | |
1121 | { |
|
1120 | { | |
1122 | status = RTEMS_SUCCESSFUL; |
|
1121 | status = RTEMS_SUCCESSFUL; | |
1123 | } |
|
1122 | } | |
1124 | } |
|
1123 | } | |
1125 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
1124 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
1126 | { |
|
1125 | { | |
1127 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
1126 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
1128 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1127 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1129 | { |
|
1128 | { | |
1130 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
1129 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
1131 | } |
|
1130 | } | |
1132 | else |
|
1131 | else | |
1133 | { |
|
1132 | { | |
1134 | status = RTEMS_SUCCESSFUL; |
|
1133 | status = RTEMS_SUCCESSFUL; | |
1135 | } |
|
1134 | } | |
1136 | } |
|
1135 | } | |
1137 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1136 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1138 | { |
|
1137 | { | |
1139 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1138 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1140 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1139 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1141 | { |
|
1140 | { | |
1142 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1141 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1143 | } |
|
1142 | } | |
1144 | else |
|
1143 | else | |
1145 | { |
|
1144 | { | |
1146 | status = RTEMS_SUCCESSFUL; |
|
1145 | status = RTEMS_SUCCESSFUL; | |
1147 | } |
|
1146 | } | |
1148 | } |
|
1147 | } | |
1149 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
1148 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
1150 | { |
|
1149 | { | |
1151 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
1150 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
1152 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1151 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1153 | { |
|
1152 | { | |
1154 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
1153 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
1155 | } |
|
1154 | } | |
1156 | else |
|
1155 | else | |
1157 | { |
|
1156 | { | |
1158 | status = RTEMS_SUCCESSFUL; |
|
1157 | status = RTEMS_SUCCESSFUL; | |
1159 | } |
|
1158 | } | |
1160 | } |
|
1159 | } | |
1161 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
1160 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
1162 | { |
|
1161 | { | |
1163 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
1162 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
1164 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1163 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1165 | { |
|
1164 | { | |
1166 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
1165 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
1167 | } |
|
1166 | } | |
1168 | else |
|
1167 | else | |
1169 | { |
|
1168 | { | |
1170 | status = RTEMS_SUCCESSFUL; |
|
1169 | status = RTEMS_SUCCESSFUL; | |
1171 | } |
|
1170 | } | |
1172 | } |
|
1171 | } | |
1173 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
1172 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
1174 | { |
|
1173 | { | |
1175 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
1174 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
1176 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1175 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1177 | { |
|
1176 | { | |
1178 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
1177 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
1179 | } |
|
1178 | } | |
1180 | else |
|
1179 | else | |
1181 | { |
|
1180 | { | |
1182 | status = RTEMS_SUCCESSFUL; |
|
1181 | status = RTEMS_SUCCESSFUL; | |
1183 | } |
|
1182 | } | |
1184 | } |
|
1183 | } | |
1185 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
1184 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
1186 | { |
|
1185 | { | |
1187 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
1186 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
1188 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1187 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1189 | { |
|
1188 | { | |
1190 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
1189 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
1191 | } |
|
1190 | } | |
1192 | else |
|
1191 | else | |
1193 | { |
|
1192 | { | |
1194 | status = RTEMS_SUCCESSFUL; |
|
1193 | status = RTEMS_SUCCESSFUL; | |
1195 | } |
|
1194 | } | |
1196 | } |
|
1195 | } | |
1197 |
|
1196 | |||
1198 | return status; |
|
1197 | return status; | |
1199 | } |
|
1198 | } | |
1200 |
|
1199 | |||
1201 | int suspend_asm_tasks( void ) |
|
1200 | int suspend_asm_tasks( void ) | |
1202 | { |
|
1201 | { | |
1203 | /** This function suspends the science tasks. |
|
1202 | /** This function suspends the science tasks. | |
1204 | * |
|
1203 | * | |
1205 | * @return RTEMS directive status codes: |
|
1204 | * @return RTEMS directive status codes: | |
1206 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1205 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1207 | * - RTEMS_INVALID_ID - task id invalid |
|
1206 | * - RTEMS_INVALID_ID - task id invalid | |
1208 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1207 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
1209 | * |
|
1208 | * | |
1210 | */ |
|
1209 | */ | |
1211 |
|
1210 | |||
1212 | rtems_status_code status; |
|
1211 | rtems_status_code status; | |
1213 |
|
1212 | |||
1214 | PRINTF("in suspend_science_tasks\n") |
|
1213 | PRINTF("in suspend_science_tasks\n") | |
1215 |
|
1214 | |||
1216 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
1215 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
1217 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1216 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1218 | { |
|
1217 | { | |
1219 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1218 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
1220 | } |
|
1219 | } | |
1221 | else |
|
1220 | else | |
1222 | { |
|
1221 | { | |
1223 | status = RTEMS_SUCCESSFUL; |
|
1222 | status = RTEMS_SUCCESSFUL; | |
1224 | } |
|
1223 | } | |
1225 |
|
1224 | |||
1226 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
1225 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
1227 | { |
|
1226 | { | |
1228 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
1227 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
1229 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1228 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1230 | { |
|
1229 | { | |
1231 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
1230 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
1232 | } |
|
1231 | } | |
1233 | else |
|
1232 | else | |
1234 | { |
|
1233 | { | |
1235 | status = RTEMS_SUCCESSFUL; |
|
1234 | status = RTEMS_SUCCESSFUL; | |
1236 | } |
|
1235 | } | |
1237 | } |
|
1236 | } | |
1238 |
|
1237 | |||
1239 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
1238 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
1240 | { |
|
1239 | { | |
1241 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
1240 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
1242 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1241 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1243 | { |
|
1242 | { | |
1244 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
1243 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
1245 | } |
|
1244 | } | |
1246 | else |
|
1245 | else | |
1247 | { |
|
1246 | { | |
1248 | status = RTEMS_SUCCESSFUL; |
|
1247 | status = RTEMS_SUCCESSFUL; | |
1249 | } |
|
1248 | } | |
1250 | } |
|
1249 | } | |
1251 |
|
1250 | |||
1252 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
1251 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
1253 | { |
|
1252 | { | |
1254 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
1253 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
1255 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1254 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1256 | { |
|
1255 | { | |
1257 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
1256 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
1258 | } |
|
1257 | } | |
1259 | else |
|
1258 | else | |
1260 | { |
|
1259 | { | |
1261 | status = RTEMS_SUCCESSFUL; |
|
1260 | status = RTEMS_SUCCESSFUL; | |
1262 | } |
|
1261 | } | |
1263 | } |
|
1262 | } | |
1264 |
|
1263 | |||
1265 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
1264 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
1266 | { |
|
1265 | { | |
1267 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
1266 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
1268 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1267 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1269 | { |
|
1268 | { | |
1270 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
1269 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
1271 | } |
|
1270 | } | |
1272 | else |
|
1271 | else | |
1273 | { |
|
1272 | { | |
1274 | status = RTEMS_SUCCESSFUL; |
|
1273 | status = RTEMS_SUCCESSFUL; | |
1275 | } |
|
1274 | } | |
1276 | } |
|
1275 | } | |
1277 |
|
1276 | |||
1278 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1277 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1279 | { |
|
1278 | { | |
1280 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1279 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1281 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1280 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1282 | { |
|
1281 | { | |
1283 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1282 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1284 | } |
|
1283 | } | |
1285 | else |
|
1284 | else | |
1286 | { |
|
1285 | { | |
1287 | status = RTEMS_SUCCESSFUL; |
|
1286 | status = RTEMS_SUCCESSFUL; | |
1288 | } |
|
1287 | } | |
1289 | } |
|
1288 | } | |
1290 |
|
1289 | |||
1291 | return status; |
|
1290 | return status; | |
1292 | } |
|
1291 | } | |
1293 |
|
1292 | |||
1294 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
1293 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) | |
1295 | { |
|
1294 | { | |
1296 |
|
1295 | |||
1297 | WFP_reset_current_ring_nodes(); |
|
1296 | WFP_reset_current_ring_nodes(); | |
1298 |
|
1297 | |||
1299 | reset_waveform_picker_regs(); |
|
1298 | reset_waveform_picker_regs(); | |
1300 |
|
1299 | |||
1301 | set_wfp_burst_enable_register( mode ); |
|
1300 | set_wfp_burst_enable_register( mode ); | |
1302 |
|
1301 | |||
1303 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1302 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
1304 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1303 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
1305 |
|
1304 | |||
1306 | if (transitionCoarseTime == 0) |
|
1305 | if (transitionCoarseTime == 0) | |
1307 | { |
|
1306 | { | |
1308 | // instant transition means transition on the next valid date |
|
1307 | // instant transition means transition on the next valid date | |
1309 | // this is mandatory to have a good snapshot period and a good correction of the snapshot period |
|
1308 | // this is mandatory to have a good snapshot period and a good correction of the snapshot period | |
1310 | waveform_picker_regs->start_date = time_management_regs->coarse_time + 1; |
|
1309 | waveform_picker_regs->start_date = time_management_regs->coarse_time + 1; | |
1311 | } |
|
1310 | } | |
1312 | else |
|
1311 | else | |
1313 | { |
|
1312 | { | |
1314 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
1313 | waveform_picker_regs->start_date = transitionCoarseTime; | |
1315 | } |
|
1314 | } | |
1316 |
|
1315 | |||
1317 | update_last_valid_transition_date(waveform_picker_regs->start_date); |
|
1316 | update_last_valid_transition_date(waveform_picker_regs->start_date); | |
1318 |
|
1317 | |||
1319 | } |
|
1318 | } | |
1320 |
|
1319 | |||
1321 | void launch_spectral_matrix( void ) |
|
1320 | void launch_spectral_matrix( void ) | |
1322 | { |
|
1321 | { | |
1323 | SM_reset_current_ring_nodes(); |
|
1322 | SM_reset_current_ring_nodes(); | |
1324 |
|
1323 | |||
1325 | reset_spectral_matrix_regs(); |
|
1324 | reset_spectral_matrix_regs(); | |
1326 |
|
1325 | |||
1327 | reset_nb_sm(); |
|
1326 | reset_nb_sm(); | |
1328 |
|
1327 | |||
1329 | set_sm_irq_onNewMatrix( 1 ); |
|
1328 | set_sm_irq_onNewMatrix( 1 ); | |
1330 |
|
1329 | |||
1331 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1330 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1332 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1331 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1333 |
|
1332 | |||
1334 | } |
|
1333 | } | |
1335 |
|
1334 | |||
1336 | void set_sm_irq_onNewMatrix( unsigned char value ) |
|
1335 | void set_sm_irq_onNewMatrix( unsigned char value ) | |
1337 | { |
|
1336 | { | |
1338 | if (value == 1) |
|
1337 | if (value == 1) | |
1339 | { |
|
1338 | { | |
1340 | spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_NEW_MATRIX; |
|
1339 | spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_NEW_MATRIX; | |
1341 | } |
|
1340 | } | |
1342 | else |
|
1341 | else | |
1343 | { |
|
1342 | { | |
1344 | spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_NEW_MATRIX; // 1110 |
|
1343 | spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_NEW_MATRIX; // 1110 | |
1345 | } |
|
1344 | } | |
1346 | } |
|
1345 | } | |
1347 |
|
1346 | |||
1348 | void set_sm_irq_onError( unsigned char value ) |
|
1347 | void set_sm_irq_onError( unsigned char value ) | |
1349 | { |
|
1348 | { | |
1350 | if (value == 1) |
|
1349 | if (value == 1) | |
1351 | { |
|
1350 | { | |
1352 | spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_ERROR; |
|
1351 | spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_ERROR; | |
1353 | } |
|
1352 | } | |
1354 | else |
|
1353 | else | |
1355 | { |
|
1354 | { | |
1356 | spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_ERROR; // 1101 |
|
1355 | spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_ERROR; // 1101 | |
1357 | } |
|
1356 | } | |
1358 | } |
|
1357 | } | |
1359 |
|
1358 | |||
1360 | //***************************** |
|
1359 | //***************************** | |
1361 | // CONFIGURE CALIBRATION SIGNAL |
|
1360 | // CONFIGURE CALIBRATION SIGNAL | |
1362 | void setCalibrationPrescaler( unsigned int prescaler ) |
|
1361 | void setCalibrationPrescaler( unsigned int prescaler ) | |
1363 | { |
|
1362 | { | |
1364 | // prescaling of the master clock (25 MHz) |
|
1363 | // prescaling of the master clock (25 MHz) | |
1365 | // master clock is divided by 2^prescaler |
|
1364 | // master clock is divided by 2^prescaler | |
1366 | time_management_regs->calPrescaler = prescaler; |
|
1365 | time_management_regs->calPrescaler = prescaler; | |
1367 | } |
|
1366 | } | |
1368 |
|
1367 | |||
1369 | void setCalibrationDivisor( unsigned int divisionFactor ) |
|
1368 | void setCalibrationDivisor( unsigned int divisionFactor ) | |
1370 | { |
|
1369 | { | |
1371 | // division of the prescaled clock by the division factor |
|
1370 | // division of the prescaled clock by the division factor | |
1372 | time_management_regs->calDivisor = divisionFactor; |
|
1371 | time_management_regs->calDivisor = divisionFactor; | |
1373 | } |
|
1372 | } | |
1374 |
|
1373 | |||
1375 | void setCalibrationData( void ) |
|
1374 | void setCalibrationData( void ) | |
1376 | { |
|
1375 | { | |
1377 | /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal |
|
1376 | /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal | |
1378 | * |
|
1377 | * | |
1379 | * @param void |
|
1378 | * @param void | |
1380 | * |
|
1379 | * | |
1381 | * @return void |
|
1380 | * @return void | |
1382 | * |
|
1381 | * | |
1383 | */ |
|
1382 | */ | |
1384 |
|
1383 | |||
1385 | unsigned int k; |
|
1384 | unsigned int k; | |
1386 | unsigned short data; |
|
1385 | unsigned short data; | |
1387 | float val; |
|
1386 | float val; | |
1388 | float Ts; |
|
1387 | float Ts; | |
1389 |
|
1388 | |||
1390 | time_management_regs->calDataPtr = INIT_CHAR; |
|
1389 | time_management_regs->calDataPtr = INIT_CHAR; | |
1391 |
|
1390 | |||
1392 | Ts = 1 / CAL_FS; |
|
1391 | Ts = 1 / CAL_FS; | |
1393 |
|
1392 | |||
1394 | // build the signal for the SCM calibration |
|
1393 | // build the signal for the SCM calibration | |
1395 | for (k = 0; k < CAL_NB_PTS; k++) |
|
1394 | for (k = 0; k < CAL_NB_PTS; k++) | |
1396 | { |
|
1395 | { | |
1397 |
val = sin( |
|
1396 | val = CAL_A0 * sin( CAL_W0 * k * Ts ) | |
1398 |
+ sin( |
|
1397 | + CAL_A1 * sin( CAL_W1 * k * Ts ); | |
1399 | data = (unsigned short) ((val * CAL_SCALE_FACTOR) + CONST_2048); |
|
1398 | data = (unsigned short) ((val * CAL_SCALE_FACTOR) + CONST_2048); | |
1400 | time_management_regs->calData = data & CAL_DATA_MASK; |
|
1399 | time_management_regs->calData = data & CAL_DATA_MASK; | |
1401 | } |
|
1400 | } | |
1402 | } |
|
1401 | } | |
1403 |
|
1402 | |||
1404 | void setCalibrationDataInterleaved( void ) |
|
1403 | void setCalibrationDataInterleaved( void ) | |
1405 | { |
|
1404 | { | |
1406 | /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal |
|
1405 | /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal | |
1407 | * |
|
1406 | * | |
1408 | * @param void |
|
1407 | * @param void | |
1409 | * |
|
1408 | * | |
1410 | * @return void |
|
1409 | * @return void | |
1411 | * |
|
1410 | * | |
1412 | * In interleaved mode, one can store more values than in normal mode. |
|
1411 | * In interleaved mode, one can store more values than in normal mode. | |
1413 | * The data are stored in bunch of 18 bits, 12 bits from one sample and 6 bits from another sample. |
|
1412 | * The data are stored in bunch of 18 bits, 12 bits from one sample and 6 bits from another sample. | |
1414 | * T store 3 values, one need two write operations. |
|
1413 | * T store 3 values, one need two write operations. | |
1415 | * s1 [ b11 b10 b9 b8 b7 b6 ] s0 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ] |
|
1414 | * s1 [ b11 b10 b9 b8 b7 b6 ] s0 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ] | |
1416 | * s1 [ b5 b4 b3 b2 b1 b0 ] s2 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ] |
|
1415 | * s1 [ b5 b4 b3 b2 b1 b0 ] s2 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ] | |
1417 | * |
|
1416 | * | |
1418 | */ |
|
1417 | */ | |
1419 |
|
1418 | |||
1420 | unsigned int k; |
|
1419 | unsigned int k; | |
1421 | float val; |
|
1420 | float val; | |
1422 | float Ts; |
|
1421 | float Ts; | |
1423 | unsigned short data[CAL_NB_PTS_INTER]; |
|
1422 | unsigned short data[CAL_NB_PTS_INTER]; | |
1424 | unsigned char *dataPtr; |
|
1423 | unsigned char *dataPtr; | |
1425 |
|
1424 | |||
1426 | Ts = 1 / CAL_FS_INTER; |
|
1425 | Ts = 1 / CAL_FS_INTER; | |
1427 |
|
1426 | |||
1428 | time_management_regs->calDataPtr = INIT_CHAR; |
|
1427 | time_management_regs->calDataPtr = INIT_CHAR; | |
1429 |
|
1428 | |||
1430 | // build the signal for the SCM calibration |
|
1429 | // build the signal for the SCM calibration | |
1431 | for (k=0; k<CAL_NB_PTS_INTER; k++) |
|
1430 | for (k=0; k<CAL_NB_PTS_INTER; k++) | |
1432 | { |
|
1431 | { | |
1433 | val = sin( 2 * pi * CAL_F0 * k * Ts ) |
|
1432 | val = sin( 2 * pi * CAL_F0 * k * Ts ) | |
1434 | + sin( 2 * pi * CAL_F1 * k * Ts ); |
|
1433 | + sin( 2 * pi * CAL_F1 * k * Ts ); | |
1435 | data[k] = (unsigned short) ((val * CONST_512) + CONST_2048); |
|
1434 | data[k] = (unsigned short) ((val * CONST_512) + CONST_2048); | |
1436 | } |
|
1435 | } | |
1437 |
|
1436 | |||
1438 | // write the signal in interleaved mode |
|
1437 | // write the signal in interleaved mode | |
1439 | for (k=0; k < STEPS_FOR_STORAGE_INTER; k++) |
|
1438 | for (k=0; k < STEPS_FOR_STORAGE_INTER; k++) | |
1440 | { |
|
1439 | { | |
1441 | dataPtr = (unsigned char*) &data[ (k * BYTES_FOR_2_SAMPLES) + 2 ]; |
|
1440 | dataPtr = (unsigned char*) &data[ (k * BYTES_FOR_2_SAMPLES) + 2 ]; | |
1442 | time_management_regs->calData = ( data[ k * BYTES_FOR_2_SAMPLES ] & CAL_DATA_MASK ) |
|
1441 | time_management_regs->calData = ( data[ k * BYTES_FOR_2_SAMPLES ] & CAL_DATA_MASK ) | |
1443 | + ( (dataPtr[0] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER); |
|
1442 | + ( (dataPtr[0] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER); | |
1444 | time_management_regs->calData = ( data[(k * BYTES_FOR_2_SAMPLES) + 1] & CAL_DATA_MASK ) |
|
1443 | time_management_regs->calData = ( data[(k * BYTES_FOR_2_SAMPLES) + 1] & CAL_DATA_MASK ) | |
1445 | + ( (dataPtr[1] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER); |
|
1444 | + ( (dataPtr[1] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER); | |
1446 | } |
|
1445 | } | |
1447 | } |
|
1446 | } | |
1448 |
|
1447 | |||
1449 | void setCalibrationReload( bool state) |
|
1448 | void setCalibrationReload( bool state) | |
1450 | { |
|
1449 | { | |
1451 | if (state == true) |
|
1450 | if (state == true) | |
1452 | { |
|
1451 | { | |
1453 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_RELOAD; // [0001 0000] |
|
1452 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_RELOAD; // [0001 0000] | |
1454 | } |
|
1453 | } | |
1455 | else |
|
1454 | else | |
1456 | { |
|
1455 | { | |
1457 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_RELOAD; // [1110 1111] |
|
1456 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_RELOAD; // [1110 1111] | |
1458 | } |
|
1457 | } | |
1459 | } |
|
1458 | } | |
1460 |
|
1459 | |||
1461 | void setCalibrationEnable( bool state ) |
|
1460 | void setCalibrationEnable( bool state ) | |
1462 | { |
|
1461 | { | |
1463 | // this bit drives the multiplexer |
|
1462 | // this bit drives the multiplexer | |
1464 | if (state == true) |
|
1463 | if (state == true) | |
1465 | { |
|
1464 | { | |
1466 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_ENABLE; // [0100 0000] |
|
1465 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_ENABLE; // [0100 0000] | |
1467 | } |
|
1466 | } | |
1468 | else |
|
1467 | else | |
1469 | { |
|
1468 | { | |
1470 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_ENABLE; // [1011 1111] |
|
1469 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_ENABLE; // [1011 1111] | |
1471 | } |
|
1470 | } | |
1472 | } |
|
1471 | } | |
1473 |
|
1472 | |||
1474 | void setCalibrationInterleaved( bool state ) |
|
1473 | void setCalibrationInterleaved( bool state ) | |
1475 | { |
|
1474 | { | |
1476 | // this bit drives the multiplexer |
|
1475 | // this bit drives the multiplexer | |
1477 | if (state == true) |
|
1476 | if (state == true) | |
1478 | { |
|
1477 | { | |
1479 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_SET_INTERLEAVED; // [0010 0000] |
|
1478 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_SET_INTERLEAVED; // [0010 0000] | |
1480 | } |
|
1479 | } | |
1481 | else |
|
1480 | else | |
1482 | { |
|
1481 | { | |
1483 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_SET_INTERLEAVED; // [1101 1111] |
|
1482 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_SET_INTERLEAVED; // [1101 1111] | |
1484 | } |
|
1483 | } | |
1485 | } |
|
1484 | } | |
1486 |
|
1485 | |||
1487 | void setCalibration( bool state ) |
|
1486 | void setCalibration( bool state ) | |
1488 | { |
|
1487 | { | |
1489 | if (state == true) |
|
1488 | if (state == true) | |
1490 | { |
|
1489 | { | |
1491 | setCalibrationEnable( true ); |
|
1490 | setCalibrationEnable( true ); | |
1492 | setCalibrationReload( false ); |
|
1491 | setCalibrationReload( false ); | |
1493 | set_hk_lfr_calib_enable( true ); |
|
1492 | set_hk_lfr_calib_enable( true ); | |
1494 | } |
|
1493 | } | |
1495 | else |
|
1494 | else | |
1496 | { |
|
1495 | { | |
1497 | setCalibrationEnable( false ); |
|
1496 | setCalibrationEnable( false ); | |
1498 | setCalibrationReload( true ); |
|
1497 | setCalibrationReload( true ); | |
1499 | set_hk_lfr_calib_enable( false ); |
|
1498 | set_hk_lfr_calib_enable( false ); | |
1500 | } |
|
1499 | } | |
1501 | } |
|
1500 | } | |
1502 |
|
1501 | |||
1503 | void configureCalibration( bool interleaved ) |
|
1502 | void configureCalibration( bool interleaved ) | |
1504 | { |
|
1503 | { | |
1505 | setCalibration( false ); |
|
1504 | setCalibration( false ); | |
1506 | if ( interleaved == true ) |
|
1505 | if ( interleaved == true ) | |
1507 | { |
|
1506 | { | |
1508 | setCalibrationInterleaved( true ); |
|
1507 | setCalibrationInterleaved( true ); | |
1509 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1508 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1510 | setCalibrationDivisor( CAL_F_DIVISOR_INTER ); // => 240 384 |
|
1509 | setCalibrationDivisor( CAL_F_DIVISOR_INTER ); // => 240 384 | |
1511 | setCalibrationDataInterleaved(); |
|
1510 | setCalibrationDataInterleaved(); | |
1512 | } |
|
1511 | } | |
1513 | else |
|
1512 | else | |
1514 | { |
|
1513 | { | |
1515 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1514 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1516 | setCalibrationDivisor( CAL_F_DIVISOR ); // => 160 256 (39 - 1) |
|
1515 | setCalibrationDivisor( CAL_F_DIVISOR ); // => 160 256 (39 - 1) | |
1517 | setCalibrationData(); |
|
1516 | setCalibrationData(); | |
1518 | } |
|
1517 | } | |
1519 | } |
|
1518 | } | |
1520 |
|
1519 | |||
1521 | //**************** |
|
1520 | //**************** | |
1522 | // CLOSING ACTIONS |
|
1521 | // CLOSING ACTIONS | |
1523 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1522 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1524 | { |
|
1523 | { | |
1525 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
1524 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
1526 | * |
|
1525 | * | |
1527 | * @param TC points to the TC being processed |
|
1526 | * @param TC points to the TC being processed | |
1528 | * @param time is the time used to date the TC execution |
|
1527 | * @param time is the time used to date the TC execution | |
1529 | * |
|
1528 | * | |
1530 | */ |
|
1529 | */ | |
1531 |
|
1530 | |||
1532 | unsigned int val; |
|
1531 | unsigned int val; | |
1533 |
|
1532 | |||
1534 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1533 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
1535 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1534 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
1536 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = INIT_CHAR; |
|
1535 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = INIT_CHAR; | |
1537 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1536 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
1538 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = INIT_CHAR; |
|
1537 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = INIT_CHAR; | |
1539 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1538 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
1540 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_0] = time[BYTE_0]; |
|
1539 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_0] = time[BYTE_0]; | |
1541 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_1] = time[BYTE_1]; |
|
1540 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_1] = time[BYTE_1]; | |
1542 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_2] = time[BYTE_2]; |
|
1541 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_2] = time[BYTE_2]; | |
1543 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_3] = time[BYTE_3]; |
|
1542 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_3] = time[BYTE_3]; | |
1544 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_4] = time[BYTE_4]; |
|
1543 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_4] = time[BYTE_4]; | |
1545 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_5] = time[BYTE_5]; |
|
1544 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_5] = time[BYTE_5]; | |
1546 |
|
1545 | |||
1547 | val = (housekeeping_packet.hk_lfr_exe_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
1546 | val = (housekeeping_packet.hk_lfr_exe_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
1548 | val++; |
|
1547 | val++; | |
1549 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); |
|
1548 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); | |
1550 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
1549 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
1551 | } |
|
1550 | } | |
1552 |
|
1551 | |||
1553 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1552 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1554 | { |
|
1553 | { | |
1555 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
1554 | /** This function is used to update the HK packets statistics after a TC rejection. | |
1556 | * |
|
1555 | * | |
1557 | * @param TC points to the TC being processed |
|
1556 | * @param TC points to the TC being processed | |
1558 | * @param time is the time used to date the TC rejection |
|
1557 | * @param time is the time used to date the TC rejection | |
1559 | * |
|
1558 | * | |
1560 | */ |
|
1559 | */ | |
1561 |
|
1560 | |||
1562 | unsigned int val; |
|
1561 | unsigned int val; | |
1563 |
|
1562 | |||
1564 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1563 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
1565 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1564 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
1566 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = INIT_CHAR; |
|
1565 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = INIT_CHAR; | |
1567 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1566 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
1568 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = INIT_CHAR; |
|
1567 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = INIT_CHAR; | |
1569 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1568 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
1570 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_0] = time[BYTE_0]; |
|
1569 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_0] = time[BYTE_0]; | |
1571 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_1] = time[BYTE_1]; |
|
1570 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_1] = time[BYTE_1]; | |
1572 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_2] = time[BYTE_2]; |
|
1571 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_2] = time[BYTE_2]; | |
1573 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_3] = time[BYTE_3]; |
|
1572 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_3] = time[BYTE_3]; | |
1574 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_4] = time[BYTE_4]; |
|
1573 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_4] = time[BYTE_4]; | |
1575 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_5] = time[BYTE_5]; |
|
1574 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_5] = time[BYTE_5]; | |
1576 |
|
1575 | |||
1577 | val = (housekeeping_packet.hk_lfr_rej_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
1576 | val = (housekeeping_packet.hk_lfr_rej_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
1578 | val++; |
|
1577 | val++; | |
1579 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); |
|
1578 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); | |
1580 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
1579 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
1581 | } |
|
1580 | } | |
1582 |
|
1581 | |||
1583 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
1582 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) | |
1584 | { |
|
1583 | { | |
1585 | /** This function is the last step of the TC execution workflow. |
|
1584 | /** This function is the last step of the TC execution workflow. | |
1586 | * |
|
1585 | * | |
1587 | * @param TC points to the TC being processed |
|
1586 | * @param TC points to the TC being processed | |
1588 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
1587 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
1589 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
1588 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
1590 | * @param time is the time used to date the TC execution |
|
1589 | * @param time is the time used to date the TC execution | |
1591 | * |
|
1590 | * | |
1592 | */ |
|
1591 | */ | |
1593 |
|
1592 | |||
1594 | unsigned char requestedMode; |
|
1593 | unsigned char requestedMode; | |
1595 |
|
1594 | |||
1596 | if (result == LFR_SUCCESSFUL) |
|
1595 | if (result == LFR_SUCCESSFUL) | |
1597 | { |
|
1596 | { | |
1598 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
1597 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
1599 | & |
|
1598 | & | |
1600 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
1599 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
1601 | ) |
|
1600 | ) | |
1602 | { |
|
1601 | { | |
1603 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1602 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
1604 | } |
|
1603 | } | |
1605 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
1604 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) | |
1606 | { |
|
1605 | { | |
1607 | //********************************** |
|
1606 | //********************************** | |
1608 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
1607 | // UPDATE THE LFRMODE LOCAL VARIABLE | |
1609 | requestedMode = TC->dataAndCRC[1]; |
|
1608 | requestedMode = TC->dataAndCRC[1]; | |
1610 | updateLFRCurrentMode( requestedMode ); |
|
1609 | updateLFRCurrentMode( requestedMode ); | |
1611 | } |
|
1610 | } | |
1612 | } |
|
1611 | } | |
1613 | else if (result == LFR_EXE_ERROR) |
|
1612 | else if (result == LFR_EXE_ERROR) | |
1614 | { |
|
1613 | { | |
1615 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
1614 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
1616 | } |
|
1615 | } | |
1617 | } |
|
1616 | } | |
1618 |
|
1617 | |||
1619 | //*************************** |
|
1618 | //*************************** | |
1620 | // Interrupt Service Routines |
|
1619 | // Interrupt Service Routines | |
1621 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1620 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
1622 | { |
|
1621 | { | |
1623 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1622 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1624 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") |
|
1623 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") | |
1625 | } |
|
1624 | } | |
1626 | } |
|
1625 | } | |
1627 |
|
1626 | |||
1628 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1627 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
1629 | { |
|
1628 | { | |
1630 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1629 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1631 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") |
|
1630 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") | |
1632 | } |
|
1631 | } | |
1633 | } |
|
1632 | } | |
1634 |
|
1633 | |||
1635 | //**************** |
|
1634 | //**************** | |
1636 | // OTHER FUNCTIONS |
|
1635 | // OTHER FUNCTIONS | |
1637 | void updateLFRCurrentMode( unsigned char requestedMode ) |
|
1636 | void updateLFRCurrentMode( unsigned char requestedMode ) | |
1638 | { |
|
1637 | { | |
1639 | /** This function updates the value of the global variable lfrCurrentMode. |
|
1638 | /** This function updates the value of the global variable lfrCurrentMode. | |
1640 | * |
|
1639 | * | |
1641 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
1640 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
1642 | * |
|
1641 | * | |
1643 | */ |
|
1642 | */ | |
1644 |
|
1643 | |||
1645 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
1644 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
1646 | housekeeping_packet.lfr_status_word[0] = (housekeeping_packet.lfr_status_word[0] & STATUS_WORD_LFR_MODE_MASK) |
|
1645 | housekeeping_packet.lfr_status_word[0] = (housekeeping_packet.lfr_status_word[0] & STATUS_WORD_LFR_MODE_MASK) | |
1647 | + (unsigned char) ( requestedMode << STATUS_WORD_LFR_MODE_SHIFT ); |
|
1646 | + (unsigned char) ( requestedMode << STATUS_WORD_LFR_MODE_SHIFT ); | |
1648 | lfrCurrentMode = requestedMode; |
|
1647 | lfrCurrentMode = requestedMode; | |
1649 | } |
|
1648 | } | |
1650 |
|
1649 | |||
1651 | void set_lfr_soft_reset( unsigned char value ) |
|
1650 | void set_lfr_soft_reset( unsigned char value ) | |
1652 | { |
|
1651 | { | |
1653 | if (value == 1) |
|
1652 | if (value == 1) | |
1654 | { |
|
1653 | { | |
1655 | time_management_regs->ctrl = time_management_regs->ctrl | BIT_SOFT_RESET; // [0100] |
|
1654 | time_management_regs->ctrl = time_management_regs->ctrl | BIT_SOFT_RESET; // [0100] | |
1656 | } |
|
1655 | } | |
1657 | else |
|
1656 | else | |
1658 | { |
|
1657 | { | |
1659 | time_management_regs->ctrl = time_management_regs->ctrl & MASK_SOFT_RESET; // [1011] |
|
1658 | time_management_regs->ctrl = time_management_regs->ctrl & MASK_SOFT_RESET; // [1011] | |
1660 | } |
|
1659 | } | |
1661 | } |
|
1660 | } | |
1662 |
|
1661 | |||
1663 | void reset_lfr( void ) |
|
1662 | void reset_lfr( void ) | |
1664 | { |
|
1663 | { | |
1665 | set_lfr_soft_reset( 1 ); |
|
1664 | set_lfr_soft_reset( 1 ); | |
1666 |
|
1665 | |||
1667 | set_lfr_soft_reset( 0 ); |
|
1666 | set_lfr_soft_reset( 0 ); | |
1668 |
|
1667 | |||
1669 | set_hk_lfr_sc_potential_flag( true ); |
|
1668 | set_hk_lfr_sc_potential_flag( true ); | |
1670 | } |
|
1669 | } |
General Comments 0
You need to be logged in to leave comments.
Login now