@@ -1,2 +1,2 | |||||
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters | |
2 | 721463c11a484e6a3439e16c99f8bd27720b9265 header/lfr_common_headers |
|
2 | ff85ce82cd9845f180cb578272717bcb76b62cb5 header/lfr_common_headers |
@@ -1,77 +1,78 | |||||
1 | #ifndef FSW_MISC_H_INCLUDED |
|
1 | #ifndef FSW_MISC_H_INCLUDED | |
2 | #define FSW_MISC_H_INCLUDED |
|
2 | #define FSW_MISC_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <stdio.h> |
|
5 | #include <stdio.h> | |
6 | #include <grspw.h> |
|
6 | #include <grspw.h> | |
7 | #include <grlib_regs.h> |
|
7 | #include <grlib_regs.h> | |
8 |
|
8 | |||
9 | #include "fsw_params.h" |
|
9 | #include "fsw_params.h" | |
10 | #include "fsw_spacewire.h" |
|
10 | #include "fsw_spacewire.h" | |
11 | #include "lfr_cpu_usage_report.h" |
|
11 | #include "lfr_cpu_usage_report.h" | |
12 |
|
12 | |||
13 | enum lfr_reset_cause_t{ |
|
13 | enum lfr_reset_cause_t{ | |
14 | UNKNOWN_CAUSE, |
|
14 | UNKNOWN_CAUSE, | |
15 | POWER_ON, |
|
15 | POWER_ON, | |
16 | TC_RESET, |
|
16 | TC_RESET, | |
17 | WATCHDOG, |
|
17 | WATCHDOG, | |
18 | ERROR_RESET, |
|
18 | ERROR_RESET, | |
19 | UNEXP_RESET |
|
19 | UNEXP_RESET | |
20 | }; |
|
20 | }; | |
21 |
|
21 | |||
22 | extern gptimer_regs_t *gptimer_regs; |
|
22 | extern gptimer_regs_t *gptimer_regs; | |
23 |
|
23 | |||
24 | #define LFR_RESET_CAUSE_UNKNOWN_CAUSE 0 |
|
24 | #define LFR_RESET_CAUSE_UNKNOWN_CAUSE 0 | |
25 |
|
25 | |||
26 | rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic |
|
26 | rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic | |
27 | rtems_id HK_id; // id of the HK rate monotonic period |
|
27 | rtems_id HK_id; // id of the HK rate monotonic period | |
28 |
|
28 | |||
29 | void timer_configure( unsigned char timer, unsigned int clock_divider, |
|
29 | void timer_configure( unsigned char timer, unsigned int clock_divider, | |
30 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); |
|
30 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); | |
31 | void timer_start( unsigned char timer ); |
|
31 | void timer_start( unsigned char timer ); | |
32 | void timer_stop( unsigned char timer ); |
|
32 | void timer_stop( unsigned char timer ); | |
33 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider); |
|
33 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider); | |
34 |
|
34 | |||
35 | // WATCHDOG |
|
35 | // WATCHDOG | |
36 | rtems_isr watchdog_isr( rtems_vector_number vector ); |
|
36 | rtems_isr watchdog_isr( rtems_vector_number vector ); | |
37 | void watchdog_configure(void); |
|
37 | void watchdog_configure(void); | |
38 | void watchdog_stop(void); |
|
38 | void watchdog_stop(void); | |
39 | void watchdog_start(void); |
|
39 | void watchdog_start(void); | |
40 |
|
40 | |||
41 | // SERIAL LINK |
|
41 | // SERIAL LINK | |
42 | int send_console_outputs_on_apbuart_port( void ); |
|
42 | int send_console_outputs_on_apbuart_port( void ); | |
43 | int enable_apbuart_transmitter( void ); |
|
43 | int enable_apbuart_transmitter( void ); | |
44 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); |
|
44 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); | |
45 |
|
45 | |||
46 | // RTEMS TASKS |
|
46 | // RTEMS TASKS | |
47 | rtems_task load_task( rtems_task_argument argument ); |
|
47 | rtems_task load_task( rtems_task_argument argument ); | |
48 | rtems_task hous_task( rtems_task_argument argument ); |
|
48 | rtems_task hous_task( rtems_task_argument argument ); | |
49 | rtems_task dumb_task( rtems_task_argument unused ); |
|
49 | rtems_task dumb_task( rtems_task_argument unused ); | |
50 |
|
50 | |||
51 | void init_housekeeping_parameters( void ); |
|
51 | void init_housekeeping_parameters( void ); | |
52 | void increment_seq_counter(unsigned short *packetSequenceControl); |
|
52 | void increment_seq_counter(unsigned short *packetSequenceControl); | |
53 | void getTime( unsigned char *time); |
|
53 | void getTime( unsigned char *time); | |
54 | unsigned long long int getTimeAsUnsignedLongLongInt( ); |
|
54 | unsigned long long int getTimeAsUnsignedLongLongInt( ); | |
55 | void send_dumb_hk( void ); |
|
55 | void send_dumb_hk( void ); | |
56 | void get_temperatures( unsigned char *temperatures ); |
|
56 | void get_temperatures( unsigned char *temperatures ); | |
57 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ); |
|
57 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ); | |
58 | void get_cpu_load( unsigned char *resource_statistics ); |
|
58 | void get_cpu_load( unsigned char *resource_statistics ); | |
59 | void set_hk_lfr_sc_potential_flag( bool state ); |
|
59 | void set_hk_lfr_sc_potential_flag( bool state ); | |
60 | void set_hk_lfr_mag_fields_flag( bool state ); |
|
60 | void set_hk_lfr_mag_fields_flag( bool state ); | |
61 | void set_hk_lfr_calib_enable( bool state ); |
|
61 | void set_hk_lfr_calib_enable( bool state ); | |
62 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ); |
|
62 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ); | |
|
63 | void hk_lfr_le_me_he_update(); | |||
63 |
|
64 | |||
64 | extern int sched_yield( void ); |
|
65 | extern int sched_yield( void ); | |
65 | extern void rtems_cpu_usage_reset(); |
|
66 | extern void rtems_cpu_usage_reset(); | |
66 | extern ring_node *current_ring_node_f3; |
|
67 | extern ring_node *current_ring_node_f3; | |
67 | extern ring_node *ring_node_to_send_cwf_f3; |
|
68 | extern ring_node *ring_node_to_send_cwf_f3; | |
68 | extern ring_node waveform_ring_f3[]; |
|
69 | extern ring_node waveform_ring_f3[]; | |
69 | extern unsigned short sequenceCounterHK; |
|
70 | extern unsigned short sequenceCounterHK; | |
70 |
|
71 | |||
71 | extern unsigned char hk_lfr_q_sd_fifo_size_max; |
|
72 | extern unsigned char hk_lfr_q_sd_fifo_size_max; | |
72 | extern unsigned char hk_lfr_q_rv_fifo_size_max; |
|
73 | extern unsigned char hk_lfr_q_rv_fifo_size_max; | |
73 | extern unsigned char hk_lfr_q_p0_fifo_size_max; |
|
74 | extern unsigned char hk_lfr_q_p0_fifo_size_max; | |
74 | extern unsigned char hk_lfr_q_p1_fifo_size_max; |
|
75 | extern unsigned char hk_lfr_q_p1_fifo_size_max; | |
75 | extern unsigned char hk_lfr_q_p2_fifo_size_max; |
|
76 | extern unsigned char hk_lfr_q_p2_fifo_size_max; | |
76 |
|
77 | |||
77 | #endif // FSW_MISC_H_INCLUDED |
|
78 | #endif // FSW_MISC_H_INCLUDED |
@@ -1,51 +1,50 | |||||
1 | #ifndef FSW_SPACEWIRE_H_INCLUDED |
|
1 | #ifndef FSW_SPACEWIRE_H_INCLUDED | |
2 | #define FSW_SPACEWIRE_H_INCLUDED |
|
2 | #define FSW_SPACEWIRE_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <grspw.h> |
|
5 | #include <grspw.h> | |
6 |
|
6 | |||
7 | #include <fcntl.h> // for O_RDWR |
|
7 | #include <fcntl.h> // for O_RDWR | |
8 | #include <unistd.h> // for the read call |
|
8 | #include <unistd.h> // for the read call | |
9 | #include <sys/ioctl.h> // for the ioctl call |
|
9 | #include <sys/ioctl.h> // for the ioctl call | |
10 | #include <errno.h> |
|
10 | #include <errno.h> | |
11 |
|
11 | |||
12 | #include "fsw_params.h" |
|
12 | #include "fsw_params.h" | |
13 | #include "tc_handler.h" |
|
13 | #include "tc_handler.h" | |
14 | #include "fsw_init.h" |
|
14 | #include "fsw_init.h" | |
15 |
|
15 | |||
16 | extern spw_stats spacewire_stats; |
|
16 | extern spw_stats spacewire_stats; | |
17 | extern spw_stats spacewire_stats_backup; |
|
17 | extern spw_stats spacewire_stats_backup; | |
18 |
|
18 | |||
19 | // RTEMS TASK |
|
19 | // RTEMS TASK | |
20 | rtems_task spiq_task( rtems_task_argument argument ); |
|
20 | rtems_task spiq_task( rtems_task_argument argument ); | |
21 | rtems_task recv_task( rtems_task_argument unused ); |
|
21 | rtems_task recv_task( rtems_task_argument unused ); | |
22 | rtems_task send_task( rtems_task_argument argument ); |
|
22 | rtems_task send_task( rtems_task_argument argument ); | |
23 | rtems_task wtdg_task( rtems_task_argument argument ); |
|
23 | rtems_task wtdg_task( rtems_task_argument argument ); | |
24 |
|
24 | |||
25 | int spacewire_open_link( void ); |
|
25 | int spacewire_open_link( void ); | |
26 | int spacewire_start_link( int fd ); |
|
26 | int spacewire_start_link( int fd ); | |
27 | int spacewire_stop_and_start_link( int fd ); |
|
27 | int spacewire_stop_and_start_link( int fd ); | |
28 | int spacewire_configure_link(int fd ); |
|
28 | int spacewire_configure_link(int fd ); | |
29 | int spacewire_reset_link( void ); |
|
29 | int spacewire_reset_link( void ); | |
30 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force |
|
30 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force | |
31 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable |
|
31 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable | |
32 | void spacewire_compute_stats_offsets( void ); |
|
32 | void spacewire_compute_stats_offsets( void ); | |
33 | void spacewire_update_statistics( void ); |
|
33 | void spacewire_update_statistics( void ); | |
34 |
|
34 | |||
35 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ); |
|
35 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ); | |
36 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ); |
|
36 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ); | |
37 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ); |
|
37 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ); | |
38 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_CWF_t *header ); |
|
38 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_CWF_t *header ); | |
39 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_SWF_t *header ); |
|
39 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_SWF_t *header ); | |
40 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_CWF_t *header ); |
|
40 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_CWF_t *header ); | |
41 | void spw_send_asm_f0( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_ASM_t *header ); |
|
41 | void spw_send_asm_f0( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_ASM_t *header ); | |
42 | void spw_send_asm_f1( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_ASM_t *header ); |
|
42 | void spw_send_asm_f1( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_ASM_t *header ); | |
43 | void spw_send_asm_f2( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_ASM_t *header ); |
|
43 | void spw_send_asm_f2( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_ASM_t *header ); | |
44 | void spw_send_k_dump( ring_node *ring_node_to_send ); |
|
44 | void spw_send_k_dump( ring_node *ring_node_to_send ); | |
45 |
|
45 | |||
46 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ); |
|
46 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ); | |
47 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ); |
|
|||
48 |
|
47 | |||
49 | void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc ); |
|
48 | void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc ); | |
50 |
|
49 | |||
51 | #endif // FSW_SPACEWIRE_H_INCLUDED |
|
50 | #endif // FSW_SPACEWIRE_H_INCLUDED |
@@ -1,77 +1,80 | |||||
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 | extern unsigned int lastValidTransitionDate; | |||
|
16 | ||||
15 | //**** |
|
17 | //**** | |
16 | // ISR |
|
18 | // ISR | |
17 | rtems_isr commutation_isr1( rtems_vector_number vector ); |
|
19 | rtems_isr commutation_isr1( rtems_vector_number vector ); | |
18 | rtems_isr commutation_isr2( rtems_vector_number vector ); |
|
20 | rtems_isr commutation_isr2( rtems_vector_number vector ); | |
19 |
|
21 | |||
20 | //*********** |
|
22 | //*********** | |
21 | // RTEMS TASK |
|
23 | // RTEMS TASK | |
22 | rtems_task actn_task( rtems_task_argument unused ); |
|
24 | rtems_task actn_task( rtems_task_argument unused ); | |
23 |
|
25 | |||
24 | //*********** |
|
26 | //*********** | |
25 | // TC ACTIONS |
|
27 | // TC ACTIONS | |
26 | int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
28 | int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); | |
27 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
29 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
28 | int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
30 | int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
29 | int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
31 | int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); | |
30 | int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
32 | int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); | |
31 | int action_update_time( ccsdsTelecommandPacket_t *TC); |
|
33 | int action_update_time( ccsdsTelecommandPacket_t *TC); | |
32 |
|
34 | |||
33 | // mode transition |
|
35 | // mode transition | |
34 | int check_mode_value( unsigned char requestedMode ); |
|
36 | int check_mode_value( unsigned char requestedMode ); | |
35 | int check_mode_transition( unsigned char requestedMode ); |
|
37 | int check_mode_transition( unsigned char requestedMode ); | |
|
38 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ); | |||
36 | int check_transition_date( unsigned int transitionCoarseTime ); |
|
39 | int check_transition_date( unsigned int transitionCoarseTime ); | |
37 | int stop_spectral_matrices( void ); |
|
40 | int stop_spectral_matrices( void ); | |
38 | int stop_current_mode( void ); |
|
41 | int stop_current_mode( void ); | |
39 | int enter_mode_standby( void ); |
|
42 | int enter_mode_standby( void ); | |
40 | int enter_mode_normal( unsigned int transitionCoarseTime ); |
|
43 | int enter_mode_normal( unsigned int transitionCoarseTime ); | |
41 | int enter_mode_burst( unsigned int transitionCoarseTime ); |
|
44 | int enter_mode_burst( unsigned int transitionCoarseTime ); | |
42 | int enter_mode_sbm1( unsigned int transitionCoarseTime ); |
|
45 | int enter_mode_sbm1( unsigned int transitionCoarseTime ); | |
43 | int enter_mode_sbm2( unsigned int transitionCoarseTime ); |
|
46 | int enter_mode_sbm2( unsigned int transitionCoarseTime ); | |
44 | int restart_science_tasks( unsigned char lfrRequestedMode ); |
|
47 | int restart_science_tasks( unsigned char lfrRequestedMode ); | |
45 | int restart_asm_tasks(unsigned char lfrRequestedMode ); |
|
48 | int restart_asm_tasks(unsigned char lfrRequestedMode ); | |
46 | int suspend_science_tasks(void); |
|
49 | int suspend_science_tasks(void); | |
47 | int suspend_asm_tasks( void ); |
|
50 | int suspend_asm_tasks( void ); | |
48 | void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime ); |
|
51 | void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime ); | |
49 | void launch_spectral_matrix( void ); |
|
52 | void launch_spectral_matrix( void ); | |
50 | void set_sm_irq_onNewMatrix( unsigned char value ); |
|
53 | void set_sm_irq_onNewMatrix( unsigned char value ); | |
51 | void set_sm_irq_onError( unsigned char value ); |
|
54 | void set_sm_irq_onError( unsigned char value ); | |
52 |
|
55 | |||
53 | // other functions |
|
56 | // other functions | |
54 | void updateLFRCurrentMode(); |
|
57 | void updateLFRCurrentMode(); | |
55 | void set_lfr_soft_reset( unsigned char value ); |
|
58 | void set_lfr_soft_reset( unsigned char value ); | |
56 | void reset_lfr( void ); |
|
59 | void reset_lfr( void ); | |
57 | // CALIBRATION |
|
60 | // CALIBRATION | |
58 | void setCalibrationPrescaler( unsigned int prescaler ); |
|
61 | void setCalibrationPrescaler( unsigned int prescaler ); | |
59 | void setCalibrationDivisor( unsigned int divisionFactor ); |
|
62 | void setCalibrationDivisor( unsigned int divisionFactor ); | |
60 | void setCalibrationData( void ); |
|
63 | void setCalibrationData( void ); | |
61 | void setCalibrationReload( bool state); |
|
64 | void setCalibrationReload( bool state); | |
62 | void setCalibrationEnable( bool state ); |
|
65 | void setCalibrationEnable( bool state ); | |
63 | void setCalibrationInterleaved( bool state ); |
|
66 | void setCalibrationInterleaved( bool state ); | |
64 | void setCalibration( bool state ); |
|
67 | void setCalibration( bool state ); | |
65 | void configureCalibration( bool interleaved ); |
|
68 | void configureCalibration( bool interleaved ); | |
66 | // |
|
69 | // | |
67 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time ); |
|
70 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time ); | |
68 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time ); |
|
71 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time ); | |
69 | void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ); |
|
72 | void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ); | |
70 |
|
73 | |||
71 | extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
74 | extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); | |
72 | extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
75 | extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); | |
73 |
|
76 | |||
74 | #endif // TC_HANDLER_H_INCLUDED |
|
77 | #endif // TC_HANDLER_H_INCLUDED | |
75 |
|
78 | |||
76 |
|
79 | |||
77 |
|
80 |
@@ -1,79 +1,80 | |||||
1 | /** Global variables of the LFR flight software. |
|
1 | /** Global variables of the LFR flight software. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * Among global variables, there are: |
|
6 | * Among global variables, there are: | |
7 | * - RTEMS names and id. |
|
7 | * - RTEMS names and id. | |
8 | * - APB configuration registers. |
|
8 | * - APB configuration registers. | |
9 | * - waveforms global buffers, used by the waveform picker hardware module to store data. |
|
9 | * - waveforms global buffers, used by the waveform picker hardware module to store data. | |
10 | * - spectral matrices buffesr, used by the hardware module to store data. |
|
10 | * - spectral matrices buffesr, used by the hardware module to store data. | |
11 | * - variable related to LFR modes parameters. |
|
11 | * - variable related to LFR modes parameters. | |
12 | * - the global HK packet buffer. |
|
12 | * - the global HK packet buffer. | |
13 | * - the global dump parameter buffer. |
|
13 | * - the global dump parameter buffer. | |
14 | * |
|
14 | * | |
15 | */ |
|
15 | */ | |
16 |
|
16 | |||
17 | #include <rtems.h> |
|
17 | #include <rtems.h> | |
18 | #include <grspw.h> |
|
18 | #include <grspw.h> | |
19 |
|
19 | |||
20 | #include "ccsds_types.h" |
|
20 | #include "ccsds_types.h" | |
21 | #include "grlib_regs.h" |
|
21 | #include "grlib_regs.h" | |
22 | #include "fsw_params.h" |
|
22 | #include "fsw_params.h" | |
23 | #include "fsw_params_wf_handler.h" |
|
23 | #include "fsw_params_wf_handler.h" | |
24 |
|
24 | |||
25 | // RTEMS GLOBAL VARIABLES |
|
25 | // RTEMS GLOBAL VARIABLES | |
26 | rtems_name misc_name[5]; |
|
26 | rtems_name misc_name[5]; | |
27 | rtems_name Task_name[20]; /* array of task names */ |
|
27 | rtems_name Task_name[20]; /* array of task names */ | |
28 | rtems_id Task_id[20]; /* array of task ids */ |
|
28 | rtems_id Task_id[20]; /* array of task ids */ | |
29 | int fdSPW = 0; |
|
29 | int fdSPW = 0; | |
30 | int fdUART = 0; |
|
30 | int fdUART = 0; | |
31 | unsigned char lfrCurrentMode; |
|
31 | unsigned char lfrCurrentMode; | |
32 | unsigned char pa_bia_status_info; |
|
32 | unsigned char pa_bia_status_info; | |
33 |
|
33 | |||
34 | // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584 |
|
34 | // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584 | |
35 | // 97 * 256 = 24832 => delta = 248 bytes = 62 words |
|
35 | // 97 * 256 = 24832 => delta = 248 bytes = 62 words | |
36 | // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264 |
|
36 | // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264 | |
37 | // 127 * 256 = 32512 => delta = 248 bytes = 62 words |
|
37 | // 127 * 256 = 32512 => delta = 248 bytes = 62 words | |
38 | // F0 F1 F2 F3 |
|
38 | // F0 F1 F2 F3 | |
39 | volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
39 | volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
40 | volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
40 | volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
41 | volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
41 | volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
42 | volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
42 | volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
43 |
|
43 | |||
44 | //*********************************** |
|
44 | //*********************************** | |
45 | // SPECTRAL MATRICES GLOBAL VARIABLES |
|
45 | // SPECTRAL MATRICES GLOBAL VARIABLES | |
46 |
|
46 | |||
47 | // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00 |
|
47 | // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00 | |
48 | volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
48 | volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); | |
49 | volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
49 | volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); | |
50 | volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
50 | volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); | |
51 |
|
51 | |||
52 | // APB CONFIGURATION REGISTERS |
|
52 | // APB CONFIGURATION REGISTERS | |
53 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; |
|
53 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; | |
54 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; |
|
54 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; | |
55 | waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER; |
|
55 | waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER; | |
56 | spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; |
|
56 | spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; | |
57 |
|
57 | |||
58 | // MODE PARAMETERS |
|
58 | // MODE PARAMETERS | |
59 | Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
59 | Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; | |
60 | struct param_local_str param_local; |
|
60 | struct param_local_str param_local; | |
|
61 | unsigned int lastValidTransitionDate; | |||
61 |
|
62 | |||
62 | // HK PACKETS |
|
63 | // HK PACKETS | |
63 | Packet_TM_LFR_HK_t housekeeping_packet; |
|
64 | Packet_TM_LFR_HK_t housekeeping_packet; | |
64 | // message queues occupancy |
|
65 | // message queues occupancy | |
65 | unsigned char hk_lfr_q_sd_fifo_size_max; |
|
66 | unsigned char hk_lfr_q_sd_fifo_size_max; | |
66 | unsigned char hk_lfr_q_rv_fifo_size_max; |
|
67 | unsigned char hk_lfr_q_rv_fifo_size_max; | |
67 | unsigned char hk_lfr_q_p0_fifo_size_max; |
|
68 | unsigned char hk_lfr_q_p0_fifo_size_max; | |
68 | unsigned char hk_lfr_q_p1_fifo_size_max; |
|
69 | unsigned char hk_lfr_q_p1_fifo_size_max; | |
69 | unsigned char hk_lfr_q_p2_fifo_size_max; |
|
70 | unsigned char hk_lfr_q_p2_fifo_size_max; | |
70 | // sequence counters are incremented by APID (PID + CAT) and destination ID |
|
71 | // sequence counters are incremented by APID (PID + CAT) and destination ID | |
71 | unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; |
|
72 | unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; | |
72 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; |
|
73 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; | |
73 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID]; |
|
74 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID]; | |
74 | unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID]; |
|
75 | unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID]; | |
75 | unsigned short sequenceCounterHK; |
|
76 | unsigned short sequenceCounterHK; | |
76 | spw_stats spacewire_stats; |
|
77 | spw_stats spacewire_stats; | |
77 | spw_stats spacewire_stats_backup; |
|
78 | spw_stats spacewire_stats_backup; | |
78 |
|
79 | |||
79 |
|
80 |
@@ -1,864 +1,865 | |||||
1 | /** This is the RTEMS initialization module. |
|
1 | /** This is the RTEMS initialization module. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * This module contains two very different information: |
|
6 | * This module contains two very different information: | |
7 | * - specific instructions to configure the compilation of the RTEMS executive |
|
7 | * - specific instructions to configure the compilation of the RTEMS executive | |
8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task |
|
8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task | |
9 | * |
|
9 | * | |
10 | */ |
|
10 | */ | |
11 |
|
11 | |||
12 | //************************* |
|
12 | //************************* | |
13 | // GPL reminder to be added |
|
13 | // GPL reminder to be added | |
14 | //************************* |
|
14 | //************************* | |
15 |
|
15 | |||
16 | #include <rtems.h> |
|
16 | #include <rtems.h> | |
17 |
|
17 | |||
18 | /* configuration information */ |
|
18 | /* configuration information */ | |
19 |
|
19 | |||
20 | #define CONFIGURE_INIT |
|
20 | #define CONFIGURE_INIT | |
21 |
|
21 | |||
22 | #include <bsp.h> /* for device driver prototypes */ |
|
22 | #include <bsp.h> /* for device driver prototypes */ | |
23 |
|
23 | |||
24 | /* configuration information */ |
|
24 | /* configuration information */ | |
25 |
|
25 | |||
26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
28 |
|
28 | |||
29 | #define CONFIGURE_MAXIMUM_TASKS 20 |
|
29 | #define CONFIGURE_MAXIMUM_TASKS 20 | |
30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE | |
31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) | |
32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 | |
33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 | |
34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) | |
35 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) |
|
35 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) | |
36 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
36 | #define CONFIGURE_MAXIMUM_DRIVERS 16 | |
37 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
37 | #define CONFIGURE_MAXIMUM_PERIODS 5 | |
38 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) |
|
38 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) | |
39 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 |
|
39 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 | |
40 | #ifdef PRINT_STACK_REPORT |
|
40 | #ifdef PRINT_STACK_REPORT | |
41 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
41 | #define CONFIGURE_STACK_CHECKER_ENABLED | |
42 | #endif |
|
42 | #endif | |
43 |
|
43 | |||
44 | #include <rtems/confdefs.h> |
|
44 | #include <rtems/confdefs.h> | |
45 |
|
45 | |||
46 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
46 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ | |
47 | #ifdef RTEMS_DRVMGR_STARTUP |
|
47 | #ifdef RTEMS_DRVMGR_STARTUP | |
48 | #ifdef LEON3 |
|
48 | #ifdef LEON3 | |
49 | /* Add Timer and UART Driver */ |
|
49 | /* Add Timer and UART Driver */ | |
50 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
50 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
51 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
51 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER | |
52 | #endif |
|
52 | #endif | |
53 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
53 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
54 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
54 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART | |
55 | #endif |
|
55 | #endif | |
56 | #endif |
|
56 | #endif | |
57 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
57 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ | |
58 | #include <drvmgr/drvmgr_confdefs.h> |
|
58 | #include <drvmgr/drvmgr_confdefs.h> | |
59 | #endif |
|
59 | #endif | |
60 |
|
60 | |||
61 | #include "fsw_init.h" |
|
61 | #include "fsw_init.h" | |
62 | #include "fsw_config.c" |
|
62 | #include "fsw_config.c" | |
63 | #include "GscMemoryLPP.hpp" |
|
63 | #include "GscMemoryLPP.hpp" | |
64 |
|
64 | |||
65 | void initCache() |
|
65 | void initCache() | |
66 | { |
|
66 | { | |
67 | unsigned int cacheControlRegister; |
|
67 | unsigned int cacheControlRegister; | |
68 |
|
68 | |||
69 | cacheControlRegister = getCacheControlRegister(); |
|
69 | cacheControlRegister = getCacheControlRegister(); | |
70 | PRINTF1("(0) cacheControlRegister = %x\n", cacheControlRegister) |
|
70 | PRINTF1("(0) cacheControlRegister = %x\n", cacheControlRegister) | |
71 |
|
71 | |||
72 | resetCacheControlRegister(); |
|
72 | resetCacheControlRegister(); | |
73 |
|
73 | |||
74 | enableInstructionCache(); |
|
74 | enableInstructionCache(); | |
75 | enableDataCache(); |
|
75 | enableDataCache(); | |
76 | enableInstructionBurstFetch(); |
|
76 | enableInstructionBurstFetch(); | |
77 |
|
77 | |||
78 | cacheControlRegister = getCacheControlRegister(); |
|
78 | cacheControlRegister = getCacheControlRegister(); | |
79 | PRINTF1("(1) cacheControlRegister = %x\n", cacheControlRegister) |
|
79 | PRINTF1("(1) cacheControlRegister = %x\n", cacheControlRegister) | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | rtems_task Init( rtems_task_argument ignored ) |
|
82 | rtems_task Init( rtems_task_argument ignored ) | |
83 | { |
|
83 | { | |
84 | /** This is the RTEMS INIT taks, it is the first task launched by the system. |
|
84 | /** This is the RTEMS INIT taks, it is the first task launched by the system. | |
85 | * |
|
85 | * | |
86 | * @param unused is the starting argument of the RTEMS task |
|
86 | * @param unused is the starting argument of the RTEMS task | |
87 | * |
|
87 | * | |
88 | * The INIT task create and run all other RTEMS tasks. |
|
88 | * The INIT task create and run all other RTEMS tasks. | |
89 | * |
|
89 | * | |
90 | */ |
|
90 | */ | |
91 |
|
91 | |||
92 | //*********** |
|
92 | //*********** | |
93 | // INIT CACHE |
|
93 | // INIT CACHE | |
94 |
|
94 | |||
95 | unsigned char *vhdlVersion; |
|
95 | unsigned char *vhdlVersion; | |
96 |
|
96 | |||
97 | reset_lfr(); |
|
97 | reset_lfr(); | |
98 |
|
98 | |||
99 | reset_local_time(); |
|
99 | reset_local_time(); | |
100 |
|
100 | |||
101 | rtems_cpu_usage_reset(); |
|
101 | rtems_cpu_usage_reset(); | |
102 |
|
102 | |||
103 | rtems_status_code status; |
|
103 | rtems_status_code status; | |
104 | rtems_status_code status_spw; |
|
104 | rtems_status_code status_spw; | |
105 | rtems_isr_entry old_isr_handler; |
|
105 | rtems_isr_entry old_isr_handler; | |
106 |
|
106 | |||
107 | // UART settings |
|
107 | // UART settings | |
108 | send_console_outputs_on_apbuart_port(); |
|
108 | send_console_outputs_on_apbuart_port(); | |
109 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
109 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); | |
110 | enable_apbuart_transmitter(); |
|
110 | enable_apbuart_transmitter(); | |
111 |
|
111 | |||
112 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
112 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") | |
113 |
|
113 | |||
114 |
|
114 | |||
115 | PRINTF("\n\n\n\n\n") |
|
115 | PRINTF("\n\n\n\n\n") | |
116 |
|
116 | |||
117 | initCache(); |
|
117 | initCache(); | |
118 |
|
118 | |||
119 | PRINTF("*************************\n") |
|
119 | PRINTF("*************************\n") | |
120 | PRINTF("** LFR Flight Software **\n") |
|
120 | PRINTF("** LFR Flight Software **\n") | |
121 | PRINTF1("** %d.", SW_VERSION_N1) |
|
121 | PRINTF1("** %d.", SW_VERSION_N1) | |
122 | PRINTF1("%d." , SW_VERSION_N2) |
|
122 | PRINTF1("%d." , SW_VERSION_N2) | |
123 | PRINTF1("%d." , SW_VERSION_N3) |
|
123 | PRINTF1("%d." , SW_VERSION_N3) | |
124 | PRINTF1("%d **\n", SW_VERSION_N4) |
|
124 | PRINTF1("%d **\n", SW_VERSION_N4) | |
125 |
|
125 | |||
126 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
126 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
127 | PRINTF("** VHDL **\n") |
|
127 | PRINTF("** VHDL **\n") | |
128 | PRINTF1("** %d.", vhdlVersion[1]) |
|
128 | PRINTF1("** %d.", vhdlVersion[1]) | |
129 | PRINTF1("%d." , vhdlVersion[2]) |
|
129 | PRINTF1("%d." , vhdlVersion[2]) | |
130 | PRINTF1("%d **\n", vhdlVersion[3]) |
|
130 | PRINTF1("%d **\n", vhdlVersion[3]) | |
131 | PRINTF("*************************\n") |
|
131 | PRINTF("*************************\n") | |
132 | PRINTF("\n\n") |
|
132 | PRINTF("\n\n") | |
133 |
|
133 | |||
134 | init_parameter_dump(); |
|
134 | init_parameter_dump(); | |
135 | init_kcoefficients_dump(); |
|
135 | init_kcoefficients_dump(); | |
136 | init_local_mode_parameters(); |
|
136 | init_local_mode_parameters(); | |
137 | init_housekeeping_parameters(); |
|
137 | init_housekeeping_parameters(); | |
138 | init_k_coefficients_prc0(); |
|
138 | init_k_coefficients_prc0(); | |
139 | init_k_coefficients_prc1(); |
|
139 | init_k_coefficients_prc1(); | |
140 | init_k_coefficients_prc2(); |
|
140 | init_k_coefficients_prc2(); | |
141 | pa_bia_status_info = 0x00; |
|
141 | pa_bia_status_info = 0x00; | |
|
142 | update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE ); | |||
142 |
|
143 | |||
143 | // waveform picker initialization |
|
144 | // waveform picker initialization | |
144 | WFP_init_rings(); LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings |
|
145 | WFP_init_rings(); LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings | |
145 | WFP_reset_current_ring_nodes(); |
|
146 | WFP_reset_current_ring_nodes(); | |
146 | reset_waveform_picker_regs(); |
|
147 | reset_waveform_picker_regs(); | |
147 |
|
148 | |||
148 | // spectral matrices initialization |
|
149 | // spectral matrices initialization | |
149 | SM_init_rings(); // initialize spectral matrices rings |
|
150 | SM_init_rings(); // initialize spectral matrices rings | |
150 | SM_reset_current_ring_nodes(); |
|
151 | SM_reset_current_ring_nodes(); | |
151 | reset_spectral_matrix_regs(); |
|
152 | reset_spectral_matrix_regs(); | |
152 |
|
153 | |||
153 | // configure calibration |
|
154 | // configure calibration | |
154 | configureCalibration( false ); // true means interleaved mode, false is for normal mode |
|
155 | configureCalibration( false ); // true means interleaved mode, false is for normal mode | |
155 |
|
156 | |||
156 | updateLFRCurrentMode(); |
|
157 | updateLFRCurrentMode(); | |
157 |
|
158 | |||
158 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
159 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) | |
159 |
|
160 | |||
160 | create_names(); // create all names |
|
161 | create_names(); // create all names | |
161 |
|
162 | |||
162 | status = create_message_queues(); // create message queues |
|
163 | status = create_message_queues(); // create message queues | |
163 | if (status != RTEMS_SUCCESSFUL) |
|
164 | if (status != RTEMS_SUCCESSFUL) | |
164 | { |
|
165 | { | |
165 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
166 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) | |
166 | } |
|
167 | } | |
167 |
|
168 | |||
168 | status = create_all_tasks(); // create all tasks |
|
169 | status = create_all_tasks(); // create all tasks | |
169 | if (status != RTEMS_SUCCESSFUL) |
|
170 | if (status != RTEMS_SUCCESSFUL) | |
170 | { |
|
171 | { | |
171 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) |
|
172 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) | |
172 | } |
|
173 | } | |
173 |
|
174 | |||
174 | // ************************** |
|
175 | // ************************** | |
175 | // <SPACEWIRE INITIALIZATION> |
|
176 | // <SPACEWIRE INITIALIZATION> | |
176 | grspw_timecode_callback = &timecode_irq_handler; |
|
177 | grspw_timecode_callback = &timecode_irq_handler; | |
177 |
|
178 | |||
178 | status_spw = spacewire_open_link(); // (1) open the link |
|
179 | status_spw = spacewire_open_link(); // (1) open the link | |
179 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
180 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
180 | { |
|
181 | { | |
181 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
182 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) | |
182 | } |
|
183 | } | |
183 |
|
184 | |||
184 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
185 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link | |
185 | { |
|
186 | { | |
186 | status_spw = spacewire_configure_link( fdSPW ); |
|
187 | status_spw = spacewire_configure_link( fdSPW ); | |
187 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
188 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
188 | { |
|
189 | { | |
189 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
190 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) | |
190 | } |
|
191 | } | |
191 | } |
|
192 | } | |
192 |
|
193 | |||
193 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
194 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link | |
194 | { |
|
195 | { | |
195 | status_spw = spacewire_start_link( fdSPW ); |
|
196 | status_spw = spacewire_start_link( fdSPW ); | |
196 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
197 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
197 | { |
|
198 | { | |
198 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
199 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) | |
199 | } |
|
200 | } | |
200 | } |
|
201 | } | |
201 | // </SPACEWIRE INITIALIZATION> |
|
202 | // </SPACEWIRE INITIALIZATION> | |
202 | // *************************** |
|
203 | // *************************** | |
203 |
|
204 | |||
204 | status = start_all_tasks(); // start all tasks |
|
205 | status = start_all_tasks(); // start all tasks | |
205 | if (status != RTEMS_SUCCESSFUL) |
|
206 | if (status != RTEMS_SUCCESSFUL) | |
206 | { |
|
207 | { | |
207 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
208 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) | |
208 | } |
|
209 | } | |
209 |
|
210 | |||
210 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
211 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization | |
211 | status = start_recv_send_tasks(); |
|
212 | status = start_recv_send_tasks(); | |
212 | if ( status != RTEMS_SUCCESSFUL ) |
|
213 | if ( status != RTEMS_SUCCESSFUL ) | |
213 | { |
|
214 | { | |
214 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
215 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) | |
215 | } |
|
216 | } | |
216 |
|
217 | |||
217 | // suspend science tasks, they will be restarted later depending on the mode |
|
218 | // suspend science tasks, they will be restarted later depending on the mode | |
218 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) |
|
219 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) | |
219 | if (status != RTEMS_SUCCESSFUL) |
|
220 | if (status != RTEMS_SUCCESSFUL) | |
220 | { |
|
221 | { | |
221 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
222 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) | |
222 | } |
|
223 | } | |
223 |
|
224 | |||
224 | // configure IRQ handling for the waveform picker unit |
|
225 | // configure IRQ handling for the waveform picker unit | |
225 | status = rtems_interrupt_catch( waveforms_isr, |
|
226 | status = rtems_interrupt_catch( waveforms_isr, | |
226 | IRQ_SPARC_WAVEFORM_PICKER, |
|
227 | IRQ_SPARC_WAVEFORM_PICKER, | |
227 | &old_isr_handler) ; |
|
228 | &old_isr_handler) ; | |
228 | // configure IRQ handling for the spectral matrices unit |
|
229 | // configure IRQ handling for the spectral matrices unit | |
229 | status = rtems_interrupt_catch( spectral_matrices_isr, |
|
230 | status = rtems_interrupt_catch( spectral_matrices_isr, | |
230 | IRQ_SPARC_SPECTRAL_MATRIX, |
|
231 | IRQ_SPARC_SPECTRAL_MATRIX, | |
231 | &old_isr_handler) ; |
|
232 | &old_isr_handler) ; | |
232 |
|
233 | |||
233 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
234 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery | |
234 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
235 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
235 | { |
|
236 | { | |
236 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
237 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); | |
237 | if ( status != RTEMS_SUCCESSFUL ) { |
|
238 | if ( status != RTEMS_SUCCESSFUL ) { | |
238 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
239 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) | |
239 | } |
|
240 | } | |
240 | } |
|
241 | } | |
241 |
|
242 | |||
242 | BOOT_PRINTF("delete INIT\n") |
|
243 | BOOT_PRINTF("delete INIT\n") | |
243 |
|
244 | |||
244 | set_hk_lfr_sc_potential_flag( true ); |
|
245 | set_hk_lfr_sc_potential_flag( true ); | |
245 |
|
246 | |||
246 | status = rtems_task_delete(RTEMS_SELF); |
|
247 | status = rtems_task_delete(RTEMS_SELF); | |
247 |
|
248 | |||
248 | } |
|
249 | } | |
249 |
|
250 | |||
250 | void init_local_mode_parameters( void ) |
|
251 | void init_local_mode_parameters( void ) | |
251 | { |
|
252 | { | |
252 | /** This function initialize the param_local global variable with default values. |
|
253 | /** This function initialize the param_local global variable with default values. | |
253 | * |
|
254 | * | |
254 | */ |
|
255 | */ | |
255 |
|
256 | |||
256 | unsigned int i; |
|
257 | unsigned int i; | |
257 |
|
258 | |||
258 | // LOCAL PARAMETERS |
|
259 | // LOCAL PARAMETERS | |
259 |
|
260 | |||
260 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
261 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) | |
261 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
262 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) | |
262 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) |
|
263 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) | |
263 |
|
264 | |||
264 | // init sequence counters |
|
265 | // init sequence counters | |
265 |
|
266 | |||
266 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
267 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) | |
267 | { |
|
268 | { | |
268 | sequenceCounters_TC_EXE[i] = 0x00; |
|
269 | sequenceCounters_TC_EXE[i] = 0x00; | |
269 | sequenceCounters_TM_DUMP[i] = 0x00; |
|
270 | sequenceCounters_TM_DUMP[i] = 0x00; | |
270 | } |
|
271 | } | |
271 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; |
|
272 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; | |
272 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; |
|
273 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; | |
273 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
274 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
274 | } |
|
275 | } | |
275 |
|
276 | |||
276 | void reset_local_time( void ) |
|
277 | void reset_local_time( void ) | |
277 | { |
|
278 | { | |
278 | time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000 |
|
279 | time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000 | |
279 | } |
|
280 | } | |
280 |
|
281 | |||
281 | void create_names( void ) // create all names for tasks and queues |
|
282 | void create_names( void ) // create all names for tasks and queues | |
282 | { |
|
283 | { | |
283 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
284 | /** This function creates all RTEMS names used in the software for tasks and queues. | |
284 | * |
|
285 | * | |
285 | * @return RTEMS directive status codes: |
|
286 | * @return RTEMS directive status codes: | |
286 | * - RTEMS_SUCCESSFUL - successful completion |
|
287 | * - RTEMS_SUCCESSFUL - successful completion | |
287 | * |
|
288 | * | |
288 | */ |
|
289 | */ | |
289 |
|
290 | |||
290 | // task names |
|
291 | // task names | |
291 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
292 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); | |
292 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
293 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
293 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
294 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); | |
294 | Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' ); |
|
295 | Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' ); | |
295 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
296 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); | |
296 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); |
|
297 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); | |
297 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
298 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |
298 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
299 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); | |
299 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
300 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
300 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); |
|
301 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); | |
301 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
302 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); | |
302 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
303 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); | |
303 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
304 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); | |
304 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
305 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); | |
305 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); |
|
306 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); | |
306 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); |
|
307 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); | |
307 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); |
|
308 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); | |
308 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); |
|
309 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); | |
309 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); |
|
310 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); | |
310 |
|
311 | |||
311 | // rate monotonic period names |
|
312 | // rate monotonic period names | |
312 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
313 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
313 |
|
314 | |||
314 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
315 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
315 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
316 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
316 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
317 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); | |
317 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
318 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); | |
318 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
319 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); | |
319 | } |
|
320 | } | |
320 |
|
321 | |||
321 | int create_all_tasks( void ) // create all tasks which run in the software |
|
322 | int create_all_tasks( void ) // create all tasks which run in the software | |
322 | { |
|
323 | { | |
323 | /** This function creates all RTEMS tasks used in the software. |
|
324 | /** This function creates all RTEMS tasks used in the software. | |
324 | * |
|
325 | * | |
325 | * @return RTEMS directive status codes: |
|
326 | * @return RTEMS directive status codes: | |
326 | * - RTEMS_SUCCESSFUL - task created successfully |
|
327 | * - RTEMS_SUCCESSFUL - task created successfully | |
327 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
328 | * - RTEMS_INVALID_ADDRESS - id is NULL | |
328 | * - RTEMS_INVALID_NAME - invalid task name |
|
329 | * - RTEMS_INVALID_NAME - invalid task name | |
329 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
330 | * - RTEMS_INVALID_PRIORITY - invalid task priority | |
330 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
331 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured | |
331 | * - RTEMS_TOO_MANY - too many tasks created |
|
332 | * - RTEMS_TOO_MANY - too many tasks created | |
332 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
333 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context | |
333 | * - RTEMS_TOO_MANY - too many global objects |
|
334 | * - RTEMS_TOO_MANY - too many global objects | |
334 | * |
|
335 | * | |
335 | */ |
|
336 | */ | |
336 |
|
337 | |||
337 | rtems_status_code status; |
|
338 | rtems_status_code status; | |
338 |
|
339 | |||
339 | //********** |
|
340 | //********** | |
340 | // SPACEWIRE |
|
341 | // SPACEWIRE | |
341 | // RECV |
|
342 | // RECV | |
342 | status = rtems_task_create( |
|
343 | status = rtems_task_create( | |
343 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
344 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, | |
344 | RTEMS_DEFAULT_MODES, |
|
345 | RTEMS_DEFAULT_MODES, | |
345 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
346 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] | |
346 | ); |
|
347 | ); | |
347 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
348 | if (status == RTEMS_SUCCESSFUL) // SEND | |
348 | { |
|
349 | { | |
349 | status = rtems_task_create( |
|
350 | status = rtems_task_create( | |
350 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
351 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2, | |
351 | RTEMS_DEFAULT_MODES, |
|
352 | RTEMS_DEFAULT_MODES, | |
352 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] |
|
353 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] | |
353 | ); |
|
354 | ); | |
354 | } |
|
355 | } | |
355 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
356 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
356 | { |
|
357 | { | |
357 | status = rtems_task_create( |
|
358 | status = rtems_task_create( | |
358 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, |
|
359 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, | |
359 | RTEMS_DEFAULT_MODES, |
|
360 | RTEMS_DEFAULT_MODES, | |
360 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] |
|
361 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] | |
361 | ); |
|
362 | ); | |
362 | } |
|
363 | } | |
363 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
364 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
364 | { |
|
365 | { | |
365 | status = rtems_task_create( |
|
366 | status = rtems_task_create( | |
366 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
367 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
367 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
368 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
368 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
369 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] | |
369 | ); |
|
370 | ); | |
370 | } |
|
371 | } | |
371 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
372 | if (status == RTEMS_SUCCESSFUL) // SPIQ | |
372 | { |
|
373 | { | |
373 | status = rtems_task_create( |
|
374 | status = rtems_task_create( | |
374 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
375 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, | |
375 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
376 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
376 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
377 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] | |
377 | ); |
|
378 | ); | |
378 | } |
|
379 | } | |
379 |
|
380 | |||
380 | //****************** |
|
381 | //****************** | |
381 | // SPECTRAL MATRICES |
|
382 | // SPECTRAL MATRICES | |
382 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
383 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
383 | { |
|
384 | { | |
384 | status = rtems_task_create( |
|
385 | status = rtems_task_create( | |
385 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
386 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, | |
386 | RTEMS_DEFAULT_MODES, |
|
387 | RTEMS_DEFAULT_MODES, | |
387 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
388 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] | |
388 | ); |
|
389 | ); | |
389 | } |
|
390 | } | |
390 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
391 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
391 | { |
|
392 | { | |
392 | status = rtems_task_create( |
|
393 | status = rtems_task_create( | |
393 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
394 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2, | |
394 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
395 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
395 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] |
|
396 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] | |
396 | ); |
|
397 | ); | |
397 | } |
|
398 | } | |
398 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
399 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
399 | { |
|
400 | { | |
400 | status = rtems_task_create( |
|
401 | status = rtems_task_create( | |
401 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, |
|
402 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, | |
402 | RTEMS_DEFAULT_MODES, |
|
403 | RTEMS_DEFAULT_MODES, | |
403 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] |
|
404 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] | |
404 | ); |
|
405 | ); | |
405 | } |
|
406 | } | |
406 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
407 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
407 | { |
|
408 | { | |
408 | status = rtems_task_create( |
|
409 | status = rtems_task_create( | |
409 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
410 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2, | |
410 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
411 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
411 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] |
|
412 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] | |
412 | ); |
|
413 | ); | |
413 | } |
|
414 | } | |
414 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
415 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
415 | { |
|
416 | { | |
416 | status = rtems_task_create( |
|
417 | status = rtems_task_create( | |
417 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, |
|
418 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, | |
418 | RTEMS_DEFAULT_MODES, |
|
419 | RTEMS_DEFAULT_MODES, | |
419 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] |
|
420 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] | |
420 | ); |
|
421 | ); | |
421 | } |
|
422 | } | |
422 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
423 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
423 | { |
|
424 | { | |
424 | status = rtems_task_create( |
|
425 | status = rtems_task_create( | |
425 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
426 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2, | |
426 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
427 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
427 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] |
|
428 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] | |
428 | ); |
|
429 | ); | |
429 | } |
|
430 | } | |
430 |
|
431 | |||
431 | //**************** |
|
432 | //**************** | |
432 | // WAVEFORM PICKER |
|
433 | // WAVEFORM PICKER | |
433 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
434 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
434 | { |
|
435 | { | |
435 | status = rtems_task_create( |
|
436 | status = rtems_task_create( | |
436 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
437 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, | |
437 | RTEMS_DEFAULT_MODES, |
|
438 | RTEMS_DEFAULT_MODES, | |
438 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
439 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
439 | ); |
|
440 | ); | |
440 | } |
|
441 | } | |
441 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
442 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
442 | { |
|
443 | { | |
443 | status = rtems_task_create( |
|
444 | status = rtems_task_create( | |
444 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
445 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, | |
445 | RTEMS_DEFAULT_MODES, |
|
446 | RTEMS_DEFAULT_MODES, | |
446 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] |
|
447 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] | |
447 | ); |
|
448 | ); | |
448 | } |
|
449 | } | |
449 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
450 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
450 | { |
|
451 | { | |
451 | status = rtems_task_create( |
|
452 | status = rtems_task_create( | |
452 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
453 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, | |
453 | RTEMS_DEFAULT_MODES, |
|
454 | RTEMS_DEFAULT_MODES, | |
454 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] |
|
455 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] | |
455 | ); |
|
456 | ); | |
456 | } |
|
457 | } | |
457 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
458 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
458 | { |
|
459 | { | |
459 | status = rtems_task_create( |
|
460 | status = rtems_task_create( | |
460 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
461 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, | |
461 | RTEMS_DEFAULT_MODES, |
|
462 | RTEMS_DEFAULT_MODES, | |
462 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] |
|
463 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] | |
463 | ); |
|
464 | ); | |
464 | } |
|
465 | } | |
465 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
466 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
466 | { |
|
467 | { | |
467 | status = rtems_task_create( |
|
468 | status = rtems_task_create( | |
468 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, |
|
469 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, | |
469 | RTEMS_DEFAULT_MODES, |
|
470 | RTEMS_DEFAULT_MODES, | |
470 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] |
|
471 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] | |
471 | ); |
|
472 | ); | |
472 | } |
|
473 | } | |
473 |
|
474 | |||
474 | //***** |
|
475 | //***** | |
475 | // MISC |
|
476 | // MISC | |
476 | if (status == RTEMS_SUCCESSFUL) // LOAD |
|
477 | if (status == RTEMS_SUCCESSFUL) // LOAD | |
477 | { |
|
478 | { | |
478 | status = rtems_task_create( |
|
479 | status = rtems_task_create( | |
479 | Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE, |
|
480 | Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE, | |
480 | RTEMS_DEFAULT_MODES, |
|
481 | RTEMS_DEFAULT_MODES, | |
481 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD] |
|
482 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD] | |
482 | ); |
|
483 | ); | |
483 | } |
|
484 | } | |
484 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
485 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
485 | { |
|
486 | { | |
486 | status = rtems_task_create( |
|
487 | status = rtems_task_create( | |
487 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
488 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, | |
488 | RTEMS_DEFAULT_MODES, |
|
489 | RTEMS_DEFAULT_MODES, | |
489 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
490 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
490 | ); |
|
491 | ); | |
491 | } |
|
492 | } | |
492 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
493 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
493 | { |
|
494 | { | |
494 | status = rtems_task_create( |
|
495 | status = rtems_task_create( | |
495 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
496 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, | |
496 | RTEMS_DEFAULT_MODES, |
|
497 | RTEMS_DEFAULT_MODES, | |
497 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] |
|
498 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] | |
498 | ); |
|
499 | ); | |
499 | } |
|
500 | } | |
500 |
|
501 | |||
501 | return status; |
|
502 | return status; | |
502 | } |
|
503 | } | |
503 |
|
504 | |||
504 | int start_recv_send_tasks( void ) |
|
505 | int start_recv_send_tasks( void ) | |
505 | { |
|
506 | { | |
506 | rtems_status_code status; |
|
507 | rtems_status_code status; | |
507 |
|
508 | |||
508 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
509 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |
509 | if (status!=RTEMS_SUCCESSFUL) { |
|
510 | if (status!=RTEMS_SUCCESSFUL) { | |
510 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
511 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") | |
511 | } |
|
512 | } | |
512 |
|
513 | |||
513 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
514 | if (status == RTEMS_SUCCESSFUL) // SEND | |
514 | { |
|
515 | { | |
515 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
516 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); | |
516 | if (status!=RTEMS_SUCCESSFUL) { |
|
517 | if (status!=RTEMS_SUCCESSFUL) { | |
517 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
518 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") | |
518 | } |
|
519 | } | |
519 | } |
|
520 | } | |
520 |
|
521 | |||
521 | return status; |
|
522 | return status; | |
522 | } |
|
523 | } | |
523 |
|
524 | |||
524 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
525 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS | |
525 | { |
|
526 | { | |
526 | /** This function starts all RTEMS tasks used in the software. |
|
527 | /** This function starts all RTEMS tasks used in the software. | |
527 | * |
|
528 | * | |
528 | * @return RTEMS directive status codes: |
|
529 | * @return RTEMS directive status codes: | |
529 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
530 | * - RTEMS_SUCCESSFUL - ask started successfully | |
530 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
531 | * - RTEMS_INVALID_ADDRESS - invalid task entry point | |
531 | * - RTEMS_INVALID_ID - invalid task id |
|
532 | * - RTEMS_INVALID_ID - invalid task id | |
532 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
533 | * - RTEMS_INCORRECT_STATE - task not in the dormant state | |
533 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
534 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task | |
534 | * |
|
535 | * | |
535 | */ |
|
536 | */ | |
536 | // starts all the tasks fot eh flight software |
|
537 | // starts all the tasks fot eh flight software | |
537 |
|
538 | |||
538 | rtems_status_code status; |
|
539 | rtems_status_code status; | |
539 |
|
540 | |||
540 | //********** |
|
541 | //********** | |
541 | // SPACEWIRE |
|
542 | // SPACEWIRE | |
542 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
543 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); | |
543 | if (status!=RTEMS_SUCCESSFUL) { |
|
544 | if (status!=RTEMS_SUCCESSFUL) { | |
544 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
545 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") | |
545 | } |
|
546 | } | |
546 |
|
547 | |||
547 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
548 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
548 | { |
|
549 | { | |
549 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); |
|
550 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); | |
550 | if (status!=RTEMS_SUCCESSFUL) { |
|
551 | if (status!=RTEMS_SUCCESSFUL) { | |
551 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") |
|
552 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") | |
552 | } |
|
553 | } | |
553 | } |
|
554 | } | |
554 |
|
555 | |||
555 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
556 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
556 | { |
|
557 | { | |
557 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
558 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |
558 | if (status!=RTEMS_SUCCESSFUL) { |
|
559 | if (status!=RTEMS_SUCCESSFUL) { | |
559 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
560 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") | |
560 | } |
|
561 | } | |
561 | } |
|
562 | } | |
562 |
|
563 | |||
563 | //****************** |
|
564 | //****************** | |
564 | // SPECTRAL MATRICES |
|
565 | // SPECTRAL MATRICES | |
565 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
566 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
566 | { |
|
567 | { | |
567 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); |
|
568 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); | |
568 | if (status!=RTEMS_SUCCESSFUL) { |
|
569 | if (status!=RTEMS_SUCCESSFUL) { | |
569 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
570 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") | |
570 | } |
|
571 | } | |
571 | } |
|
572 | } | |
572 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
573 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
573 | { |
|
574 | { | |
574 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); |
|
575 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); | |
575 | if (status!=RTEMS_SUCCESSFUL) { |
|
576 | if (status!=RTEMS_SUCCESSFUL) { | |
576 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") |
|
577 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") | |
577 | } |
|
578 | } | |
578 | } |
|
579 | } | |
579 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
580 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
580 | { |
|
581 | { | |
581 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); |
|
582 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); | |
582 | if (status!=RTEMS_SUCCESSFUL) { |
|
583 | if (status!=RTEMS_SUCCESSFUL) { | |
583 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") |
|
584 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") | |
584 | } |
|
585 | } | |
585 | } |
|
586 | } | |
586 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
587 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
587 | { |
|
588 | { | |
588 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); |
|
589 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); | |
589 | if (status!=RTEMS_SUCCESSFUL) { |
|
590 | if (status!=RTEMS_SUCCESSFUL) { | |
590 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") |
|
591 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") | |
591 | } |
|
592 | } | |
592 | } |
|
593 | } | |
593 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
594 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
594 | { |
|
595 | { | |
595 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); |
|
596 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); | |
596 | if (status!=RTEMS_SUCCESSFUL) { |
|
597 | if (status!=RTEMS_SUCCESSFUL) { | |
597 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") |
|
598 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") | |
598 | } |
|
599 | } | |
599 | } |
|
600 | } | |
600 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
601 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
601 | { |
|
602 | { | |
602 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); |
|
603 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); | |
603 | if (status!=RTEMS_SUCCESSFUL) { |
|
604 | if (status!=RTEMS_SUCCESSFUL) { | |
604 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") |
|
605 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") | |
605 | } |
|
606 | } | |
606 | } |
|
607 | } | |
607 |
|
608 | |||
608 | //**************** |
|
609 | //**************** | |
609 | // WAVEFORM PICKER |
|
610 | // WAVEFORM PICKER | |
610 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
611 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
611 | { |
|
612 | { | |
612 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
613 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |
613 | if (status!=RTEMS_SUCCESSFUL) { |
|
614 | if (status!=RTEMS_SUCCESSFUL) { | |
614 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
615 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") | |
615 | } |
|
616 | } | |
616 | } |
|
617 | } | |
617 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
618 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
618 | { |
|
619 | { | |
619 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
620 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); | |
620 | if (status!=RTEMS_SUCCESSFUL) { |
|
621 | if (status!=RTEMS_SUCCESSFUL) { | |
621 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
622 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") | |
622 | } |
|
623 | } | |
623 | } |
|
624 | } | |
624 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
625 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
625 | { |
|
626 | { | |
626 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
627 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); | |
627 | if (status!=RTEMS_SUCCESSFUL) { |
|
628 | if (status!=RTEMS_SUCCESSFUL) { | |
628 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
629 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") | |
629 | } |
|
630 | } | |
630 | } |
|
631 | } | |
631 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
632 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
632 | { |
|
633 | { | |
633 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
634 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); | |
634 | if (status!=RTEMS_SUCCESSFUL) { |
|
635 | if (status!=RTEMS_SUCCESSFUL) { | |
635 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
636 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") | |
636 | } |
|
637 | } | |
637 | } |
|
638 | } | |
638 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
639 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
639 | { |
|
640 | { | |
640 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); |
|
641 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); | |
641 | if (status!=RTEMS_SUCCESSFUL) { |
|
642 | if (status!=RTEMS_SUCCESSFUL) { | |
642 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") |
|
643 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") | |
643 | } |
|
644 | } | |
644 | } |
|
645 | } | |
645 |
|
646 | |||
646 | //***** |
|
647 | //***** | |
647 | // MISC |
|
648 | // MISC | |
648 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
649 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
649 | { |
|
650 | { | |
650 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
651 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |
651 | if (status!=RTEMS_SUCCESSFUL) { |
|
652 | if (status!=RTEMS_SUCCESSFUL) { | |
652 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
653 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") | |
653 | } |
|
654 | } | |
654 | } |
|
655 | } | |
655 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
656 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
656 | { |
|
657 | { | |
657 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
658 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |
658 | if (status!=RTEMS_SUCCESSFUL) { |
|
659 | if (status!=RTEMS_SUCCESSFUL) { | |
659 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
660 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
660 | } |
|
661 | } | |
661 | } |
|
662 | } | |
662 | if (status == RTEMS_SUCCESSFUL) // LOAD |
|
663 | if (status == RTEMS_SUCCESSFUL) // LOAD | |
663 | { |
|
664 | { | |
664 | status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 ); |
|
665 | status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 ); | |
665 | if (status!=RTEMS_SUCCESSFUL) { |
|
666 | if (status!=RTEMS_SUCCESSFUL) { | |
666 | BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n") |
|
667 | BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n") | |
667 | } |
|
668 | } | |
668 | } |
|
669 | } | |
669 |
|
670 | |||
670 | return status; |
|
671 | return status; | |
671 | } |
|
672 | } | |
672 |
|
673 | |||
673 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
674 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software | |
674 | { |
|
675 | { | |
675 | rtems_status_code status_recv; |
|
676 | rtems_status_code status_recv; | |
676 | rtems_status_code status_send; |
|
677 | rtems_status_code status_send; | |
677 | rtems_status_code status_q_p0; |
|
678 | rtems_status_code status_q_p0; | |
678 | rtems_status_code status_q_p1; |
|
679 | rtems_status_code status_q_p1; | |
679 | rtems_status_code status_q_p2; |
|
680 | rtems_status_code status_q_p2; | |
680 | rtems_status_code ret; |
|
681 | rtems_status_code ret; | |
681 | rtems_id queue_id; |
|
682 | rtems_id queue_id; | |
682 |
|
683 | |||
683 | //**************************************** |
|
684 | //**************************************** | |
684 | // create the queue for handling valid TCs |
|
685 | // create the queue for handling valid TCs | |
685 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
686 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], | |
686 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, |
|
687 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, | |
687 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
688 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
688 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
689 | if ( status_recv != RTEMS_SUCCESSFUL ) { | |
689 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
690 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) | |
690 | } |
|
691 | } | |
691 |
|
692 | |||
692 | //************************************************ |
|
693 | //************************************************ | |
693 | // create the queue for handling TM packet sending |
|
694 | // create the queue for handling TM packet sending | |
694 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
695 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], | |
695 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, |
|
696 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, | |
696 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
697 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
697 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
698 | if ( status_send != RTEMS_SUCCESSFUL ) { | |
698 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
699 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) | |
699 | } |
|
700 | } | |
700 |
|
701 | |||
701 | //***************************************************************************** |
|
702 | //***************************************************************************** | |
702 | // create the queue for handling averaged spectral matrices for processing @ f0 |
|
703 | // create the queue for handling averaged spectral matrices for processing @ f0 | |
703 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], |
|
704 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], | |
704 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, |
|
705 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, | |
705 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
706 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
706 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { |
|
707 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { | |
707 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) |
|
708 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) | |
708 | } |
|
709 | } | |
709 |
|
710 | |||
710 | //***************************************************************************** |
|
711 | //***************************************************************************** | |
711 | // create the queue for handling averaged spectral matrices for processing @ f1 |
|
712 | // create the queue for handling averaged spectral matrices for processing @ f1 | |
712 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], |
|
713 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], | |
713 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, |
|
714 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, | |
714 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
715 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
715 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { |
|
716 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { | |
716 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) |
|
717 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) | |
717 | } |
|
718 | } | |
718 |
|
719 | |||
719 | //***************************************************************************** |
|
720 | //***************************************************************************** | |
720 | // create the queue for handling averaged spectral matrices for processing @ f2 |
|
721 | // create the queue for handling averaged spectral matrices for processing @ f2 | |
721 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], |
|
722 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], | |
722 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, |
|
723 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, | |
723 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
724 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
724 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { |
|
725 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { | |
725 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) |
|
726 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) | |
726 | } |
|
727 | } | |
727 |
|
728 | |||
728 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
729 | if ( status_recv != RTEMS_SUCCESSFUL ) | |
729 | { |
|
730 | { | |
730 | ret = status_recv; |
|
731 | ret = status_recv; | |
731 | } |
|
732 | } | |
732 | else if( status_send != RTEMS_SUCCESSFUL ) |
|
733 | else if( status_send != RTEMS_SUCCESSFUL ) | |
733 | { |
|
734 | { | |
734 | ret = status_send; |
|
735 | ret = status_send; | |
735 | } |
|
736 | } | |
736 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) |
|
737 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) | |
737 | { |
|
738 | { | |
738 | ret = status_q_p0; |
|
739 | ret = status_q_p0; | |
739 | } |
|
740 | } | |
740 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) |
|
741 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) | |
741 | { |
|
742 | { | |
742 | ret = status_q_p1; |
|
743 | ret = status_q_p1; | |
743 | } |
|
744 | } | |
744 | else |
|
745 | else | |
745 | { |
|
746 | { | |
746 | ret = status_q_p2; |
|
747 | ret = status_q_p2; | |
747 | } |
|
748 | } | |
748 |
|
749 | |||
749 | return ret; |
|
750 | return ret; | |
750 | } |
|
751 | } | |
751 |
|
752 | |||
752 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) |
|
753 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) | |
753 | { |
|
754 | { | |
754 | rtems_status_code status; |
|
755 | rtems_status_code status; | |
755 | rtems_name queue_name; |
|
756 | rtems_name queue_name; | |
756 |
|
757 | |||
757 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
758 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
758 |
|
759 | |||
759 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
760 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
760 |
|
761 | |||
761 | return status; |
|
762 | return status; | |
762 | } |
|
763 | } | |
763 |
|
764 | |||
764 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) |
|
765 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) | |
765 | { |
|
766 | { | |
766 | rtems_status_code status; |
|
767 | rtems_status_code status; | |
767 | rtems_name queue_name; |
|
768 | rtems_name queue_name; | |
768 |
|
769 | |||
769 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
770 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
770 |
|
771 | |||
771 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
772 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
772 |
|
773 | |||
773 | return status; |
|
774 | return status; | |
774 | } |
|
775 | } | |
775 |
|
776 | |||
776 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) |
|
777 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) | |
777 | { |
|
778 | { | |
778 | rtems_status_code status; |
|
779 | rtems_status_code status; | |
779 | rtems_name queue_name; |
|
780 | rtems_name queue_name; | |
780 |
|
781 | |||
781 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
782 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); | |
782 |
|
783 | |||
783 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
784 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
784 |
|
785 | |||
785 | return status; |
|
786 | return status; | |
786 | } |
|
787 | } | |
787 |
|
788 | |||
788 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) |
|
789 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) | |
789 | { |
|
790 | { | |
790 | rtems_status_code status; |
|
791 | rtems_status_code status; | |
791 | rtems_name queue_name; |
|
792 | rtems_name queue_name; | |
792 |
|
793 | |||
793 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
794 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); | |
794 |
|
795 | |||
795 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
796 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
796 |
|
797 | |||
797 | return status; |
|
798 | return status; | |
798 | } |
|
799 | } | |
799 |
|
800 | |||
800 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) |
|
801 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) | |
801 | { |
|
802 | { | |
802 | rtems_status_code status; |
|
803 | rtems_status_code status; | |
803 | rtems_name queue_name; |
|
804 | rtems_name queue_name; | |
804 |
|
805 | |||
805 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
806 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); | |
806 |
|
807 | |||
807 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
808 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
808 |
|
809 | |||
809 | return status; |
|
810 | return status; | |
810 | } |
|
811 | } | |
811 |
|
812 | |||
812 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) |
|
813 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) | |
813 | { |
|
814 | { | |
814 | u_int32_t count; |
|
815 | u_int32_t count; | |
815 | rtems_status_code status; |
|
816 | rtems_status_code status; | |
816 |
|
817 | |||
817 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
818 | status = rtems_message_queue_get_number_pending( queue_id, &count ); | |
818 |
|
819 | |||
819 | count = count + 1; |
|
820 | count = count + 1; | |
820 |
|
821 | |||
821 | if (status != RTEMS_SUCCESSFUL) |
|
822 | if (status != RTEMS_SUCCESSFUL) | |
822 | { |
|
823 | { | |
823 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) |
|
824 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) | |
824 | } |
|
825 | } | |
825 | else |
|
826 | else | |
826 | { |
|
827 | { | |
827 | if (count > *fifo_size_max) |
|
828 | if (count > *fifo_size_max) | |
828 | { |
|
829 | { | |
829 | *fifo_size_max = count; |
|
830 | *fifo_size_max = count; | |
830 | } |
|
831 | } | |
831 | } |
|
832 | } | |
832 | } |
|
833 | } | |
833 |
|
834 | |||
834 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) |
|
835 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) | |
835 | { |
|
836 | { | |
836 | unsigned char i; |
|
837 | unsigned char i; | |
837 |
|
838 | |||
838 | //*************** |
|
839 | //*************** | |
839 | // BUFFER ADDRESS |
|
840 | // BUFFER ADDRESS | |
840 | for(i=0; i<nbNodes; i++) |
|
841 | for(i=0; i<nbNodes; i++) | |
841 | { |
|
842 | { | |
842 | ring[i].coarseTime = 0xffffffff; |
|
843 | ring[i].coarseTime = 0xffffffff; | |
843 | ring[i].fineTime = 0xffffffff; |
|
844 | ring[i].fineTime = 0xffffffff; | |
844 | ring[i].sid = 0x00; |
|
845 | ring[i].sid = 0x00; | |
845 | ring[i].status = 0x00; |
|
846 | ring[i].status = 0x00; | |
846 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; |
|
847 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; | |
847 | } |
|
848 | } | |
848 |
|
849 | |||
849 | //***** |
|
850 | //***** | |
850 | // NEXT |
|
851 | // NEXT | |
851 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; |
|
852 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; | |
852 | for(i=0; i<nbNodes-1; i++) |
|
853 | for(i=0; i<nbNodes-1; i++) | |
853 | { |
|
854 | { | |
854 | ring[i].next = (ring_node*) &ring[ i + 1 ]; |
|
855 | ring[i].next = (ring_node*) &ring[ i + 1 ]; | |
855 | } |
|
856 | } | |
856 |
|
857 | |||
857 | //********* |
|
858 | //********* | |
858 | // PREVIOUS |
|
859 | // PREVIOUS | |
859 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; |
|
860 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; | |
860 | for(i=1; i<nbNodes; i++) |
|
861 | for(i=1; i<nbNodes; i++) | |
861 | { |
|
862 | { | |
862 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; |
|
863 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; | |
863 | } |
|
864 | } | |
864 | } |
|
865 | } |
@@ -1,652 +1,698 | |||||
1 | /** General usage functions and RTEMS tasks. |
|
1 | /** General usage functions and RTEMS tasks. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | */ |
|
6 | */ | |
7 |
|
7 | |||
8 | #include "fsw_misc.h" |
|
8 | #include "fsw_misc.h" | |
9 |
|
9 | |||
10 | void timer_configure(unsigned char timer, unsigned int clock_divider, |
|
10 | void timer_configure(unsigned char timer, unsigned int clock_divider, | |
11 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
11 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) | |
12 | { |
|
12 | { | |
13 | /** This function configures a GPTIMER timer instantiated in the VHDL design. |
|
13 | /** This function configures a GPTIMER timer instantiated in the VHDL design. | |
14 | * |
|
14 | * | |
15 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
15 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
16 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
16 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
17 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
17 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
18 | * @param interrupt_level is the interrupt level that the timer drives. |
|
18 | * @param interrupt_level is the interrupt level that the timer drives. | |
19 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. |
|
19 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. | |
20 | * |
|
20 | * | |
21 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 |
|
21 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 | |
22 | * |
|
22 | * | |
23 | */ |
|
23 | */ | |
24 |
|
24 | |||
25 | rtems_status_code status; |
|
25 | rtems_status_code status; | |
26 | rtems_isr_entry old_isr_handler; |
|
26 | rtems_isr_entry old_isr_handler; | |
27 |
|
27 | |||
28 | gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register |
|
28 | gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register | |
29 |
|
29 | |||
30 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
30 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels | |
31 | if (status!=RTEMS_SUCCESSFUL) |
|
31 | if (status!=RTEMS_SUCCESSFUL) | |
32 | { |
|
32 | { | |
33 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") |
|
33 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | timer_set_clock_divider( timer, clock_divider); |
|
36 | timer_set_clock_divider( timer, clock_divider); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | void timer_start(unsigned char timer) |
|
39 | void timer_start(unsigned char timer) | |
40 | { |
|
40 | { | |
41 | /** This function starts a GPTIMER timer. |
|
41 | /** This function starts a GPTIMER timer. | |
42 | * |
|
42 | * | |
43 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
43 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
44 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
44 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
45 | * |
|
45 | * | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
48 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any | |
49 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register |
|
49 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register | |
50 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer |
|
50 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer | |
51 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart |
|
51 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart | |
52 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable |
|
52 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | void timer_stop(unsigned char timer) |
|
55 | void timer_stop(unsigned char timer) | |
56 | { |
|
56 | { | |
57 | /** This function stops a GPTIMER timer. |
|
57 | /** This function stops a GPTIMER timer. | |
58 | * |
|
58 | * | |
59 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
59 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
60 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
60 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
61 | * |
|
61 | * | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer |
|
64 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer | |
65 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable |
|
65 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable | |
66 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
66 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider) |
|
69 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider) | |
70 | { |
|
70 | { | |
71 | /** This function sets the clock divider of a GPTIMER timer. |
|
71 | /** This function sets the clock divider of a GPTIMER timer. | |
72 | * |
|
72 | * | |
73 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
73 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
74 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
74 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
75 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
75 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
76 | * |
|
76 | * | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
79 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | // WATCHDOG |
|
82 | // WATCHDOG | |
83 |
|
83 | |||
84 | rtems_isr watchdog_isr( rtems_vector_number vector ) |
|
84 | rtems_isr watchdog_isr( rtems_vector_number vector ) | |
85 | { |
|
85 | { | |
86 | rtems_status_code status_code; |
|
86 | rtems_status_code status_code; | |
87 |
|
87 | |||
88 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 ); |
|
88 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 ); | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | void watchdog_configure(void) |
|
91 | void watchdog_configure(void) | |
92 | { |
|
92 | { | |
93 | /** This function configure the watchdog. |
|
93 | /** This function configure the watchdog. | |
94 | * |
|
94 | * | |
95 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
95 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
96 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
96 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
97 | * |
|
97 | * | |
98 | * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB. |
|
98 | * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB. | |
99 | * |
|
99 | * | |
100 | */ |
|
100 | */ | |
101 |
|
101 | |||
102 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration |
|
102 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration | |
103 |
|
103 | |||
104 | timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr ); |
|
104 | timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr ); | |
105 |
|
105 | |||
106 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt |
|
106 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | void watchdog_stop(void) |
|
109 | void watchdog_stop(void) | |
110 | { |
|
110 | { | |
111 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line |
|
111 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line | |
112 | timer_stop( TIMER_WATCHDOG ); |
|
112 | timer_stop( TIMER_WATCHDOG ); | |
113 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt |
|
113 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt | |
114 | } |
|
114 | } | |
115 |
|
115 | |||
116 | void watchdog_reload(void) |
|
116 | void watchdog_reload(void) | |
117 | { |
|
117 | { | |
118 | /** This function reloads the watchdog timer counter with the timer reload value. |
|
118 | /** This function reloads the watchdog timer counter with the timer reload value. | |
119 | * |
|
119 | * | |
120 | * |
|
120 | * | |
121 | */ |
|
121 | */ | |
122 |
|
122 | |||
123 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register |
|
123 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register | |
124 | } |
|
124 | } | |
125 |
|
125 | |||
126 | void watchdog_start(void) |
|
126 | void watchdog_start(void) | |
127 | { |
|
127 | { | |
128 | /** This function starts the watchdog timer. |
|
128 | /** This function starts the watchdog timer. | |
129 | * |
|
129 | * | |
130 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
130 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
131 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
131 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
132 | * |
|
132 | * | |
133 | */ |
|
133 | */ | |
134 |
|
134 | |||
135 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); |
|
135 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); | |
136 |
|
136 | |||
137 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000010; // clear pending IRQ if any |
|
137 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000010; // clear pending IRQ if any | |
138 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register |
|
138 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register | |
139 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000001; // EN enable the timer |
|
139 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000001; // EN enable the timer | |
140 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000008; // IE interrupt enable |
|
140 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000008; // IE interrupt enable | |
141 |
|
141 | |||
142 | LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG ); |
|
142 | LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG ); | |
143 |
|
143 | |||
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port |
|
146 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port | |
147 | { |
|
147 | { | |
148 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
148 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
149 |
|
149 | |||
150 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; |
|
150 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; | |
151 |
|
151 | |||
152 | return 0; |
|
152 | return 0; | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register |
|
155 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register | |
156 | { |
|
156 | { | |
157 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
157 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
158 |
|
158 | |||
159 | apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE; |
|
159 | apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE; | |
160 |
|
160 | |||
161 | return 0; |
|
161 | return 0; | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) |
|
164 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) | |
165 | { |
|
165 | { | |
166 | /** This function sets the scaler reload register of the apbuart module |
|
166 | /** This function sets the scaler reload register of the apbuart module | |
167 | * |
|
167 | * | |
168 | * @param regs is the address of the apbuart registers in memory |
|
168 | * @param regs is the address of the apbuart registers in memory | |
169 | * @param value is the value that will be stored in the scaler register |
|
169 | * @param value is the value that will be stored in the scaler register | |
170 | * |
|
170 | * | |
171 | * The value shall be set by the software to get data on the serial interface. |
|
171 | * The value shall be set by the software to get data on the serial interface. | |
172 | * |
|
172 | * | |
173 | */ |
|
173 | */ | |
174 |
|
174 | |||
175 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; |
|
175 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; | |
176 |
|
176 | |||
177 | apbuart_regs->scaler = value; |
|
177 | apbuart_regs->scaler = value; | |
178 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) |
|
178 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) | |
179 | } |
|
179 | } | |
180 |
|
180 | |||
181 | //************ |
|
181 | //************ | |
182 | // RTEMS TASKS |
|
182 | // RTEMS TASKS | |
183 |
|
183 | |||
184 | rtems_task load_task(rtems_task_argument argument) |
|
184 | rtems_task load_task(rtems_task_argument argument) | |
185 | { |
|
185 | { | |
186 | BOOT_PRINTF("in LOAD *** \n") |
|
186 | BOOT_PRINTF("in LOAD *** \n") | |
187 |
|
187 | |||
188 | rtems_status_code status; |
|
188 | rtems_status_code status; | |
189 | unsigned int i; |
|
189 | unsigned int i; | |
190 | unsigned int j; |
|
190 | unsigned int j; | |
191 | rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic |
|
191 | rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic | |
192 | rtems_id watchdog_period_id; // id of the watchdog rate monotonic period |
|
192 | rtems_id watchdog_period_id; // id of the watchdog rate monotonic period | |
193 |
|
193 | |||
194 | name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' ); |
|
194 | name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' ); | |
195 |
|
195 | |||
196 | status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id ); |
|
196 | status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id ); | |
197 | if( status != RTEMS_SUCCESSFUL ) { |
|
197 | if( status != RTEMS_SUCCESSFUL ) { | |
198 | PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
198 | PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status ) | |
199 | } |
|
199 | } | |
200 |
|
200 | |||
201 | i = 0; |
|
201 | i = 0; | |
202 | j = 0; |
|
202 | j = 0; | |
203 |
|
203 | |||
204 | watchdog_configure(); |
|
204 | watchdog_configure(); | |
205 |
|
205 | |||
206 | watchdog_start(); |
|
206 | watchdog_start(); | |
207 |
|
207 | |||
208 | while(1){ |
|
208 | while(1){ | |
209 | status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD ); |
|
209 | status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD ); | |
210 | watchdog_reload(); |
|
210 | watchdog_reload(); | |
211 | i = i + 1; |
|
211 | i = i + 1; | |
212 | if ( i == 10 ) |
|
212 | if ( i == 10 ) | |
213 | { |
|
213 | { | |
214 | i = 0; |
|
214 | i = 0; | |
215 | j = j + 1; |
|
215 | j = j + 1; | |
216 | PRINTF1("%d\n", j) |
|
216 | PRINTF1("%d\n", j) | |
217 | } |
|
217 | } | |
218 | if (j == 3 ) |
|
218 | if (j == 3 ) | |
219 | { |
|
219 | { | |
220 | status = rtems_task_delete(RTEMS_SELF); |
|
220 | status = rtems_task_delete(RTEMS_SELF); | |
221 | } |
|
221 | } | |
222 | } |
|
222 | } | |
223 | } |
|
223 | } | |
224 |
|
224 | |||
225 | rtems_task hous_task(rtems_task_argument argument) |
|
225 | rtems_task hous_task(rtems_task_argument argument) | |
226 | { |
|
226 | { | |
227 | rtems_status_code status; |
|
227 | rtems_status_code status; | |
228 | rtems_status_code spare_status; |
|
228 | rtems_status_code spare_status; | |
229 | rtems_id queue_id; |
|
229 | rtems_id queue_id; | |
230 | rtems_rate_monotonic_period_status period_status; |
|
230 | rtems_rate_monotonic_period_status period_status; | |
231 |
|
231 | |||
232 | status = get_message_queue_id_send( &queue_id ); |
|
232 | status = get_message_queue_id_send( &queue_id ); | |
233 | if (status != RTEMS_SUCCESSFUL) |
|
233 | if (status != RTEMS_SUCCESSFUL) | |
234 | { |
|
234 | { | |
235 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
235 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | BOOT_PRINTF("in HOUS ***\n") |
|
238 | BOOT_PRINTF("in HOUS ***\n") | |
239 |
|
239 | |||
240 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { |
|
240 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { | |
241 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); |
|
241 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); | |
242 | if( status != RTEMS_SUCCESSFUL ) { |
|
242 | if( status != RTEMS_SUCCESSFUL ) { | |
243 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
243 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) | |
244 | } |
|
244 | } | |
245 | } |
|
245 | } | |
246 |
|
246 | |||
247 | status = rtems_rate_monotonic_cancel(HK_id); |
|
247 | status = rtems_rate_monotonic_cancel(HK_id); | |
248 | if( status != RTEMS_SUCCESSFUL ) { |
|
248 | if( status != RTEMS_SUCCESSFUL ) { | |
249 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) |
|
249 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) | |
250 | } |
|
250 | } | |
251 | else { |
|
251 | else { | |
252 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") |
|
252 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") | |
253 | } |
|
253 | } | |
254 |
|
254 | |||
255 | // startup phase |
|
255 | // startup phase | |
256 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); |
|
256 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); | |
257 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
257 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
258 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
258 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
259 | while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway |
|
259 | while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway | |
260 | { |
|
260 | { | |
261 | if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization |
|
261 | if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization | |
262 | { |
|
262 | { | |
263 | break; // break if LFR is synchronized |
|
263 | break; // break if LFR is synchronized | |
264 | } |
|
264 | } | |
265 | else |
|
265 | else | |
266 | { |
|
266 | { | |
267 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
267 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
268 | // sched_yield(); |
|
268 | // sched_yield(); | |
269 | status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms |
|
269 | status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms | |
270 | } |
|
270 | } | |
271 | } |
|
271 | } | |
272 | status = rtems_rate_monotonic_cancel(HK_id); |
|
272 | status = rtems_rate_monotonic_cancel(HK_id); | |
273 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
273 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
274 |
|
274 | |||
275 | set_hk_lfr_reset_cause( POWER_ON ); |
|
275 | set_hk_lfr_reset_cause( POWER_ON ); | |
276 |
|
276 | |||
277 | while(1){ // launch the rate monotonic task |
|
277 | while(1){ // launch the rate monotonic task | |
278 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); |
|
278 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); | |
279 | if ( status != RTEMS_SUCCESSFUL ) { |
|
279 | if ( status != RTEMS_SUCCESSFUL ) { | |
280 | PRINTF1( "in HOUS *** ERR period: %d\n", status); |
|
280 | PRINTF1( "in HOUS *** ERR period: %d\n", status); | |
281 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); |
|
281 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); | |
282 | } |
|
282 | } | |
283 | else { |
|
283 | else { | |
284 | housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8); |
|
284 | housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8); | |
285 | housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK ); |
|
285 | housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK ); | |
286 | increment_seq_counter( &sequenceCounterHK ); |
|
286 | increment_seq_counter( &sequenceCounterHK ); | |
287 |
|
287 | |||
288 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
288 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
289 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
289 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
290 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
290 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
291 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
291 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
292 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
292 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
293 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
293 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
294 |
|
294 | |||
295 | spacewire_update_statistics(); |
|
295 | spacewire_update_statistics(); | |
296 |
|
296 | |||
|
297 | hk_lfr_le_me_he_update(); | |||
|
298 | ||||
297 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; |
|
299 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; | |
298 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; |
|
300 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; | |
299 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; |
|
301 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; | |
300 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; |
|
302 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; | |
301 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; |
|
303 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; | |
302 |
|
304 | |||
303 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; |
|
305 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; | |
304 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
306 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
305 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); |
|
307 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); | |
306 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); |
|
308 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); | |
307 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); |
|
309 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); | |
308 |
|
310 | |||
309 | // SEND PACKET |
|
311 | // SEND PACKET | |
310 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, |
|
312 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, | |
311 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
313 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
312 | if (status != RTEMS_SUCCESSFUL) { |
|
314 | if (status != RTEMS_SUCCESSFUL) { | |
313 | PRINTF1("in HOUS *** ERR send: %d\n", status) |
|
315 | PRINTF1("in HOUS *** ERR send: %d\n", status) | |
314 | } |
|
316 | } | |
315 | } |
|
317 | } | |
316 | } |
|
318 | } | |
317 |
|
319 | |||
318 | PRINTF("in HOUS *** deleting task\n") |
|
320 | PRINTF("in HOUS *** deleting task\n") | |
319 |
|
321 | |||
320 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
322 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
321 |
|
323 | |||
322 | return; |
|
324 | return; | |
323 | } |
|
325 | } | |
324 |
|
326 | |||
325 | rtems_task dumb_task( rtems_task_argument unused ) |
|
327 | rtems_task dumb_task( rtems_task_argument unused ) | |
326 | { |
|
328 | { | |
327 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. |
|
329 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. | |
328 | * |
|
330 | * | |
329 | * @param unused is the starting argument of the RTEMS task |
|
331 | * @param unused is the starting argument of the RTEMS task | |
330 | * |
|
332 | * | |
331 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. |
|
333 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. | |
332 | * |
|
334 | * | |
333 | */ |
|
335 | */ | |
334 |
|
336 | |||
335 | unsigned int i; |
|
337 | unsigned int i; | |
336 | unsigned int intEventOut; |
|
338 | unsigned int intEventOut; | |
337 | unsigned int coarse_time = 0; |
|
339 | unsigned int coarse_time = 0; | |
338 | unsigned int fine_time = 0; |
|
340 | unsigned int fine_time = 0; | |
339 | rtems_event_set event_out; |
|
341 | rtems_event_set event_out; | |
340 |
|
342 | |||
341 | char *DumbMessages[13] = {"in DUMB *** default", // RTEMS_EVENT_0 |
|
343 | char *DumbMessages[13] = {"in DUMB *** default", // RTEMS_EVENT_0 | |
342 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 |
|
344 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 | |
343 | "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2 |
|
345 | "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2 | |
344 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 |
|
346 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 | |
345 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 |
|
347 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 | |
346 | "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5 |
|
348 | "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5 | |
347 | "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6 |
|
349 | "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6 | |
348 | "ready for dump", // RTEMS_EVENT_7 |
|
350 | "ready for dump", // RTEMS_EVENT_7 | |
349 | "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8 |
|
351 | "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8 | |
350 | "tick", // RTEMS_EVENT_9 |
|
352 | "tick", // RTEMS_EVENT_9 | |
351 | "VHDL ERR *** waveform picker", // RTEMS_EVENT_10 |
|
353 | "VHDL ERR *** waveform picker", // RTEMS_EVENT_10 | |
352 | "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11 |
|
354 | "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11 | |
353 | "WATCHDOG timer" // RTEMS_EVENT_12 |
|
355 | "WATCHDOG timer" // RTEMS_EVENT_12 | |
354 | }; |
|
356 | }; | |
355 |
|
357 | |||
356 | BOOT_PRINTF("in DUMB *** \n") |
|
358 | BOOT_PRINTF("in DUMB *** \n") | |
357 |
|
359 | |||
358 | while(1){ |
|
360 | while(1){ | |
359 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 |
|
361 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | |
360 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 |
|
362 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 | |
361 | | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12, |
|
363 | | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12, | |
362 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
364 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT | |
363 | intEventOut = (unsigned int) event_out; |
|
365 | intEventOut = (unsigned int) event_out; | |
364 | for ( i=0; i<32; i++) |
|
366 | for ( i=0; i<32; i++) | |
365 | { |
|
367 | { | |
366 | if ( ((intEventOut >> i) & 0x0001) != 0) |
|
368 | if ( ((intEventOut >> i) & 0x0001) != 0) | |
367 | { |
|
369 | { | |
368 | coarse_time = time_management_regs->coarse_time; |
|
370 | coarse_time = time_management_regs->coarse_time; | |
369 | fine_time = time_management_regs->fine_time; |
|
371 | fine_time = time_management_regs->fine_time; | |
370 | if (i==12) |
|
372 | if (i==12) | |
371 | { |
|
373 | { | |
372 | PRINTF1("%s\n", DumbMessages[12]) |
|
374 | PRINTF1("%s\n", DumbMessages[12]) | |
373 | } |
|
375 | } | |
374 | } |
|
376 | } | |
375 | } |
|
377 | } | |
376 | } |
|
378 | } | |
377 | } |
|
379 | } | |
378 |
|
380 | |||
379 | //***************************** |
|
381 | //***************************** | |
380 | // init housekeeping parameters |
|
382 | // init housekeeping parameters | |
381 |
|
383 | |||
382 | void init_housekeeping_parameters( void ) |
|
384 | void init_housekeeping_parameters( void ) | |
383 | { |
|
385 | { | |
384 | /** This function initialize the housekeeping_packet global variable with default values. |
|
386 | /** This function initialize the housekeeping_packet global variable with default values. | |
385 | * |
|
387 | * | |
386 | */ |
|
388 | */ | |
387 |
|
389 | |||
388 | unsigned int i = 0; |
|
390 | unsigned int i = 0; | |
389 | unsigned char *parameters; |
|
391 | unsigned char *parameters; | |
390 | unsigned char sizeOfHK; |
|
392 | unsigned char sizeOfHK; | |
391 |
|
393 | |||
392 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); |
|
394 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); | |
393 |
|
395 | |||
394 | parameters = (unsigned char*) &housekeeping_packet; |
|
396 | parameters = (unsigned char*) &housekeeping_packet; | |
395 |
|
397 | |||
396 | for(i = 0; i< sizeOfHK; i++) |
|
398 | for(i = 0; i< sizeOfHK; i++) | |
397 | { |
|
399 | { | |
398 | parameters[i] = 0x00; |
|
400 | parameters[i] = 0x00; | |
399 | } |
|
401 | } | |
400 |
|
402 | |||
401 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
403 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
402 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
404 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
403 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
405 | housekeeping_packet.reserved = DEFAULT_RESERVED; | |
404 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
406 | housekeeping_packet.userApplication = CCSDS_USER_APP; | |
405 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
407 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); | |
406 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
408 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
407 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
409 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
408 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
410 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
409 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
411 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); | |
410 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
412 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
411 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
413 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
412 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
414 | housekeeping_packet.serviceType = TM_TYPE_HK; | |
413 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
415 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; | |
414 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
416 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
415 | housekeeping_packet.sid = SID_HK; |
|
417 | housekeeping_packet.sid = SID_HK; | |
416 |
|
418 | |||
417 | // init status word |
|
419 | // init status word | |
418 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; |
|
420 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; | |
419 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; |
|
421 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; | |
420 | // init software version |
|
422 | // init software version | |
421 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
423 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
422 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
424 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
423 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
425 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; | |
424 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
426 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; | |
425 | // init fpga version |
|
427 | // init fpga version | |
426 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
428 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
427 | housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
429 | housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1 | |
428 | housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
430 | housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2 | |
429 | housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
431 | housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3 | |
430 |
|
432 | |||
431 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; |
|
433 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; | |
432 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; |
|
434 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; | |
433 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; |
|
435 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; | |
434 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; |
|
436 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; | |
435 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; |
|
437 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; | |
436 | } |
|
438 | } | |
437 |
|
439 | |||
438 | void increment_seq_counter( unsigned short *packetSequenceControl ) |
|
440 | void increment_seq_counter( unsigned short *packetSequenceControl ) | |
439 | { |
|
441 | { | |
440 | /** This function increment the sequence counter passes in argument. |
|
442 | /** This function increment the sequence counter passes in argument. | |
441 | * |
|
443 | * | |
442 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. |
|
444 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. | |
443 | * |
|
445 | * | |
444 | */ |
|
446 | */ | |
445 |
|
447 | |||
446 | unsigned short segmentation_grouping_flag; |
|
448 | unsigned short segmentation_grouping_flag; | |
447 | unsigned short sequence_cnt; |
|
449 | unsigned short sequence_cnt; | |
448 |
|
450 | |||
449 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6 |
|
451 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6 | |
450 | sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111] |
|
452 | sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111] | |
451 |
|
453 | |||
452 | if ( sequence_cnt < SEQ_CNT_MAX) |
|
454 | if ( sequence_cnt < SEQ_CNT_MAX) | |
453 | { |
|
455 | { | |
454 | sequence_cnt = sequence_cnt + 1; |
|
456 | sequence_cnt = sequence_cnt + 1; | |
455 | } |
|
457 | } | |
456 | else |
|
458 | else | |
457 | { |
|
459 | { | |
458 | sequence_cnt = 0; |
|
460 | sequence_cnt = 0; | |
459 | } |
|
461 | } | |
460 |
|
462 | |||
461 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; |
|
463 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; | |
462 | } |
|
464 | } | |
463 |
|
465 | |||
464 | void getTime( unsigned char *time) |
|
466 | void getTime( unsigned char *time) | |
465 | { |
|
467 | { | |
466 | /** This function write the current local time in the time buffer passed in argument. |
|
468 | /** This function write the current local time in the time buffer passed in argument. | |
467 | * |
|
469 | * | |
468 | */ |
|
470 | */ | |
469 |
|
471 | |||
470 | time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
472 | time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
471 | time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
473 | time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
472 | time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
474 | time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
473 | time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
475 | time[3] = (unsigned char) (time_management_regs->coarse_time); | |
474 | time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
476 | time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
475 | time[5] = (unsigned char) (time_management_regs->fine_time); |
|
477 | time[5] = (unsigned char) (time_management_regs->fine_time); | |
476 | } |
|
478 | } | |
477 |
|
479 | |||
478 | unsigned long long int getTimeAsUnsignedLongLongInt( ) |
|
480 | unsigned long long int getTimeAsUnsignedLongLongInt( ) | |
479 | { |
|
481 | { | |
480 | /** This function write the current local time in the time buffer passed in argument. |
|
482 | /** This function write the current local time in the time buffer passed in argument. | |
481 | * |
|
483 | * | |
482 | */ |
|
484 | */ | |
483 | unsigned long long int time; |
|
485 | unsigned long long int time; | |
484 |
|
486 | |||
485 | time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 ) |
|
487 | time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 ) | |
486 | + time_management_regs->fine_time; |
|
488 | + time_management_regs->fine_time; | |
487 |
|
489 | |||
488 | return time; |
|
490 | return time; | |
489 | } |
|
491 | } | |
490 |
|
492 | |||
491 | void send_dumb_hk( void ) |
|
493 | void send_dumb_hk( void ) | |
492 | { |
|
494 | { | |
493 | Packet_TM_LFR_HK_t dummy_hk_packet; |
|
495 | Packet_TM_LFR_HK_t dummy_hk_packet; | |
494 | unsigned char *parameters; |
|
496 | unsigned char *parameters; | |
495 | unsigned int i; |
|
497 | unsigned int i; | |
496 | rtems_id queue_id; |
|
498 | rtems_id queue_id; | |
497 |
|
499 | |||
498 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
500 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
499 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
501 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
500 | dummy_hk_packet.reserved = DEFAULT_RESERVED; |
|
502 | dummy_hk_packet.reserved = DEFAULT_RESERVED; | |
501 | dummy_hk_packet.userApplication = CCSDS_USER_APP; |
|
503 | dummy_hk_packet.userApplication = CCSDS_USER_APP; | |
502 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
504 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); | |
503 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
505 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
504 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
506 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
505 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
507 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
506 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
508 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); | |
507 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
509 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
508 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
510 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
509 | dummy_hk_packet.serviceType = TM_TYPE_HK; |
|
511 | dummy_hk_packet.serviceType = TM_TYPE_HK; | |
510 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; |
|
512 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; | |
511 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
513 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
512 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
514 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
513 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
515 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
514 | dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
516 | dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
515 | dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
517 | dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
516 | dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
518 | dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
517 | dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
519 | dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
518 | dummy_hk_packet.sid = SID_HK; |
|
520 | dummy_hk_packet.sid = SID_HK; | |
519 |
|
521 | |||
520 | // init status word |
|
522 | // init status word | |
521 | dummy_hk_packet.lfr_status_word[0] = 0xff; |
|
523 | dummy_hk_packet.lfr_status_word[0] = 0xff; | |
522 | dummy_hk_packet.lfr_status_word[1] = 0xff; |
|
524 | dummy_hk_packet.lfr_status_word[1] = 0xff; | |
523 | // init software version |
|
525 | // init software version | |
524 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
526 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
525 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
527 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
526 | dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
528 | dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3; | |
527 | dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
529 | dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4; | |
528 | // init fpga version |
|
530 | // init fpga version | |
529 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0); |
|
531 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0); | |
530 | dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
532 | dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1 | |
531 | dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
533 | dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2 | |
532 | dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
534 | dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3 | |
533 |
|
535 | |||
534 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; |
|
536 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; | |
535 |
|
537 | |||
536 | for (i=0; i<100; i++) |
|
538 | for (i=0; i<100; i++) | |
537 | { |
|
539 | { | |
538 | parameters[i] = 0xff; |
|
540 | parameters[i] = 0xff; | |
539 | } |
|
541 | } | |
540 |
|
542 | |||
541 | get_message_queue_id_send( &queue_id ); |
|
543 | get_message_queue_id_send( &queue_id ); | |
542 |
|
544 | |||
543 | rtems_message_queue_send( queue_id, &dummy_hk_packet, |
|
545 | rtems_message_queue_send( queue_id, &dummy_hk_packet, | |
544 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
546 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
545 | } |
|
547 | } | |
546 |
|
548 | |||
547 | void get_temperatures( unsigned char *temperatures ) |
|
549 | void get_temperatures( unsigned char *temperatures ) | |
548 | { |
|
550 | { | |
549 | unsigned char* temp_scm_ptr; |
|
551 | unsigned char* temp_scm_ptr; | |
550 | unsigned char* temp_pcb_ptr; |
|
552 | unsigned char* temp_pcb_ptr; | |
551 | unsigned char* temp_fpga_ptr; |
|
553 | unsigned char* temp_fpga_ptr; | |
552 |
|
554 | |||
553 | // SEL1 SEL0 |
|
555 | // SEL1 SEL0 | |
554 | // 0 0 => PCB |
|
556 | // 0 0 => PCB | |
555 | // 0 1 => FPGA |
|
557 | // 0 1 => FPGA | |
556 | // 1 0 => SCM |
|
558 | // 1 0 => SCM | |
557 |
|
559 | |||
558 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; |
|
560 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; | |
559 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; |
|
561 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; | |
560 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; |
|
562 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; | |
561 |
|
563 | |||
562 | temperatures[0] = temp_scm_ptr[2]; |
|
564 | temperatures[0] = temp_scm_ptr[2]; | |
563 | temperatures[1] = temp_scm_ptr[3]; |
|
565 | temperatures[1] = temp_scm_ptr[3]; | |
564 | temperatures[2] = temp_pcb_ptr[2]; |
|
566 | temperatures[2] = temp_pcb_ptr[2]; | |
565 | temperatures[3] = temp_pcb_ptr[3]; |
|
567 | temperatures[3] = temp_pcb_ptr[3]; | |
566 | temperatures[4] = temp_fpga_ptr[2]; |
|
568 | temperatures[4] = temp_fpga_ptr[2]; | |
567 | temperatures[5] = temp_fpga_ptr[3]; |
|
569 | temperatures[5] = temp_fpga_ptr[3]; | |
568 | } |
|
570 | } | |
569 |
|
571 | |||
570 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) |
|
572 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) | |
571 | { |
|
573 | { | |
572 | unsigned char* v_ptr; |
|
574 | unsigned char* v_ptr; | |
573 | unsigned char* e1_ptr; |
|
575 | unsigned char* e1_ptr; | |
574 | unsigned char* e2_ptr; |
|
576 | unsigned char* e2_ptr; | |
575 |
|
577 | |||
576 | v_ptr = (unsigned char *) &waveform_picker_regs->v; |
|
578 | v_ptr = (unsigned char *) &waveform_picker_regs->v; | |
577 | e1_ptr = (unsigned char *) &waveform_picker_regs->e1; |
|
579 | e1_ptr = (unsigned char *) &waveform_picker_regs->e1; | |
578 | e2_ptr = (unsigned char *) &waveform_picker_regs->e2; |
|
580 | e2_ptr = (unsigned char *) &waveform_picker_regs->e2; | |
579 |
|
581 | |||
580 | spacecraft_potential[0] = v_ptr[2]; |
|
582 | spacecraft_potential[0] = v_ptr[2]; | |
581 | spacecraft_potential[1] = v_ptr[3]; |
|
583 | spacecraft_potential[1] = v_ptr[3]; | |
582 | spacecraft_potential[2] = e1_ptr[2]; |
|
584 | spacecraft_potential[2] = e1_ptr[2]; | |
583 | spacecraft_potential[3] = e1_ptr[3]; |
|
585 | spacecraft_potential[3] = e1_ptr[3]; | |
584 | spacecraft_potential[4] = e2_ptr[2]; |
|
586 | spacecraft_potential[4] = e2_ptr[2]; | |
585 | spacecraft_potential[5] = e2_ptr[3]; |
|
587 | spacecraft_potential[5] = e2_ptr[3]; | |
586 | } |
|
588 | } | |
587 |
|
589 | |||
588 | void get_cpu_load( unsigned char *resource_statistics ) |
|
590 | void get_cpu_load( unsigned char *resource_statistics ) | |
589 | { |
|
591 | { | |
590 | unsigned char cpu_load; |
|
592 | unsigned char cpu_load; | |
591 |
|
593 | |||
592 | cpu_load = lfr_rtems_cpu_usage_report(); |
|
594 | cpu_load = lfr_rtems_cpu_usage_report(); | |
593 |
|
595 | |||
594 | // HK_LFR_CPU_LOAD |
|
596 | // HK_LFR_CPU_LOAD | |
595 | resource_statistics[0] = cpu_load; |
|
597 | resource_statistics[0] = cpu_load; | |
596 |
|
598 | |||
597 | // HK_LFR_CPU_LOAD_MAX |
|
599 | // HK_LFR_CPU_LOAD_MAX | |
598 | if (cpu_load > resource_statistics[1]) |
|
600 | if (cpu_load > resource_statistics[1]) | |
599 | { |
|
601 | { | |
600 | resource_statistics[1] = cpu_load; |
|
602 | resource_statistics[1] = cpu_load; | |
601 | } |
|
603 | } | |
602 |
|
604 | |||
603 | // CPU_LOAD_AVE |
|
605 | // CPU_LOAD_AVE | |
604 | resource_statistics[2] = 0; |
|
606 | resource_statistics[2] = 0; | |
605 |
|
607 | |||
606 | #ifndef PRINT_TASK_STATISTICS |
|
608 | #ifndef PRINT_TASK_STATISTICS | |
607 | rtems_cpu_usage_reset(); |
|
609 | rtems_cpu_usage_reset(); | |
608 | #endif |
|
610 | #endif | |
609 |
|
611 | |||
610 | } |
|
612 | } | |
611 |
|
613 | |||
612 | void set_hk_lfr_sc_potential_flag( bool state ) |
|
614 | void set_hk_lfr_sc_potential_flag( bool state ) | |
613 | { |
|
615 | { | |
614 | if (state == true) |
|
616 | if (state == true) | |
615 | { |
|
617 | { | |
616 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000] |
|
618 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000] | |
617 | } |
|
619 | } | |
618 | else |
|
620 | else | |
619 | { |
|
621 | { | |
620 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111] |
|
622 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111] | |
621 | } |
|
623 | } | |
622 | } |
|
624 | } | |
623 |
|
625 | |||
624 | void set_hk_lfr_mag_fields_flag( bool state ) |
|
626 | void set_hk_lfr_mag_fields_flag( bool state ) | |
625 | { |
|
627 | { | |
626 | if (state == true) |
|
628 | if (state == true) | |
627 | { |
|
629 | { | |
628 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000] |
|
630 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000] | |
629 | } |
|
631 | } | |
630 | else |
|
632 | else | |
631 | { |
|
633 | { | |
632 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xd7; // [1101 1111] |
|
634 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xd7; // [1101 1111] | |
633 | } |
|
635 | } | |
634 | } |
|
636 | } | |
635 |
|
637 | |||
636 | void set_hk_lfr_calib_enable( bool state ) |
|
638 | void set_hk_lfr_calib_enable( bool state ) | |
637 | { |
|
639 | { | |
638 | if (state == true) |
|
640 | if (state == true) | |
639 | { |
|
641 | { | |
640 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000] |
|
642 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000] | |
641 | } |
|
643 | } | |
642 | else |
|
644 | else | |
643 | { |
|
645 | { | |
644 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111] |
|
646 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111] | |
645 | } |
|
647 | } | |
646 | } |
|
648 | } | |
647 |
|
649 | |||
648 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) |
|
650 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) | |
649 | { |
|
651 | { | |
650 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] |
|
652 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | |
651 | | (lfr_reset_cause & 0x07 ); // [0000 0111] |
|
653 | | (lfr_reset_cause & 0x07 ); // [0000 0111] | |
652 | } |
|
654 | } | |
|
655 | ||||
|
656 | void hk_lfr_le_me_he_update() | |||
|
657 | { | |||
|
658 | unsigned int hk_lfr_le_cnt; | |||
|
659 | unsigned int hk_lfr_me_cnt; | |||
|
660 | unsigned int hk_lfr_he_cnt; | |||
|
661 | ||||
|
662 | hk_lfr_le_cnt = 0; | |||
|
663 | hk_lfr_me_cnt = 0; | |||
|
664 | hk_lfr_he_cnt = 0; | |||
|
665 | ||||
|
666 | //update the low severity error counter | |||
|
667 | hk_lfr_le_cnt = | |||
|
668 | housekeeping_packet.hk_lfr_dpu_spw_parity | |||
|
669 | + housekeeping_packet.hk_lfr_dpu_spw_disconnect | |||
|
670 | + housekeeping_packet.hk_lfr_dpu_spw_escape | |||
|
671 | + housekeeping_packet.hk_lfr_dpu_spw_credit | |||
|
672 | + housekeeping_packet.hk_lfr_dpu_spw_write_sync | |||
|
673 | + housekeeping_packet.hk_lfr_dpu_spw_rx_ahb | |||
|
674 | + housekeeping_packet.hk_lfr_dpu_spw_tx_ahb | |||
|
675 | + housekeeping_packet.hk_lfr_time_timecode_ctr; | |||
|
676 | ||||
|
677 | //update the medium severity error counter | |||
|
678 | hk_lfr_me_cnt = | |||
|
679 | housekeeping_packet.hk_lfr_dpu_spw_early_eop | |||
|
680 | + housekeeping_packet.hk_lfr_dpu_spw_invalid_addr | |||
|
681 | + housekeeping_packet.hk_lfr_dpu_spw_eep | |||
|
682 | + housekeeping_packet.hk_lfr_dpu_spw_rx_too_big; | |||
|
683 | ||||
|
684 | //update the high severity error counter | |||
|
685 | hk_lfr_he_cnt = 0; | |||
|
686 | ||||
|
687 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |||
|
688 | // LE | |||
|
689 | housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((hk_lfr_le_cnt & 0xff00) >> 8); | |||
|
690 | housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (hk_lfr_le_cnt & 0x00ff); | |||
|
691 | // ME | |||
|
692 | housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((hk_lfr_me_cnt & 0xff00) >> 8); | |||
|
693 | housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (hk_lfr_me_cnt & 0x00ff); | |||
|
694 | // HE | |||
|
695 | housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & 0xff00) >> 8); | |||
|
696 | housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & 0x00ff); | |||
|
697 | ||||
|
698 | } |
@@ -1,1308 +1,1295 | |||||
1 | /** Functions related to the SpaceWire interface. |
|
1 | /** Functions related to the SpaceWire interface. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle SpaceWire transmissions: |
|
6 | * A group of functions to handle SpaceWire transmissions: | |
7 | * - configuration of the SpaceWire link |
|
7 | * - configuration of the SpaceWire link | |
8 | * - SpaceWire related interruption requests processing |
|
8 | * - SpaceWire related interruption requests processing | |
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task |
|
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task | |
10 | * - reception of TeleCommands by a dedicated RTEMS task |
|
10 | * - reception of TeleCommands by a dedicated RTEMS task | |
11 | * |
|
11 | * | |
12 | */ |
|
12 | */ | |
13 |
|
13 | |||
14 | #include "fsw_spacewire.h" |
|
14 | #include "fsw_spacewire.h" | |
15 |
|
15 | |||
16 | rtems_name semq_name; |
|
16 | rtems_name semq_name; | |
17 | rtems_id semq_id; |
|
17 | rtems_id semq_id; | |
18 |
|
18 | |||
19 | //***************** |
|
19 | //***************** | |
20 | // waveform headers |
|
20 | // waveform headers | |
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF; |
|
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF; | |
22 | Header_TM_LFR_SCIENCE_SWF_t headerSWF; |
|
22 | Header_TM_LFR_SCIENCE_SWF_t headerSWF; | |
23 | Header_TM_LFR_SCIENCE_ASM_t headerASM; |
|
23 | Header_TM_LFR_SCIENCE_ASM_t headerASM; | |
24 |
|
24 | |||
25 | //*********** |
|
25 | //*********** | |
26 | // RTEMS TASK |
|
26 | // RTEMS TASK | |
27 | rtems_task spiq_task(rtems_task_argument unused) |
|
27 | rtems_task spiq_task(rtems_task_argument unused) | |
28 | { |
|
28 | { | |
29 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. |
|
29 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. | |
30 | * |
|
30 | * | |
31 | * @param unused is the starting argument of the RTEMS task |
|
31 | * @param unused is the starting argument of the RTEMS task | |
32 | * |
|
32 | * | |
33 | */ |
|
33 | */ | |
34 |
|
34 | |||
35 | rtems_event_set event_out; |
|
35 | rtems_event_set event_out; | |
36 | rtems_status_code status; |
|
36 | rtems_status_code status; | |
37 | int linkStatus; |
|
37 | int linkStatus; | |
38 |
|
38 | |||
39 | BOOT_PRINTF("in SPIQ *** \n") |
|
39 | BOOT_PRINTF("in SPIQ *** \n") | |
40 |
|
40 | |||
41 | while(true){ |
|
41 | while(true){ | |
42 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
42 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT | |
43 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") |
|
43 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") | |
44 |
|
44 | |||
45 | // [0] SUSPEND RECV AND SEND TASKS |
|
45 | // [0] SUSPEND RECV AND SEND TASKS | |
46 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); |
|
46 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); | |
47 | if ( status != RTEMS_SUCCESSFUL ) { |
|
47 | if ( status != RTEMS_SUCCESSFUL ) { | |
48 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") |
|
48 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") | |
49 | } |
|
49 | } | |
50 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); |
|
50 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); | |
51 | if ( status != RTEMS_SUCCESSFUL ) { |
|
51 | if ( status != RTEMS_SUCCESSFUL ) { | |
52 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") |
|
52 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | // [1] CHECK THE LINK |
|
55 | // [1] CHECK THE LINK | |
56 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) |
|
56 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) | |
57 | if ( linkStatus != 5) { |
|
57 | if ( linkStatus != 5) { | |
58 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) |
|
58 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) | |
59 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
59 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT |
|
62 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT | |
63 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) |
|
63 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) | |
64 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link |
|
64 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link | |
65 | { |
|
65 | { | |
66 | spacewire_compute_stats_offsets(); |
|
66 | spacewire_compute_stats_offsets(); | |
67 | status = spacewire_reset_link( ); |
|
67 | status = spacewire_reset_link( ); | |
68 | } |
|
68 | } | |
69 | else // [2.b] in run state, start the link |
|
69 | else // [2.b] in run state, start the link | |
70 | { |
|
70 | { | |
71 | status = spacewire_stop_and_start_link( fdSPW ); // start the link |
|
71 | status = spacewire_stop_and_start_link( fdSPW ); // start the link | |
72 | if ( status != RTEMS_SUCCESSFUL) |
|
72 | if ( status != RTEMS_SUCCESSFUL) | |
73 | { |
|
73 | { | |
74 | PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status) |
|
74 | PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status) | |
75 | } |
|
75 | } | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS |
|
78 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS | |
79 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully |
|
79 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully | |
80 | { |
|
80 | { | |
81 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
81 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
82 | if ( status != RTEMS_SUCCESSFUL ) { |
|
82 | if ( status != RTEMS_SUCCESSFUL ) { | |
83 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") |
|
83 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") | |
84 | } |
|
84 | } | |
85 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
85 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
86 | if ( status != RTEMS_SUCCESSFUL ) { |
|
86 | if ( status != RTEMS_SUCCESSFUL ) { | |
87 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") |
|
87 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") | |
88 | } |
|
88 | } | |
89 | } |
|
89 | } | |
90 | else // [3.b] the link is not in run state, go in STANDBY mode |
|
90 | else // [3.b] the link is not in run state, go in STANDBY mode | |
91 | { |
|
91 | { | |
92 | status = enter_mode_standby(); |
|
92 | status = enter_mode_standby(); | |
93 | if ( status != RTEMS_SUCCESSFUL ) { |
|
93 | if ( status != RTEMS_SUCCESSFUL ) { | |
94 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) |
|
94 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) | |
95 | } |
|
95 | } | |
96 | // wake the WTDG task up to wait for the link recovery |
|
96 | // wake the WTDG task up to wait for the link recovery | |
97 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); |
|
97 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); | |
98 | status = rtems_task_suspend( RTEMS_SELF ); |
|
98 | status = rtems_task_suspend( RTEMS_SELF ); | |
99 | } |
|
99 | } | |
100 | } |
|
100 | } | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | rtems_task recv_task( rtems_task_argument unused ) |
|
103 | rtems_task recv_task( rtems_task_argument unused ) | |
104 | { |
|
104 | { | |
105 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. |
|
105 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. | |
106 | * |
|
106 | * | |
107 | * @param unused is the starting argument of the RTEMS task |
|
107 | * @param unused is the starting argument of the RTEMS task | |
108 | * |
|
108 | * | |
109 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: |
|
109 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: | |
110 | * 1. It reads the incoming data. |
|
110 | * 1. It reads the incoming data. | |
111 | * 2. Launches the acceptance procedure. |
|
111 | * 2. Launches the acceptance procedure. | |
112 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. |
|
112 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. | |
113 | * |
|
113 | * | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | int len; |
|
116 | int len; | |
117 | ccsdsTelecommandPacket_t currentTC; |
|
117 | ccsdsTelecommandPacket_t currentTC; | |
118 | unsigned char computed_CRC[ 2 ]; |
|
118 | unsigned char computed_CRC[ 2 ]; | |
119 | unsigned char currentTC_LEN_RCV[ 2 ]; |
|
119 | unsigned char currentTC_LEN_RCV[ 2 ]; | |
120 | unsigned char destinationID; |
|
120 | unsigned char destinationID; | |
121 | unsigned int estimatedPacketLength; |
|
121 | unsigned int estimatedPacketLength; | |
122 | unsigned int parserCode; |
|
122 | unsigned int parserCode; | |
123 | rtems_status_code status; |
|
123 | rtems_status_code status; | |
124 | rtems_id queue_recv_id; |
|
124 | rtems_id queue_recv_id; | |
125 | rtems_id queue_send_id; |
|
125 | rtems_id queue_send_id; | |
126 |
|
126 | |||
127 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes |
|
127 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes | |
128 |
|
128 | |||
129 | status = get_message_queue_id_recv( &queue_recv_id ); |
|
129 | status = get_message_queue_id_recv( &queue_recv_id ); | |
130 | if (status != RTEMS_SUCCESSFUL) |
|
130 | if (status != RTEMS_SUCCESSFUL) | |
131 | { |
|
131 | { | |
132 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) |
|
132 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | status = get_message_queue_id_send( &queue_send_id ); |
|
135 | status = get_message_queue_id_send( &queue_send_id ); | |
136 | if (status != RTEMS_SUCCESSFUL) |
|
136 | if (status != RTEMS_SUCCESSFUL) | |
137 | { |
|
137 | { | |
138 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) |
|
138 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 | BOOT_PRINTF("in RECV *** \n") |
|
141 | BOOT_PRINTF("in RECV *** \n") | |
142 |
|
142 | |||
143 | while(1) |
|
143 | while(1) | |
144 | { |
|
144 | { | |
145 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking |
|
145 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking | |
146 | if (len == -1){ // error during the read call |
|
146 | if (len == -1){ // error during the read call | |
147 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) |
|
147 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) | |
148 | } |
|
148 | } | |
149 | else { |
|
149 | else { | |
150 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { |
|
150 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { | |
151 | PRINTF("in RECV *** packet lenght too short\n") |
|
151 | PRINTF("in RECV *** packet lenght too short\n") | |
152 | } |
|
152 | } | |
153 | else { |
|
153 | else { | |
154 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes |
|
154 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes | |
155 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); |
|
155 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); | |
156 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); |
|
156 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); | |
157 | // CHECK THE TC |
|
157 | // CHECK THE TC | |
158 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; |
|
158 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; | |
159 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) |
|
159 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) | |
160 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) |
|
160 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) | |
161 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) |
|
161 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) | |
162 | || (parserCode == WRONG_SRC_ID) ) |
|
162 | || (parserCode == WRONG_SRC_ID) ) | |
163 | { // send TM_LFR_TC_EXE_CORRUPTED |
|
163 | { // send TM_LFR_TC_EXE_CORRUPTED | |
164 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) |
|
164 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) | |
165 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
165 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
166 | && |
|
166 | && | |
167 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
167 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
168 | ) |
|
168 | ) | |
169 | { |
|
169 | { | |
170 | if ( parserCode == WRONG_SRC_ID ) |
|
170 | if ( parserCode == WRONG_SRC_ID ) | |
171 | { |
|
171 | { | |
172 | destinationID = SID_TC_GROUND; |
|
172 | destinationID = SID_TC_GROUND; | |
173 | } |
|
173 | } | |
174 | else |
|
174 | else | |
175 | { |
|
175 | { | |
176 | destinationID = currentTC.sourceID; |
|
176 | destinationID = currentTC.sourceID; | |
177 | } |
|
177 | } | |
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, |
|
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, | |
179 | computed_CRC, currentTC_LEN_RCV, |
|
179 | computed_CRC, currentTC_LEN_RCV, | |
180 | destinationID ); |
|
180 | destinationID ); | |
181 | } |
|
181 | } | |
182 | } |
|
182 | } | |
183 | else |
|
183 | else | |
184 | { // send valid TC to the action launcher |
|
184 | { // send valid TC to the action launcher | |
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, |
|
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, | |
186 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); |
|
186 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); | |
187 | } |
|
187 | } | |
188 | } |
|
188 | } | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 | update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max ); |
|
191 | update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max ); | |
192 |
|
192 | |||
193 | } |
|
193 | } | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | rtems_task send_task( rtems_task_argument argument) |
|
196 | rtems_task send_task( rtems_task_argument argument) | |
197 | { |
|
197 | { | |
198 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. |
|
198 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. | |
199 | * |
|
199 | * | |
200 | * @param unused is the starting argument of the RTEMS task |
|
200 | * @param unused is the starting argument of the RTEMS task | |
201 | * |
|
201 | * | |
202 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: |
|
202 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: | |
203 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. |
|
203 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. | |
204 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After |
|
204 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After | |
205 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the |
|
205 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the | |
206 | * data it contains. |
|
206 | * data it contains. | |
207 | * |
|
207 | * | |
208 | */ |
|
208 | */ | |
209 |
|
209 | |||
210 | rtems_status_code status; // RTEMS status code |
|
210 | rtems_status_code status; // RTEMS status code | |
211 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
211 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
212 | ring_node *incomingRingNodePtr; |
|
212 | ring_node *incomingRingNodePtr; | |
213 | int ring_node_address; |
|
213 | int ring_node_address; | |
214 | char *charPtr; |
|
214 | char *charPtr; | |
215 | spw_ioctl_pkt_send *spw_ioctl_send; |
|
215 | spw_ioctl_pkt_send *spw_ioctl_send; | |
216 | size_t size; // size of the incoming TC packet |
|
216 | size_t size; // size of the incoming TC packet | |
217 | rtems_id queue_send_id; |
|
217 | rtems_id queue_send_id; | |
218 | unsigned int sid; |
|
218 | unsigned int sid; | |
219 | unsigned char sidAsUnsignedChar; |
|
219 | unsigned char sidAsUnsignedChar; | |
220 | unsigned char type; |
|
220 | unsigned char type; | |
221 |
|
221 | |||
222 | incomingRingNodePtr = NULL; |
|
222 | incomingRingNodePtr = NULL; | |
223 | ring_node_address = 0; |
|
223 | ring_node_address = 0; | |
224 | charPtr = (char *) &ring_node_address; |
|
224 | charPtr = (char *) &ring_node_address; | |
225 | sid = 0; |
|
225 | sid = 0; | |
226 | sidAsUnsignedChar = 0; |
|
226 | sidAsUnsignedChar = 0; | |
227 |
|
227 | |||
228 | init_header_cwf( &headerCWF ); |
|
228 | init_header_cwf( &headerCWF ); | |
229 | init_header_swf( &headerSWF ); |
|
229 | init_header_swf( &headerSWF ); | |
230 | init_header_asm( &headerASM ); |
|
230 | init_header_asm( &headerASM ); | |
231 |
|
231 | |||
232 | status = get_message_queue_id_send( &queue_send_id ); |
|
232 | status = get_message_queue_id_send( &queue_send_id ); | |
233 | if (status != RTEMS_SUCCESSFUL) |
|
233 | if (status != RTEMS_SUCCESSFUL) | |
234 | { |
|
234 | { | |
235 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
235 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | BOOT_PRINTF("in SEND *** \n") |
|
238 | BOOT_PRINTF("in SEND *** \n") | |
239 |
|
239 | |||
240 | while(1) |
|
240 | while(1) | |
241 | { |
|
241 | { | |
242 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, |
|
242 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, | |
243 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
243 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); | |
244 |
|
244 | |||
245 | if (status!=RTEMS_SUCCESSFUL) |
|
245 | if (status!=RTEMS_SUCCESSFUL) | |
246 | { |
|
246 | { | |
247 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
247 | PRINTF1("in SEND *** (1) ERR = %d\n", status) | |
248 | } |
|
248 | } | |
249 | else |
|
249 | else | |
250 | { |
|
250 | { | |
251 | if ( size == sizeof(ring_node*) ) |
|
251 | if ( size == sizeof(ring_node*) ) | |
252 | { |
|
252 | { | |
253 | charPtr[0] = incomingData[0]; |
|
253 | charPtr[0] = incomingData[0]; | |
254 | charPtr[1] = incomingData[1]; |
|
254 | charPtr[1] = incomingData[1]; | |
255 | charPtr[2] = incomingData[2]; |
|
255 | charPtr[2] = incomingData[2]; | |
256 | charPtr[3] = incomingData[3]; |
|
256 | charPtr[3] = incomingData[3]; | |
257 | incomingRingNodePtr = (ring_node*) ring_node_address; |
|
257 | incomingRingNodePtr = (ring_node*) ring_node_address; | |
258 | sid = incomingRingNodePtr->sid; |
|
258 | sid = incomingRingNodePtr->sid; | |
259 | if ( (sid==SID_NORM_CWF_LONG_F3) |
|
259 | if ( (sid==SID_NORM_CWF_LONG_F3) | |
260 | || (sid==SID_BURST_CWF_F2 ) |
|
260 | || (sid==SID_BURST_CWF_F2 ) | |
261 | || (sid==SID_SBM1_CWF_F1 ) |
|
261 | || (sid==SID_SBM1_CWF_F1 ) | |
262 | || (sid==SID_SBM2_CWF_F2 )) |
|
262 | || (sid==SID_SBM2_CWF_F2 )) | |
263 | { |
|
263 | { | |
264 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); |
|
264 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); | |
265 | } |
|
265 | } | |
266 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) |
|
266 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) | |
267 | { |
|
267 | { | |
268 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); |
|
268 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); | |
269 | } |
|
269 | } | |
270 | else if ( (sid==SID_NORM_CWF_F3) ) |
|
270 | else if ( (sid==SID_NORM_CWF_F3) ) | |
271 | { |
|
271 | { | |
272 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); |
|
272 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); | |
273 | } |
|
273 | } | |
274 | else if (sid==SID_NORM_ASM_F0) |
|
274 | else if (sid==SID_NORM_ASM_F0) | |
275 | { |
|
275 | { | |
276 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); |
|
276 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); | |
277 | } |
|
277 | } | |
278 | else if (sid==SID_NORM_ASM_F1) |
|
278 | else if (sid==SID_NORM_ASM_F1) | |
279 | { |
|
279 | { | |
280 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); |
|
280 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); | |
281 | } |
|
281 | } | |
282 | else if (sid==SID_NORM_ASM_F2) |
|
282 | else if (sid==SID_NORM_ASM_F2) | |
283 | { |
|
283 | { | |
284 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); |
|
284 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); | |
285 | } |
|
285 | } | |
286 | else if ( sid==TM_CODE_K_DUMP ) |
|
286 | else if ( sid==TM_CODE_K_DUMP ) | |
287 | { |
|
287 | { | |
288 | spw_send_k_dump( incomingRingNodePtr ); |
|
288 | spw_send_k_dump( incomingRingNodePtr ); | |
289 | } |
|
289 | } | |
290 | else |
|
290 | else | |
291 | { |
|
291 | { | |
292 | PRINTF1("unexpected sid = %d\n", sid); |
|
292 | PRINTF1("unexpected sid = %d\n", sid); | |
293 | } |
|
293 | } | |
294 | } |
|
294 | } | |
295 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet |
|
295 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet | |
296 | { |
|
296 | { | |
297 | sidAsUnsignedChar = (unsigned char) incomingData[ PACKET_POS_PA_LFR_SID_PKT ]; |
|
297 | sidAsUnsignedChar = (unsigned char) incomingData[ PACKET_POS_PA_LFR_SID_PKT ]; | |
298 | sid = sidAsUnsignedChar; |
|
298 | sid = sidAsUnsignedChar; | |
299 | type = (unsigned char) incomingData[ PACKET_POS_SERVICE_TYPE ]; |
|
299 | type = (unsigned char) incomingData[ PACKET_POS_SERVICE_TYPE ]; | |
300 | if (type == TM_TYPE_LFR_SCIENCE) // this is a BP packet, all other types are handled differently |
|
300 | if (type == TM_TYPE_LFR_SCIENCE) // this is a BP packet, all other types are handled differently | |
301 | // SET THE SEQUENCE_CNT PARAMETER IN CASE OF BP0 OR BP1 PACKETS |
|
301 | // SET THE SEQUENCE_CNT PARAMETER IN CASE OF BP0 OR BP1 PACKETS | |
302 | { |
|
302 | { | |
303 | increment_seq_counter_source_id( (unsigned char*) &incomingData[ PACKET_POS_SEQUENCE_CNT ], sid ); |
|
303 | increment_seq_counter_source_id( (unsigned char*) &incomingData[ PACKET_POS_SEQUENCE_CNT ], sid ); | |
304 | } |
|
304 | } | |
305 |
|
305 | |||
306 | status = write( fdSPW, incomingData, size ); |
|
306 | status = write( fdSPW, incomingData, size ); | |
307 | if (status == -1){ |
|
307 | if (status == -1){ | |
308 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
308 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
309 | } |
|
309 | } | |
310 | } |
|
310 | } | |
311 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
311 | else // the incoming message is a spw_ioctl_pkt_send structure | |
312 | { |
|
312 | { | |
313 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
313 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; | |
314 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
314 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); | |
315 | if (status == -1){ |
|
315 | if (status == -1){ | |
316 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) |
|
316 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) | |
317 | } |
|
317 | } | |
318 | } |
|
318 | } | |
319 | } |
|
319 | } | |
320 |
|
320 | |||
321 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); |
|
321 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); | |
322 |
|
322 | |||
323 | } |
|
323 | } | |
324 | } |
|
324 | } | |
325 |
|
325 | |||
326 | rtems_task wtdg_task( rtems_task_argument argument ) |
|
326 | rtems_task wtdg_task( rtems_task_argument argument ) | |
327 | { |
|
327 | { | |
328 | rtems_event_set event_out; |
|
328 | rtems_event_set event_out; | |
329 | rtems_status_code status; |
|
329 | rtems_status_code status; | |
330 | int linkStatus; |
|
330 | int linkStatus; | |
331 |
|
331 | |||
332 | BOOT_PRINTF("in WTDG ***\n") |
|
332 | BOOT_PRINTF("in WTDG ***\n") | |
333 |
|
333 | |||
334 | while(1) |
|
334 | while(1) | |
335 | { |
|
335 | { | |
336 | // wait for an RTEMS_EVENT |
|
336 | // wait for an RTEMS_EVENT | |
337 | rtems_event_receive( RTEMS_EVENT_0, |
|
337 | rtems_event_receive( RTEMS_EVENT_0, | |
338 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
338 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
339 | PRINTF("in WTDG *** wait for the link\n") |
|
339 | PRINTF("in WTDG *** wait for the link\n") | |
340 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
340 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
341 | while( linkStatus != 5) // wait for the link |
|
341 | while( linkStatus != 5) // wait for the link | |
342 | { |
|
342 | { | |
343 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms |
|
343 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms | |
344 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
344 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
345 | } |
|
345 | } | |
346 |
|
346 | |||
347 | status = spacewire_stop_and_start_link( fdSPW ); |
|
347 | status = spacewire_stop_and_start_link( fdSPW ); | |
348 |
|
348 | |||
349 | if (status != RTEMS_SUCCESSFUL) |
|
349 | if (status != RTEMS_SUCCESSFUL) | |
350 | { |
|
350 | { | |
351 | PRINTF1("in WTDG *** ERR link not started %d\n", status) |
|
351 | PRINTF1("in WTDG *** ERR link not started %d\n", status) | |
352 | } |
|
352 | } | |
353 | else |
|
353 | else | |
354 | { |
|
354 | { | |
355 | PRINTF("in WTDG *** OK link started\n") |
|
355 | PRINTF("in WTDG *** OK link started\n") | |
356 | } |
|
356 | } | |
357 |
|
357 | |||
358 | // restart the SPIQ task |
|
358 | // restart the SPIQ task | |
359 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); |
|
359 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); | |
360 | if ( status != RTEMS_SUCCESSFUL ) { |
|
360 | if ( status != RTEMS_SUCCESSFUL ) { | |
361 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") |
|
361 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") | |
362 | } |
|
362 | } | |
363 |
|
363 | |||
364 | // restart RECV and SEND |
|
364 | // restart RECV and SEND | |
365 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
365 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
366 | if ( status != RTEMS_SUCCESSFUL ) { |
|
366 | if ( status != RTEMS_SUCCESSFUL ) { | |
367 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") |
|
367 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") | |
368 | } |
|
368 | } | |
369 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
369 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
370 | if ( status != RTEMS_SUCCESSFUL ) { |
|
370 | if ( status != RTEMS_SUCCESSFUL ) { | |
371 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") |
|
371 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") | |
372 | } |
|
372 | } | |
373 | } |
|
373 | } | |
374 | } |
|
374 | } | |
375 |
|
375 | |||
376 | //**************** |
|
376 | //**************** | |
377 | // OTHER FUNCTIONS |
|
377 | // OTHER FUNCTIONS | |
378 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] |
|
378 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] | |
379 | { |
|
379 | { | |
380 | /** This function opens the SpaceWire link. |
|
380 | /** This function opens the SpaceWire link. | |
381 | * |
|
381 | * | |
382 | * @return a valid file descriptor in case of success, -1 in case of a failure |
|
382 | * @return a valid file descriptor in case of success, -1 in case of a failure | |
383 | * |
|
383 | * | |
384 | */ |
|
384 | */ | |
385 | rtems_status_code status; |
|
385 | rtems_status_code status; | |
386 |
|
386 | |||
387 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware |
|
387 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware | |
388 | if ( fdSPW < 0 ) { |
|
388 | if ( fdSPW < 0 ) { | |
389 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) |
|
389 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) | |
390 | } |
|
390 | } | |
391 | else |
|
391 | else | |
392 | { |
|
392 | { | |
393 | status = RTEMS_SUCCESSFUL; |
|
393 | status = RTEMS_SUCCESSFUL; | |
394 | } |
|
394 | } | |
395 |
|
395 | |||
396 | return status; |
|
396 | return status; | |
397 | } |
|
397 | } | |
398 |
|
398 | |||
399 | int spacewire_start_link( int fd ) |
|
399 | int spacewire_start_link( int fd ) | |
400 | { |
|
400 | { | |
401 | rtems_status_code status; |
|
401 | rtems_status_code status; | |
402 |
|
402 | |||
403 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
403 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
404 | // -1 default hardcoded driver timeout |
|
404 | // -1 default hardcoded driver timeout | |
405 |
|
405 | |||
406 | return status; |
|
406 | return status; | |
407 | } |
|
407 | } | |
408 |
|
408 | |||
409 | int spacewire_stop_and_start_link( int fd ) |
|
409 | int spacewire_stop_and_start_link( int fd ) | |
410 | { |
|
410 | { | |
411 | rtems_status_code status; |
|
411 | rtems_status_code status; | |
412 |
|
412 | |||
413 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 |
|
413 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 | |
414 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
414 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
415 | // -1 default hardcoded driver timeout |
|
415 | // -1 default hardcoded driver timeout | |
416 |
|
416 | |||
417 | return status; |
|
417 | return status; | |
418 | } |
|
418 | } | |
419 |
|
419 | |||
420 | int spacewire_configure_link( int fd ) |
|
420 | int spacewire_configure_link( int fd ) | |
421 | { |
|
421 | { | |
422 | /** This function configures the SpaceWire link. |
|
422 | /** This function configures the SpaceWire link. | |
423 | * |
|
423 | * | |
424 | * @return GR-RTEMS-DRIVER directive status codes: |
|
424 | * @return GR-RTEMS-DRIVER directive status codes: | |
425 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. |
|
425 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. | |
426 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. |
|
426 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. | |
427 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. |
|
427 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. | |
428 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. |
|
428 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. | |
429 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. |
|
429 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. | |
430 | * - 5 EIO - Error when writing to grswp hardware registers. |
|
430 | * - 5 EIO - Error when writing to grswp hardware registers. | |
431 | * - 2 ENOENT - No such file or directory |
|
431 | * - 2 ENOENT - No such file or directory | |
432 | */ |
|
432 | */ | |
433 |
|
433 | |||
434 | rtems_status_code status; |
|
434 | rtems_status_code status; | |
435 |
|
435 | |||
436 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force |
|
436 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force | |
437 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration |
|
437 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration | |
438 |
|
438 | |||
439 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
439 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception | |
440 | if (status!=RTEMS_SUCCESSFUL) { |
|
440 | if (status!=RTEMS_SUCCESSFUL) { | |
441 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
441 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |
442 | } |
|
442 | } | |
443 | // |
|
443 | // | |
444 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a |
|
444 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a | |
445 | if (status!=RTEMS_SUCCESSFUL) { |
|
445 | if (status!=RTEMS_SUCCESSFUL) { | |
446 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
446 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |
447 | } |
|
447 | } | |
448 | // |
|
448 | // | |
449 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
449 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts | |
450 | if (status!=RTEMS_SUCCESSFUL) { |
|
450 | if (status!=RTEMS_SUCCESSFUL) { | |
451 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
451 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |
452 | } |
|
452 | } | |
453 | // |
|
453 | // | |
454 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
454 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit | |
455 | if (status!=RTEMS_SUCCESSFUL) { |
|
455 | if (status!=RTEMS_SUCCESSFUL) { | |
456 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
456 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |
457 | } |
|
457 | } | |
458 | // |
|
458 | // | |
459 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks |
|
459 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks | |
460 | if (status!=RTEMS_SUCCESSFUL) { |
|
460 | if (status!=RTEMS_SUCCESSFUL) { | |
461 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") |
|
461 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") | |
462 | } |
|
462 | } | |
463 | // |
|
463 | // | |
464 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available |
|
464 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available | |
465 | if (status!=RTEMS_SUCCESSFUL) { |
|
465 | if (status!=RTEMS_SUCCESSFUL) { | |
466 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
466 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") | |
467 | } |
|
467 | } | |
468 | // |
|
468 | // | |
469 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
469 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] | |
470 | if (status!=RTEMS_SUCCESSFUL) { |
|
470 | if (status!=RTEMS_SUCCESSFUL) { | |
471 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
471 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") | |
472 | } |
|
472 | } | |
473 |
|
473 | |||
474 | return status; |
|
474 | return status; | |
475 | } |
|
475 | } | |
476 |
|
476 | |||
477 | int spacewire_reset_link( void ) |
|
477 | int spacewire_reset_link( void ) | |
478 | { |
|
478 | { | |
479 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. |
|
479 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. | |
480 | * |
|
480 | * | |
481 | * @return RTEMS directive status code: |
|
481 | * @return RTEMS directive status code: | |
482 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. |
|
482 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. | |
483 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. |
|
483 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. | |
484 | * |
|
484 | * | |
485 | */ |
|
485 | */ | |
486 |
|
486 | |||
487 | rtems_status_code status_spw; |
|
487 | rtems_status_code status_spw; | |
488 | rtems_status_code status; |
|
488 | rtems_status_code status; | |
489 | int i; |
|
489 | int i; | |
490 |
|
490 | |||
491 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) |
|
491 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) | |
492 | { |
|
492 | { | |
493 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); |
|
493 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); | |
494 |
|
494 | |||
495 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM |
|
495 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM | |
496 |
|
496 | |||
497 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
497 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
498 |
|
498 | |||
499 | status_spw = spacewire_stop_and_start_link( fdSPW ); |
|
499 | status_spw = spacewire_stop_and_start_link( fdSPW ); | |
500 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
500 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
501 | { |
|
501 | { | |
502 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) |
|
502 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) | |
503 | } |
|
503 | } | |
504 |
|
504 | |||
505 | if ( status_spw == RTEMS_SUCCESSFUL) |
|
505 | if ( status_spw == RTEMS_SUCCESSFUL) | |
506 | { |
|
506 | { | |
507 | break; |
|
507 | break; | |
508 | } |
|
508 | } | |
509 | } |
|
509 | } | |
510 |
|
510 | |||
511 | return status_spw; |
|
511 | return status_spw; | |
512 | } |
|
512 | } | |
513 |
|
513 | |||
514 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force |
|
514 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force | |
515 | { |
|
515 | { | |
516 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. |
|
516 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. | |
517 | * |
|
517 | * | |
518 | * @param val is the value, 0 or 1, used to set the value of the NP bit. |
|
518 | * @param val is the value, 0 or 1, used to set the value of the NP bit. | |
519 | * @param regAddr is the address of the GRSPW control register. |
|
519 | * @param regAddr is the address of the GRSPW control register. | |
520 | * |
|
520 | * | |
521 | * NP is the bit 20 of the GRSPW control register. |
|
521 | * NP is the bit 20 of the GRSPW control register. | |
522 | * |
|
522 | * | |
523 | */ |
|
523 | */ | |
524 |
|
524 | |||
525 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
525 | unsigned int *spwptr = (unsigned int*) regAddr; | |
526 |
|
526 | |||
527 | if (val == 1) { |
|
527 | if (val == 1) { | |
528 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
528 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit | |
529 | } |
|
529 | } | |
530 | if (val== 0) { |
|
530 | if (val== 0) { | |
531 | *spwptr = *spwptr & 0xffdfffff; |
|
531 | *spwptr = *spwptr & 0xffdfffff; | |
532 | } |
|
532 | } | |
533 | } |
|
533 | } | |
534 |
|
534 | |||
535 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable |
|
535 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable | |
536 | { |
|
536 | { | |
537 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. |
|
537 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. | |
538 | * |
|
538 | * | |
539 | * @param val is the value, 0 or 1, used to set the value of the RE bit. |
|
539 | * @param val is the value, 0 or 1, used to set the value of the RE bit. | |
540 | * @param regAddr is the address of the GRSPW control register. |
|
540 | * @param regAddr is the address of the GRSPW control register. | |
541 | * |
|
541 | * | |
542 | * RE is the bit 16 of the GRSPW control register. |
|
542 | * RE is the bit 16 of the GRSPW control register. | |
543 | * |
|
543 | * | |
544 | */ |
|
544 | */ | |
545 |
|
545 | |||
546 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
546 | unsigned int *spwptr = (unsigned int*) regAddr; | |
547 |
|
547 | |||
548 | if (val == 1) |
|
548 | if (val == 1) | |
549 | { |
|
549 | { | |
550 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
550 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit | |
551 | } |
|
551 | } | |
552 | if (val== 0) |
|
552 | if (val== 0) | |
553 | { |
|
553 | { | |
554 | *spwptr = *spwptr & 0xfffdffff; |
|
554 | *spwptr = *spwptr & 0xfffdffff; | |
555 | } |
|
555 | } | |
556 | } |
|
556 | } | |
557 |
|
557 | |||
558 | void spacewire_compute_stats_offsets( void ) |
|
558 | void spacewire_compute_stats_offsets( void ) | |
559 | { |
|
559 | { | |
560 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. |
|
560 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. | |
561 | * |
|
561 | * | |
562 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics |
|
562 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics | |
563 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it |
|
563 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it | |
564 | * during the open systel call). |
|
564 | * during the open systel call). | |
565 | * |
|
565 | * | |
566 | */ |
|
566 | */ | |
567 |
|
567 | |||
568 | spw_stats spacewire_stats_grspw; |
|
568 | spw_stats spacewire_stats_grspw; | |
569 | rtems_status_code status; |
|
569 | rtems_status_code status; | |
570 |
|
570 | |||
571 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
571 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
572 |
|
572 | |||
573 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
573 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received | |
574 | + spacewire_stats.packets_received; |
|
574 | + spacewire_stats.packets_received; | |
575 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
575 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent | |
576 | + spacewire_stats.packets_sent; |
|
576 | + spacewire_stats.packets_sent; | |
577 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
577 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err | |
578 | + spacewire_stats.parity_err; |
|
578 | + spacewire_stats.parity_err; | |
579 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
579 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err | |
580 | + spacewire_stats.disconnect_err; |
|
580 | + spacewire_stats.disconnect_err; | |
581 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
581 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err | |
582 | + spacewire_stats.escape_err; |
|
582 | + spacewire_stats.escape_err; | |
583 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
583 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err | |
584 | + spacewire_stats.credit_err; |
|
584 | + spacewire_stats.credit_err; | |
585 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
585 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err | |
586 | + spacewire_stats.write_sync_err; |
|
586 | + spacewire_stats.write_sync_err; | |
587 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
587 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err | |
588 | + spacewire_stats.rx_rmap_header_crc_err; |
|
588 | + spacewire_stats.rx_rmap_header_crc_err; | |
589 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
589 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err | |
590 | + spacewire_stats.rx_rmap_data_crc_err; |
|
590 | + spacewire_stats.rx_rmap_data_crc_err; | |
591 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
591 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep | |
592 | + spacewire_stats.early_ep; |
|
592 | + spacewire_stats.early_ep; | |
593 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
593 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address | |
594 | + spacewire_stats.invalid_address; |
|
594 | + spacewire_stats.invalid_address; | |
595 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
595 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err | |
596 | + spacewire_stats.rx_eep_err; |
|
596 | + spacewire_stats.rx_eep_err; | |
597 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
597 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated | |
598 | + spacewire_stats.rx_truncated; |
|
598 | + spacewire_stats.rx_truncated; | |
599 | } |
|
599 | } | |
600 |
|
600 | |||
601 | void spacewire_update_statistics( void ) |
|
601 | void spacewire_update_statistics( void ) | |
602 | { |
|
602 | { | |
603 | rtems_status_code status; |
|
603 | rtems_status_code status; | |
604 | spw_stats spacewire_stats_grspw; |
|
604 | spw_stats spacewire_stats_grspw; | |
605 |
|
605 | |||
606 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
606 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
607 |
|
607 | |||
608 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
608 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received | |
609 | + spacewire_stats_grspw.packets_received; |
|
609 | + spacewire_stats_grspw.packets_received; | |
610 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
610 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent | |
611 | + spacewire_stats_grspw.packets_sent; |
|
611 | + spacewire_stats_grspw.packets_sent; | |
612 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
612 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err | |
613 | + spacewire_stats_grspw.parity_err; |
|
613 | + spacewire_stats_grspw.parity_err; | |
614 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
614 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err | |
615 | + spacewire_stats_grspw.disconnect_err; |
|
615 | + spacewire_stats_grspw.disconnect_err; | |
616 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
616 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err | |
617 | + spacewire_stats_grspw.escape_err; |
|
617 | + spacewire_stats_grspw.escape_err; | |
618 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
618 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err | |
619 | + spacewire_stats_grspw.credit_err; |
|
619 | + spacewire_stats_grspw.credit_err; | |
620 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
620 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err | |
621 | + spacewire_stats_grspw.write_sync_err; |
|
621 | + spacewire_stats_grspw.write_sync_err; | |
622 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
622 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err | |
623 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
623 | + spacewire_stats_grspw.rx_rmap_header_crc_err; | |
624 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
624 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err | |
625 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
625 | + spacewire_stats_grspw.rx_rmap_data_crc_err; | |
626 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
626 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep | |
627 | + spacewire_stats_grspw.early_ep; |
|
627 | + spacewire_stats_grspw.early_ep; | |
628 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
628 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address | |
629 | + spacewire_stats_grspw.invalid_address; |
|
629 | + spacewire_stats_grspw.invalid_address; | |
630 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
630 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err | |
631 | + spacewire_stats_grspw.rx_eep_err; |
|
631 | + spacewire_stats_grspw.rx_eep_err; | |
632 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
632 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated | |
633 | + spacewire_stats_grspw.rx_truncated; |
|
633 | + spacewire_stats_grspw.rx_truncated; | |
634 | //spacewire_stats.tx_link_err; |
|
634 | //spacewire_stats.tx_link_err; | |
635 |
|
635 | |||
636 | //**************************** |
|
636 | //**************************** | |
637 | // DPU_SPACEWIRE_IF_STATISTICS |
|
637 | // DPU_SPACEWIRE_IF_STATISTICS | |
638 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
638 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); | |
639 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
639 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); | |
640 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
640 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); | |
641 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
641 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); | |
642 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
642 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; | |
643 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
643 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; | |
644 |
|
644 | |||
645 | //****************************************** |
|
645 | //****************************************** | |
646 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
646 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY | |
647 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
647 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; | |
648 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
648 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; | |
649 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
649 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; | |
650 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
650 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; | |
651 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
651 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; | |
652 |
|
652 | |||
653 | //********************************************* |
|
653 | //********************************************* | |
654 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
654 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY | |
655 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
655 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; | |
656 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
656 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; | |
657 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
657 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; | |
658 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
658 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; | |
659 | } |
|
659 | } | |
660 |
|
660 | |||
661 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
661 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) | |
662 | { |
|
662 | { | |
663 | // a valid timecode has been received, write it in the HK report |
|
663 | // a valid timecode has been received, write it in the HK report | |
664 | unsigned int *grspwPtr; |
|
664 | unsigned int *grspwPtr; | |
665 | unsigned char timecodeCtr; |
|
665 | unsigned char timecodeCtr; | |
666 | unsigned char updateTimeCtr; |
|
666 | unsigned char updateTimeCtr; | |
667 |
|
667 | |||
668 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); |
|
668 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); | |
669 |
|
669 | |||
670 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [1111 1111] |
|
670 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [1111 1111] | |
671 | timecodeCtr = (unsigned char) (grspwPtr[0] & 0x3f); // [0011 1111] |
|
671 | timecodeCtr = (unsigned char) (grspwPtr[0] & 0x3f); // [0011 1111] | |
672 | updateTimeCtr = time_management_regs->coarse_time_load & 0x3f; // [0011 1111] |
|
672 | updateTimeCtr = time_management_regs->coarse_time_load & 0x3f; // [0011 1111] | |
673 |
|
673 | |||
674 | // update the number of valid timecodes that have been received |
|
674 | // update the number of valid timecodes that have been received | |
675 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) |
|
675 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) | |
676 | { |
|
676 | { | |
677 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; |
|
677 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; | |
678 | } |
|
678 | } | |
679 | else |
|
679 | else | |
680 | { |
|
680 | { | |
681 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; |
|
681 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; | |
682 | } |
|
682 | } | |
683 |
|
683 | |||
684 | // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370 |
|
684 | // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370 | |
685 | if (timecodeCtr != updateTimeCtr) |
|
685 | if (timecodeCtr != updateTimeCtr) | |
686 | { |
|
686 | { | |
687 | if (housekeeping_packet.hk_lfr_time_timecode_ctr == 255) |
|
687 | if (housekeeping_packet.hk_lfr_time_timecode_ctr == 255) | |
688 | { |
|
688 | { | |
689 | housekeeping_packet.hk_lfr_time_timecode_ctr = 0; |
|
689 | housekeeping_packet.hk_lfr_time_timecode_ctr = 0; | |
690 | } |
|
690 | } | |
691 | else |
|
691 | else | |
692 | { |
|
692 | { | |
693 | housekeeping_packet.hk_lfr_time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr + 1; |
|
693 | housekeeping_packet.hk_lfr_time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr + 1; | |
694 | } |
|
694 | } | |
695 | } |
|
695 | } | |
696 | } |
|
696 | } | |
697 |
|
697 | |||
698 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
|||
699 | { |
|
|||
700 | int linkStatus; |
|
|||
701 | rtems_status_code status; |
|
|||
702 |
|
||||
703 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
|||
704 |
|
||||
705 | if ( linkStatus == 5) { |
|
|||
706 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
|||
707 | status = RTEMS_SUCCESSFUL; |
|
|||
708 | } |
|
|||
709 | } |
|
|||
710 |
|
||||
711 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
698 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) | |
712 | { |
|
699 | { | |
713 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
700 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
714 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
701 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
715 | header->reserved = DEFAULT_RESERVED; |
|
702 | header->reserved = DEFAULT_RESERVED; | |
716 | header->userApplication = CCSDS_USER_APP; |
|
703 | header->userApplication = CCSDS_USER_APP; | |
717 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; |
|
704 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; | |
718 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; |
|
705 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; | |
719 | header->packetLength[0] = 0x00; |
|
706 | header->packetLength[0] = 0x00; | |
720 | header->packetLength[1] = 0x00; |
|
707 | header->packetLength[1] = 0x00; | |
721 | // DATA FIELD HEADER |
|
708 | // DATA FIELD HEADER | |
722 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
709 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
723 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
710 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
724 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
711 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
725 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
712 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
726 | header->time[0] = 0x00; |
|
713 | header->time[0] = 0x00; | |
727 | header->time[0] = 0x00; |
|
714 | header->time[0] = 0x00; | |
728 | header->time[0] = 0x00; |
|
715 | header->time[0] = 0x00; | |
729 | header->time[0] = 0x00; |
|
716 | header->time[0] = 0x00; | |
730 | header->time[0] = 0x00; |
|
717 | header->time[0] = 0x00; | |
731 | header->time[0] = 0x00; |
|
718 | header->time[0] = 0x00; | |
732 | // AUXILIARY DATA HEADER |
|
719 | // AUXILIARY DATA HEADER | |
733 | header->sid = 0x00; |
|
720 | header->sid = 0x00; | |
734 | header->hkBIA = DEFAULT_HKBIA; |
|
721 | header->hkBIA = DEFAULT_HKBIA; | |
735 | header->blkNr[0] = 0x00; |
|
722 | header->blkNr[0] = 0x00; | |
736 | header->blkNr[1] = 0x00; |
|
723 | header->blkNr[1] = 0x00; | |
737 | } |
|
724 | } | |
738 |
|
725 | |||
739 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
726 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) | |
740 | { |
|
727 | { | |
741 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
728 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
742 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
729 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
743 | header->reserved = DEFAULT_RESERVED; |
|
730 | header->reserved = DEFAULT_RESERVED; | |
744 | header->userApplication = CCSDS_USER_APP; |
|
731 | header->userApplication = CCSDS_USER_APP; | |
745 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
732 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
746 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
733 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
747 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
734 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
748 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
735 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
749 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
736 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
750 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
737 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
751 | // DATA FIELD HEADER |
|
738 | // DATA FIELD HEADER | |
752 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
739 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
753 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
740 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
754 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
741 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
755 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
742 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
756 | header->time[0] = 0x00; |
|
743 | header->time[0] = 0x00; | |
757 | header->time[0] = 0x00; |
|
744 | header->time[0] = 0x00; | |
758 | header->time[0] = 0x00; |
|
745 | header->time[0] = 0x00; | |
759 | header->time[0] = 0x00; |
|
746 | header->time[0] = 0x00; | |
760 | header->time[0] = 0x00; |
|
747 | header->time[0] = 0x00; | |
761 | header->time[0] = 0x00; |
|
748 | header->time[0] = 0x00; | |
762 | // AUXILIARY DATA HEADER |
|
749 | // AUXILIARY DATA HEADER | |
763 | header->sid = 0x00; |
|
750 | header->sid = 0x00; | |
764 | header->hkBIA = DEFAULT_HKBIA; |
|
751 | header->hkBIA = DEFAULT_HKBIA; | |
765 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
752 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT | |
766 | header->pktNr = 0x00; |
|
753 | header->pktNr = 0x00; | |
767 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
754 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
768 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
755 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
769 | } |
|
756 | } | |
770 |
|
757 | |||
771 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
758 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) | |
772 | { |
|
759 | { | |
773 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
760 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
774 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
761 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
775 | header->reserved = DEFAULT_RESERVED; |
|
762 | header->reserved = DEFAULT_RESERVED; | |
776 | header->userApplication = CCSDS_USER_APP; |
|
763 | header->userApplication = CCSDS_USER_APP; | |
777 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
764 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
778 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
765 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
779 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
766 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
780 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
767 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
781 | header->packetLength[0] = 0x00; |
|
768 | header->packetLength[0] = 0x00; | |
782 | header->packetLength[1] = 0x00; |
|
769 | header->packetLength[1] = 0x00; | |
783 | // DATA FIELD HEADER |
|
770 | // DATA FIELD HEADER | |
784 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
771 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
785 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
772 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
786 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
773 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
787 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
774 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
788 | header->time[0] = 0x00; |
|
775 | header->time[0] = 0x00; | |
789 | header->time[0] = 0x00; |
|
776 | header->time[0] = 0x00; | |
790 | header->time[0] = 0x00; |
|
777 | header->time[0] = 0x00; | |
791 | header->time[0] = 0x00; |
|
778 | header->time[0] = 0x00; | |
792 | header->time[0] = 0x00; |
|
779 | header->time[0] = 0x00; | |
793 | header->time[0] = 0x00; |
|
780 | header->time[0] = 0x00; | |
794 | // AUXILIARY DATA HEADER |
|
781 | // AUXILIARY DATA HEADER | |
795 | header->sid = 0x00; |
|
782 | header->sid = 0x00; | |
796 | header->biaStatusInfo = 0x00; |
|
783 | header->biaStatusInfo = 0x00; | |
797 | header->pa_lfr_pkt_cnt_asm = 0x00; |
|
784 | header->pa_lfr_pkt_cnt_asm = 0x00; | |
798 | header->pa_lfr_pkt_nr_asm = 0x00; |
|
785 | header->pa_lfr_pkt_nr_asm = 0x00; | |
799 | header->pa_lfr_asm_blk_nr[0] = 0x00; |
|
786 | header->pa_lfr_asm_blk_nr[0] = 0x00; | |
800 | header->pa_lfr_asm_blk_nr[1] = 0x00; |
|
787 | header->pa_lfr_asm_blk_nr[1] = 0x00; | |
801 | } |
|
788 | } | |
802 |
|
789 | |||
803 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, |
|
790 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, | |
804 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
791 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
805 | { |
|
792 | { | |
806 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
793 | /** This function sends CWF CCSDS packets (F2, F1 or F0). | |
807 | * |
|
794 | * | |
808 | * @param waveform points to the buffer containing the data that will be send. |
|
795 | * @param waveform points to the buffer containing the data that will be send. | |
809 | * @param sid is the source identifier of the data that will be sent. |
|
796 | * @param sid is the source identifier of the data that will be sent. | |
810 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
797 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
811 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
798 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
812 | * contain information to setup the transmission of the data packets. |
|
799 | * contain information to setup the transmission of the data packets. | |
813 | * |
|
800 | * | |
814 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
801 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
815 | * |
|
802 | * | |
816 | */ |
|
803 | */ | |
817 |
|
804 | |||
818 | unsigned int i; |
|
805 | unsigned int i; | |
819 | int ret; |
|
806 | int ret; | |
820 | unsigned int coarseTime; |
|
807 | unsigned int coarseTime; | |
821 | unsigned int fineTime; |
|
808 | unsigned int fineTime; | |
822 | rtems_status_code status; |
|
809 | rtems_status_code status; | |
823 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
810 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
824 | int *dataPtr; |
|
811 | int *dataPtr; | |
825 | unsigned char sid; |
|
812 | unsigned char sid; | |
826 |
|
813 | |||
827 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
814 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
828 | spw_ioctl_send_CWF.options = 0; |
|
815 | spw_ioctl_send_CWF.options = 0; | |
829 |
|
816 | |||
830 | ret = LFR_DEFAULT; |
|
817 | ret = LFR_DEFAULT; | |
831 | sid = (unsigned char) ring_node_to_send->sid; |
|
818 | sid = (unsigned char) ring_node_to_send->sid; | |
832 |
|
819 | |||
833 | coarseTime = ring_node_to_send->coarseTime; |
|
820 | coarseTime = ring_node_to_send->coarseTime; | |
834 | fineTime = ring_node_to_send->fineTime; |
|
821 | fineTime = ring_node_to_send->fineTime; | |
835 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
822 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
836 |
|
823 | |||
837 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
824 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
838 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
825 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
839 | header->hkBIA = pa_bia_status_info; |
|
826 | header->hkBIA = pa_bia_status_info; | |
840 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
827 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
841 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
828 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
842 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
829 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
843 |
|
830 | |||
844 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform |
|
831 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform | |
845 | { |
|
832 | { | |
846 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; |
|
833 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; | |
847 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
834 | spw_ioctl_send_CWF.hdr = (char*) header; | |
848 | // BUILD THE DATA |
|
835 | // BUILD THE DATA | |
849 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
836 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; | |
850 |
|
837 | |||
851 | // SET PACKET SEQUENCE CONTROL |
|
838 | // SET PACKET SEQUENCE CONTROL | |
852 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
839 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
853 |
|
840 | |||
854 | // SET SID |
|
841 | // SET SID | |
855 | header->sid = sid; |
|
842 | header->sid = sid; | |
856 |
|
843 | |||
857 | // SET PACKET TIME |
|
844 | // SET PACKET TIME | |
858 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); |
|
845 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); | |
859 | // |
|
846 | // | |
860 | header->time[0] = header->acquisitionTime[0]; |
|
847 | header->time[0] = header->acquisitionTime[0]; | |
861 | header->time[1] = header->acquisitionTime[1]; |
|
848 | header->time[1] = header->acquisitionTime[1]; | |
862 | header->time[2] = header->acquisitionTime[2]; |
|
849 | header->time[2] = header->acquisitionTime[2]; | |
863 | header->time[3] = header->acquisitionTime[3]; |
|
850 | header->time[3] = header->acquisitionTime[3]; | |
864 | header->time[4] = header->acquisitionTime[4]; |
|
851 | header->time[4] = header->acquisitionTime[4]; | |
865 | header->time[5] = header->acquisitionTime[5]; |
|
852 | header->time[5] = header->acquisitionTime[5]; | |
866 |
|
853 | |||
867 | // SET PACKET ID |
|
854 | // SET PACKET ID | |
868 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
855 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) | |
869 | { |
|
856 | { | |
870 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); |
|
857 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); | |
871 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); |
|
858 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); | |
872 | } |
|
859 | } | |
873 | else |
|
860 | else | |
874 | { |
|
861 | { | |
875 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
862 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
876 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
863 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
877 | } |
|
864 | } | |
878 |
|
865 | |||
879 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
866 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
880 | if (status != RTEMS_SUCCESSFUL) { |
|
867 | if (status != RTEMS_SUCCESSFUL) { | |
881 | ret = LFR_DEFAULT; |
|
868 | ret = LFR_DEFAULT; | |
882 | } |
|
869 | } | |
883 | } |
|
870 | } | |
884 |
|
871 | |||
885 | return ret; |
|
872 | return ret; | |
886 | } |
|
873 | } | |
887 |
|
874 | |||
888 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, |
|
875 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, | |
889 | Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
876 | Header_TM_LFR_SCIENCE_SWF_t *header ) | |
890 | { |
|
877 | { | |
891 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
878 | /** This function sends SWF CCSDS packets (F2, F1 or F0). | |
892 | * |
|
879 | * | |
893 | * @param waveform points to the buffer containing the data that will be send. |
|
880 | * @param waveform points to the buffer containing the data that will be send. | |
894 | * @param sid is the source identifier of the data that will be sent. |
|
881 | * @param sid is the source identifier of the data that will be sent. | |
895 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
882 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. | |
896 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
883 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
897 | * contain information to setup the transmission of the data packets. |
|
884 | * contain information to setup the transmission of the data packets. | |
898 | * |
|
885 | * | |
899 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
886 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
900 | * |
|
887 | * | |
901 | */ |
|
888 | */ | |
902 |
|
889 | |||
903 | unsigned int i; |
|
890 | unsigned int i; | |
904 | int ret; |
|
891 | int ret; | |
905 | unsigned int coarseTime; |
|
892 | unsigned int coarseTime; | |
906 | unsigned int fineTime; |
|
893 | unsigned int fineTime; | |
907 | rtems_status_code status; |
|
894 | rtems_status_code status; | |
908 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
895 | spw_ioctl_pkt_send spw_ioctl_send_SWF; | |
909 | int *dataPtr; |
|
896 | int *dataPtr; | |
910 | unsigned char sid; |
|
897 | unsigned char sid; | |
911 |
|
898 | |||
912 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; |
|
899 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; | |
913 | spw_ioctl_send_SWF.options = 0; |
|
900 | spw_ioctl_send_SWF.options = 0; | |
914 |
|
901 | |||
915 | ret = LFR_DEFAULT; |
|
902 | ret = LFR_DEFAULT; | |
916 |
|
903 | |||
917 | coarseTime = ring_node_to_send->coarseTime; |
|
904 | coarseTime = ring_node_to_send->coarseTime; | |
918 | fineTime = ring_node_to_send->fineTime; |
|
905 | fineTime = ring_node_to_send->fineTime; | |
919 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
906 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
920 | sid = ring_node_to_send->sid; |
|
907 | sid = ring_node_to_send->sid; | |
921 |
|
908 | |||
922 | header->hkBIA = pa_bia_status_info; |
|
909 | header->hkBIA = pa_bia_status_info; | |
923 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
910 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
924 |
|
911 | |||
925 | for (i=0; i<7; i++) // send waveform |
|
912 | for (i=0; i<7; i++) // send waveform | |
926 | { |
|
913 | { | |
927 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; |
|
914 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; | |
928 | spw_ioctl_send_SWF.hdr = (char*) header; |
|
915 | spw_ioctl_send_SWF.hdr = (char*) header; | |
929 |
|
916 | |||
930 | // SET PACKET SEQUENCE CONTROL |
|
917 | // SET PACKET SEQUENCE CONTROL | |
931 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
918 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
932 |
|
919 | |||
933 | // SET PACKET LENGTH AND BLKNR |
|
920 | // SET PACKET LENGTH AND BLKNR | |
934 | if (i == 6) |
|
921 | if (i == 6) | |
935 | { |
|
922 | { | |
936 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
923 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; | |
937 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
924 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); | |
938 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
925 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); | |
939 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
926 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); | |
940 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
927 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); | |
941 | } |
|
928 | } | |
942 | else |
|
929 | else | |
943 | { |
|
930 | { | |
944 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
931 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; | |
945 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
932 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); | |
946 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
933 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); | |
947 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
934 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); | |
948 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
935 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); | |
949 | } |
|
936 | } | |
950 |
|
937 | |||
951 | // SET PACKET TIME |
|
938 | // SET PACKET TIME | |
952 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); |
|
939 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); | |
953 | // |
|
940 | // | |
954 | header->time[0] = header->acquisitionTime[0]; |
|
941 | header->time[0] = header->acquisitionTime[0]; | |
955 | header->time[1] = header->acquisitionTime[1]; |
|
942 | header->time[1] = header->acquisitionTime[1]; | |
956 | header->time[2] = header->acquisitionTime[2]; |
|
943 | header->time[2] = header->acquisitionTime[2]; | |
957 | header->time[3] = header->acquisitionTime[3]; |
|
944 | header->time[3] = header->acquisitionTime[3]; | |
958 | header->time[4] = header->acquisitionTime[4]; |
|
945 | header->time[4] = header->acquisitionTime[4]; | |
959 | header->time[5] = header->acquisitionTime[5]; |
|
946 | header->time[5] = header->acquisitionTime[5]; | |
960 |
|
947 | |||
961 | // SET SID |
|
948 | // SET SID | |
962 | header->sid = sid; |
|
949 | header->sid = sid; | |
963 |
|
950 | |||
964 | // SET PKTNR |
|
951 | // SET PKTNR | |
965 | header->pktNr = i+1; // PKT_NR |
|
952 | header->pktNr = i+1; // PKT_NR | |
966 |
|
953 | |||
967 | // SEND PACKET |
|
954 | // SEND PACKET | |
968 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); |
|
955 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); | |
969 | if (status != RTEMS_SUCCESSFUL) { |
|
956 | if (status != RTEMS_SUCCESSFUL) { | |
970 | ret = LFR_DEFAULT; |
|
957 | ret = LFR_DEFAULT; | |
971 | } |
|
958 | } | |
972 | } |
|
959 | } | |
973 |
|
960 | |||
974 | return ret; |
|
961 | return ret; | |
975 | } |
|
962 | } | |
976 |
|
963 | |||
977 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, |
|
964 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, | |
978 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
965 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
979 | { |
|
966 | { | |
980 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
967 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
981 | * |
|
968 | * | |
982 | * @param waveform points to the buffer containing the data that will be send. |
|
969 | * @param waveform points to the buffer containing the data that will be send. | |
983 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
970 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
984 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
971 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
985 | * contain information to setup the transmission of the data packets. |
|
972 | * contain information to setup the transmission of the data packets. | |
986 | * |
|
973 | * | |
987 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
974 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
988 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
975 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
989 | * |
|
976 | * | |
990 | */ |
|
977 | */ | |
991 |
|
978 | |||
992 | unsigned int i; |
|
979 | unsigned int i; | |
993 | int ret; |
|
980 | int ret; | |
994 | unsigned int coarseTime; |
|
981 | unsigned int coarseTime; | |
995 | unsigned int fineTime; |
|
982 | unsigned int fineTime; | |
996 | rtems_status_code status; |
|
983 | rtems_status_code status; | |
997 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
984 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
998 | char *dataPtr; |
|
985 | char *dataPtr; | |
999 | unsigned char sid; |
|
986 | unsigned char sid; | |
1000 |
|
987 | |||
1001 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
988 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
1002 | spw_ioctl_send_CWF.options = 0; |
|
989 | spw_ioctl_send_CWF.options = 0; | |
1003 |
|
990 | |||
1004 | ret = LFR_DEFAULT; |
|
991 | ret = LFR_DEFAULT; | |
1005 | sid = ring_node_to_send->sid; |
|
992 | sid = ring_node_to_send->sid; | |
1006 |
|
993 | |||
1007 | coarseTime = ring_node_to_send->coarseTime; |
|
994 | coarseTime = ring_node_to_send->coarseTime; | |
1008 | fineTime = ring_node_to_send->fineTime; |
|
995 | fineTime = ring_node_to_send->fineTime; | |
1009 | dataPtr = (char*) ring_node_to_send->buffer_address; |
|
996 | dataPtr = (char*) ring_node_to_send->buffer_address; | |
1010 |
|
997 | |||
1011 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
998 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); | |
1012 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
999 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); | |
1013 | header->hkBIA = pa_bia_status_info; |
|
1000 | header->hkBIA = pa_bia_status_info; | |
1014 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1001 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1015 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
1002 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); | |
1016 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
1003 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); | |
1017 |
|
1004 | |||
1018 | //********************* |
|
1005 | //********************* | |
1019 | // SEND CWF3_light DATA |
|
1006 | // SEND CWF3_light DATA | |
1020 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform |
|
1007 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform | |
1021 | { |
|
1008 | { | |
1022 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; |
|
1009 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; | |
1023 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
1010 | spw_ioctl_send_CWF.hdr = (char*) header; | |
1024 | // BUILD THE DATA |
|
1011 | // BUILD THE DATA | |
1025 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
1012 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; | |
1026 |
|
1013 | |||
1027 | // SET PACKET SEQUENCE COUNTER |
|
1014 | // SET PACKET SEQUENCE COUNTER | |
1028 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1015 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1029 |
|
1016 | |||
1030 | // SET SID |
|
1017 | // SET SID | |
1031 | header->sid = sid; |
|
1018 | header->sid = sid; | |
1032 |
|
1019 | |||
1033 | // SET PACKET TIME |
|
1020 | // SET PACKET TIME | |
1034 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); |
|
1021 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); | |
1035 | // |
|
1022 | // | |
1036 | header->time[0] = header->acquisitionTime[0]; |
|
1023 | header->time[0] = header->acquisitionTime[0]; | |
1037 | header->time[1] = header->acquisitionTime[1]; |
|
1024 | header->time[1] = header->acquisitionTime[1]; | |
1038 | header->time[2] = header->acquisitionTime[2]; |
|
1025 | header->time[2] = header->acquisitionTime[2]; | |
1039 | header->time[3] = header->acquisitionTime[3]; |
|
1026 | header->time[3] = header->acquisitionTime[3]; | |
1040 | header->time[4] = header->acquisitionTime[4]; |
|
1027 | header->time[4] = header->acquisitionTime[4]; | |
1041 | header->time[5] = header->acquisitionTime[5]; |
|
1028 | header->time[5] = header->acquisitionTime[5]; | |
1042 |
|
1029 | |||
1043 | // SET PACKET ID |
|
1030 | // SET PACKET ID | |
1044 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
1031 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
1045 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
1032 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
1046 |
|
1033 | |||
1047 | // SEND PACKET |
|
1034 | // SEND PACKET | |
1048 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
1035 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
1049 | if (status != RTEMS_SUCCESSFUL) { |
|
1036 | if (status != RTEMS_SUCCESSFUL) { | |
1050 | ret = LFR_DEFAULT; |
|
1037 | ret = LFR_DEFAULT; | |
1051 | } |
|
1038 | } | |
1052 | } |
|
1039 | } | |
1053 |
|
1040 | |||
1054 | return ret; |
|
1041 | return ret; | |
1055 | } |
|
1042 | } | |
1056 |
|
1043 | |||
1057 | void spw_send_asm_f0( ring_node *ring_node_to_send, |
|
1044 | void spw_send_asm_f0( ring_node *ring_node_to_send, | |
1058 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1045 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1059 | { |
|
1046 | { | |
1060 | unsigned int i; |
|
1047 | unsigned int i; | |
1061 | unsigned int length = 0; |
|
1048 | unsigned int length = 0; | |
1062 | rtems_status_code status; |
|
1049 | rtems_status_code status; | |
1063 | unsigned int sid; |
|
1050 | unsigned int sid; | |
1064 | float *spectral_matrix; |
|
1051 | float *spectral_matrix; | |
1065 | int coarseTime; |
|
1052 | int coarseTime; | |
1066 | int fineTime; |
|
1053 | int fineTime; | |
1067 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1054 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1068 |
|
1055 | |||
1069 | sid = ring_node_to_send->sid; |
|
1056 | sid = ring_node_to_send->sid; | |
1070 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1057 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1071 | coarseTime = ring_node_to_send->coarseTime; |
|
1058 | coarseTime = ring_node_to_send->coarseTime; | |
1072 | fineTime = ring_node_to_send->fineTime; |
|
1059 | fineTime = ring_node_to_send->fineTime; | |
1073 |
|
1060 | |||
1074 | header->biaStatusInfo = pa_bia_status_info; |
|
1061 | header->biaStatusInfo = pa_bia_status_info; | |
1075 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1062 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1076 |
|
1063 | |||
1077 | for (i=0; i<3; i++) |
|
1064 | for (i=0; i<3; i++) | |
1078 | { |
|
1065 | { | |
1079 | if ((i==0) || (i==1)) |
|
1066 | if ((i==0) || (i==1)) | |
1080 | { |
|
1067 | { | |
1081 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; |
|
1068 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; | |
1082 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1069 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1083 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) |
|
1070 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1084 | ]; |
|
1071 | ]; | |
1085 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; |
|
1072 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; | |
1086 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1073 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1087 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB |
|
1074 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB | |
1088 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB |
|
1075 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB | |
1089 | } |
|
1076 | } | |
1090 | else |
|
1077 | else | |
1091 | { |
|
1078 | { | |
1092 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; |
|
1079 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; | |
1093 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1080 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1094 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) |
|
1081 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1095 | ]; |
|
1082 | ]; | |
1096 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; |
|
1083 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; | |
1097 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1084 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1098 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB |
|
1085 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB | |
1099 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB |
|
1086 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB | |
1100 | } |
|
1087 | } | |
1101 |
|
1088 | |||
1102 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1089 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1103 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1090 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1104 | spw_ioctl_send_ASM.options = 0; |
|
1091 | spw_ioctl_send_ASM.options = 0; | |
1105 |
|
1092 | |||
1106 | // (2) BUILD THE HEADER |
|
1093 | // (2) BUILD THE HEADER | |
1107 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1094 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1108 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1095 | header->packetLength[0] = (unsigned char) (length>>8); | |
1109 | header->packetLength[1] = (unsigned char) (length); |
|
1096 | header->packetLength[1] = (unsigned char) (length); | |
1110 | header->sid = (unsigned char) sid; // SID |
|
1097 | header->sid = (unsigned char) sid; // SID | |
1111 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1098 | header->pa_lfr_pkt_cnt_asm = 3; | |
1112 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1099 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1113 |
|
1100 | |||
1114 | // (3) SET PACKET TIME |
|
1101 | // (3) SET PACKET TIME | |
1115 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1102 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1116 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1103 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1117 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1104 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1118 | header->time[3] = (unsigned char) (coarseTime); |
|
1105 | header->time[3] = (unsigned char) (coarseTime); | |
1119 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1106 | header->time[4] = (unsigned char) (fineTime>>8); | |
1120 | header->time[5] = (unsigned char) (fineTime); |
|
1107 | header->time[5] = (unsigned char) (fineTime); | |
1121 | // |
|
1108 | // | |
1122 | header->acquisitionTime[0] = header->time[0]; |
|
1109 | header->acquisitionTime[0] = header->time[0]; | |
1123 | header->acquisitionTime[1] = header->time[1]; |
|
1110 | header->acquisitionTime[1] = header->time[1]; | |
1124 | header->acquisitionTime[2] = header->time[2]; |
|
1111 | header->acquisitionTime[2] = header->time[2]; | |
1125 | header->acquisitionTime[3] = header->time[3]; |
|
1112 | header->acquisitionTime[3] = header->time[3]; | |
1126 | header->acquisitionTime[4] = header->time[4]; |
|
1113 | header->acquisitionTime[4] = header->time[4]; | |
1127 | header->acquisitionTime[5] = header->time[5]; |
|
1114 | header->acquisitionTime[5] = header->time[5]; | |
1128 |
|
1115 | |||
1129 | // (4) SEND PACKET |
|
1116 | // (4) SEND PACKET | |
1130 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1117 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1131 | if (status != RTEMS_SUCCESSFUL) { |
|
1118 | if (status != RTEMS_SUCCESSFUL) { | |
1132 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) |
|
1119 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1133 | } |
|
1120 | } | |
1134 | } |
|
1121 | } | |
1135 | } |
|
1122 | } | |
1136 |
|
1123 | |||
1137 | void spw_send_asm_f1( ring_node *ring_node_to_send, |
|
1124 | void spw_send_asm_f1( ring_node *ring_node_to_send, | |
1138 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1125 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1139 | { |
|
1126 | { | |
1140 | unsigned int i; |
|
1127 | unsigned int i; | |
1141 | unsigned int length = 0; |
|
1128 | unsigned int length = 0; | |
1142 | rtems_status_code status; |
|
1129 | rtems_status_code status; | |
1143 | unsigned int sid; |
|
1130 | unsigned int sid; | |
1144 | float *spectral_matrix; |
|
1131 | float *spectral_matrix; | |
1145 | int coarseTime; |
|
1132 | int coarseTime; | |
1146 | int fineTime; |
|
1133 | int fineTime; | |
1147 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1134 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1148 |
|
1135 | |||
1149 | sid = ring_node_to_send->sid; |
|
1136 | sid = ring_node_to_send->sid; | |
1150 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1137 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1151 | coarseTime = ring_node_to_send->coarseTime; |
|
1138 | coarseTime = ring_node_to_send->coarseTime; | |
1152 | fineTime = ring_node_to_send->fineTime; |
|
1139 | fineTime = ring_node_to_send->fineTime; | |
1153 |
|
1140 | |||
1154 | header->biaStatusInfo = pa_bia_status_info; |
|
1141 | header->biaStatusInfo = pa_bia_status_info; | |
1155 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1142 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1156 |
|
1143 | |||
1157 | for (i=0; i<3; i++) |
|
1144 | for (i=0; i<3; i++) | |
1158 | { |
|
1145 | { | |
1159 | if ((i==0) || (i==1)) |
|
1146 | if ((i==0) || (i==1)) | |
1160 | { |
|
1147 | { | |
1161 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; |
|
1148 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; | |
1162 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1149 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1163 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1150 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1164 | ]; |
|
1151 | ]; | |
1165 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; |
|
1152 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; | |
1166 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1153 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1167 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB |
|
1154 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB | |
1168 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB |
|
1155 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB | |
1169 | } |
|
1156 | } | |
1170 | else |
|
1157 | else | |
1171 | { |
|
1158 | { | |
1172 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; |
|
1159 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; | |
1173 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1160 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1174 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1161 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1175 | ]; |
|
1162 | ]; | |
1176 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; |
|
1163 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; | |
1177 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1164 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1178 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB |
|
1165 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB | |
1179 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB |
|
1166 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB | |
1180 | } |
|
1167 | } | |
1181 |
|
1168 | |||
1182 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1169 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1183 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1170 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1184 | spw_ioctl_send_ASM.options = 0; |
|
1171 | spw_ioctl_send_ASM.options = 0; | |
1185 |
|
1172 | |||
1186 | // (2) BUILD THE HEADER |
|
1173 | // (2) BUILD THE HEADER | |
1187 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1174 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1188 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1175 | header->packetLength[0] = (unsigned char) (length>>8); | |
1189 | header->packetLength[1] = (unsigned char) (length); |
|
1176 | header->packetLength[1] = (unsigned char) (length); | |
1190 | header->sid = (unsigned char) sid; // SID |
|
1177 | header->sid = (unsigned char) sid; // SID | |
1191 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1178 | header->pa_lfr_pkt_cnt_asm = 3; | |
1192 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1179 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1193 |
|
1180 | |||
1194 | // (3) SET PACKET TIME |
|
1181 | // (3) SET PACKET TIME | |
1195 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1182 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1196 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1183 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1197 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1184 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1198 | header->time[3] = (unsigned char) (coarseTime); |
|
1185 | header->time[3] = (unsigned char) (coarseTime); | |
1199 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1186 | header->time[4] = (unsigned char) (fineTime>>8); | |
1200 | header->time[5] = (unsigned char) (fineTime); |
|
1187 | header->time[5] = (unsigned char) (fineTime); | |
1201 | // |
|
1188 | // | |
1202 | header->acquisitionTime[0] = header->time[0]; |
|
1189 | header->acquisitionTime[0] = header->time[0]; | |
1203 | header->acquisitionTime[1] = header->time[1]; |
|
1190 | header->acquisitionTime[1] = header->time[1]; | |
1204 | header->acquisitionTime[2] = header->time[2]; |
|
1191 | header->acquisitionTime[2] = header->time[2]; | |
1205 | header->acquisitionTime[3] = header->time[3]; |
|
1192 | header->acquisitionTime[3] = header->time[3]; | |
1206 | header->acquisitionTime[4] = header->time[4]; |
|
1193 | header->acquisitionTime[4] = header->time[4]; | |
1207 | header->acquisitionTime[5] = header->time[5]; |
|
1194 | header->acquisitionTime[5] = header->time[5]; | |
1208 |
|
1195 | |||
1209 | // (4) SEND PACKET |
|
1196 | // (4) SEND PACKET | |
1210 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1197 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1211 | if (status != RTEMS_SUCCESSFUL) { |
|
1198 | if (status != RTEMS_SUCCESSFUL) { | |
1212 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) |
|
1199 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1213 | } |
|
1200 | } | |
1214 | } |
|
1201 | } | |
1215 | } |
|
1202 | } | |
1216 |
|
1203 | |||
1217 | void spw_send_asm_f2( ring_node *ring_node_to_send, |
|
1204 | void spw_send_asm_f2( ring_node *ring_node_to_send, | |
1218 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1205 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1219 | { |
|
1206 | { | |
1220 | unsigned int i; |
|
1207 | unsigned int i; | |
1221 | unsigned int length = 0; |
|
1208 | unsigned int length = 0; | |
1222 | rtems_status_code status; |
|
1209 | rtems_status_code status; | |
1223 | unsigned int sid; |
|
1210 | unsigned int sid; | |
1224 | float *spectral_matrix; |
|
1211 | float *spectral_matrix; | |
1225 | int coarseTime; |
|
1212 | int coarseTime; | |
1226 | int fineTime; |
|
1213 | int fineTime; | |
1227 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1214 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1228 |
|
1215 | |||
1229 | sid = ring_node_to_send->sid; |
|
1216 | sid = ring_node_to_send->sid; | |
1230 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1217 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1231 | coarseTime = ring_node_to_send->coarseTime; |
|
1218 | coarseTime = ring_node_to_send->coarseTime; | |
1232 | fineTime = ring_node_to_send->fineTime; |
|
1219 | fineTime = ring_node_to_send->fineTime; | |
1233 |
|
1220 | |||
1234 | header->biaStatusInfo = pa_bia_status_info; |
|
1221 | header->biaStatusInfo = pa_bia_status_info; | |
1235 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1222 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1236 |
|
1223 | |||
1237 | for (i=0; i<3; i++) |
|
1224 | for (i=0; i<3; i++) | |
1238 | { |
|
1225 | { | |
1239 |
|
1226 | |||
1240 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; |
|
1227 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; | |
1241 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1228 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1242 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) |
|
1229 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) | |
1243 | ]; |
|
1230 | ]; | |
1244 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; |
|
1231 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; | |
1245 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; |
|
1232 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; | |
1246 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB |
|
1233 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB | |
1247 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB |
|
1234 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB | |
1248 |
|
1235 | |||
1249 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1236 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1250 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1237 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1251 | spw_ioctl_send_ASM.options = 0; |
|
1238 | spw_ioctl_send_ASM.options = 0; | |
1252 |
|
1239 | |||
1253 | // (2) BUILD THE HEADER |
|
1240 | // (2) BUILD THE HEADER | |
1254 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1241 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1255 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1242 | header->packetLength[0] = (unsigned char) (length>>8); | |
1256 | header->packetLength[1] = (unsigned char) (length); |
|
1243 | header->packetLength[1] = (unsigned char) (length); | |
1257 | header->sid = (unsigned char) sid; // SID |
|
1244 | header->sid = (unsigned char) sid; // SID | |
1258 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1245 | header->pa_lfr_pkt_cnt_asm = 3; | |
1259 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1246 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1260 |
|
1247 | |||
1261 | // (3) SET PACKET TIME |
|
1248 | // (3) SET PACKET TIME | |
1262 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1249 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1263 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1250 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1264 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1251 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1265 | header->time[3] = (unsigned char) (coarseTime); |
|
1252 | header->time[3] = (unsigned char) (coarseTime); | |
1266 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1253 | header->time[4] = (unsigned char) (fineTime>>8); | |
1267 | header->time[5] = (unsigned char) (fineTime); |
|
1254 | header->time[5] = (unsigned char) (fineTime); | |
1268 | // |
|
1255 | // | |
1269 | header->acquisitionTime[0] = header->time[0]; |
|
1256 | header->acquisitionTime[0] = header->time[0]; | |
1270 | header->acquisitionTime[1] = header->time[1]; |
|
1257 | header->acquisitionTime[1] = header->time[1]; | |
1271 | header->acquisitionTime[2] = header->time[2]; |
|
1258 | header->acquisitionTime[2] = header->time[2]; | |
1272 | header->acquisitionTime[3] = header->time[3]; |
|
1259 | header->acquisitionTime[3] = header->time[3]; | |
1273 | header->acquisitionTime[4] = header->time[4]; |
|
1260 | header->acquisitionTime[4] = header->time[4]; | |
1274 | header->acquisitionTime[5] = header->time[5]; |
|
1261 | header->acquisitionTime[5] = header->time[5]; | |
1275 |
|
1262 | |||
1276 | // (4) SEND PACKET |
|
1263 | // (4) SEND PACKET | |
1277 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1264 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1278 | if (status != RTEMS_SUCCESSFUL) { |
|
1265 | if (status != RTEMS_SUCCESSFUL) { | |
1279 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) |
|
1266 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1280 | } |
|
1267 | } | |
1281 | } |
|
1268 | } | |
1282 | } |
|
1269 | } | |
1283 |
|
1270 | |||
1284 | void spw_send_k_dump( ring_node *ring_node_to_send ) |
|
1271 | void spw_send_k_dump( ring_node *ring_node_to_send ) | |
1285 | { |
|
1272 | { | |
1286 | rtems_status_code status; |
|
1273 | rtems_status_code status; | |
1287 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; |
|
1274 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; | |
1288 | unsigned int packetLength; |
|
1275 | unsigned int packetLength; | |
1289 | unsigned int size; |
|
1276 | unsigned int size; | |
1290 |
|
1277 | |||
1291 | PRINTF("spw_send_k_dump\n") |
|
1278 | PRINTF("spw_send_k_dump\n") | |
1292 |
|
1279 | |||
1293 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; |
|
1280 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; | |
1294 |
|
1281 | |||
1295 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; |
|
1282 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; | |
1296 |
|
1283 | |||
1297 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
1284 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
1298 |
|
1285 | |||
1299 | PRINTF2("packetLength %d, size %d\n", packetLength, size ) |
|
1286 | PRINTF2("packetLength %d, size %d\n", packetLength, size ) | |
1300 |
|
1287 | |||
1301 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); |
|
1288 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); | |
1302 |
|
1289 | |||
1303 | if (status == -1){ |
|
1290 | if (status == -1){ | |
1304 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
1291 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
1305 | } |
|
1292 | } | |
1306 |
|
1293 | |||
1307 | ring_node_to_send->status = 0x00; |
|
1294 | ring_node_to_send->status = 0x00; | |
1308 | } |
|
1295 | } |
@@ -1,1519 +1,1604 | |||||
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 TC; // TC sent to the ACTN task |
|
32 | ccsdsTelecommandPacket_t 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[6]; |
|
35 | unsigned char time[6]; | |
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 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
39 | status = get_message_queue_id_recv( &queue_rcv_id ); | |
40 | if (status != RTEMS_SUCCESSFUL) |
|
40 | if (status != RTEMS_SUCCESSFUL) | |
41 | { |
|
41 | { | |
42 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
42 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | status = get_message_queue_id_send( &queue_snd_id ); |
|
45 | status = get_message_queue_id_send( &queue_snd_id ); | |
46 | if (status != RTEMS_SUCCESSFUL) |
|
46 | if (status != RTEMS_SUCCESSFUL) | |
47 | { |
|
47 | { | |
48 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
48 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | result = LFR_SUCCESSFUL; |
|
51 | result = LFR_SUCCESSFUL; | |
52 | subtype = 0; // subtype of the current TC packet |
|
52 | subtype = 0; // subtype of the current TC packet | |
53 |
|
53 | |||
54 | BOOT_PRINTF("in ACTN *** \n") |
|
54 | BOOT_PRINTF("in ACTN *** \n") | |
55 |
|
55 | |||
56 | while(1) |
|
56 | while(1) | |
57 | { |
|
57 | { | |
58 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
58 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, | |
59 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
59 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); | |
60 | getTime( time ); // set time to the current time |
|
60 | getTime( time ); // set time to the current time | |
61 | if (status!=RTEMS_SUCCESSFUL) |
|
61 | if (status!=RTEMS_SUCCESSFUL) | |
62 | { |
|
62 | { | |
63 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
63 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) | |
64 | } |
|
64 | } | |
65 | else |
|
65 | else | |
66 | { |
|
66 | { | |
67 | subtype = TC.serviceSubType; |
|
67 | subtype = TC.serviceSubType; | |
68 | switch(subtype) |
|
68 | switch(subtype) | |
69 | { |
|
69 | { | |
70 | case TC_SUBTYPE_RESET: |
|
70 | case TC_SUBTYPE_RESET: | |
71 | result = action_reset( &TC, queue_snd_id, time ); |
|
71 | result = action_reset( &TC, queue_snd_id, time ); | |
72 | close_action( &TC, result, queue_snd_id ); |
|
72 | close_action( &TC, result, queue_snd_id ); | |
73 | break; |
|
73 | break; | |
74 | case TC_SUBTYPE_LOAD_COMM: |
|
74 | case TC_SUBTYPE_LOAD_COMM: | |
75 | result = action_load_common_par( &TC ); |
|
75 | result = action_load_common_par( &TC ); | |
76 | close_action( &TC, result, queue_snd_id ); |
|
76 | close_action( &TC, result, queue_snd_id ); | |
77 | break; |
|
77 | break; | |
78 | case TC_SUBTYPE_LOAD_NORM: |
|
78 | case TC_SUBTYPE_LOAD_NORM: | |
79 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
79 | result = action_load_normal_par( &TC, queue_snd_id, time ); | |
80 | close_action( &TC, result, queue_snd_id ); |
|
80 | close_action( &TC, result, queue_snd_id ); | |
81 | break; |
|
81 | break; | |
82 | case TC_SUBTYPE_LOAD_BURST: |
|
82 | case TC_SUBTYPE_LOAD_BURST: | |
83 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
83 | result = action_load_burst_par( &TC, queue_snd_id, time ); | |
84 | close_action( &TC, result, queue_snd_id ); |
|
84 | close_action( &TC, result, queue_snd_id ); | |
85 | break; |
|
85 | break; | |
86 | case TC_SUBTYPE_LOAD_SBM1: |
|
86 | case TC_SUBTYPE_LOAD_SBM1: | |
87 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
87 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); | |
88 | close_action( &TC, result, queue_snd_id ); |
|
88 | close_action( &TC, result, queue_snd_id ); | |
89 | break; |
|
89 | break; | |
90 | case TC_SUBTYPE_LOAD_SBM2: |
|
90 | case TC_SUBTYPE_LOAD_SBM2: | |
91 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
91 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); | |
92 | close_action( &TC, result, queue_snd_id ); |
|
92 | close_action( &TC, result, queue_snd_id ); | |
93 | break; |
|
93 | break; | |
94 | case TC_SUBTYPE_DUMP: |
|
94 | case TC_SUBTYPE_DUMP: | |
95 | result = action_dump_par( &TC, queue_snd_id ); |
|
95 | result = action_dump_par( &TC, queue_snd_id ); | |
96 | close_action( &TC, result, queue_snd_id ); |
|
96 | close_action( &TC, result, queue_snd_id ); | |
97 | break; |
|
97 | break; | |
98 | case TC_SUBTYPE_ENTER: |
|
98 | case TC_SUBTYPE_ENTER: | |
99 | result = action_enter_mode( &TC, queue_snd_id ); |
|
99 | result = action_enter_mode( &TC, queue_snd_id ); | |
100 | close_action( &TC, result, queue_snd_id ); |
|
100 | close_action( &TC, result, queue_snd_id ); | |
101 | break; |
|
101 | break; | |
102 | case TC_SUBTYPE_UPDT_INFO: |
|
102 | case TC_SUBTYPE_UPDT_INFO: | |
103 | result = action_update_info( &TC, queue_snd_id ); |
|
103 | result = action_update_info( &TC, queue_snd_id ); | |
104 | close_action( &TC, result, queue_snd_id ); |
|
104 | close_action( &TC, result, queue_snd_id ); | |
105 | break; |
|
105 | break; | |
106 | case TC_SUBTYPE_EN_CAL: |
|
106 | case TC_SUBTYPE_EN_CAL: | |
107 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
107 | result = action_enable_calibration( &TC, queue_snd_id, time ); | |
108 | close_action( &TC, result, queue_snd_id ); |
|
108 | close_action( &TC, result, queue_snd_id ); | |
109 | break; |
|
109 | break; | |
110 | case TC_SUBTYPE_DIS_CAL: |
|
110 | case TC_SUBTYPE_DIS_CAL: | |
111 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
111 | result = action_disable_calibration( &TC, queue_snd_id, time ); | |
112 | close_action( &TC, result, queue_snd_id ); |
|
112 | close_action( &TC, result, queue_snd_id ); | |
113 | break; |
|
113 | break; | |
114 | case TC_SUBTYPE_LOAD_K: |
|
114 | case TC_SUBTYPE_LOAD_K: | |
115 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); |
|
115 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); | |
116 | close_action( &TC, result, queue_snd_id ); |
|
116 | close_action( &TC, result, queue_snd_id ); | |
117 | break; |
|
117 | break; | |
118 | case TC_SUBTYPE_DUMP_K: |
|
118 | case TC_SUBTYPE_DUMP_K: | |
119 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); |
|
119 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); | |
120 | close_action( &TC, result, queue_snd_id ); |
|
120 | close_action( &TC, result, queue_snd_id ); | |
121 | break; |
|
121 | break; | |
122 | case TC_SUBTYPE_LOAD_FBINS: |
|
122 | case TC_SUBTYPE_LOAD_FBINS: | |
123 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); |
|
123 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); | |
124 | close_action( &TC, result, queue_snd_id ); |
|
124 | close_action( &TC, result, queue_snd_id ); | |
125 | break; |
|
125 | break; | |
126 | case TC_SUBTYPE_UPDT_TIME: |
|
126 | case TC_SUBTYPE_UPDT_TIME: | |
127 | result = action_update_time( &TC ); |
|
127 | result = action_update_time( &TC ); | |
128 | close_action( &TC, result, queue_snd_id ); |
|
128 | close_action( &TC, result, queue_snd_id ); | |
129 | break; |
|
129 | break; | |
130 | default: |
|
130 | default: | |
131 | break; |
|
131 | break; | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 | } |
|
134 | } | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | //*********** |
|
137 | //*********** | |
138 | // TC ACTIONS |
|
138 | // TC ACTIONS | |
139 |
|
139 | |||
140 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
140 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
141 | { |
|
141 | { | |
142 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
142 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. | |
143 | * |
|
143 | * | |
144 | * @param TC points to the TeleCommand packet that is being processed |
|
144 | * @param TC points to the TeleCommand packet that is being processed | |
145 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
145 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
146 | * |
|
146 | * | |
147 | */ |
|
147 | */ | |
148 |
|
148 | |||
149 | PRINTF("this is the end!!!\n") |
|
149 | PRINTF("this is the end!!!\n") | |
150 | exit(0); |
|
150 | exit(0); | |
151 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
151 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
152 | return LFR_DEFAULT; |
|
152 | return LFR_DEFAULT; | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
155 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
156 | { |
|
156 | { | |
157 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
157 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. | |
158 | * |
|
158 | * | |
159 | * @param TC points to the TeleCommand packet that is being processed |
|
159 | * @param TC points to the TeleCommand packet that is being processed | |
160 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
160 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
161 | * |
|
161 | * | |
162 | */ |
|
162 | */ | |
163 |
|
163 | |||
164 | rtems_status_code status; |
|
164 | rtems_status_code status; | |
165 | unsigned char requestedMode; |
|
165 | unsigned char requestedMode; | |
166 | unsigned int *transitionCoarseTime_ptr; |
|
166 | unsigned int *transitionCoarseTime_ptr; | |
167 | unsigned int transitionCoarseTime; |
|
167 | unsigned int transitionCoarseTime; | |
168 | unsigned char * bytePosPtr; |
|
168 | unsigned char * bytePosPtr; | |
169 |
|
169 | |||
170 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
170 | bytePosPtr = (unsigned char *) &TC->packetID; | |
171 |
|
171 | |||
172 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
172 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; | |
173 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); |
|
173 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); | |
174 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; |
|
174 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; | |
175 |
|
175 | |||
176 | status = check_mode_value( requestedMode ); |
|
176 | status = check_mode_value( requestedMode ); | |
177 |
|
177 | |||
178 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
178 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent | |
179 | { |
|
179 | { | |
180 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); |
|
180 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); | |
181 | } |
|
181 | } | |
|
182 | ||||
182 | else // the mode value is valid, check the transition |
|
183 | else // the mode value is valid, check the transition | |
183 | { |
|
184 | { | |
184 | status = check_mode_transition(requestedMode); |
|
185 | status = check_mode_transition(requestedMode); | |
185 | if (status != LFR_SUCCESSFUL) |
|
186 | if (status != LFR_SUCCESSFUL) | |
186 | { |
|
187 | { | |
187 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
188 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") | |
188 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
189 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
189 | } |
|
190 | } | |
190 | } |
|
191 | } | |
191 |
|
192 | |||
192 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date |
|
193 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date | |
193 | { |
|
194 | { | |
194 | status = check_transition_date( transitionCoarseTime ); |
|
195 | status = check_transition_date( transitionCoarseTime ); | |
195 | if (status != LFR_SUCCESSFUL) |
|
196 | if (status != LFR_SUCCESSFUL) | |
196 | { |
|
197 | { | |
197 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") |
|
198 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") | |
198 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, |
|
199 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, | |
199 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, |
|
200 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, | |
200 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); |
|
201 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); | |
201 | } |
|
202 | } | |
202 | } |
|
203 | } | |
203 |
|
204 | |||
204 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
205 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode | |
205 | { |
|
206 | { | |
206 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
207 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); | |
207 |
|
208 | |||
|
209 | ||||
|
210 | ||||
208 | switch(requestedMode) |
|
211 | switch(requestedMode) | |
209 | { |
|
212 | { | |
210 | case LFR_MODE_STANDBY: |
|
213 | case LFR_MODE_STANDBY: | |
211 | status = enter_mode_standby(); |
|
214 | status = enter_mode_standby(); | |
212 | break; |
|
215 | break; | |
213 | case LFR_MODE_NORMAL: |
|
216 | case LFR_MODE_NORMAL: | |
214 | status = enter_mode_normal( transitionCoarseTime ); |
|
217 | status = enter_mode_normal( transitionCoarseTime ); | |
215 | break; |
|
218 | break; | |
216 | case LFR_MODE_BURST: |
|
219 | case LFR_MODE_BURST: | |
217 | status = enter_mode_burst( transitionCoarseTime ); |
|
220 | status = enter_mode_burst( transitionCoarseTime ); | |
218 | break; |
|
221 | break; | |
219 | case LFR_MODE_SBM1: |
|
222 | case LFR_MODE_SBM1: | |
220 | status = enter_mode_sbm1( transitionCoarseTime ); |
|
223 | status = enter_mode_sbm1( transitionCoarseTime ); | |
221 | break; |
|
224 | break; | |
222 | case LFR_MODE_SBM2: |
|
225 | case LFR_MODE_SBM2: | |
223 | status = enter_mode_sbm2( transitionCoarseTime ); |
|
226 | status = enter_mode_sbm2( transitionCoarseTime ); | |
224 | break; |
|
227 | break; | |
225 | default: |
|
228 | default: | |
226 | break; |
|
229 | break; | |
227 | } |
|
230 | } | |
228 | } |
|
231 | } | |
229 |
|
232 | |||
230 | return status; |
|
233 | return status; | |
231 | } |
|
234 | } | |
232 |
|
235 | |||
233 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
236 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
234 | { |
|
237 | { | |
235 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
238 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
236 | * |
|
239 | * | |
237 | * @param TC points to the TeleCommand packet that is being processed |
|
240 | * @param TC points to the TeleCommand packet that is being processed | |
238 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
241 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
239 | * |
|
242 | * | |
240 | * @return LFR directive status code: |
|
243 | * @return LFR directive status code: | |
241 | * - LFR_DEFAULT |
|
244 | * - LFR_DEFAULT | |
242 | * - LFR_SUCCESSFUL |
|
245 | * - LFR_SUCCESSFUL | |
243 | * |
|
246 | * | |
244 | */ |
|
247 | */ | |
245 |
|
248 | |||
246 | unsigned int val; |
|
249 | unsigned int val; | |
247 | int result; |
|
250 | int result; | |
248 | unsigned int status; |
|
251 | unsigned int status; | |
249 | unsigned char mode; |
|
252 | unsigned char mode; | |
250 | unsigned char * bytePosPtr; |
|
253 | unsigned char * bytePosPtr; | |
251 |
|
254 | |||
252 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
255 | bytePosPtr = (unsigned char *) &TC->packetID; | |
253 |
|
256 | |||
254 | // check LFR mode |
|
257 | // check LFR mode | |
255 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
258 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; | |
256 | status = check_update_info_hk_lfr_mode( mode ); |
|
259 | status = check_update_info_hk_lfr_mode( mode ); | |
257 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
260 | if (status == LFR_SUCCESSFUL) // check TDS mode | |
258 | { |
|
261 | { | |
259 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
262 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; | |
260 | status = check_update_info_hk_tds_mode( mode ); |
|
263 | status = check_update_info_hk_tds_mode( mode ); | |
261 | } |
|
264 | } | |
262 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
265 | if (status == LFR_SUCCESSFUL) // check THR mode | |
263 | { |
|
266 | { | |
264 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
267 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); | |
265 | status = check_update_info_hk_thr_mode( mode ); |
|
268 | status = check_update_info_hk_thr_mode( mode ); | |
266 | } |
|
269 | } | |
267 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
270 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful | |
268 | { |
|
271 | { | |
269 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
272 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | |
270 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
273 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
271 | val++; |
|
274 | val++; | |
272 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
275 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); | |
273 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
276 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
274 | } |
|
277 | } | |
275 |
|
278 | |||
276 | // pa_bia_status_info |
|
279 | // pa_bia_status_info | |
277 | // => pa_bia_mode_mux_set 3 bits |
|
280 | // => pa_bia_mode_mux_set 3 bits | |
278 | // => pa_bia_mode_hv_enabled 1 bit |
|
281 | // => pa_bia_mode_hv_enabled 1 bit | |
279 | // => pa_bia_mode_bias1_enabled 1 bit |
|
282 | // => pa_bia_mode_bias1_enabled 1 bit | |
280 | // => pa_bia_mode_bias2_enabled 1 bit |
|
283 | // => pa_bia_mode_bias2_enabled 1 bit | |
281 | // => pa_bia_mode_bias3_enabled 1 bit |
|
284 | // => pa_bia_mode_bias3_enabled 1 bit | |
282 | // => pa_bia_on_off (cp_dpu_bias_on_off) |
|
285 | // => pa_bia_on_off (cp_dpu_bias_on_off) | |
283 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110] |
|
286 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110] | |
284 | pa_bia_status_info = pa_bia_status_info |
|
287 | pa_bia_status_info = pa_bia_status_info | |
285 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1); |
|
288 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1); | |
286 |
|
289 | |||
287 | result = status; |
|
290 | result = status; | |
288 |
|
291 | |||
289 | return result; |
|
292 | return result; | |
290 | } |
|
293 | } | |
291 |
|
294 | |||
292 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
295 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
293 | { |
|
296 | { | |
294 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
297 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
295 | * |
|
298 | * | |
296 | * @param TC points to the TeleCommand packet that is being processed |
|
299 | * @param TC points to the TeleCommand packet that is being processed | |
297 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
300 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
298 | * |
|
301 | * | |
299 | */ |
|
302 | */ | |
300 |
|
303 | |||
301 | int result; |
|
304 | int result; | |
302 |
|
305 | |||
303 | result = LFR_DEFAULT; |
|
306 | result = LFR_DEFAULT; | |
304 |
|
307 | |||
305 | setCalibration( true ); |
|
308 | setCalibration( true ); | |
306 |
|
309 | |||
307 | result = LFR_SUCCESSFUL; |
|
310 | result = LFR_SUCCESSFUL; | |
308 |
|
311 | |||
309 | return result; |
|
312 | return result; | |
310 | } |
|
313 | } | |
311 |
|
314 | |||
312 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
315 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
313 | { |
|
316 | { | |
314 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
317 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
315 | * |
|
318 | * | |
316 | * @param TC points to the TeleCommand packet that is being processed |
|
319 | * @param TC points to the TeleCommand packet that is being processed | |
317 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
320 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
318 | * |
|
321 | * | |
319 | */ |
|
322 | */ | |
320 |
|
323 | |||
321 | int result; |
|
324 | int result; | |
322 |
|
325 | |||
323 | result = LFR_DEFAULT; |
|
326 | result = LFR_DEFAULT; | |
324 |
|
327 | |||
325 | setCalibration( false ); |
|
328 | setCalibration( false ); | |
326 |
|
329 | |||
327 | result = LFR_SUCCESSFUL; |
|
330 | result = LFR_SUCCESSFUL; | |
328 |
|
331 | |||
329 | return result; |
|
332 | return result; | |
330 | } |
|
333 | } | |
331 |
|
334 | |||
332 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
335 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
333 | { |
|
336 | { | |
334 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
337 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
335 | * |
|
338 | * | |
336 | * @param TC points to the TeleCommand packet that is being processed |
|
339 | * @param TC points to the TeleCommand packet that is being processed | |
337 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
340 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
338 | * |
|
341 | * | |
339 | * @return LFR_SUCCESSFUL |
|
342 | * @return LFR_SUCCESSFUL | |
340 | * |
|
343 | * | |
341 | */ |
|
344 | */ | |
342 |
|
345 | |||
343 | unsigned int val; |
|
346 | unsigned int val; | |
344 |
|
347 | |||
345 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
348 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | |
346 | + (TC->dataAndCRC[1] << 16) |
|
349 | + (TC->dataAndCRC[1] << 16) | |
347 | + (TC->dataAndCRC[2] << 8) |
|
350 | + (TC->dataAndCRC[2] << 8) | |
348 | + TC->dataAndCRC[3]; |
|
351 | + TC->dataAndCRC[3]; | |
349 |
|
352 | |||
350 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
353 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | |
351 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
354 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
352 | val++; |
|
355 | val++; | |
353 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
356 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | |
354 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
357 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
355 |
|
358 | |||
356 | return LFR_SUCCESSFUL; |
|
359 | return LFR_SUCCESSFUL; | |
357 | } |
|
360 | } | |
358 |
|
361 | |||
359 | //******************* |
|
362 | //******************* | |
360 | // ENTERING THE MODES |
|
363 | // ENTERING THE MODES | |
361 | int check_mode_value( unsigned char requestedMode ) |
|
364 | int check_mode_value( unsigned char requestedMode ) | |
362 | { |
|
365 | { | |
363 | int status; |
|
366 | int status; | |
364 |
|
367 | |||
365 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
368 | if ( (requestedMode != LFR_MODE_STANDBY) | |
366 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
369 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
367 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
370 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
368 | { |
|
371 | { | |
369 | status = LFR_DEFAULT; |
|
372 | status = LFR_DEFAULT; | |
370 | } |
|
373 | } | |
371 | else |
|
374 | else | |
372 | { |
|
375 | { | |
373 | status = LFR_SUCCESSFUL; |
|
376 | status = LFR_SUCCESSFUL; | |
374 | } |
|
377 | } | |
375 |
|
378 | |||
376 | return status; |
|
379 | return status; | |
377 | } |
|
380 | } | |
378 |
|
381 | |||
379 | int check_mode_transition( unsigned char requestedMode ) |
|
382 | int check_mode_transition( unsigned char requestedMode ) | |
380 | { |
|
383 | { | |
381 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
384 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
382 | * |
|
385 | * | |
383 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
386 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
384 | * |
|
387 | * | |
385 | * @return LFR directive status codes: |
|
388 | * @return LFR directive status codes: | |
386 | * - LFR_SUCCESSFUL - the transition is authorized |
|
389 | * - LFR_SUCCESSFUL - the transition is authorized | |
387 | * - LFR_DEFAULT - the transition is not authorized |
|
390 | * - LFR_DEFAULT - the transition is not authorized | |
388 | * |
|
391 | * | |
389 | */ |
|
392 | */ | |
390 |
|
393 | |||
391 | int status; |
|
394 | int status; | |
392 |
|
395 | |||
393 | switch (requestedMode) |
|
396 | switch (requestedMode) | |
394 | { |
|
397 | { | |
395 | case LFR_MODE_STANDBY: |
|
398 | case LFR_MODE_STANDBY: | |
396 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
399 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
397 | status = LFR_DEFAULT; |
|
400 | status = LFR_DEFAULT; | |
398 | } |
|
401 | } | |
399 | else |
|
402 | else | |
400 | { |
|
403 | { | |
401 | status = LFR_SUCCESSFUL; |
|
404 | status = LFR_SUCCESSFUL; | |
402 | } |
|
405 | } | |
403 | break; |
|
406 | break; | |
404 | case LFR_MODE_NORMAL: |
|
407 | case LFR_MODE_NORMAL: | |
405 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
408 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
406 | status = LFR_DEFAULT; |
|
409 | status = LFR_DEFAULT; | |
407 | } |
|
410 | } | |
408 | else { |
|
411 | else { | |
409 | status = LFR_SUCCESSFUL; |
|
412 | status = LFR_SUCCESSFUL; | |
410 | } |
|
413 | } | |
411 | break; |
|
414 | break; | |
412 | case LFR_MODE_BURST: |
|
415 | case LFR_MODE_BURST: | |
413 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
416 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
414 | status = LFR_DEFAULT; |
|
417 | status = LFR_DEFAULT; | |
415 | } |
|
418 | } | |
416 | else { |
|
419 | else { | |
417 | status = LFR_SUCCESSFUL; |
|
420 | status = LFR_SUCCESSFUL; | |
418 | } |
|
421 | } | |
419 | break; |
|
422 | break; | |
420 | case LFR_MODE_SBM1: |
|
423 | case LFR_MODE_SBM1: | |
421 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
424 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
422 | status = LFR_DEFAULT; |
|
425 | status = LFR_DEFAULT; | |
423 | } |
|
426 | } | |
424 | else { |
|
427 | else { | |
425 | status = LFR_SUCCESSFUL; |
|
428 | status = LFR_SUCCESSFUL; | |
426 | } |
|
429 | } | |
427 | break; |
|
430 | break; | |
428 | case LFR_MODE_SBM2: |
|
431 | case LFR_MODE_SBM2: | |
429 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
432 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
430 | status = LFR_DEFAULT; |
|
433 | status = LFR_DEFAULT; | |
431 | } |
|
434 | } | |
432 | else { |
|
435 | else { | |
433 | status = LFR_SUCCESSFUL; |
|
436 | status = LFR_SUCCESSFUL; | |
434 | } |
|
437 | } | |
435 | break; |
|
438 | break; | |
436 | default: |
|
439 | default: | |
437 | status = LFR_DEFAULT; |
|
440 | status = LFR_DEFAULT; | |
438 | break; |
|
441 | break; | |
439 | } |
|
442 | } | |
440 |
|
443 | |||
441 | return status; |
|
444 | return status; | |
442 | } |
|
445 | } | |
443 |
|
446 | |||
|
447 | void update_last_valid_transition_date(unsigned int transitionCoarseTime) | |||
|
448 | { | |||
|
449 | lastValidTransitionDate = transitionCoarseTime; | |||
|
450 | } | |||
|
451 | ||||
444 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
452 | int check_transition_date( unsigned int transitionCoarseTime ) | |
445 | { |
|
453 | { | |
446 | int status; |
|
454 | int status; | |
447 | unsigned int localCoarseTime; |
|
455 | unsigned int localCoarseTime; | |
448 | unsigned int deltaCoarseTime; |
|
456 | unsigned int deltaCoarseTime; | |
449 |
|
457 | |||
450 | status = LFR_SUCCESSFUL; |
|
458 | status = LFR_SUCCESSFUL; | |
451 |
|
459 | |||
452 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
460 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition | |
453 | { |
|
461 | { | |
454 | status = LFR_SUCCESSFUL; |
|
462 | status = LFR_SUCCESSFUL; | |
455 | } |
|
463 | } | |
456 | else |
|
464 | else | |
457 | { |
|
465 | { | |
458 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
466 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; | |
459 |
|
467 | |||
460 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) |
|
468 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) | |
461 |
|
469 | |||
462 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
470 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 | |
463 | { |
|
471 | { | |
464 | status = LFR_DEFAULT; |
|
472 | status = LFR_DEFAULT; | |
465 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") |
|
473 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") | |
466 | } |
|
474 | } | |
467 |
|
475 | |||
468 | if (status == LFR_SUCCESSFUL) |
|
476 | if (status == LFR_SUCCESSFUL) | |
469 | { |
|
477 | { | |
470 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
478 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; | |
471 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
479 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 | |
472 | { |
|
480 | { | |
473 | status = LFR_DEFAULT; |
|
481 | status = LFR_DEFAULT; | |
474 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
482 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) | |
475 | } |
|
483 | } | |
476 | } |
|
484 | } | |
477 | } |
|
485 | } | |
478 |
|
486 | |||
479 | return status; |
|
487 | return status; | |
480 | } |
|
488 | } | |
481 |
|
489 | |||
482 | int restart_asm_activities( unsigned char lfrRequestedMode ) |
|
490 | int restart_asm_activities( unsigned char lfrRequestedMode ) | |
483 | { |
|
491 | { | |
484 | rtems_status_code status; |
|
492 | rtems_status_code status; | |
485 |
|
493 | |||
486 | status = stop_spectral_matrices(); |
|
494 | status = stop_spectral_matrices(); | |
487 |
|
495 | |||
488 | status = restart_asm_tasks( lfrRequestedMode ); |
|
496 | status = restart_asm_tasks( lfrRequestedMode ); | |
489 |
|
497 | |||
490 | launch_spectral_matrix(); |
|
498 | launch_spectral_matrix(); | |
491 |
|
499 | |||
492 | return status; |
|
500 | return status; | |
493 | } |
|
501 | } | |
494 |
|
502 | |||
495 | int stop_spectral_matrices( void ) |
|
503 | int stop_spectral_matrices( void ) | |
496 | { |
|
504 | { | |
497 | /** This function stops and restarts the current mode average spectral matrices activities. |
|
505 | /** This function stops and restarts the current mode average spectral matrices activities. | |
498 | * |
|
506 | * | |
499 | * @return RTEMS directive status codes: |
|
507 | * @return RTEMS directive status codes: | |
500 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
508 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
501 | * - RTEMS_INVALID_ID - task id invalid |
|
509 | * - RTEMS_INVALID_ID - task id invalid | |
502 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
510 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
503 | * |
|
511 | * | |
504 | */ |
|
512 | */ | |
505 |
|
513 | |||
506 | rtems_status_code status; |
|
514 | rtems_status_code status; | |
507 |
|
515 | |||
508 | status = RTEMS_SUCCESSFUL; |
|
516 | status = RTEMS_SUCCESSFUL; | |
509 |
|
517 | |||
510 | // (1) mask interruptions |
|
518 | // (1) mask interruptions | |
511 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
519 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
512 |
|
520 | |||
513 | // (2) reset spectral matrices registers |
|
521 | // (2) reset spectral matrices registers | |
514 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
522 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
515 | reset_sm_status(); |
|
523 | reset_sm_status(); | |
516 |
|
524 | |||
517 | // (3) clear interruptions |
|
525 | // (3) clear interruptions | |
518 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
526 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
519 |
|
527 | |||
520 | // suspend several tasks |
|
528 | // suspend several tasks | |
521 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
529 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
522 | status = suspend_asm_tasks(); |
|
530 | status = suspend_asm_tasks(); | |
523 | } |
|
531 | } | |
524 |
|
532 | |||
525 | if (status != RTEMS_SUCCESSFUL) |
|
533 | if (status != RTEMS_SUCCESSFUL) | |
526 | { |
|
534 | { | |
527 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
535 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
528 | } |
|
536 | } | |
529 |
|
537 | |||
530 | return status; |
|
538 | return status; | |
531 | } |
|
539 | } | |
532 |
|
540 | |||
533 | int stop_current_mode( void ) |
|
541 | int stop_current_mode( void ) | |
534 | { |
|
542 | { | |
535 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
543 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
536 | * |
|
544 | * | |
537 | * @return RTEMS directive status codes: |
|
545 | * @return RTEMS directive status codes: | |
538 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
546 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
539 | * - RTEMS_INVALID_ID - task id invalid |
|
547 | * - RTEMS_INVALID_ID - task id invalid | |
540 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
548 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
541 | * |
|
549 | * | |
542 | */ |
|
550 | */ | |
543 |
|
551 | |||
544 | rtems_status_code status; |
|
552 | rtems_status_code status; | |
545 |
|
553 | |||
546 | status = RTEMS_SUCCESSFUL; |
|
554 | status = RTEMS_SUCCESSFUL; | |
547 |
|
555 | |||
548 | // (1) mask interruptions |
|
556 | // (1) mask interruptions | |
549 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
557 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
550 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
558 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
551 |
|
559 | |||
552 | // (2) reset waveform picker registers |
|
560 | // (2) reset waveform picker registers | |
553 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
561 | reset_wfp_burst_enable(); // reset burst and enable bits | |
554 | reset_wfp_status(); // reset all the status bits |
|
562 | reset_wfp_status(); // reset all the status bits | |
555 |
|
563 | |||
556 | // (3) reset spectral matrices registers |
|
564 | // (3) reset spectral matrices registers | |
557 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
565 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
558 | reset_sm_status(); |
|
566 | reset_sm_status(); | |
559 |
|
567 | |||
560 | // reset lfr VHDL module |
|
568 | // reset lfr VHDL module | |
561 | reset_lfr(); |
|
569 | reset_lfr(); | |
562 |
|
570 | |||
563 | reset_extractSWF(); // reset the extractSWF flag to false |
|
571 | reset_extractSWF(); // reset the extractSWF flag to false | |
564 |
|
572 | |||
565 | // (4) clear interruptions |
|
573 | // (4) clear interruptions | |
566 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
574 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
567 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
575 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
568 |
|
576 | |||
569 | // suspend several tasks |
|
577 | // suspend several tasks | |
570 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
578 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
571 | status = suspend_science_tasks(); |
|
579 | status = suspend_science_tasks(); | |
572 | } |
|
580 | } | |
573 |
|
581 | |||
574 | if (status != RTEMS_SUCCESSFUL) |
|
582 | if (status != RTEMS_SUCCESSFUL) | |
575 | { |
|
583 | { | |
576 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
584 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
577 | } |
|
585 | } | |
578 |
|
586 | |||
579 | return status; |
|
587 | return status; | |
580 | } |
|
588 | } | |
581 |
|
589 | |||
582 | int enter_mode_standby() |
|
590 | int enter_mode_standby() | |
583 | { |
|
591 | { | |
|
592 | /** This function is used to put LFR in the STANDBY mode. | |||
|
593 | * | |||
|
594 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |||
|
595 | * | |||
|
596 | * @return RTEMS directive status codes: | |||
|
597 | * - RTEMS_SUCCESSFUL - task restarted successfully | |||
|
598 | * - RTEMS_INVALID_ID - task id invalid | |||
|
599 | * - RTEMS_INCORRECT_STATE - task never started | |||
|
600 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |||
|
601 | * | |||
|
602 | * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE | |||
|
603 | * is immediate. | |||
|
604 | * | |||
|
605 | */ | |||
|
606 | ||||
584 | int status; |
|
607 | int status; | |
585 |
|
608 | |||
586 | status = stop_current_mode(); // STOP THE CURRENT MODE |
|
609 | status = stop_current_mode(); // STOP THE CURRENT MODE | |
587 |
|
610 | |||
588 | #ifdef PRINT_TASK_STATISTICS |
|
611 | #ifdef PRINT_TASK_STATISTICS | |
589 | rtems_cpu_usage_report(); |
|
612 | rtems_cpu_usage_report(); | |
590 | #endif |
|
613 | #endif | |
591 |
|
614 | |||
592 | #ifdef PRINT_STACK_REPORT |
|
615 | #ifdef PRINT_STACK_REPORT | |
593 | PRINTF("stack report selected\n") |
|
616 | PRINTF("stack report selected\n") | |
594 | rtems_stack_checker_report_usage(); |
|
617 | rtems_stack_checker_report_usage(); | |
595 | #endif |
|
618 | #endif | |
596 |
|
619 | |||
597 | return status; |
|
620 | return status; | |
598 | } |
|
621 | } | |
599 |
|
622 | |||
600 | int enter_mode_normal( unsigned int transitionCoarseTime ) |
|
623 | int enter_mode_normal( unsigned int transitionCoarseTime ) | |
601 | { |
|
624 | { | |
|
625 | /** This function is used to start the NORMAL mode. | |||
|
626 | * | |||
|
627 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |||
|
628 | * | |||
|
629 | * @return RTEMS directive status codes: | |||
|
630 | * - RTEMS_SUCCESSFUL - task restarted successfully | |||
|
631 | * - RTEMS_INVALID_ID - task id invalid | |||
|
632 | * - RTEMS_INCORRECT_STATE - task never started | |||
|
633 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |||
|
634 | * | |||
|
635 | * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2, | |||
|
636 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. | |||
|
637 | * | |||
|
638 | */ | |||
|
639 | ||||
602 | int status; |
|
640 | int status; | |
603 |
|
641 | |||
604 | #ifdef PRINT_TASK_STATISTICS |
|
642 | #ifdef PRINT_TASK_STATISTICS | |
605 | rtems_cpu_usage_reset(); |
|
643 | rtems_cpu_usage_reset(); | |
606 | #endif |
|
644 | #endif | |
607 |
|
645 | |||
608 | status = RTEMS_UNSATISFIED; |
|
646 | status = RTEMS_UNSATISFIED; | |
609 |
|
647 | |||
610 | switch( lfrCurrentMode ) |
|
648 | switch( lfrCurrentMode ) | |
611 | { |
|
649 | { | |
612 | case LFR_MODE_STANDBY: |
|
650 | case LFR_MODE_STANDBY: | |
613 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks |
|
651 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks | |
614 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
652 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
615 | { |
|
653 | { | |
616 | launch_spectral_matrix( ); |
|
654 | launch_spectral_matrix( ); | |
617 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
655 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
618 | } |
|
656 | } | |
619 | break; |
|
657 | break; | |
620 | case LFR_MODE_BURST: |
|
658 | case LFR_MODE_BURST: | |
621 | status = stop_current_mode(); // stop the current mode |
|
659 | status = stop_current_mode(); // stop the current mode | |
622 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks |
|
660 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks | |
623 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
661 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
624 | { |
|
662 | { | |
625 | launch_spectral_matrix( ); |
|
663 | launch_spectral_matrix( ); | |
626 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
664 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
627 | } |
|
665 | } | |
628 | break; |
|
666 | break; | |
629 | case LFR_MODE_SBM1: |
|
667 | case LFR_MODE_SBM1: | |
630 | restart_asm_activities( LFR_MODE_NORMAL ); |
|
668 | restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters | |
631 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
669 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
632 | break; |
|
670 | break; | |
633 | case LFR_MODE_SBM2: |
|
671 | case LFR_MODE_SBM2: | |
634 | restart_asm_activities( LFR_MODE_NORMAL ); |
|
672 | restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters | |
635 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
673 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
636 | break; |
|
674 | break; | |
637 | default: |
|
675 | default: | |
638 | break; |
|
676 | break; | |
639 | } |
|
677 | } | |
640 |
|
678 | |||
641 | if (status != RTEMS_SUCCESSFUL) |
|
679 | if (status != RTEMS_SUCCESSFUL) | |
642 | { |
|
680 | { | |
643 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) |
|
681 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) | |
644 | status = RTEMS_UNSATISFIED; |
|
682 | status = RTEMS_UNSATISFIED; | |
645 | } |
|
683 | } | |
646 |
|
684 | |||
647 | return status; |
|
685 | return status; | |
648 | } |
|
686 | } | |
649 |
|
687 | |||
650 | int enter_mode_burst( unsigned int transitionCoarseTime ) |
|
688 | int enter_mode_burst( unsigned int transitionCoarseTime ) | |
651 | { |
|
689 | { | |
|
690 | /** This function is used to start the BURST mode. | |||
|
691 | * | |||
|
692 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |||
|
693 | * | |||
|
694 | * @return RTEMS directive status codes: | |||
|
695 | * - RTEMS_SUCCESSFUL - task restarted successfully | |||
|
696 | * - RTEMS_INVALID_ID - task id invalid | |||
|
697 | * - RTEMS_INCORRECT_STATE - task never started | |||
|
698 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |||
|
699 | * | |||
|
700 | * The way the BURST mode is started does not depend on the LFR current mode. | |||
|
701 | * | |||
|
702 | */ | |||
|
703 | ||||
|
704 | ||||
652 | int status; |
|
705 | int status; | |
653 |
|
706 | |||
654 | #ifdef PRINT_TASK_STATISTICS |
|
707 | #ifdef PRINT_TASK_STATISTICS | |
655 | rtems_cpu_usage_reset(); |
|
708 | rtems_cpu_usage_reset(); | |
656 | #endif |
|
709 | #endif | |
657 |
|
710 | |||
658 | status = stop_current_mode(); // stop the current mode |
|
711 | status = stop_current_mode(); // stop the current mode | |
659 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks |
|
712 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks | |
660 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
713 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
661 | { |
|
714 | { | |
662 | launch_spectral_matrix( ); |
|
715 | launch_spectral_matrix( ); | |
663 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); |
|
716 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); | |
664 | } |
|
717 | } | |
665 |
|
718 | |||
666 | if (status != RTEMS_SUCCESSFUL) |
|
719 | if (status != RTEMS_SUCCESSFUL) | |
667 | { |
|
720 | { | |
668 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) |
|
721 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) | |
669 | status = RTEMS_UNSATISFIED; |
|
722 | status = RTEMS_UNSATISFIED; | |
670 | } |
|
723 | } | |
671 |
|
724 | |||
672 | return status; |
|
725 | return status; | |
673 | } |
|
726 | } | |
674 |
|
727 | |||
675 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) |
|
728 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) | |
676 | { |
|
729 | { | |
|
730 | /** This function is used to start the SBM1 mode. | |||
|
731 | * | |||
|
732 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |||
|
733 | * | |||
|
734 | * @return RTEMS directive status codes: | |||
|
735 | * - RTEMS_SUCCESSFUL - task restarted successfully | |||
|
736 | * - RTEMS_INVALID_ID - task id invalid | |||
|
737 | * - RTEMS_INCORRECT_STATE - task never started | |||
|
738 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |||
|
739 | * | |||
|
740 | * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2, | |||
|
741 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other | |||
|
742 | * cases, the acquisition is completely restarted. | |||
|
743 | * | |||
|
744 | */ | |||
|
745 | ||||
677 | int status; |
|
746 | int status; | |
678 |
|
747 | |||
679 | #ifdef PRINT_TASK_STATISTICS |
|
748 | #ifdef PRINT_TASK_STATISTICS | |
680 | rtems_cpu_usage_reset(); |
|
749 | rtems_cpu_usage_reset(); | |
681 | #endif |
|
750 | #endif | |
682 |
|
751 | |||
683 | status = RTEMS_UNSATISFIED; |
|
752 | status = RTEMS_UNSATISFIED; | |
684 |
|
753 | |||
685 | switch( lfrCurrentMode ) |
|
754 | switch( lfrCurrentMode ) | |
686 | { |
|
755 | { | |
687 | case LFR_MODE_STANDBY: |
|
756 | case LFR_MODE_STANDBY: | |
688 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks |
|
757 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks | |
689 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
758 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
690 | { |
|
759 | { | |
691 | launch_spectral_matrix( ); |
|
760 | launch_spectral_matrix( ); | |
692 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
761 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
693 | } |
|
762 | } | |
694 | break; |
|
763 | break; | |
695 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action |
|
764 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action | |
696 | restart_asm_activities( LFR_MODE_SBM1 ); |
|
765 | restart_asm_activities( LFR_MODE_SBM1 ); | |
697 | status = LFR_SUCCESSFUL; |
|
766 | status = LFR_SUCCESSFUL; | |
698 | break; |
|
767 | break; | |
699 | case LFR_MODE_BURST: |
|
768 | case LFR_MODE_BURST: | |
700 | status = stop_current_mode(); // stop the current mode |
|
769 | status = stop_current_mode(); // stop the current mode | |
701 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks |
|
770 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks | |
702 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
771 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
703 | { |
|
772 | { | |
704 | launch_spectral_matrix( ); |
|
773 | launch_spectral_matrix( ); | |
705 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
774 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
706 | } |
|
775 | } | |
707 | break; |
|
776 | break; | |
708 | case LFR_MODE_SBM2: |
|
777 | case LFR_MODE_SBM2: | |
709 | restart_asm_activities( LFR_MODE_SBM1 ); |
|
778 | restart_asm_activities( LFR_MODE_SBM1 ); | |
710 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
779 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
711 | break; |
|
780 | break; | |
712 | default: |
|
781 | default: | |
713 | break; |
|
782 | break; | |
714 | } |
|
783 | } | |
715 |
|
784 | |||
716 | if (status != RTEMS_SUCCESSFUL) |
|
785 | if (status != RTEMS_SUCCESSFUL) | |
717 | { |
|
786 | { | |
718 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status) |
|
787 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status) | |
719 | status = RTEMS_UNSATISFIED; |
|
788 | status = RTEMS_UNSATISFIED; | |
720 | } |
|
789 | } | |
721 |
|
790 | |||
722 | return status; |
|
791 | return status; | |
723 | } |
|
792 | } | |
724 |
|
793 | |||
725 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) |
|
794 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) | |
726 | { |
|
795 | { | |
|
796 | /** This function is used to start the SBM2 mode. | |||
|
797 | * | |||
|
798 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |||
|
799 | * | |||
|
800 | * @return RTEMS directive status codes: | |||
|
801 | * - RTEMS_SUCCESSFUL - task restarted successfully | |||
|
802 | * - RTEMS_INVALID_ID - task id invalid | |||
|
803 | * - RTEMS_INCORRECT_STATE - task never started | |||
|
804 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |||
|
805 | * | |||
|
806 | * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1, | |||
|
807 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other | |||
|
808 | * cases, the acquisition is completely restarted. | |||
|
809 | * | |||
|
810 | */ | |||
|
811 | ||||
727 | int status; |
|
812 | int status; | |
728 |
|
813 | |||
729 | #ifdef PRINT_TASK_STATISTICS |
|
814 | #ifdef PRINT_TASK_STATISTICS | |
730 | rtems_cpu_usage_reset(); |
|
815 | rtems_cpu_usage_reset(); | |
731 | #endif |
|
816 | #endif | |
732 |
|
817 | |||
733 | status = RTEMS_UNSATISFIED; |
|
818 | status = RTEMS_UNSATISFIED; | |
734 |
|
819 | |||
735 | switch( lfrCurrentMode ) |
|
820 | switch( lfrCurrentMode ) | |
736 | { |
|
821 | { | |
737 | case LFR_MODE_STANDBY: |
|
822 | case LFR_MODE_STANDBY: | |
738 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks |
|
823 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks | |
739 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
824 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
740 | { |
|
825 | { | |
741 | launch_spectral_matrix( ); |
|
826 | launch_spectral_matrix( ); | |
742 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
827 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
743 | } |
|
828 | } | |
744 | break; |
|
829 | break; | |
745 | case LFR_MODE_NORMAL: |
|
830 | case LFR_MODE_NORMAL: | |
746 | restart_asm_activities( LFR_MODE_SBM2 ); |
|
831 | restart_asm_activities( LFR_MODE_SBM2 ); | |
747 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
832 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
748 | break; |
|
833 | break; | |
749 | case LFR_MODE_BURST: |
|
834 | case LFR_MODE_BURST: | |
750 | status = stop_current_mode(); // stop the current mode |
|
835 | status = stop_current_mode(); // stop the current mode | |
751 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks |
|
836 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks | |
752 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
837 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
753 | { |
|
838 | { | |
754 | launch_spectral_matrix( ); |
|
839 | launch_spectral_matrix( ); | |
755 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
840 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
756 | } |
|
841 | } | |
757 | break; |
|
842 | break; | |
758 | case LFR_MODE_SBM1: |
|
843 | case LFR_MODE_SBM1: | |
759 | restart_asm_activities( LFR_MODE_SBM2 ); |
|
844 | restart_asm_activities( LFR_MODE_SBM2 ); | |
760 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
845 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
761 | break; |
|
846 | break; | |
762 | default: |
|
847 | default: | |
763 | break; |
|
848 | break; | |
764 | } |
|
849 | } | |
765 |
|
850 | |||
766 | if (status != RTEMS_SUCCESSFUL) |
|
851 | if (status != RTEMS_SUCCESSFUL) | |
767 | { |
|
852 | { | |
768 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) |
|
853 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) | |
769 | status = RTEMS_UNSATISFIED; |
|
854 | status = RTEMS_UNSATISFIED; | |
770 | } |
|
855 | } | |
771 |
|
856 | |||
772 | return status; |
|
857 | return status; | |
773 | } |
|
858 | } | |
774 |
|
859 | |||
775 | int restart_science_tasks( unsigned char lfrRequestedMode ) |
|
860 | int restart_science_tasks( unsigned char lfrRequestedMode ) | |
776 | { |
|
861 | { | |
777 | /** This function is used to restart all science tasks. |
|
862 | /** This function is used to restart all science tasks. | |
778 | * |
|
863 | * | |
779 | * @return RTEMS directive status codes: |
|
864 | * @return RTEMS directive status codes: | |
780 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
865 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
781 | * - RTEMS_INVALID_ID - task id invalid |
|
866 | * - RTEMS_INVALID_ID - task id invalid | |
782 | * - RTEMS_INCORRECT_STATE - task never started |
|
867 | * - RTEMS_INCORRECT_STATE - task never started | |
783 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
868 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
784 | * |
|
869 | * | |
785 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
870 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 | |
786 | * |
|
871 | * | |
787 | */ |
|
872 | */ | |
788 |
|
873 | |||
789 | rtems_status_code status[10]; |
|
874 | rtems_status_code status[10]; | |
790 | rtems_status_code ret; |
|
875 | rtems_status_code ret; | |
791 |
|
876 | |||
792 | ret = RTEMS_SUCCESSFUL; |
|
877 | ret = RTEMS_SUCCESSFUL; | |
793 |
|
878 | |||
794 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
879 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
795 | if (status[0] != RTEMS_SUCCESSFUL) |
|
880 | if (status[0] != RTEMS_SUCCESSFUL) | |
796 | { |
|
881 | { | |
797 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
882 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
798 | } |
|
883 | } | |
799 |
|
884 | |||
800 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
885 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
801 | if (status[1] != RTEMS_SUCCESSFUL) |
|
886 | if (status[1] != RTEMS_SUCCESSFUL) | |
802 | { |
|
887 | { | |
803 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
888 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
804 | } |
|
889 | } | |
805 |
|
890 | |||
806 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
891 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
807 | if (status[2] != RTEMS_SUCCESSFUL) |
|
892 | if (status[2] != RTEMS_SUCCESSFUL) | |
808 | { |
|
893 | { | |
809 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) |
|
894 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) | |
810 | } |
|
895 | } | |
811 |
|
896 | |||
812 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
897 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
813 | if (status[3] != RTEMS_SUCCESSFUL) |
|
898 | if (status[3] != RTEMS_SUCCESSFUL) | |
814 | { |
|
899 | { | |
815 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) |
|
900 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) | |
816 | } |
|
901 | } | |
817 |
|
902 | |||
818 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
903 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
819 | if (status[4] != RTEMS_SUCCESSFUL) |
|
904 | if (status[4] != RTEMS_SUCCESSFUL) | |
820 | { |
|
905 | { | |
821 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) |
|
906 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) | |
822 | } |
|
907 | } | |
823 |
|
908 | |||
824 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
909 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
825 | if (status[5] != RTEMS_SUCCESSFUL) |
|
910 | if (status[5] != RTEMS_SUCCESSFUL) | |
826 | { |
|
911 | { | |
827 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) |
|
912 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) | |
828 | } |
|
913 | } | |
829 |
|
914 | |||
830 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
915 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
831 | if (status[6] != RTEMS_SUCCESSFUL) |
|
916 | if (status[6] != RTEMS_SUCCESSFUL) | |
832 | { |
|
917 | { | |
833 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) |
|
918 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) | |
834 | } |
|
919 | } | |
835 |
|
920 | |||
836 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
921 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
837 | if (status[7] != RTEMS_SUCCESSFUL) |
|
922 | if (status[7] != RTEMS_SUCCESSFUL) | |
838 | { |
|
923 | { | |
839 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) |
|
924 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) | |
840 | } |
|
925 | } | |
841 |
|
926 | |||
842 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
927 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
843 | if (status[8] != RTEMS_SUCCESSFUL) |
|
928 | if (status[8] != RTEMS_SUCCESSFUL) | |
844 | { |
|
929 | { | |
845 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) |
|
930 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) | |
846 | } |
|
931 | } | |
847 |
|
932 | |||
848 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
933 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
849 | if (status[9] != RTEMS_SUCCESSFUL) |
|
934 | if (status[9] != RTEMS_SUCCESSFUL) | |
850 | { |
|
935 | { | |
851 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) |
|
936 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) | |
852 | } |
|
937 | } | |
853 |
|
938 | |||
854 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
939 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
855 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
940 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
856 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || |
|
941 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || | |
857 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || |
|
942 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || | |
858 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) |
|
943 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) | |
859 | { |
|
944 | { | |
860 | ret = RTEMS_UNSATISFIED; |
|
945 | ret = RTEMS_UNSATISFIED; | |
861 | } |
|
946 | } | |
862 |
|
947 | |||
863 | return ret; |
|
948 | return ret; | |
864 | } |
|
949 | } | |
865 |
|
950 | |||
866 | int restart_asm_tasks( unsigned char lfrRequestedMode ) |
|
951 | int restart_asm_tasks( unsigned char lfrRequestedMode ) | |
867 | { |
|
952 | { | |
868 | /** This function is used to restart average spectral matrices tasks. |
|
953 | /** This function is used to restart average spectral matrices tasks. | |
869 | * |
|
954 | * | |
870 | * @return RTEMS directive status codes: |
|
955 | * @return RTEMS directive status codes: | |
871 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
956 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
872 | * - RTEMS_INVALID_ID - task id invalid |
|
957 | * - RTEMS_INVALID_ID - task id invalid | |
873 | * - RTEMS_INCORRECT_STATE - task never started |
|
958 | * - RTEMS_INCORRECT_STATE - task never started | |
874 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
959 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
875 | * |
|
960 | * | |
876 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 |
|
961 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 | |
877 | * |
|
962 | * | |
878 | */ |
|
963 | */ | |
879 |
|
964 | |||
880 | rtems_status_code status[6]; |
|
965 | rtems_status_code status[6]; | |
881 | rtems_status_code ret; |
|
966 | rtems_status_code ret; | |
882 |
|
967 | |||
883 | ret = RTEMS_SUCCESSFUL; |
|
968 | ret = RTEMS_SUCCESSFUL; | |
884 |
|
969 | |||
885 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
970 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
886 | if (status[0] != RTEMS_SUCCESSFUL) |
|
971 | if (status[0] != RTEMS_SUCCESSFUL) | |
887 | { |
|
972 | { | |
888 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
973 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
889 | } |
|
974 | } | |
890 |
|
975 | |||
891 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
976 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
892 | if (status[1] != RTEMS_SUCCESSFUL) |
|
977 | if (status[1] != RTEMS_SUCCESSFUL) | |
893 | { |
|
978 | { | |
894 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
979 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
895 | } |
|
980 | } | |
896 |
|
981 | |||
897 | status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
982 | status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
898 | if (status[2] != RTEMS_SUCCESSFUL) |
|
983 | if (status[2] != RTEMS_SUCCESSFUL) | |
899 | { |
|
984 | { | |
900 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2]) |
|
985 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2]) | |
901 | } |
|
986 | } | |
902 |
|
987 | |||
903 | status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
988 | status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
904 | if (status[3] != RTEMS_SUCCESSFUL) |
|
989 | if (status[3] != RTEMS_SUCCESSFUL) | |
905 | { |
|
990 | { | |
906 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3]) |
|
991 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3]) | |
907 | } |
|
992 | } | |
908 |
|
993 | |||
909 | status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
994 | status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
910 | if (status[4] != RTEMS_SUCCESSFUL) |
|
995 | if (status[4] != RTEMS_SUCCESSFUL) | |
911 | { |
|
996 | { | |
912 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4]) |
|
997 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4]) | |
913 | } |
|
998 | } | |
914 |
|
999 | |||
915 | status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
1000 | status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
916 | if (status[5] != RTEMS_SUCCESSFUL) |
|
1001 | if (status[5] != RTEMS_SUCCESSFUL) | |
917 | { |
|
1002 | { | |
918 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5]) |
|
1003 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5]) | |
919 | } |
|
1004 | } | |
920 |
|
1005 | |||
921 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
1006 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
922 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
1007 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
923 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) |
|
1008 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) | |
924 | { |
|
1009 | { | |
925 | ret = RTEMS_UNSATISFIED; |
|
1010 | ret = RTEMS_UNSATISFIED; | |
926 | } |
|
1011 | } | |
927 |
|
1012 | |||
928 | return ret; |
|
1013 | return ret; | |
929 | } |
|
1014 | } | |
930 |
|
1015 | |||
931 | int suspend_science_tasks( void ) |
|
1016 | int suspend_science_tasks( void ) | |
932 | { |
|
1017 | { | |
933 | /** This function suspends the science tasks. |
|
1018 | /** This function suspends the science tasks. | |
934 | * |
|
1019 | * | |
935 | * @return RTEMS directive status codes: |
|
1020 | * @return RTEMS directive status codes: | |
936 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1021 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
937 | * - RTEMS_INVALID_ID - task id invalid |
|
1022 | * - RTEMS_INVALID_ID - task id invalid | |
938 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1023 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
939 | * |
|
1024 | * | |
940 | */ |
|
1025 | */ | |
941 |
|
1026 | |||
942 | rtems_status_code status; |
|
1027 | rtems_status_code status; | |
943 |
|
1028 | |||
944 | PRINTF("in suspend_science_tasks\n") |
|
1029 | PRINTF("in suspend_science_tasks\n") | |
945 |
|
1030 | |||
946 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
1031 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
947 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1032 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
948 | { |
|
1033 | { | |
949 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1034 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
950 | } |
|
1035 | } | |
951 | else |
|
1036 | else | |
952 | { |
|
1037 | { | |
953 | status = RTEMS_SUCCESSFUL; |
|
1038 | status = RTEMS_SUCCESSFUL; | |
954 | } |
|
1039 | } | |
955 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
1040 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
956 | { |
|
1041 | { | |
957 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
1042 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
958 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1043 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
959 | { |
|
1044 | { | |
960 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
1045 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
961 | } |
|
1046 | } | |
962 | else |
|
1047 | else | |
963 | { |
|
1048 | { | |
964 | status = RTEMS_SUCCESSFUL; |
|
1049 | status = RTEMS_SUCCESSFUL; | |
965 | } |
|
1050 | } | |
966 | } |
|
1051 | } | |
967 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
1052 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
968 | { |
|
1053 | { | |
969 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
1054 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
970 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1055 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
971 | { |
|
1056 | { | |
972 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
1057 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
973 | } |
|
1058 | } | |
974 | else |
|
1059 | else | |
975 | { |
|
1060 | { | |
976 | status = RTEMS_SUCCESSFUL; |
|
1061 | status = RTEMS_SUCCESSFUL; | |
977 | } |
|
1062 | } | |
978 | } |
|
1063 | } | |
979 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
1064 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
980 | { |
|
1065 | { | |
981 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
1066 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
982 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1067 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
983 | { |
|
1068 | { | |
984 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
1069 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
985 | } |
|
1070 | } | |
986 | else |
|
1071 | else | |
987 | { |
|
1072 | { | |
988 | status = RTEMS_SUCCESSFUL; |
|
1073 | status = RTEMS_SUCCESSFUL; | |
989 | } |
|
1074 | } | |
990 | } |
|
1075 | } | |
991 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
1076 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
992 | { |
|
1077 | { | |
993 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
1078 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
994 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1079 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
995 | { |
|
1080 | { | |
996 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
1081 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
997 | } |
|
1082 | } | |
998 | else |
|
1083 | else | |
999 | { |
|
1084 | { | |
1000 | status = RTEMS_SUCCESSFUL; |
|
1085 | status = RTEMS_SUCCESSFUL; | |
1001 | } |
|
1086 | } | |
1002 | } |
|
1087 | } | |
1003 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1088 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1004 | { |
|
1089 | { | |
1005 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1090 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1006 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1091 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1007 | { |
|
1092 | { | |
1008 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1093 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1009 | } |
|
1094 | } | |
1010 | else |
|
1095 | else | |
1011 | { |
|
1096 | { | |
1012 | status = RTEMS_SUCCESSFUL; |
|
1097 | status = RTEMS_SUCCESSFUL; | |
1013 | } |
|
1098 | } | |
1014 | } |
|
1099 | } | |
1015 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
1100 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
1016 | { |
|
1101 | { | |
1017 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
1102 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
1018 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1103 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1019 | { |
|
1104 | { | |
1020 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
1105 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
1021 | } |
|
1106 | } | |
1022 | else |
|
1107 | else | |
1023 | { |
|
1108 | { | |
1024 | status = RTEMS_SUCCESSFUL; |
|
1109 | status = RTEMS_SUCCESSFUL; | |
1025 | } |
|
1110 | } | |
1026 | } |
|
1111 | } | |
1027 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
1112 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
1028 | { |
|
1113 | { | |
1029 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
1114 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
1030 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1115 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1031 | { |
|
1116 | { | |
1032 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
1117 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
1033 | } |
|
1118 | } | |
1034 | else |
|
1119 | else | |
1035 | { |
|
1120 | { | |
1036 | status = RTEMS_SUCCESSFUL; |
|
1121 | status = RTEMS_SUCCESSFUL; | |
1037 | } |
|
1122 | } | |
1038 | } |
|
1123 | } | |
1039 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
1124 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
1040 | { |
|
1125 | { | |
1041 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
1126 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
1042 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1127 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1043 | { |
|
1128 | { | |
1044 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
1129 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
1045 | } |
|
1130 | } | |
1046 | else |
|
1131 | else | |
1047 | { |
|
1132 | { | |
1048 | status = RTEMS_SUCCESSFUL; |
|
1133 | status = RTEMS_SUCCESSFUL; | |
1049 | } |
|
1134 | } | |
1050 | } |
|
1135 | } | |
1051 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
1136 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
1052 | { |
|
1137 | { | |
1053 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
1138 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
1054 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1139 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1055 | { |
|
1140 | { | |
1056 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
1141 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
1057 | } |
|
1142 | } | |
1058 | else |
|
1143 | else | |
1059 | { |
|
1144 | { | |
1060 | status = RTEMS_SUCCESSFUL; |
|
1145 | status = RTEMS_SUCCESSFUL; | |
1061 | } |
|
1146 | } | |
1062 | } |
|
1147 | } | |
1063 |
|
1148 | |||
1064 | return status; |
|
1149 | return status; | |
1065 | } |
|
1150 | } | |
1066 |
|
1151 | |||
1067 | int suspend_asm_tasks( void ) |
|
1152 | int suspend_asm_tasks( void ) | |
1068 | { |
|
1153 | { | |
1069 | /** This function suspends the science tasks. |
|
1154 | /** This function suspends the science tasks. | |
1070 | * |
|
1155 | * | |
1071 | * @return RTEMS directive status codes: |
|
1156 | * @return RTEMS directive status codes: | |
1072 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1157 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1073 | * - RTEMS_INVALID_ID - task id invalid |
|
1158 | * - RTEMS_INVALID_ID - task id invalid | |
1074 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1159 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
1075 | * |
|
1160 | * | |
1076 | */ |
|
1161 | */ | |
1077 |
|
1162 | |||
1078 | rtems_status_code status; |
|
1163 | rtems_status_code status; | |
1079 |
|
1164 | |||
1080 | PRINTF("in suspend_science_tasks\n") |
|
1165 | PRINTF("in suspend_science_tasks\n") | |
1081 |
|
1166 | |||
1082 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
1167 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
1083 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1168 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1084 | { |
|
1169 | { | |
1085 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1170 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
1086 | } |
|
1171 | } | |
1087 | else |
|
1172 | else | |
1088 | { |
|
1173 | { | |
1089 | status = RTEMS_SUCCESSFUL; |
|
1174 | status = RTEMS_SUCCESSFUL; | |
1090 | } |
|
1175 | } | |
1091 |
|
1176 | |||
1092 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
1177 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
1093 | { |
|
1178 | { | |
1094 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
1179 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
1095 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1180 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1096 | { |
|
1181 | { | |
1097 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
1182 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
1098 | } |
|
1183 | } | |
1099 | else |
|
1184 | else | |
1100 | { |
|
1185 | { | |
1101 | status = RTEMS_SUCCESSFUL; |
|
1186 | status = RTEMS_SUCCESSFUL; | |
1102 | } |
|
1187 | } | |
1103 | } |
|
1188 | } | |
1104 |
|
1189 | |||
1105 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
1190 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
1106 | { |
|
1191 | { | |
1107 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
1192 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
1108 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1193 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1109 | { |
|
1194 | { | |
1110 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
1195 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
1111 | } |
|
1196 | } | |
1112 | else |
|
1197 | else | |
1113 | { |
|
1198 | { | |
1114 | status = RTEMS_SUCCESSFUL; |
|
1199 | status = RTEMS_SUCCESSFUL; | |
1115 | } |
|
1200 | } | |
1116 | } |
|
1201 | } | |
1117 |
|
1202 | |||
1118 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
1203 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
1119 | { |
|
1204 | { | |
1120 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
1205 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
1121 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1206 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1122 | { |
|
1207 | { | |
1123 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
1208 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
1124 | } |
|
1209 | } | |
1125 | else |
|
1210 | else | |
1126 | { |
|
1211 | { | |
1127 | status = RTEMS_SUCCESSFUL; |
|
1212 | status = RTEMS_SUCCESSFUL; | |
1128 | } |
|
1213 | } | |
1129 | } |
|
1214 | } | |
1130 |
|
1215 | |||
1131 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
1216 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
1132 | { |
|
1217 | { | |
1133 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
1218 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
1134 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1219 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1135 | { |
|
1220 | { | |
1136 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
1221 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
1137 | } |
|
1222 | } | |
1138 | else |
|
1223 | else | |
1139 | { |
|
1224 | { | |
1140 | status = RTEMS_SUCCESSFUL; |
|
1225 | status = RTEMS_SUCCESSFUL; | |
1141 | } |
|
1226 | } | |
1142 | } |
|
1227 | } | |
1143 |
|
1228 | |||
1144 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1229 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1145 | { |
|
1230 | { | |
1146 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1231 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1147 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1232 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1148 | { |
|
1233 | { | |
1149 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1234 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1150 | } |
|
1235 | } | |
1151 | else |
|
1236 | else | |
1152 | { |
|
1237 | { | |
1153 | status = RTEMS_SUCCESSFUL; |
|
1238 | status = RTEMS_SUCCESSFUL; | |
1154 | } |
|
1239 | } | |
1155 | } |
|
1240 | } | |
1156 |
|
1241 | |||
1157 | return status; |
|
1242 | return status; | |
1158 | } |
|
1243 | } | |
1159 |
|
1244 | |||
1160 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
1245 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) | |
1161 | { |
|
1246 | { | |
1162 | WFP_reset_current_ring_nodes(); |
|
1247 | WFP_reset_current_ring_nodes(); | |
1163 |
|
1248 | |||
1164 | reset_waveform_picker_regs(); |
|
1249 | reset_waveform_picker_regs(); | |
1165 |
|
1250 | |||
1166 | set_wfp_burst_enable_register( mode ); |
|
1251 | set_wfp_burst_enable_register( mode ); | |
1167 |
|
1252 | |||
1168 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1253 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
1169 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1254 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
1170 |
|
1255 | |||
1171 | if (transitionCoarseTime == 0) |
|
1256 | if (transitionCoarseTime == 0) | |
1172 | { |
|
1257 | { | |
1173 | waveform_picker_regs->start_date = time_management_regs->coarse_time; |
|
1258 | waveform_picker_regs->start_date = time_management_regs->coarse_time; | |
1174 | } |
|
1259 | } | |
1175 | else |
|
1260 | else | |
1176 | { |
|
1261 | { | |
1177 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
1262 | waveform_picker_regs->start_date = transitionCoarseTime; | |
1178 | } |
|
1263 | } | |
1179 |
|
1264 | |||
1180 | } |
|
1265 | } | |
1181 |
|
1266 | |||
1182 | void launch_spectral_matrix( void ) |
|
1267 | void launch_spectral_matrix( void ) | |
1183 | { |
|
1268 | { | |
1184 | SM_reset_current_ring_nodes(); |
|
1269 | SM_reset_current_ring_nodes(); | |
1185 |
|
1270 | |||
1186 | reset_spectral_matrix_regs(); |
|
1271 | reset_spectral_matrix_regs(); | |
1187 |
|
1272 | |||
1188 | reset_nb_sm(); |
|
1273 | reset_nb_sm(); | |
1189 |
|
1274 | |||
1190 | set_sm_irq_onNewMatrix( 1 ); |
|
1275 | set_sm_irq_onNewMatrix( 1 ); | |
1191 |
|
1276 | |||
1192 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1277 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1193 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1278 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1194 |
|
1279 | |||
1195 | } |
|
1280 | } | |
1196 |
|
1281 | |||
1197 | void set_sm_irq_onNewMatrix( unsigned char value ) |
|
1282 | void set_sm_irq_onNewMatrix( unsigned char value ) | |
1198 | { |
|
1283 | { | |
1199 | if (value == 1) |
|
1284 | if (value == 1) | |
1200 | { |
|
1285 | { | |
1201 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
1286 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; | |
1202 | } |
|
1287 | } | |
1203 | else |
|
1288 | else | |
1204 | { |
|
1289 | { | |
1205 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
1290 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 | |
1206 | } |
|
1291 | } | |
1207 | } |
|
1292 | } | |
1208 |
|
1293 | |||
1209 | void set_sm_irq_onError( unsigned char value ) |
|
1294 | void set_sm_irq_onError( unsigned char value ) | |
1210 | { |
|
1295 | { | |
1211 | if (value == 1) |
|
1296 | if (value == 1) | |
1212 | { |
|
1297 | { | |
1213 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; |
|
1298 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; | |
1214 | } |
|
1299 | } | |
1215 | else |
|
1300 | else | |
1216 | { |
|
1301 | { | |
1217 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 |
|
1302 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 | |
1218 | } |
|
1303 | } | |
1219 | } |
|
1304 | } | |
1220 |
|
1305 | |||
1221 | //***************************** |
|
1306 | //***************************** | |
1222 | // CONFIGURE CALIBRATION SIGNAL |
|
1307 | // CONFIGURE CALIBRATION SIGNAL | |
1223 | void setCalibrationPrescaler( unsigned int prescaler ) |
|
1308 | void setCalibrationPrescaler( unsigned int prescaler ) | |
1224 | { |
|
1309 | { | |
1225 | // prescaling of the master clock (25 MHz) |
|
1310 | // prescaling of the master clock (25 MHz) | |
1226 | // master clock is divided by 2^prescaler |
|
1311 | // master clock is divided by 2^prescaler | |
1227 | time_management_regs->calPrescaler = prescaler; |
|
1312 | time_management_regs->calPrescaler = prescaler; | |
1228 | } |
|
1313 | } | |
1229 |
|
1314 | |||
1230 | void setCalibrationDivisor( unsigned int divisionFactor ) |
|
1315 | void setCalibrationDivisor( unsigned int divisionFactor ) | |
1231 | { |
|
1316 | { | |
1232 | // division of the prescaled clock by the division factor |
|
1317 | // division of the prescaled clock by the division factor | |
1233 | time_management_regs->calDivisor = divisionFactor; |
|
1318 | time_management_regs->calDivisor = divisionFactor; | |
1234 | } |
|
1319 | } | |
1235 |
|
1320 | |||
1236 | void setCalibrationData( void ){ |
|
1321 | void setCalibrationData( void ){ | |
1237 | unsigned int k; |
|
1322 | unsigned int k; | |
1238 | unsigned short data; |
|
1323 | unsigned short data; | |
1239 | float val; |
|
1324 | float val; | |
1240 | float f0; |
|
1325 | float f0; | |
1241 | float f1; |
|
1326 | float f1; | |
1242 | float fs; |
|
1327 | float fs; | |
1243 | float Ts; |
|
1328 | float Ts; | |
1244 | float scaleFactor; |
|
1329 | float scaleFactor; | |
1245 |
|
1330 | |||
1246 | f0 = 625; |
|
1331 | f0 = 625; | |
1247 | f1 = 10000; |
|
1332 | f1 = 10000; | |
1248 | fs = 160256.410; |
|
1333 | fs = 160256.410; | |
1249 | Ts = 1. / fs; |
|
1334 | Ts = 1. / fs; | |
1250 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV |
|
1335 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV | |
1251 |
|
1336 | |||
1252 | time_management_regs->calDataPtr = 0x00; |
|
1337 | time_management_regs->calDataPtr = 0x00; | |
1253 |
|
1338 | |||
1254 | // build the signal for the SCM calibration |
|
1339 | // build the signal for the SCM calibration | |
1255 | for (k=0; k<256; k++) |
|
1340 | for (k=0; k<256; k++) | |
1256 | { |
|
1341 | { | |
1257 | val = sin( 2 * pi * f0 * k * Ts ) |
|
1342 | val = sin( 2 * pi * f0 * k * Ts ) | |
1258 | + sin( 2 * pi * f1 * k * Ts ); |
|
1343 | + sin( 2 * pi * f1 * k * Ts ); | |
1259 | data = (unsigned short) ((val * scaleFactor) + 2048); |
|
1344 | data = (unsigned short) ((val * scaleFactor) + 2048); | |
1260 | time_management_regs->calData = data & 0xfff; |
|
1345 | time_management_regs->calData = data & 0xfff; | |
1261 | } |
|
1346 | } | |
1262 | } |
|
1347 | } | |
1263 |
|
1348 | |||
1264 | void setCalibrationDataInterleaved( void ){ |
|
1349 | void setCalibrationDataInterleaved( void ){ | |
1265 | unsigned int k; |
|
1350 | unsigned int k; | |
1266 | float val; |
|
1351 | float val; | |
1267 | float f0; |
|
1352 | float f0; | |
1268 | float f1; |
|
1353 | float f1; | |
1269 | float fs; |
|
1354 | float fs; | |
1270 | float Ts; |
|
1355 | float Ts; | |
1271 | unsigned short data[384]; |
|
1356 | unsigned short data[384]; | |
1272 | unsigned char *dataPtr; |
|
1357 | unsigned char *dataPtr; | |
1273 |
|
1358 | |||
1274 | f0 = 625; |
|
1359 | f0 = 625; | |
1275 | f1 = 10000; |
|
1360 | f1 = 10000; | |
1276 | fs = 240384.615; |
|
1361 | fs = 240384.615; | |
1277 | Ts = 1. / fs; |
|
1362 | Ts = 1. / fs; | |
1278 |
|
1363 | |||
1279 | time_management_regs->calDataPtr = 0x00; |
|
1364 | time_management_regs->calDataPtr = 0x00; | |
1280 |
|
1365 | |||
1281 | // build the signal for the SCM calibration |
|
1366 | // build the signal for the SCM calibration | |
1282 | for (k=0; k<384; k++) |
|
1367 | for (k=0; k<384; k++) | |
1283 | { |
|
1368 | { | |
1284 | val = sin( 2 * pi * f0 * k * Ts ) |
|
1369 | val = sin( 2 * pi * f0 * k * Ts ) | |
1285 | + sin( 2 * pi * f1 * k * Ts ); |
|
1370 | + sin( 2 * pi * f1 * k * Ts ); | |
1286 | data[k] = (unsigned short) (val * 512 + 2048); |
|
1371 | data[k] = (unsigned short) (val * 512 + 2048); | |
1287 | } |
|
1372 | } | |
1288 |
|
1373 | |||
1289 | // write the signal in interleaved mode |
|
1374 | // write the signal in interleaved mode | |
1290 | for (k=0; k<128; k++) |
|
1375 | for (k=0; k<128; k++) | |
1291 | { |
|
1376 | { | |
1292 | dataPtr = (unsigned char*) &data[k*3 + 2]; |
|
1377 | dataPtr = (unsigned char*) &data[k*3 + 2]; | |
1293 | time_management_regs->calData = (data[k*3] & 0xfff) |
|
1378 | time_management_regs->calData = (data[k*3] & 0xfff) | |
1294 | + ( (dataPtr[0] & 0x3f) << 12); |
|
1379 | + ( (dataPtr[0] & 0x3f) << 12); | |
1295 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) |
|
1380 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) | |
1296 | + ( (dataPtr[1] & 0x3f) << 12); |
|
1381 | + ( (dataPtr[1] & 0x3f) << 12); | |
1297 | } |
|
1382 | } | |
1298 | } |
|
1383 | } | |
1299 |
|
1384 | |||
1300 | void setCalibrationReload( bool state) |
|
1385 | void setCalibrationReload( bool state) | |
1301 | { |
|
1386 | { | |
1302 | if (state == true) |
|
1387 | if (state == true) | |
1303 | { |
|
1388 | { | |
1304 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] |
|
1389 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] | |
1305 | } |
|
1390 | } | |
1306 | else |
|
1391 | else | |
1307 | { |
|
1392 | { | |
1308 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] |
|
1393 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] | |
1309 | } |
|
1394 | } | |
1310 | } |
|
1395 | } | |
1311 |
|
1396 | |||
1312 | void setCalibrationEnable( bool state ) |
|
1397 | void setCalibrationEnable( bool state ) | |
1313 | { |
|
1398 | { | |
1314 | // this bit drives the multiplexer |
|
1399 | // this bit drives the multiplexer | |
1315 | if (state == true) |
|
1400 | if (state == true) | |
1316 | { |
|
1401 | { | |
1317 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] |
|
1402 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] | |
1318 | } |
|
1403 | } | |
1319 | else |
|
1404 | else | |
1320 | { |
|
1405 | { | |
1321 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] |
|
1406 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] | |
1322 | } |
|
1407 | } | |
1323 | } |
|
1408 | } | |
1324 |
|
1409 | |||
1325 | void setCalibrationInterleaved( bool state ) |
|
1410 | void setCalibrationInterleaved( bool state ) | |
1326 | { |
|
1411 | { | |
1327 | // this bit drives the multiplexer |
|
1412 | // this bit drives the multiplexer | |
1328 | if (state == true) |
|
1413 | if (state == true) | |
1329 | { |
|
1414 | { | |
1330 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] |
|
1415 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] | |
1331 | } |
|
1416 | } | |
1332 | else |
|
1417 | else | |
1333 | { |
|
1418 | { | |
1334 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] |
|
1419 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] | |
1335 | } |
|
1420 | } | |
1336 | } |
|
1421 | } | |
1337 |
|
1422 | |||
1338 | void setCalibration( bool state ) |
|
1423 | void setCalibration( bool state ) | |
1339 | { |
|
1424 | { | |
1340 | if (state == true) |
|
1425 | if (state == true) | |
1341 | { |
|
1426 | { | |
1342 | setCalibrationEnable( true ); |
|
1427 | setCalibrationEnable( true ); | |
1343 | setCalibrationReload( false ); |
|
1428 | setCalibrationReload( false ); | |
1344 | set_hk_lfr_calib_enable( true ); |
|
1429 | set_hk_lfr_calib_enable( true ); | |
1345 | } |
|
1430 | } | |
1346 | else |
|
1431 | else | |
1347 | { |
|
1432 | { | |
1348 | setCalibrationEnable( false ); |
|
1433 | setCalibrationEnable( false ); | |
1349 | setCalibrationReload( true ); |
|
1434 | setCalibrationReload( true ); | |
1350 | set_hk_lfr_calib_enable( false ); |
|
1435 | set_hk_lfr_calib_enable( false ); | |
1351 | } |
|
1436 | } | |
1352 | } |
|
1437 | } | |
1353 |
|
1438 | |||
1354 | void configureCalibration( bool interleaved ) |
|
1439 | void configureCalibration( bool interleaved ) | |
1355 | { |
|
1440 | { | |
1356 | setCalibration( false ); |
|
1441 | setCalibration( false ); | |
1357 | if ( interleaved == true ) |
|
1442 | if ( interleaved == true ) | |
1358 | { |
|
1443 | { | |
1359 | setCalibrationInterleaved( true ); |
|
1444 | setCalibrationInterleaved( true ); | |
1360 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1445 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1361 | setCalibrationDivisor( 26 ); // => 240 384 |
|
1446 | setCalibrationDivisor( 26 ); // => 240 384 | |
1362 | setCalibrationDataInterleaved(); |
|
1447 | setCalibrationDataInterleaved(); | |
1363 | } |
|
1448 | } | |
1364 | else |
|
1449 | else | |
1365 | { |
|
1450 | { | |
1366 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1451 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1367 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) |
|
1452 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) | |
1368 | setCalibrationData(); |
|
1453 | setCalibrationData(); | |
1369 | } |
|
1454 | } | |
1370 | } |
|
1455 | } | |
1371 |
|
1456 | |||
1372 | //**************** |
|
1457 | //**************** | |
1373 | // CLOSING ACTIONS |
|
1458 | // CLOSING ACTIONS | |
1374 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1459 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1375 | { |
|
1460 | { | |
1376 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
1461 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
1377 | * |
|
1462 | * | |
1378 | * @param TC points to the TC being processed |
|
1463 | * @param TC points to the TC being processed | |
1379 | * @param time is the time used to date the TC execution |
|
1464 | * @param time is the time used to date the TC execution | |
1380 | * |
|
1465 | * | |
1381 | */ |
|
1466 | */ | |
1382 |
|
1467 | |||
1383 | unsigned int val; |
|
1468 | unsigned int val; | |
1384 |
|
1469 | |||
1385 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1470 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
1386 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1471 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
1387 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
1472 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | |
1388 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1473 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
1389 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
1474 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | |
1390 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1475 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
1391 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
1476 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; | |
1392 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
1477 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; | |
1393 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
1478 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; | |
1394 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
1479 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; | |
1395 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
1480 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; | |
1396 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
1481 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; | |
1397 |
|
1482 | |||
1398 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
1483 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
1399 | val++; |
|
1484 | val++; | |
1400 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1485 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); | |
1401 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
1486 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
1402 | } |
|
1487 | } | |
1403 |
|
1488 | |||
1404 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1489 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1405 | { |
|
1490 | { | |
1406 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
1491 | /** This function is used to update the HK packets statistics after a TC rejection. | |
1407 | * |
|
1492 | * | |
1408 | * @param TC points to the TC being processed |
|
1493 | * @param TC points to the TC being processed | |
1409 | * @param time is the time used to date the TC rejection |
|
1494 | * @param time is the time used to date the TC rejection | |
1410 | * |
|
1495 | * | |
1411 | */ |
|
1496 | */ | |
1412 |
|
1497 | |||
1413 | unsigned int val; |
|
1498 | unsigned int val; | |
1414 |
|
1499 | |||
1415 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1500 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
1416 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1501 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
1417 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
1502 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | |
1418 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1503 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
1419 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
1504 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | |
1420 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1505 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
1421 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
1506 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; | |
1422 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
1507 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; | |
1423 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
1508 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; | |
1424 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
1509 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; | |
1425 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
1510 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; | |
1426 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
1511 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; | |
1427 |
|
1512 | |||
1428 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
1513 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
1429 | val++; |
|
1514 | val++; | |
1430 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1515 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); | |
1431 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
1516 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
1432 | } |
|
1517 | } | |
1433 |
|
1518 | |||
1434 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
1519 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) | |
1435 | { |
|
1520 | { | |
1436 | /** This function is the last step of the TC execution workflow. |
|
1521 | /** This function is the last step of the TC execution workflow. | |
1437 | * |
|
1522 | * | |
1438 | * @param TC points to the TC being processed |
|
1523 | * @param TC points to the TC being processed | |
1439 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
1524 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
1440 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
1525 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
1441 | * @param time is the time used to date the TC execution |
|
1526 | * @param time is the time used to date the TC execution | |
1442 | * |
|
1527 | * | |
1443 | */ |
|
1528 | */ | |
1444 |
|
1529 | |||
1445 | unsigned char requestedMode; |
|
1530 | unsigned char requestedMode; | |
1446 |
|
1531 | |||
1447 | if (result == LFR_SUCCESSFUL) |
|
1532 | if (result == LFR_SUCCESSFUL) | |
1448 | { |
|
1533 | { | |
1449 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
1534 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
1450 | & |
|
1535 | & | |
1451 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
1536 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
1452 | ) |
|
1537 | ) | |
1453 | { |
|
1538 | { | |
1454 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1539 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
1455 | } |
|
1540 | } | |
1456 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
1541 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) | |
1457 | { |
|
1542 | { | |
1458 | //********************************** |
|
1543 | //********************************** | |
1459 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
1544 | // UPDATE THE LFRMODE LOCAL VARIABLE | |
1460 | requestedMode = TC->dataAndCRC[1]; |
|
1545 | requestedMode = TC->dataAndCRC[1]; | |
1461 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
1546 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); | |
1462 | updateLFRCurrentMode(); |
|
1547 | updateLFRCurrentMode(); | |
1463 | } |
|
1548 | } | |
1464 | } |
|
1549 | } | |
1465 | else if (result == LFR_EXE_ERROR) |
|
1550 | else if (result == LFR_EXE_ERROR) | |
1466 | { |
|
1551 | { | |
1467 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
1552 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
1468 | } |
|
1553 | } | |
1469 | } |
|
1554 | } | |
1470 |
|
1555 | |||
1471 | //*************************** |
|
1556 | //*************************** | |
1472 | // Interrupt Service Routines |
|
1557 | // Interrupt Service Routines | |
1473 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1558 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
1474 | { |
|
1559 | { | |
1475 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1560 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1476 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") |
|
1561 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") | |
1477 | } |
|
1562 | } | |
1478 | } |
|
1563 | } | |
1479 |
|
1564 | |||
1480 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1565 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
1481 | { |
|
1566 | { | |
1482 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1567 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1483 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") |
|
1568 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") | |
1484 | } |
|
1569 | } | |
1485 | } |
|
1570 | } | |
1486 |
|
1571 | |||
1487 | //**************** |
|
1572 | //**************** | |
1488 | // OTHER FUNCTIONS |
|
1573 | // OTHER FUNCTIONS | |
1489 | void updateLFRCurrentMode() |
|
1574 | void updateLFRCurrentMode() | |
1490 | { |
|
1575 | { | |
1491 | /** This function updates the value of the global variable lfrCurrentMode. |
|
1576 | /** This function updates the value of the global variable lfrCurrentMode. | |
1492 | * |
|
1577 | * | |
1493 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
1578 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
1494 | * |
|
1579 | * | |
1495 | */ |
|
1580 | */ | |
1496 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
1581 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
1497 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
1582 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
1498 | } |
|
1583 | } | |
1499 |
|
1584 | |||
1500 | void set_lfr_soft_reset( unsigned char value ) |
|
1585 | void set_lfr_soft_reset( unsigned char value ) | |
1501 | { |
|
1586 | { | |
1502 | if (value == 1) |
|
1587 | if (value == 1) | |
1503 | { |
|
1588 | { | |
1504 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] |
|
1589 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] | |
1505 | } |
|
1590 | } | |
1506 | else |
|
1591 | else | |
1507 | { |
|
1592 | { | |
1508 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] |
|
1593 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] | |
1509 | } |
|
1594 | } | |
1510 | } |
|
1595 | } | |
1511 |
|
1596 | |||
1512 | void reset_lfr( void ) |
|
1597 | void reset_lfr( void ) | |
1513 | { |
|
1598 | { | |
1514 | set_lfr_soft_reset( 1 ); |
|
1599 | set_lfr_soft_reset( 1 ); | |
1515 |
|
1600 | |||
1516 | set_lfr_soft_reset( 0 ); |
|
1601 | set_lfr_soft_reset( 0 ); | |
1517 |
|
1602 | |||
1518 | set_hk_lfr_sc_potential_flag( true ); |
|
1603 | set_hk_lfr_sc_potential_flag( true ); | |
1519 | } |
|
1604 | } |
General Comments 0
You need to be logged in to leave comments.
Login now