##// END OF EJS Templates
AVGV task added...
paul -
r298:ff57d1825f54 R3_plus draft
parent child
Show More
@@ -0,0 +1,31
1 import time
2
3 proxy.loadSysDriver("SpwPlugin","SpwPlugin0")
4 SpwPlugin0.selectBridge("STAR-Dundee Spw USB Brick")
5
6 proxy.loadSysDriverToParent("dsu3plugin","SpwPlugin0")
7 proxy.loadSysDriverToParent("LFRControlPlugin","SpwPlugin0")
8
9 availableBrickCount = SpwPlugin0.StarDundeeGetAvailableBrickCount()
10 print str(availableBrickCount) + " SpaceWire brick(s) found"
11
12 SpwPlugin0.StarDundeeSelectBrick(1)
13 SpwPlugin0.StarDundeeSetBrickAsARouter(1)
14 SpwPlugin0.StarDundeeSelectLinkNumber( 1 )
15 SpwPlugin0.connectBridge()
16
17 #SpwPlugin0.TCPServerSetIP("127.0.0.1")
18 SpwPlugin0.TCPServerConnect()
19
20 # OPEN SPACEWIRE SERVER
21 #LFRControlPlugin0.SetSpwServerIP(129,104,27,164)
22 LFRControlPlugin0.TCPServerConnect()
23
24 # OPEN TM ECHO BRIDGE SERVER
25 LFRControlPlugin0.TMEchoBridgeOpenPort()
26
27 # START SENDING TIMECODES AT 1 Hz
28 SpwPlugin0.StarDundeeStartTimecodes( 1 )
29
30 # it is possible to change the time code frequency
31 #RMAPPlugin0.changeTimecodeFrequency(2)
@@ -0,0 +1,14
1 # LOAD FSW USING LINK 1
2 SpwPlugin0.StarDundeeSelectLinkNumber( 1 )
3
4 dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw")
5 #dsu3plugin0.openFile("/opt/LFR/LFR-FSW/2.0.2.3/fsw")
6 dsu3plugin0.loadFile()
7
8 dsu3plugin0.run()
9
10 # START SENDING TIMECODES AT 1 Hz
11 #SpwPlugin0.StarDundeeStartTimecodes( 1 )
12
13 # it is possible to change the time code frequency
14 #RMAPPlugin0.changeTimecodeFrequency(2)
@@ -0,0 +1,13
1 # LOAD FSW USING LINK 1
2 SpwPlugin0.StarDundeeSelectLinkNumber( 1 )
3
4 dsu3plugin0.openFile("/opt/LFR/LFR-FSW/3.0.0.10/fsw")
5 dsu3plugin0.loadFile()
6
7 dsu3plugin0.run()
8
9 # START SENDING TIMECODES AT 1 Hz
10 SpwPlugin0.StarDundeeStartTimecodes( 1 )
11
12 # it is possible to change the time code frequency
13 #RMAPPlugin0.changeTimecodeFrequency(2)
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 1ffa3d630b9ced4a87a362dafb10d9838e9cc0d9 header/lfr_common_headers
2 94f0f2fccbcb8030d9437ffbb69ee0eefaaea188 header/lfr_common_headers
@@ -1,64 +1,64
1 #ifndef FSW_INIT_H_INCLUDED
1 #ifndef FSW_INIT_H_INCLUDED
2 #define FSW_INIT_H_INCLUDED
2 #define FSW_INIT_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <leon.h>
5 #include <leon.h>
6
6
7 #include "fsw_params.h"
7 #include "fsw_params.h"
8 #include "fsw_misc.h"
8 #include "fsw_misc.h"
9 #include "fsw_processing.h"
9 #include "fsw_processing.h"
10
10
11 #include "tc_handler.h"
11 #include "tc_handler.h"
12 #include "wf_handler.h"
12 #include "wf_handler.h"
13 #include "fsw_spacewire.h"
13 #include "fsw_spacewire.h"
14
14
15 #include "avf0_prc0.h"
15 #include "avf0_prc0.h"
16 #include "avf1_prc1.h"
16 #include "avf1_prc1.h"
17 #include "avf2_prc2.h"
17 #include "avf2_prc2.h"
18
18
19 extern rtems_name Task_name[20]; /* array of task names */
19 extern rtems_name Task_name[]; /* array of task names */
20 extern rtems_id Task_id[20]; /* array of task ids */
20 extern rtems_id Task_id[]; /* array of task ids */
21 extern rtems_name timecode_timer_name;
21 extern rtems_name timecode_timer_name;
22 extern rtems_id timecode_timer_id;
22 extern rtems_id timecode_timer_id;
23 extern unsigned char pa_bia_status_info;
23 extern unsigned char pa_bia_status_info;
24 extern unsigned char cp_rpw_sc_rw_f_flags;
24 extern unsigned char cp_rpw_sc_rw_f_flags;
25 extern float cp_rpw_sc_rw1_f1;
25 extern float cp_rpw_sc_rw1_f1;
26 extern float cp_rpw_sc_rw1_f2;
26 extern float cp_rpw_sc_rw1_f2;
27 extern float cp_rpw_sc_rw2_f1;
27 extern float cp_rpw_sc_rw2_f1;
28 extern float cp_rpw_sc_rw2_f2;
28 extern float cp_rpw_sc_rw2_f2;
29 extern float cp_rpw_sc_rw3_f1;
29 extern float cp_rpw_sc_rw3_f1;
30 extern float cp_rpw_sc_rw3_f2;
30 extern float cp_rpw_sc_rw3_f2;
31 extern float cp_rpw_sc_rw4_f1;
31 extern float cp_rpw_sc_rw4_f1;
32 extern float cp_rpw_sc_rw4_f2;
32 extern float cp_rpw_sc_rw4_f2;
33 extern filterPar_t filterPar;
33 extern filterPar_t filterPar;
34
34
35 // RTEMS TASKS
35 // RTEMS TASKS
36 rtems_task Init( rtems_task_argument argument);
36 rtems_task Init( rtems_task_argument argument);
37
37
38 // OTHER functions
38 // OTHER functions
39 void create_names( void );
39 void create_names( void );
40 int create_all_tasks( void );
40 int create_all_tasks( void );
41 int start_all_tasks( void );
41 int start_all_tasks( void );
42 //
42 //
43 rtems_status_code create_message_queues( void );
43 rtems_status_code create_message_queues( void );
44 rtems_status_code create_timecode_timer( void );
44 rtems_status_code create_timecode_timer( void );
45 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
45 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
46 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
46 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
47 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
47 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
48 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
48 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
49 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
49 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
50 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max );
50 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max );
51 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize );
51 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize );
52 //
52 //
53 int start_recv_send_tasks( void );
53 int start_recv_send_tasks( void );
54 //
54 //
55 void init_local_mode_parameters( void );
55 void init_local_mode_parameters( void );
56 void reset_local_time( void );
56 void reset_local_time( void );
57
57
58 extern void rtems_cpu_usage_report( void );
58 extern void rtems_cpu_usage_report( void );
59 extern void rtems_cpu_usage_reset( void );
59 extern void rtems_cpu_usage_reset( void );
60 extern void rtems_stack_checker_report_usage( void );
60 extern void rtems_stack_checker_report_usage( void );
61
61
62 extern int sched_yield( void );
62 extern int sched_yield( void );
63
63
64 #endif // FSW_INIT_H_INCLUDED
64 #endif // FSW_INIT_H_INCLUDED
@@ -1,84 +1,87
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
13
14 enum lfr_reset_cause_t{
14 enum lfr_reset_cause_t{
15 UNKNOWN_CAUSE,
15 UNKNOWN_CAUSE,
16 POWER_ON,
16 POWER_ON,
17 TC_RESET,
17 TC_RESET,
18 WATCHDOG,
18 WATCHDOG,
19 ERROR_RESET,
19 ERROR_RESET,
20 UNEXP_RESET
20 UNEXP_RESET
21 };
21 };
22
22
23 extern gptimer_regs_t *gptimer_regs;
23 extern gptimer_regs_t *gptimer_regs;
24 extern void ASR16_get_FPRF_IURF_ErrorCounters( unsigned int*, unsigned int* );
24 extern void ASR16_get_FPRF_IURF_ErrorCounters( unsigned int*, unsigned int* );
25 extern void CCR_getInstructionAndDataErrorCounters( unsigned int*, unsigned int* );
25 extern void CCR_getInstructionAndDataErrorCounters( unsigned int*, unsigned int* );
26
26
27 #define LFR_RESET_CAUSE_UNKNOWN_CAUSE 0
27 #define LFR_RESET_CAUSE_UNKNOWN_CAUSE 0
28
28
29 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
29 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
30 rtems_id HK_id; // id of the HK rate monotonic period
30 rtems_id HK_id; // id of the HK rate monotonic period
31 rtems_name name_avgv_rate_monotonic; // name of the AVGV rate monotonic
32 rtems_id AVGV_id; // id of the AVGV rate monotonic period
31
33
32 void timer_configure( unsigned char timer, unsigned int clock_divider,
34 void timer_configure( unsigned char timer, unsigned int clock_divider,
33 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
35 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
34 void timer_start( unsigned char timer );
36 void timer_start( unsigned char timer );
35 void timer_stop( unsigned char timer );
37 void timer_stop( unsigned char timer );
36 void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider);
38 void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider);
37
39
38 // WATCHDOG
40 // WATCHDOG
39 rtems_isr watchdog_isr( rtems_vector_number vector );
41 rtems_isr watchdog_isr( rtems_vector_number vector );
40 void watchdog_configure(void);
42 void watchdog_configure(void);
41 void watchdog_stop(void);
43 void watchdog_stop(void);
42 void watchdog_reload(void);
44 void watchdog_reload(void);
43 void watchdog_start(void);
45 void watchdog_start(void);
44
46
45 // SERIAL LINK
47 // SERIAL LINK
46 int send_console_outputs_on_apbuart_port( void );
48 int send_console_outputs_on_apbuart_port( void );
47 int enable_apbuart_transmitter( void );
49 int enable_apbuart_transmitter( void );
48 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
50 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
49
51
50 // RTEMS TASKS
52 // RTEMS TASKS
51 rtems_task load_task( rtems_task_argument argument );
53 rtems_task load_task( rtems_task_argument argument );
52 rtems_task hous_task( rtems_task_argument argument );
54 rtems_task hous_task( rtems_task_argument argument );
55 rtems_task avgv_task( rtems_task_argument argument );
53 rtems_task dumb_task( rtems_task_argument unused );
56 rtems_task dumb_task( rtems_task_argument unused );
54
57
55 void init_housekeeping_parameters( void );
58 void init_housekeeping_parameters( void );
56 void increment_seq_counter(unsigned short *packetSequenceControl);
59 void increment_seq_counter(unsigned short *packetSequenceControl);
57 void getTime( unsigned char *time);
60 void getTime( unsigned char *time);
58 unsigned long long int getTimeAsUnsignedLongLongInt( );
61 unsigned long long int getTimeAsUnsignedLongLongInt( );
59 void send_dumb_hk( void );
62 void send_dumb_hk( void );
60 void get_temperatures( unsigned char *temperatures );
63 void get_temperatures( unsigned char *temperatures );
61 void get_v_e1_e2_f3( unsigned char *spacecraft_potential );
64 void get_v_e1_e2_f3( unsigned char *spacecraft_potential );
62 void get_cpu_load( unsigned char *resource_statistics );
65 void get_cpu_load( unsigned char *resource_statistics );
63 void set_hk_lfr_sc_potential_flag( bool state );
66 void set_hk_lfr_sc_potential_flag( bool state );
64 void set_sy_lfr_pas_filter_enabled( bool state );
67 void set_sy_lfr_pas_filter_enabled( bool state );
65 void set_sy_lfr_watchdog_enabled( bool state );
68 void set_sy_lfr_watchdog_enabled( bool state );
66 void set_hk_lfr_calib_enable( bool state );
69 void set_hk_lfr_calib_enable( bool state );
67 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause );
70 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause );
68 void hk_lfr_le_me_he_update();
71 void hk_lfr_le_me_he_update();
69 void set_hk_lfr_time_not_synchro();
72 void set_hk_lfr_time_not_synchro();
70
73
71 extern int sched_yield( void );
74 extern int sched_yield( void );
72 extern void rtems_cpu_usage_reset();
75 extern void rtems_cpu_usage_reset();
73 extern ring_node *current_ring_node_f3;
76 extern ring_node *current_ring_node_f3;
74 extern ring_node *ring_node_to_send_cwf_f3;
77 extern ring_node *ring_node_to_send_cwf_f3;
75 extern ring_node waveform_ring_f3[];
78 extern ring_node waveform_ring_f3[];
76 extern unsigned short sequenceCounterHK;
79 extern unsigned short sequenceCounterHK;
77
80
78 extern unsigned char hk_lfr_q_sd_fifo_size_max;
81 extern unsigned char hk_lfr_q_sd_fifo_size_max;
79 extern unsigned char hk_lfr_q_rv_fifo_size_max;
82 extern unsigned char hk_lfr_q_rv_fifo_size_max;
80 extern unsigned char hk_lfr_q_p0_fifo_size_max;
83 extern unsigned char hk_lfr_q_p0_fifo_size_max;
81 extern unsigned char hk_lfr_q_p1_fifo_size_max;
84 extern unsigned char hk_lfr_q_p1_fifo_size_max;
82 extern unsigned char hk_lfr_q_p2_fifo_size_max;
85 extern unsigned char hk_lfr_q_p2_fifo_size_max;
83
86
84 #endif // FSW_MISC_H_INCLUDED
87 #endif // FSW_MISC_H_INCLUDED
@@ -1,938 +1,955
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 21 // number of tasks concurrently active including INIT
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 // [hous] [load] [avgv]
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link]
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link]
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
50
51 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
52 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
53 #endif
53 #endif
54
54
55 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
55 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
57 #endif
57 #endif
58
58
59 #endif
59 #endif
60 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
60 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
61
61
62 #include <drvmgr/drvmgr_confdefs.h>
62 #include <drvmgr/drvmgr_confdefs.h>
63 #endif
63 #endif
64
64
65 #include "fsw_init.h"
65 #include "fsw_init.h"
66 #include "fsw_config.c"
66 #include "fsw_config.c"
67 #include "GscMemoryLPP.hpp"
67 #include "GscMemoryLPP.hpp"
68
68
69 void initCache()
69 void initCache()
70 {
70 {
71 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
71 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
72 // These should only be read and written using 32-bit LDA/STA instructions.
72 // These should only be read and written using 32-bit LDA/STA instructions.
73 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
73 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
74 // The table below shows the register addresses:
74 // The table below shows the register addresses:
75 // 0x00 Cache control register
75 // 0x00 Cache control register
76 // 0x04 Reserved
76 // 0x04 Reserved
77 // 0x08 Instruction cache configuration register
77 // 0x08 Instruction cache configuration register
78 // 0x0C Data cache configuration register
78 // 0x0C Data cache configuration register
79
79
80 // Cache Control Register Leon3 / Leon3FT
80 // Cache Control Register Leon3 / Leon3FT
81 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
81 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
82 // RFT PS TB DS FD FI FT ST IB
82 // RFT PS TB DS FD FI FT ST IB
83 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
83 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
84 // IP DP ITE IDE DTE DDE DF IF DCS ICS
84 // IP DP ITE IDE DTE DDE DF IF DCS ICS
85
85
86 unsigned int cacheControlRegister;
86 unsigned int cacheControlRegister;
87
87
88 CCR_resetCacheControlRegister();
88 CCR_resetCacheControlRegister();
89 ASR16_resetRegisterProtectionControlRegister();
89 ASR16_resetRegisterProtectionControlRegister();
90
90
91 cacheControlRegister = CCR_getValue();
91 cacheControlRegister = CCR_getValue();
92 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
92 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
93 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
93 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
94
94
95 CCR_enableInstructionCache(); // ICS bits
95 CCR_enableInstructionCache(); // ICS bits
96 CCR_enableDataCache(); // DCS bits
96 CCR_enableDataCache(); // DCS bits
97 CCR_enableInstructionBurstFetch(); // IB bit
97 CCR_enableInstructionBurstFetch(); // IB bit
98
98
99 faultTolerantScheme();
99 faultTolerantScheme();
100
100
101 cacheControlRegister = CCR_getValue();
101 cacheControlRegister = CCR_getValue();
102 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
102 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
103 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
103 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
104
104
105 PRINTF("\n");
105 PRINTF("\n");
106 }
106 }
107
107
108 rtems_task Init( rtems_task_argument ignored )
108 rtems_task Init( rtems_task_argument ignored )
109 {
109 {
110 /** This is the RTEMS INIT taks, it is the first task launched by the system.
110 /** This is the RTEMS INIT taks, it is the first task launched by the system.
111 *
111 *
112 * @param unused is the starting argument of the RTEMS task
112 * @param unused is the starting argument of the RTEMS task
113 *
113 *
114 * The INIT task create and run all other RTEMS tasks.
114 * The INIT task create and run all other RTEMS tasks.
115 *
115 *
116 */
116 */
117
117
118 //***********
118 //***********
119 // INIT CACHE
119 // INIT CACHE
120
120
121 unsigned char *vhdlVersion;
121 unsigned char *vhdlVersion;
122
122
123 reset_lfr();
123 reset_lfr();
124
124
125 reset_local_time();
125 reset_local_time();
126
126
127 rtems_cpu_usage_reset();
127 rtems_cpu_usage_reset();
128
128
129 rtems_status_code status;
129 rtems_status_code status;
130 rtems_status_code status_spw;
130 rtems_status_code status_spw;
131 rtems_isr_entry old_isr_handler;
131 rtems_isr_entry old_isr_handler;
132
132
133 // UART settings
133 // UART settings
134 enable_apbuart_transmitter();
134 enable_apbuart_transmitter();
135 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
135 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
136
136
137 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
137 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
138
138
139
139
140 PRINTF("\n\n\n\n\n")
140 PRINTF("\n\n\n\n\n")
141
141
142 initCache();
142 initCache();
143
143
144 PRINTF("*************************\n")
144 PRINTF("*************************\n")
145 PRINTF("** LFR Flight Software **\n")
145 PRINTF("** LFR Flight Software **\n")
146 PRINTF1("** %d.", SW_VERSION_N1)
146 PRINTF1("** %d-", SW_VERSION_N1)
147 PRINTF1("%d." , SW_VERSION_N2)
147 PRINTF1("%d-" , SW_VERSION_N2)
148 PRINTF1("%d." , SW_VERSION_N3)
148 PRINTF1("%d-" , SW_VERSION_N3)
149 PRINTF1("%d **\n", SW_VERSION_N4)
149 PRINTF1("%d **\n", SW_VERSION_N4)
150
150
151 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
151 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
152 PRINTF("** VHDL **\n")
152 PRINTF("** VHDL **\n")
153 PRINTF1("** %d.", vhdlVersion[1])
153 PRINTF1("** %d.", vhdlVersion[1])
154 PRINTF1("%d." , vhdlVersion[2])
154 PRINTF1("%d." , vhdlVersion[2])
155 PRINTF1("%d **\n", vhdlVersion[3])
155 PRINTF1("%d **\n", vhdlVersion[3])
156 PRINTF("*************************\n")
156 PRINTF("*************************\n")
157 PRINTF("\n\n")
157 PRINTF("\n\n")
158
158
159 init_parameter_dump();
159 init_parameter_dump();
160 init_kcoefficients_dump();
160 init_kcoefficients_dump();
161 init_local_mode_parameters();
161 init_local_mode_parameters();
162 init_housekeeping_parameters();
162 init_housekeeping_parameters();
163 init_k_coefficients_prc0();
163 init_k_coefficients_prc0();
164 init_k_coefficients_prc1();
164 init_k_coefficients_prc1();
165 init_k_coefficients_prc2();
165 init_k_coefficients_prc2();
166 pa_bia_status_info = 0x00;
166 pa_bia_status_info = 0x00;
167 cp_rpw_sc_rw_f_flags = 0x00;
167 cp_rpw_sc_rw_f_flags = 0x00;
168 cp_rpw_sc_rw1_f1 = 0.0;
168 cp_rpw_sc_rw1_f1 = 0.0;
169 cp_rpw_sc_rw1_f2 = 0.0;
169 cp_rpw_sc_rw1_f2 = 0.0;
170 cp_rpw_sc_rw2_f1 = 0.0;
170 cp_rpw_sc_rw2_f1 = 0.0;
171 cp_rpw_sc_rw2_f2 = 0.0;
171 cp_rpw_sc_rw2_f2 = 0.0;
172 cp_rpw_sc_rw3_f1 = 0.0;
172 cp_rpw_sc_rw3_f1 = 0.0;
173 cp_rpw_sc_rw3_f2 = 0.0;
173 cp_rpw_sc_rw3_f2 = 0.0;
174 cp_rpw_sc_rw4_f1 = 0.0;
174 cp_rpw_sc_rw4_f1 = 0.0;
175 cp_rpw_sc_rw4_f2 = 0.0;
175 cp_rpw_sc_rw4_f2 = 0.0;
176 // initialize filtering parameters
176 // initialize filtering parameters
177 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
177 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
178 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
178 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
179 filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD;
179 filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD;
180 filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
180 filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
181 filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT;
181 filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT;
182 filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F;
182 filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F;
183 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
183 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
184
184
185 // waveform picker initialization
185 // waveform picker initialization
186 WFP_init_rings();
186 WFP_init_rings();
187 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
187 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
188 WFP_reset_current_ring_nodes();
188 WFP_reset_current_ring_nodes();
189 reset_waveform_picker_regs();
189 reset_waveform_picker_regs();
190
190
191 // spectral matrices initialization
191 // spectral matrices initialization
192 SM_init_rings(); // initialize spectral matrices rings
192 SM_init_rings(); // initialize spectral matrices rings
193 SM_reset_current_ring_nodes();
193 SM_reset_current_ring_nodes();
194 reset_spectral_matrix_regs();
194 reset_spectral_matrix_regs();
195
195
196 // configure calibration
196 // configure calibration
197 configureCalibration( false ); // true means interleaved mode, false is for normal mode
197 configureCalibration( false ); // true means interleaved mode, false is for normal mode
198
198
199 updateLFRCurrentMode( LFR_MODE_STANDBY );
199 updateLFRCurrentMode( LFR_MODE_STANDBY );
200
200
201 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
201 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
202
202
203 create_names(); // create all names
203 create_names(); // create all names
204
204
205 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
205 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
206 if (status != RTEMS_SUCCESSFUL)
206 if (status != RTEMS_SUCCESSFUL)
207 {
207 {
208 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
208 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
209 }
209 }
210
210
211 status = create_message_queues(); // create message queues
211 status = create_message_queues(); // create message queues
212 if (status != RTEMS_SUCCESSFUL)
212 if (status != RTEMS_SUCCESSFUL)
213 {
213 {
214 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
214 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
215 }
215 }
216
216
217 status = create_all_tasks(); // create all tasks
217 status = create_all_tasks(); // create all tasks
218 if (status != RTEMS_SUCCESSFUL)
218 if (status != RTEMS_SUCCESSFUL)
219 {
219 {
220 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
220 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
221 }
221 }
222
222
223 // **************************
223 // **************************
224 // <SPACEWIRE INITIALIZATION>
224 // <SPACEWIRE INITIALIZATION>
225 status_spw = spacewire_open_link(); // (1) open the link
225 status_spw = spacewire_open_link(); // (1) open the link
226 if ( status_spw != RTEMS_SUCCESSFUL )
226 if ( status_spw != RTEMS_SUCCESSFUL )
227 {
227 {
228 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
228 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
229 }
229 }
230
230
231 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
231 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
232 {
232 {
233 status_spw = spacewire_configure_link( fdSPW );
233 status_spw = spacewire_configure_link( fdSPW );
234 if ( status_spw != RTEMS_SUCCESSFUL )
234 if ( status_spw != RTEMS_SUCCESSFUL )
235 {
235 {
236 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
236 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
237 }
237 }
238 }
238 }
239
239
240 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
240 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
241 {
241 {
242 status_spw = spacewire_start_link( fdSPW );
242 status_spw = spacewire_start_link( fdSPW );
243 if ( status_spw != RTEMS_SUCCESSFUL )
243 if ( status_spw != RTEMS_SUCCESSFUL )
244 {
244 {
245 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
245 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
246 }
246 }
247 }
247 }
248 // </SPACEWIRE INITIALIZATION>
248 // </SPACEWIRE INITIALIZATION>
249 // ***************************
249 // ***************************
250
250
251 status = start_all_tasks(); // start all tasks
251 status = start_all_tasks(); // start all tasks
252 if (status != RTEMS_SUCCESSFUL)
252 if (status != RTEMS_SUCCESSFUL)
253 {
253 {
254 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
254 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
255 }
255 }
256
256
257 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
257 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
258 status = start_recv_send_tasks();
258 status = start_recv_send_tasks();
259 if ( status != RTEMS_SUCCESSFUL )
259 if ( status != RTEMS_SUCCESSFUL )
260 {
260 {
261 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
261 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
262 }
262 }
263
263
264 // suspend science tasks, they will be restarted later depending on the mode
264 // suspend science tasks, they will be restarted later depending on the mode
265 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
265 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
266 if (status != RTEMS_SUCCESSFUL)
266 if (status != RTEMS_SUCCESSFUL)
267 {
267 {
268 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
268 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
269 }
269 }
270
270
271 // configure IRQ handling for the waveform picker unit
271 // configure IRQ handling for the waveform picker unit
272 status = rtems_interrupt_catch( waveforms_isr,
272 status = rtems_interrupt_catch( waveforms_isr,
273 IRQ_SPARC_WAVEFORM_PICKER,
273 IRQ_SPARC_WAVEFORM_PICKER,
274 &old_isr_handler) ;
274 &old_isr_handler) ;
275 // configure IRQ handling for the spectral matrices unit
275 // configure IRQ handling for the spectral matrices unit
276 status = rtems_interrupt_catch( spectral_matrices_isr,
276 status = rtems_interrupt_catch( spectral_matrices_isr,
277 IRQ_SPARC_SPECTRAL_MATRIX,
277 IRQ_SPARC_SPECTRAL_MATRIX,
278 &old_isr_handler) ;
278 &old_isr_handler) ;
279
279
280 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
280 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
281 if ( status_spw != RTEMS_SUCCESSFUL )
281 if ( status_spw != RTEMS_SUCCESSFUL )
282 {
282 {
283 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
283 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
284 if ( status != RTEMS_SUCCESSFUL ) {
284 if ( status != RTEMS_SUCCESSFUL ) {
285 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
285 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
286 }
286 }
287 }
287 }
288
288
289 BOOT_PRINTF("delete INIT\n")
289 BOOT_PRINTF("delete INIT\n")
290
290
291 set_hk_lfr_sc_potential_flag( true );
291 set_hk_lfr_sc_potential_flag( true );
292
292
293 // start the timer to detect a missing spacewire timecode
293 // start the timer to detect a missing spacewire timecode
294 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
294 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
295 // if a tickout is generated, the timer is restarted
295 // if a tickout is generated, the timer is restarted
296 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
296 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
297
297
298 grspw_timecode_callback = &timecode_irq_handler;
298 grspw_timecode_callback = &timecode_irq_handler;
299
299
300 status = rtems_task_delete(RTEMS_SELF);
300 status = rtems_task_delete(RTEMS_SELF);
301
301
302 }
302 }
303
303
304 void init_local_mode_parameters( void )
304 void init_local_mode_parameters( void )
305 {
305 {
306 /** This function initialize the param_local global variable with default values.
306 /** This function initialize the param_local global variable with default values.
307 *
307 *
308 */
308 */
309
309
310 unsigned int i;
310 unsigned int i;
311
311
312 // LOCAL PARAMETERS
312 // LOCAL PARAMETERS
313
313
314 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
314 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
315 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
315 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
316 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
316 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
317
317
318 // init sequence counters
318 // init sequence counters
319
319
320 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
320 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
321 {
321 {
322 sequenceCounters_TC_EXE[i] = 0x00;
322 sequenceCounters_TC_EXE[i] = 0x00;
323 sequenceCounters_TM_DUMP[i] = 0x00;
323 sequenceCounters_TM_DUMP[i] = 0x00;
324 }
324 }
325 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
325 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
326 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
326 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
327 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
327 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
328 }
328 }
329
329
330 void reset_local_time( void )
330 void reset_local_time( void )
331 {
331 {
332 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
332 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
333 }
333 }
334
334
335 void create_names( void ) // create all names for tasks and queues
335 void create_names( void ) // create all names for tasks and queues
336 {
336 {
337 /** This function creates all RTEMS names used in the software for tasks and queues.
337 /** This function creates all RTEMS names used in the software for tasks and queues.
338 *
338 *
339 * @return RTEMS directive status codes:
339 * @return RTEMS directive status codes:
340 * - RTEMS_SUCCESSFUL - successful completion
340 * - RTEMS_SUCCESSFUL - successful completion
341 *
341 *
342 */
342 */
343
343
344 // task names
344 // task names
345 Task_name[TASKID_AVGV] = rtems_build_name( 'A', 'V', 'G', 'V' );
345 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
346 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
346 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
347 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
347 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
348 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
348 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
349 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
349 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
350 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
350 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
351 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
351 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
352 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
352 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
353 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
353 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
354 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
354 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
355 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
355 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
356 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
356 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
357 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
357 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
358 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
358 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
359 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
359 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
360 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
360 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
361 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
361 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
362 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
362 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
363 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
363 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
364 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
364
365
365 // rate monotonic period names
366 // rate monotonic period names
366 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
367 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
368 name_avgv_rate_monotonic = rtems_build_name( 'A', 'V', 'G', 'V' );
367
369
368 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
370 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
369 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
371 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
370 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
372 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
371 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
373 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
372 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
374 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
373
375
374 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
376 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
375 }
377 }
376
378
377 int create_all_tasks( void ) // create all tasks which run in the software
379 int create_all_tasks( void ) // create all tasks which run in the software
378 {
380 {
379 /** This function creates all RTEMS tasks used in the software.
381 /** This function creates all RTEMS tasks used in the software.
380 *
382 *
381 * @return RTEMS directive status codes:
383 * @return RTEMS directive status codes:
382 * - RTEMS_SUCCESSFUL - task created successfully
384 * - RTEMS_SUCCESSFUL - task created successfully
383 * - RTEMS_INVALID_ADDRESS - id is NULL
385 * - RTEMS_INVALID_ADDRESS - id is NULL
384 * - RTEMS_INVALID_NAME - invalid task name
386 * - RTEMS_INVALID_NAME - invalid task name
385 * - RTEMS_INVALID_PRIORITY - invalid task priority
387 * - RTEMS_INVALID_PRIORITY - invalid task priority
386 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
388 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
387 * - RTEMS_TOO_MANY - too many tasks created
389 * - RTEMS_TOO_MANY - too many tasks created
388 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
390 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
389 * - RTEMS_TOO_MANY - too many global objects
391 * - RTEMS_TOO_MANY - too many global objects
390 *
392 *
391 */
393 */
392
394
393 rtems_status_code status;
395 rtems_status_code status;
394
396
395 //**********
397 //**********
396 // SPACEWIRE
398 // SPACEWIRE
397 // RECV
399 // RECV
398 status = rtems_task_create(
400 status = rtems_task_create(
399 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
401 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
400 RTEMS_DEFAULT_MODES,
402 RTEMS_DEFAULT_MODES,
401 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
403 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
402 );
404 );
403 if (status == RTEMS_SUCCESSFUL) // SEND
405 if (status == RTEMS_SUCCESSFUL) // SEND
404 {
406 {
405 status = rtems_task_create(
407 status = rtems_task_create(
406 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
408 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
407 RTEMS_DEFAULT_MODES,
409 RTEMS_DEFAULT_MODES,
408 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
410 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
409 );
411 );
410 }
412 }
411 if (status == RTEMS_SUCCESSFUL) // LINK
413 if (status == RTEMS_SUCCESSFUL) // LINK
412 {
414 {
413 status = rtems_task_create(
415 status = rtems_task_create(
414 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
416 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
415 RTEMS_DEFAULT_MODES,
417 RTEMS_DEFAULT_MODES,
416 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
418 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
417 );
419 );
418 }
420 }
419 if (status == RTEMS_SUCCESSFUL) // ACTN
421 if (status == RTEMS_SUCCESSFUL) // ACTN
420 {
422 {
421 status = rtems_task_create(
423 status = rtems_task_create(
422 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
424 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
423 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
425 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
424 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
426 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
425 );
427 );
426 }
428 }
427 if (status == RTEMS_SUCCESSFUL) // SPIQ
429 if (status == RTEMS_SUCCESSFUL) // SPIQ
428 {
430 {
429 status = rtems_task_create(
431 status = rtems_task_create(
430 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
432 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
431 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
433 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
432 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
434 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
433 );
435 );
434 }
436 }
435
437
436 //******************
438 //******************
437 // SPECTRAL MATRICES
439 // SPECTRAL MATRICES
438 if (status == RTEMS_SUCCESSFUL) // AVF0
440 if (status == RTEMS_SUCCESSFUL) // AVF0
439 {
441 {
440 status = rtems_task_create(
442 status = rtems_task_create(
441 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
443 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
442 RTEMS_DEFAULT_MODES,
444 RTEMS_DEFAULT_MODES,
443 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
445 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
444 );
446 );
445 }
447 }
446 if (status == RTEMS_SUCCESSFUL) // PRC0
448 if (status == RTEMS_SUCCESSFUL) // PRC0
447 {
449 {
448 status = rtems_task_create(
450 status = rtems_task_create(
449 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
451 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
450 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
452 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
451 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
453 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
452 );
454 );
453 }
455 }
454 if (status == RTEMS_SUCCESSFUL) // AVF1
456 if (status == RTEMS_SUCCESSFUL) // AVF1
455 {
457 {
456 status = rtems_task_create(
458 status = rtems_task_create(
457 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
459 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
458 RTEMS_DEFAULT_MODES,
460 RTEMS_DEFAULT_MODES,
459 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
461 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
460 );
462 );
461 }
463 }
462 if (status == RTEMS_SUCCESSFUL) // PRC1
464 if (status == RTEMS_SUCCESSFUL) // PRC1
463 {
465 {
464 status = rtems_task_create(
466 status = rtems_task_create(
465 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
467 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
466 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
468 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
467 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
469 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
468 );
470 );
469 }
471 }
470 if (status == RTEMS_SUCCESSFUL) // AVF2
472 if (status == RTEMS_SUCCESSFUL) // AVF2
471 {
473 {
472 status = rtems_task_create(
474 status = rtems_task_create(
473 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
475 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
474 RTEMS_DEFAULT_MODES,
476 RTEMS_DEFAULT_MODES,
475 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
477 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
476 );
478 );
477 }
479 }
478 if (status == RTEMS_SUCCESSFUL) // PRC2
480 if (status == RTEMS_SUCCESSFUL) // PRC2
479 {
481 {
480 status = rtems_task_create(
482 status = rtems_task_create(
481 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
483 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
482 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
484 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
483 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
485 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
484 );
486 );
485 }
487 }
486
488
487 //****************
489 //****************
488 // WAVEFORM PICKER
490 // WAVEFORM PICKER
489 if (status == RTEMS_SUCCESSFUL) // WFRM
491 if (status == RTEMS_SUCCESSFUL) // WFRM
490 {
492 {
491 status = rtems_task_create(
493 status = rtems_task_create(
492 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
494 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
493 RTEMS_DEFAULT_MODES,
495 RTEMS_DEFAULT_MODES,
494 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
496 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
495 );
497 );
496 }
498 }
497 if (status == RTEMS_SUCCESSFUL) // CWF3
499 if (status == RTEMS_SUCCESSFUL) // CWF3
498 {
500 {
499 status = rtems_task_create(
501 status = rtems_task_create(
500 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
502 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
501 RTEMS_DEFAULT_MODES,
503 RTEMS_DEFAULT_MODES,
502 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
504 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
503 );
505 );
504 }
506 }
505 if (status == RTEMS_SUCCESSFUL) // CWF2
507 if (status == RTEMS_SUCCESSFUL) // CWF2
506 {
508 {
507 status = rtems_task_create(
509 status = rtems_task_create(
508 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
510 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
509 RTEMS_DEFAULT_MODES,
511 RTEMS_DEFAULT_MODES,
510 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
512 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
511 );
513 );
512 }
514 }
513 if (status == RTEMS_SUCCESSFUL) // CWF1
515 if (status == RTEMS_SUCCESSFUL) // CWF1
514 {
516 {
515 status = rtems_task_create(
517 status = rtems_task_create(
516 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
518 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
517 RTEMS_DEFAULT_MODES,
519 RTEMS_DEFAULT_MODES,
518 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
520 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
519 );
521 );
520 }
522 }
521 if (status == RTEMS_SUCCESSFUL) // SWBD
523 if (status == RTEMS_SUCCESSFUL) // SWBD
522 {
524 {
523 status = rtems_task_create(
525 status = rtems_task_create(
524 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
526 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
525 RTEMS_DEFAULT_MODES,
527 RTEMS_DEFAULT_MODES,
526 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
528 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
527 );
529 );
528 }
530 }
529
531
530 //*****
532 //*****
531 // MISC
533 // MISC
532 if (status == RTEMS_SUCCESSFUL) // LOAD
534 if (status == RTEMS_SUCCESSFUL) // LOAD
533 {
535 {
534 status = rtems_task_create(
536 status = rtems_task_create(
535 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
537 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
536 RTEMS_DEFAULT_MODES,
538 RTEMS_DEFAULT_MODES,
537 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
539 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
538 );
540 );
539 }
541 }
540 if (status == RTEMS_SUCCESSFUL) // DUMB
542 if (status == RTEMS_SUCCESSFUL) // DUMB
541 {
543 {
542 status = rtems_task_create(
544 status = rtems_task_create(
543 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
545 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
544 RTEMS_DEFAULT_MODES,
546 RTEMS_DEFAULT_MODES,
545 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
547 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
546 );
548 );
547 }
549 }
548 if (status == RTEMS_SUCCESSFUL) // HOUS
550 if (status == RTEMS_SUCCESSFUL) // HOUS
549 {
551 {
550 status = rtems_task_create(
552 status = rtems_task_create(
551 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
553 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
552 RTEMS_DEFAULT_MODES,
554 RTEMS_DEFAULT_MODES,
553 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
555 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
554 );
556 );
555 }
557 }
558 if (status == RTEMS_SUCCESSFUL) // AVGV
559 {
560 status = rtems_task_create(
561 Task_name[TASKID_AVGV], TASK_PRIORITY_AVGV, RTEMS_MINIMUM_STACK_SIZE,
562 RTEMS_DEFAULT_MODES,
563 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVGV]
564 );
565 }
556
566
557 return status;
567 return status;
558 }
568 }
559
569
560 int start_recv_send_tasks( void )
570 int start_recv_send_tasks( void )
561 {
571 {
562 rtems_status_code status;
572 rtems_status_code status;
563
573
564 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
574 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
565 if (status!=RTEMS_SUCCESSFUL) {
575 if (status!=RTEMS_SUCCESSFUL) {
566 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
576 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
567 }
577 }
568
578
569 if (status == RTEMS_SUCCESSFUL) // SEND
579 if (status == RTEMS_SUCCESSFUL) // SEND
570 {
580 {
571 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
581 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
572 if (status!=RTEMS_SUCCESSFUL) {
582 if (status!=RTEMS_SUCCESSFUL) {
573 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
583 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
574 }
584 }
575 }
585 }
576
586
577 return status;
587 return status;
578 }
588 }
579
589
580 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
590 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
581 {
591 {
582 /** This function starts all RTEMS tasks used in the software.
592 /** This function starts all RTEMS tasks used in the software.
583 *
593 *
584 * @return RTEMS directive status codes:
594 * @return RTEMS directive status codes:
585 * - RTEMS_SUCCESSFUL - ask started successfully
595 * - RTEMS_SUCCESSFUL - ask started successfully
586 * - RTEMS_INVALID_ADDRESS - invalid task entry point
596 * - RTEMS_INVALID_ADDRESS - invalid task entry point
587 * - RTEMS_INVALID_ID - invalid task id
597 * - RTEMS_INVALID_ID - invalid task id
588 * - RTEMS_INCORRECT_STATE - task not in the dormant state
598 * - RTEMS_INCORRECT_STATE - task not in the dormant state
589 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
599 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
590 *
600 *
591 */
601 */
592 // starts all the tasks fot eh flight software
602 // starts all the tasks fot eh flight software
593
603
594 rtems_status_code status;
604 rtems_status_code status;
595
605
596 //**********
606 //**********
597 // SPACEWIRE
607 // SPACEWIRE
598 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
608 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
599 if (status!=RTEMS_SUCCESSFUL) {
609 if (status!=RTEMS_SUCCESSFUL) {
600 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
610 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
601 }
611 }
602
612
603 if (status == RTEMS_SUCCESSFUL) // LINK
613 if (status == RTEMS_SUCCESSFUL) // LINK
604 {
614 {
605 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
615 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
606 if (status!=RTEMS_SUCCESSFUL) {
616 if (status!=RTEMS_SUCCESSFUL) {
607 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
617 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
608 }
618 }
609 }
619 }
610
620
611 if (status == RTEMS_SUCCESSFUL) // ACTN
621 if (status == RTEMS_SUCCESSFUL) // ACTN
612 {
622 {
613 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
623 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
614 if (status!=RTEMS_SUCCESSFUL) {
624 if (status!=RTEMS_SUCCESSFUL) {
615 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
625 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
616 }
626 }
617 }
627 }
618
628
619 //******************
629 //******************
620 // SPECTRAL MATRICES
630 // SPECTRAL MATRICES
621 if (status == RTEMS_SUCCESSFUL) // AVF0
631 if (status == RTEMS_SUCCESSFUL) // AVF0
622 {
632 {
623 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
633 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
624 if (status!=RTEMS_SUCCESSFUL) {
634 if (status!=RTEMS_SUCCESSFUL) {
625 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
635 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
626 }
636 }
627 }
637 }
628 if (status == RTEMS_SUCCESSFUL) // PRC0
638 if (status == RTEMS_SUCCESSFUL) // PRC0
629 {
639 {
630 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
640 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
631 if (status!=RTEMS_SUCCESSFUL) {
641 if (status!=RTEMS_SUCCESSFUL) {
632 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
642 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
633 }
643 }
634 }
644 }
635 if (status == RTEMS_SUCCESSFUL) // AVF1
645 if (status == RTEMS_SUCCESSFUL) // AVF1
636 {
646 {
637 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
647 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
638 if (status!=RTEMS_SUCCESSFUL) {
648 if (status!=RTEMS_SUCCESSFUL) {
639 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
649 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
640 }
650 }
641 }
651 }
642 if (status == RTEMS_SUCCESSFUL) // PRC1
652 if (status == RTEMS_SUCCESSFUL) // PRC1
643 {
653 {
644 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
654 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
645 if (status!=RTEMS_SUCCESSFUL) {
655 if (status!=RTEMS_SUCCESSFUL) {
646 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
656 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
647 }
657 }
648 }
658 }
649 if (status == RTEMS_SUCCESSFUL) // AVF2
659 if (status == RTEMS_SUCCESSFUL) // AVF2
650 {
660 {
651 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
661 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
652 if (status!=RTEMS_SUCCESSFUL) {
662 if (status!=RTEMS_SUCCESSFUL) {
653 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
663 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
654 }
664 }
655 }
665 }
656 if (status == RTEMS_SUCCESSFUL) // PRC2
666 if (status == RTEMS_SUCCESSFUL) // PRC2
657 {
667 {
658 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
668 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
659 if (status!=RTEMS_SUCCESSFUL) {
669 if (status!=RTEMS_SUCCESSFUL) {
660 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
670 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
661 }
671 }
662 }
672 }
663
673
664 //****************
674 //****************
665 // WAVEFORM PICKER
675 // WAVEFORM PICKER
666 if (status == RTEMS_SUCCESSFUL) // WFRM
676 if (status == RTEMS_SUCCESSFUL) // WFRM
667 {
677 {
668 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
678 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
669 if (status!=RTEMS_SUCCESSFUL) {
679 if (status!=RTEMS_SUCCESSFUL) {
670 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
680 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
671 }
681 }
672 }
682 }
673 if (status == RTEMS_SUCCESSFUL) // CWF3
683 if (status == RTEMS_SUCCESSFUL) // CWF3
674 {
684 {
675 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
685 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
676 if (status!=RTEMS_SUCCESSFUL) {
686 if (status!=RTEMS_SUCCESSFUL) {
677 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
687 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
678 }
688 }
679 }
689 }
680 if (status == RTEMS_SUCCESSFUL) // CWF2
690 if (status == RTEMS_SUCCESSFUL) // CWF2
681 {
691 {
682 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
692 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
683 if (status!=RTEMS_SUCCESSFUL) {
693 if (status!=RTEMS_SUCCESSFUL) {
684 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
694 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
685 }
695 }
686 }
696 }
687 if (status == RTEMS_SUCCESSFUL) // CWF1
697 if (status == RTEMS_SUCCESSFUL) // CWF1
688 {
698 {
689 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
699 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
690 if (status!=RTEMS_SUCCESSFUL) {
700 if (status!=RTEMS_SUCCESSFUL) {
691 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
701 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
692 }
702 }
693 }
703 }
694 if (status == RTEMS_SUCCESSFUL) // SWBD
704 if (status == RTEMS_SUCCESSFUL) // SWBD
695 {
705 {
696 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
706 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
697 if (status!=RTEMS_SUCCESSFUL) {
707 if (status!=RTEMS_SUCCESSFUL) {
698 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
708 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
699 }
709 }
700 }
710 }
701
711
702 //*****
712 //*****
703 // MISC
713 // MISC
704 if (status == RTEMS_SUCCESSFUL) // HOUS
714 if (status == RTEMS_SUCCESSFUL) // HOUS
705 {
715 {
706 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
716 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
707 if (status!=RTEMS_SUCCESSFUL) {
717 if (status!=RTEMS_SUCCESSFUL) {
708 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
718 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
709 }
719 }
710 }
720 }
721 if (status == RTEMS_SUCCESSFUL) // AVGV
722 {
723 status = rtems_task_start( Task_id[TASKID_AVGV], avgv_task, 1 );
724 if (status!=RTEMS_SUCCESSFUL) {
725 BOOT_PRINTF("in INIT *** Error starting TASK_AVGV\n")
726 }
727 }
711 if (status == RTEMS_SUCCESSFUL) // DUMB
728 if (status == RTEMS_SUCCESSFUL) // DUMB
712 {
729 {
713 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
730 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
714 if (status!=RTEMS_SUCCESSFUL) {
731 if (status!=RTEMS_SUCCESSFUL) {
715 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
732 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
716 }
733 }
717 }
734 }
718 if (status == RTEMS_SUCCESSFUL) // LOAD
735 if (status == RTEMS_SUCCESSFUL) // LOAD
719 {
736 {
720 status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
737 status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
721 if (status!=RTEMS_SUCCESSFUL) {
738 if (status!=RTEMS_SUCCESSFUL) {
722 BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
739 BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
723 }
740 }
724 }
741 }
725
742
726 return status;
743 return status;
727 }
744 }
728
745
729 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
746 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
730 {
747 {
731 rtems_status_code status_recv;
748 rtems_status_code status_recv;
732 rtems_status_code status_send;
749 rtems_status_code status_send;
733 rtems_status_code status_q_p0;
750 rtems_status_code status_q_p0;
734 rtems_status_code status_q_p1;
751 rtems_status_code status_q_p1;
735 rtems_status_code status_q_p2;
752 rtems_status_code status_q_p2;
736 rtems_status_code ret;
753 rtems_status_code ret;
737 rtems_id queue_id;
754 rtems_id queue_id;
738
755
739 //****************************************
756 //****************************************
740 // create the queue for handling valid TCs
757 // create the queue for handling valid TCs
741 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
758 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
742 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
759 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
743 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
760 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
744 if ( status_recv != RTEMS_SUCCESSFUL ) {
761 if ( status_recv != RTEMS_SUCCESSFUL ) {
745 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
762 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
746 }
763 }
747
764
748 //************************************************
765 //************************************************
749 // create the queue for handling TM packet sending
766 // create the queue for handling TM packet sending
750 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
767 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
751 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
768 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
752 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
769 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
753 if ( status_send != RTEMS_SUCCESSFUL ) {
770 if ( status_send != RTEMS_SUCCESSFUL ) {
754 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
771 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
755 }
772 }
756
773
757 //*****************************************************************************
774 //*****************************************************************************
758 // create the queue for handling averaged spectral matrices for processing @ f0
775 // create the queue for handling averaged spectral matrices for processing @ f0
759 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
776 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
760 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
777 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
761 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
778 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
762 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
779 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
763 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
780 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
764 }
781 }
765
782
766 //*****************************************************************************
783 //*****************************************************************************
767 // create the queue for handling averaged spectral matrices for processing @ f1
784 // create the queue for handling averaged spectral matrices for processing @ f1
768 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
785 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
769 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
786 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
770 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
787 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
771 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
788 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
772 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
789 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
773 }
790 }
774
791
775 //*****************************************************************************
792 //*****************************************************************************
776 // create the queue for handling averaged spectral matrices for processing @ f2
793 // create the queue for handling averaged spectral matrices for processing @ f2
777 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
794 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
778 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
795 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
779 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
796 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
780 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
797 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
781 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
798 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
782 }
799 }
783
800
784 if ( status_recv != RTEMS_SUCCESSFUL )
801 if ( status_recv != RTEMS_SUCCESSFUL )
785 {
802 {
786 ret = status_recv;
803 ret = status_recv;
787 }
804 }
788 else if( status_send != RTEMS_SUCCESSFUL )
805 else if( status_send != RTEMS_SUCCESSFUL )
789 {
806 {
790 ret = status_send;
807 ret = status_send;
791 }
808 }
792 else if( status_q_p0 != RTEMS_SUCCESSFUL )
809 else if( status_q_p0 != RTEMS_SUCCESSFUL )
793 {
810 {
794 ret = status_q_p0;
811 ret = status_q_p0;
795 }
812 }
796 else if( status_q_p1 != RTEMS_SUCCESSFUL )
813 else if( status_q_p1 != RTEMS_SUCCESSFUL )
797 {
814 {
798 ret = status_q_p1;
815 ret = status_q_p1;
799 }
816 }
800 else
817 else
801 {
818 {
802 ret = status_q_p2;
819 ret = status_q_p2;
803 }
820 }
804
821
805 return ret;
822 return ret;
806 }
823 }
807
824
808 rtems_status_code create_timecode_timer( void )
825 rtems_status_code create_timecode_timer( void )
809 {
826 {
810 rtems_status_code status;
827 rtems_status_code status;
811
828
812 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
829 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
813
830
814 if ( status != RTEMS_SUCCESSFUL )
831 if ( status != RTEMS_SUCCESSFUL )
815 {
832 {
816 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
833 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
817 }
834 }
818 else
835 else
819 {
836 {
820 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
837 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
821 }
838 }
822
839
823 return status;
840 return status;
824 }
841 }
825
842
826 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
843 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
827 {
844 {
828 rtems_status_code status;
845 rtems_status_code status;
829 rtems_name queue_name;
846 rtems_name queue_name;
830
847
831 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
848 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
832
849
833 status = rtems_message_queue_ident( queue_name, 0, queue_id );
850 status = rtems_message_queue_ident( queue_name, 0, queue_id );
834
851
835 return status;
852 return status;
836 }
853 }
837
854
838 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
855 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
839 {
856 {
840 rtems_status_code status;
857 rtems_status_code status;
841 rtems_name queue_name;
858 rtems_name queue_name;
842
859
843 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
860 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
844
861
845 status = rtems_message_queue_ident( queue_name, 0, queue_id );
862 status = rtems_message_queue_ident( queue_name, 0, queue_id );
846
863
847 return status;
864 return status;
848 }
865 }
849
866
850 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
867 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
851 {
868 {
852 rtems_status_code status;
869 rtems_status_code status;
853 rtems_name queue_name;
870 rtems_name queue_name;
854
871
855 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
872 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
856
873
857 status = rtems_message_queue_ident( queue_name, 0, queue_id );
874 status = rtems_message_queue_ident( queue_name, 0, queue_id );
858
875
859 return status;
876 return status;
860 }
877 }
861
878
862 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
879 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
863 {
880 {
864 rtems_status_code status;
881 rtems_status_code status;
865 rtems_name queue_name;
882 rtems_name queue_name;
866
883
867 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
884 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
868
885
869 status = rtems_message_queue_ident( queue_name, 0, queue_id );
886 status = rtems_message_queue_ident( queue_name, 0, queue_id );
870
887
871 return status;
888 return status;
872 }
889 }
873
890
874 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
891 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
875 {
892 {
876 rtems_status_code status;
893 rtems_status_code status;
877 rtems_name queue_name;
894 rtems_name queue_name;
878
895
879 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
896 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
880
897
881 status = rtems_message_queue_ident( queue_name, 0, queue_id );
898 status = rtems_message_queue_ident( queue_name, 0, queue_id );
882
899
883 return status;
900 return status;
884 }
901 }
885
902
886 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
903 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
887 {
904 {
888 u_int32_t count;
905 u_int32_t count;
889 rtems_status_code status;
906 rtems_status_code status;
890
907
891 status = rtems_message_queue_get_number_pending( queue_id, &count );
908 status = rtems_message_queue_get_number_pending( queue_id, &count );
892
909
893 count = count + 1;
910 count = count + 1;
894
911
895 if (status != RTEMS_SUCCESSFUL)
912 if (status != RTEMS_SUCCESSFUL)
896 {
913 {
897 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
914 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
898 }
915 }
899 else
916 else
900 {
917 {
901 if (count > *fifo_size_max)
918 if (count > *fifo_size_max)
902 {
919 {
903 *fifo_size_max = count;
920 *fifo_size_max = count;
904 }
921 }
905 }
922 }
906 }
923 }
907
924
908 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
925 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
909 {
926 {
910 unsigned char i;
927 unsigned char i;
911
928
912 //***************
929 //***************
913 // BUFFER ADDRESS
930 // BUFFER ADDRESS
914 for(i=0; i<nbNodes; i++)
931 for(i=0; i<nbNodes; i++)
915 {
932 {
916 ring[i].coarseTime = 0xffffffff;
933 ring[i].coarseTime = 0xffffffff;
917 ring[i].fineTime = 0xffffffff;
934 ring[i].fineTime = 0xffffffff;
918 ring[i].sid = 0x00;
935 ring[i].sid = 0x00;
919 ring[i].status = 0x00;
936 ring[i].status = 0x00;
920 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
937 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
921 }
938 }
922
939
923 //*****
940 //*****
924 // NEXT
941 // NEXT
925 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
942 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
926 for(i=0; i<nbNodes-1; i++)
943 for(i=0; i<nbNodes-1; i++)
927 {
944 {
928 ring[i].next = (ring_node*) &ring[ i + 1 ];
945 ring[i].next = (ring_node*) &ring[ i + 1 ];
929 }
946 }
930
947
931 //*********
948 //*********
932 // PREVIOUS
949 // PREVIOUS
933 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
950 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
934 for(i=1; i<nbNodes; i++)
951 for(i=1; i<nbNodes; i++)
935 {
952 {
936 ring[i].previous = (ring_node*) &ring[ i - 1 ];
953 ring[i].previous = (ring_node*) &ring[ i - 1 ];
937 }
954 }
938 }
955 }
@@ -1,813 +1,898
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 PRINTF("watchdog_isr *** this is the end, exit(0)\n");
90 PRINTF("watchdog_isr *** this is the end, exit(0)\n");
91
91
92 exit(0);
92 exit(0);
93 }
93 }
94
94
95 void watchdog_configure(void)
95 void watchdog_configure(void)
96 {
96 {
97 /** This function configure the watchdog.
97 /** This function configure the watchdog.
98 *
98 *
99 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
99 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
100 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
100 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
101 *
101 *
102 * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB.
102 * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB.
103 *
103 *
104 */
104 */
105
105
106 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration
106 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration
107
107
108 timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr );
108 timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr );
109
109
110 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
110 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
111 }
111 }
112
112
113 void watchdog_stop(void)
113 void watchdog_stop(void)
114 {
114 {
115 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line
115 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line
116 timer_stop( TIMER_WATCHDOG );
116 timer_stop( TIMER_WATCHDOG );
117 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
117 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
118 }
118 }
119
119
120 void watchdog_reload(void)
120 void watchdog_reload(void)
121 {
121 {
122 /** This function reloads the watchdog timer counter with the timer reload value.
122 /** This function reloads the watchdog timer counter with the timer reload value.
123 *
123 *
124 * @param void
124 * @param void
125 *
125 *
126 * @return void
126 * @return void
127 *
127 *
128 */
128 */
129
129
130 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
130 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
131 }
131 }
132
132
133 void watchdog_start(void)
133 void watchdog_start(void)
134 {
134 {
135 /** This function starts the watchdog timer.
135 /** This function starts the watchdog timer.
136 *
136 *
137 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
137 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
138 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
138 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
139 *
139 *
140 */
140 */
141
141
142 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG );
142 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG );
143
143
144 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000010; // clear pending IRQ if any
144 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000010; // clear pending IRQ if any
145 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
145 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
146 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000001; // EN enable the timer
146 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000001; // EN enable the timer
147 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000008; // IE interrupt enable
147 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000008; // IE interrupt enable
148
148
149 LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG );
149 LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG );
150
150
151 }
151 }
152
152
153 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
153 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
154 {
154 {
155 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
155 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
156
156
157 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
157 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
158
158
159 return 0;
159 return 0;
160 }
160 }
161
161
162 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
162 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
163 {
163 {
164 /** This function sets the scaler reload register of the apbuart module
164 /** This function sets the scaler reload register of the apbuart module
165 *
165 *
166 * @param regs is the address of the apbuart registers in memory
166 * @param regs is the address of the apbuart registers in memory
167 * @param value is the value that will be stored in the scaler register
167 * @param value is the value that will be stored in the scaler register
168 *
168 *
169 * The value shall be set by the software to get data on the serial interface.
169 * The value shall be set by the software to get data on the serial interface.
170 *
170 *
171 */
171 */
172
172
173 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
173 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
174
174
175 apbuart_regs->scaler = value;
175 apbuart_regs->scaler = value;
176
176
177 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
177 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
178 }
178 }
179
179
180 //************
180 //************
181 // RTEMS TASKS
181 // RTEMS TASKS
182
182
183 rtems_task load_task(rtems_task_argument argument)
183 rtems_task load_task(rtems_task_argument argument)
184 {
184 {
185 BOOT_PRINTF("in LOAD *** \n")
185 BOOT_PRINTF("in LOAD *** \n")
186
186
187 rtems_status_code status;
187 rtems_status_code status;
188 unsigned int i;
188 unsigned int i;
189 unsigned int j;
189 unsigned int j;
190 rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic
190 rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic
191 rtems_id watchdog_period_id; // id of the watchdog rate monotonic period
191 rtems_id watchdog_period_id; // id of the watchdog rate monotonic period
192
192
193 name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' );
193 name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' );
194
194
195 status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id );
195 status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id );
196 if( status != RTEMS_SUCCESSFUL ) {
196 if( status != RTEMS_SUCCESSFUL ) {
197 PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status )
197 PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status )
198 }
198 }
199
199
200 i = 0;
200 i = 0;
201 j = 0;
201 j = 0;
202
202
203 watchdog_configure();
203 watchdog_configure();
204
204
205 watchdog_start();
205 watchdog_start();
206
206
207 set_sy_lfr_watchdog_enabled( true );
207 set_sy_lfr_watchdog_enabled( true );
208
208
209 while(1){
209 while(1){
210 status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD );
210 status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD );
211 watchdog_reload();
211 watchdog_reload();
212 i = i + 1;
212 i = i + 1;
213 if ( i == 10 )
213 if ( i == 10 )
214 {
214 {
215 i = 0;
215 i = 0;
216 j = j + 1;
216 j = j + 1;
217 PRINTF1("%d\n", j)
217 PRINTF1("%d\n", j)
218 }
218 }
219 #ifdef DEBUG_WATCHDOG
219 #ifdef DEBUG_WATCHDOG
220 if (j == 3 )
220 if (j == 3 )
221 {
221 {
222 status = rtems_task_delete(RTEMS_SELF);
222 status = rtems_task_delete(RTEMS_SELF);
223 }
223 }
224 #endif
224 #endif
225 }
225 }
226 }
226 }
227
227
228 rtems_task hous_task(rtems_task_argument argument)
228 rtems_task hous_task(rtems_task_argument argument)
229 {
229 {
230 rtems_status_code status;
230 rtems_status_code status;
231 rtems_status_code spare_status;
231 rtems_status_code spare_status;
232 rtems_id queue_id;
232 rtems_id queue_id;
233 rtems_rate_monotonic_period_status period_status;
233 rtems_rate_monotonic_period_status period_status;
234
234
235 status = get_message_queue_id_send( &queue_id );
235 status = get_message_queue_id_send( &queue_id );
236 if (status != RTEMS_SUCCESSFUL)
236 if (status != RTEMS_SUCCESSFUL)
237 {
237 {
238 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
238 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
239 }
239 }
240
240
241 BOOT_PRINTF("in HOUS ***\n");
241 BOOT_PRINTF("in HOUS ***\n");
242
242
243 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
243 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
244 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
244 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
245 if( status != RTEMS_SUCCESSFUL ) {
245 if( status != RTEMS_SUCCESSFUL ) {
246 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
246 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
247 }
247 }
248 }
248 }
249
249
250 status = rtems_rate_monotonic_cancel(HK_id);
250 status = rtems_rate_monotonic_cancel(HK_id);
251 if( status != RTEMS_SUCCESSFUL ) {
251 if( status != RTEMS_SUCCESSFUL ) {
252 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status );
252 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status );
253 }
253 }
254 else {
254 else {
255 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n");
255 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n");
256 }
256 }
257
257
258 // startup phase
258 // startup phase
259 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
259 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
260 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
260 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
261 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
261 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
262 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
262 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
263 {
263 {
264 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
264 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
265 {
265 {
266 break; // break if LFR is synchronized
266 break; // break if LFR is synchronized
267 }
267 }
268 else
268 else
269 {
269 {
270 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
270 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
271 // sched_yield();
271 // sched_yield();
272 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
272 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
273 }
273 }
274 }
274 }
275 status = rtems_rate_monotonic_cancel(HK_id);
275 status = rtems_rate_monotonic_cancel(HK_id);
276 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
276 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
277
277
278 set_hk_lfr_reset_cause( POWER_ON );
278 set_hk_lfr_reset_cause( POWER_ON );
279
279
280 while(1){ // launch the rate monotonic task
280 while(1){ // launch the rate monotonic task
281 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
281 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
282 if ( status != RTEMS_SUCCESSFUL ) {
282 if ( status != RTEMS_SUCCESSFUL ) {
283 PRINTF1( "in HOUS *** ERR period: %d\n", status);
283 PRINTF1( "in HOUS *** ERR period: %d\n", status);
284 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
284 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
285 }
285 }
286 else {
286 else {
287 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
287 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
288 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
288 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
289 increment_seq_counter( &sequenceCounterHK );
289 increment_seq_counter( &sequenceCounterHK );
290
290
291 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
291 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
292 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
292 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
293 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
293 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
294 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
294 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
295 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
295 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
296 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
296 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
297
297
298 spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] );
298 spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] );
299
299
300 spacewire_read_statistics();
300 spacewire_read_statistics();
301
301
302 update_hk_with_grspw_stats();
302 update_hk_with_grspw_stats();
303
303
304 set_hk_lfr_time_not_synchro();
304 set_hk_lfr_time_not_synchro();
305
305
306 housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max;
306 housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max;
307 housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max;
307 housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max;
308 housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max;
308 housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max;
309 housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max;
309 housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max;
310 housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max;
310 housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max;
311
311
312 housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare;
312 housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare;
313 housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
313 housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
314 get_temperatures( housekeeping_packet.hk_lfr_temp_scm );
314 get_temperatures( housekeeping_packet.hk_lfr_temp_scm );
315 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
315 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
316 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
316 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
317
317
318 hk_lfr_le_me_he_update();
318 hk_lfr_le_me_he_update();
319
319
320 housekeeping_packet.hk_lfr_sc_rw_f_flags = cp_rpw_sc_rw_f_flags;
320 housekeeping_packet.hk_lfr_sc_rw_f_flags = cp_rpw_sc_rw_f_flags;
321
321
322 // SEND PACKET
322 // SEND PACKET
323 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
323 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
324 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
324 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
325 if (status != RTEMS_SUCCESSFUL) {
325 if (status != RTEMS_SUCCESSFUL) {
326 PRINTF1("in HOUS *** ERR send: %d\n", status)
326 PRINTF1("in HOUS *** ERR send: %d\n", status)
327 }
327 }
328 }
328 }
329 }
329 }
330
330
331 PRINTF("in HOUS *** deleting task\n")
331 PRINTF("in HOUS *** deleting task\n")
332
332
333 status = rtems_task_delete( RTEMS_SELF ); // should not return
333 status = rtems_task_delete( RTEMS_SELF ); // should not return
334
334
335 return;
335 return;
336 }
336 }
337
337
338 rtems_task avgv_task(rtems_task_argument argument)
339 {
340 #define MOVING_AVERAGE 16
341 rtems_status_code status;
342 unsigned int v[MOVING_AVERAGE];
343 unsigned int e1[MOVING_AVERAGE];
344 unsigned int e2[MOVING_AVERAGE];
345 float average_v;
346 float average_e1;
347 float average_e2;
348 unsigned char k;
349 unsigned char indexOfOldValue;
350
351 BOOT_PRINTF("in AVGV ***\n");
352
353 if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
354 status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id );
355 if( status != RTEMS_SUCCESSFUL ) {
356 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
357 }
358 }
359
360 status = rtems_rate_monotonic_cancel(AVGV_id);
361 if( status != RTEMS_SUCCESSFUL ) {
362 PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status );
363 }
364 else {
365 DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n");
366 }
367
368 // initialize values
369 k = 0;
370 indexOfOldValue = MOVING_AVERAGE - 1;
371 for (k = 0; k < MOVING_AVERAGE; k++)
372 {
373 v[k] = 0;
374 e1[k] = 0;
375 e2[k] = 0;
376 average_v = 0.;
377 average_e1 = 0.;
378 average_e2 = 0.;
379 }
380
381 k = 0;
382
383 while(1){ // launch the rate monotonic task
384 status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD );
385 if ( status != RTEMS_SUCCESSFUL ) {
386 PRINTF1( "in AVGV *** ERR period: %d\n", status);
387 }
388 else {
389 // store new value in buffer
390 v[k] = waveform_picker_regs->v;
391 e1[k] = waveform_picker_regs->e1;
392 e2[k] = waveform_picker_regs->e2;
393 if (k == (MOVING_AVERAGE - 1))
394 {
395 indexOfOldValue = 0;
396 }
397 else
398 {
399 indexOfOldValue = k + 1;
400 }
401 average_v = average_v + v[k] - v[indexOfOldValue];
402 average_e1 = average_e1 + e1[k] - e1[indexOfOldValue];
403 average_e2 = average_e2 + e2[k] - e2[indexOfOldValue];
404 }
405 if (k == (MOVING_AVERAGE-1))
406 {
407 k = 0;
408 printf("tick\n");
409 }
410 else
411 {
412 k++;
413 }
414 }
415
416 PRINTF("in AVGV *** deleting task\n")
417
418 status = rtems_task_delete( RTEMS_SELF ); // should not return
419
420 return;
421 }
422
338 rtems_task dumb_task( rtems_task_argument unused )
423 rtems_task dumb_task( rtems_task_argument unused )
339 {
424 {
340 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
425 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
341 *
426 *
342 * @param unused is the starting argument of the RTEMS task
427 * @param unused is the starting argument of the RTEMS task
343 *
428 *
344 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
429 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
345 *
430 *
346 */
431 */
347
432
348 unsigned int i;
433 unsigned int i;
349 unsigned int intEventOut;
434 unsigned int intEventOut;
350 unsigned int coarse_time = 0;
435 unsigned int coarse_time = 0;
351 unsigned int fine_time = 0;
436 unsigned int fine_time = 0;
352 rtems_event_set event_out;
437 rtems_event_set event_out;
353
438
354 char *DumbMessages[15] = {"in DUMB *** default", // RTEMS_EVENT_0
439 char *DumbMessages[15] = {"in DUMB *** default", // RTEMS_EVENT_0
355 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
440 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
356 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
441 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
357 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
442 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
358 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
443 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
359 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
444 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
360 "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6
445 "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6
361 "ready for dump", // RTEMS_EVENT_7
446 "ready for dump", // RTEMS_EVENT_7
362 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
447 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
363 "tick", // RTEMS_EVENT_9
448 "tick", // RTEMS_EVENT_9
364 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
449 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
365 "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11
450 "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11
366 "WATCHDOG timer", // RTEMS_EVENT_12
451 "WATCHDOG timer", // RTEMS_EVENT_12
367 "TIMECODE timer", // RTEMS_EVENT_13
452 "TIMECODE timer", // RTEMS_EVENT_13
368 "TIMECODE ISR" // RTEMS_EVENT_14
453 "TIMECODE ISR" // RTEMS_EVENT_14
369 };
454 };
370
455
371 BOOT_PRINTF("in DUMB *** \n")
456 BOOT_PRINTF("in DUMB *** \n")
372
457
373 while(1){
458 while(1){
374 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
459 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
375 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
460 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
376 | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13
461 | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13
377 | RTEMS_EVENT_14,
462 | RTEMS_EVENT_14,
378 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
463 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
379 intEventOut = (unsigned int) event_out;
464 intEventOut = (unsigned int) event_out;
380 for ( i=0; i<32; i++)
465 for ( i=0; i<32; i++)
381 {
466 {
382 if ( ((intEventOut >> i) & 0x0001) != 0)
467 if ( ((intEventOut >> i) & 0x0001) != 0)
383 {
468 {
384 coarse_time = time_management_regs->coarse_time;
469 coarse_time = time_management_regs->coarse_time;
385 fine_time = time_management_regs->fine_time;
470 fine_time = time_management_regs->fine_time;
386 if (i==12)
471 if (i==12)
387 {
472 {
388 PRINTF1("%s\n", DumbMessages[12])
473 PRINTF1("%s\n", DumbMessages[12])
389 }
474 }
390 if (i==13)
475 if (i==13)
391 {
476 {
392 PRINTF1("%s\n", DumbMessages[13])
477 PRINTF1("%s\n", DumbMessages[13])
393 }
478 }
394 if (i==14)
479 if (i==14)
395 {
480 {
396 PRINTF1("%s\n", DumbMessages[1])
481 PRINTF1("%s\n", DumbMessages[1])
397 }
482 }
398 }
483 }
399 }
484 }
400 }
485 }
401 }
486 }
402
487
403 //*****************************
488 //*****************************
404 // init housekeeping parameters
489 // init housekeeping parameters
405
490
406 void init_housekeeping_parameters( void )
491 void init_housekeeping_parameters( void )
407 {
492 {
408 /** This function initialize the housekeeping_packet global variable with default values.
493 /** This function initialize the housekeeping_packet global variable with default values.
409 *
494 *
410 */
495 */
411
496
412 unsigned int i = 0;
497 unsigned int i = 0;
413 unsigned char *parameters;
498 unsigned char *parameters;
414 unsigned char sizeOfHK;
499 unsigned char sizeOfHK;
415
500
416 sizeOfHK = sizeof( Packet_TM_LFR_HK_t );
501 sizeOfHK = sizeof( Packet_TM_LFR_HK_t );
417
502
418 parameters = (unsigned char*) &housekeeping_packet;
503 parameters = (unsigned char*) &housekeeping_packet;
419
504
420 for(i = 0; i< sizeOfHK; i++)
505 for(i = 0; i< sizeOfHK; i++)
421 {
506 {
422 parameters[i] = 0x00;
507 parameters[i] = 0x00;
423 }
508 }
424
509
425 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
510 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
426 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
511 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
427 housekeeping_packet.reserved = DEFAULT_RESERVED;
512 housekeeping_packet.reserved = DEFAULT_RESERVED;
428 housekeeping_packet.userApplication = CCSDS_USER_APP;
513 housekeeping_packet.userApplication = CCSDS_USER_APP;
429 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
514 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
430 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
515 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
431 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
516 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
432 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
517 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
433 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
518 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
434 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
519 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
435 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
520 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
436 housekeeping_packet.serviceType = TM_TYPE_HK;
521 housekeeping_packet.serviceType = TM_TYPE_HK;
437 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
522 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
438 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
523 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
439 housekeeping_packet.sid = SID_HK;
524 housekeeping_packet.sid = SID_HK;
440
525
441 // init status word
526 // init status word
442 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
527 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
443 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
528 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
444 // init software version
529 // init software version
445 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
530 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
446 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
531 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
447 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
532 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
448 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
533 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
449 // init fpga version
534 // init fpga version
450 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
535 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
451 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
536 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
452 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
537 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
453 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
538 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
454
539
455 housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND;
540 housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND;
456 housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV;
541 housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV;
457 housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0;
542 housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0;
458 housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1;
543 housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1;
459 housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2;
544 housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2;
460 }
545 }
461
546
462 void increment_seq_counter( unsigned short *packetSequenceControl )
547 void increment_seq_counter( unsigned short *packetSequenceControl )
463 {
548 {
464 /** This function increment the sequence counter passes in argument.
549 /** This function increment the sequence counter passes in argument.
465 *
550 *
466 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
551 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
467 *
552 *
468 */
553 */
469
554
470 unsigned short segmentation_grouping_flag;
555 unsigned short segmentation_grouping_flag;
471 unsigned short sequence_cnt;
556 unsigned short sequence_cnt;
472
557
473 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
558 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
474 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
559 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
475
560
476 if ( sequence_cnt < SEQ_CNT_MAX)
561 if ( sequence_cnt < SEQ_CNT_MAX)
477 {
562 {
478 sequence_cnt = sequence_cnt + 1;
563 sequence_cnt = sequence_cnt + 1;
479 }
564 }
480 else
565 else
481 {
566 {
482 sequence_cnt = 0;
567 sequence_cnt = 0;
483 }
568 }
484
569
485 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
570 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
486 }
571 }
487
572
488 void getTime( unsigned char *time)
573 void getTime( unsigned char *time)
489 {
574 {
490 /** This function write the current local time in the time buffer passed in argument.
575 /** This function write the current local time in the time buffer passed in argument.
491 *
576 *
492 */
577 */
493
578
494 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
579 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
495 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
580 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
496 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
581 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
497 time[3] = (unsigned char) (time_management_regs->coarse_time);
582 time[3] = (unsigned char) (time_management_regs->coarse_time);
498 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
583 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
499 time[5] = (unsigned char) (time_management_regs->fine_time);
584 time[5] = (unsigned char) (time_management_regs->fine_time);
500 }
585 }
501
586
502 unsigned long long int getTimeAsUnsignedLongLongInt( )
587 unsigned long long int getTimeAsUnsignedLongLongInt( )
503 {
588 {
504 /** This function write the current local time in the time buffer passed in argument.
589 /** This function write the current local time in the time buffer passed in argument.
505 *
590 *
506 */
591 */
507 unsigned long long int time;
592 unsigned long long int time;
508
593
509 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
594 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
510 + time_management_regs->fine_time;
595 + time_management_regs->fine_time;
511
596
512 return time;
597 return time;
513 }
598 }
514
599
515 void send_dumb_hk( void )
600 void send_dumb_hk( void )
516 {
601 {
517 Packet_TM_LFR_HK_t dummy_hk_packet;
602 Packet_TM_LFR_HK_t dummy_hk_packet;
518 unsigned char *parameters;
603 unsigned char *parameters;
519 unsigned int i;
604 unsigned int i;
520 rtems_id queue_id;
605 rtems_id queue_id;
521
606
522 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
607 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
523 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
608 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
524 dummy_hk_packet.reserved = DEFAULT_RESERVED;
609 dummy_hk_packet.reserved = DEFAULT_RESERVED;
525 dummy_hk_packet.userApplication = CCSDS_USER_APP;
610 dummy_hk_packet.userApplication = CCSDS_USER_APP;
526 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
611 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
527 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
612 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
528 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
613 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
529 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
614 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
530 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
615 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
531 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
616 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
532 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
617 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
533 dummy_hk_packet.serviceType = TM_TYPE_HK;
618 dummy_hk_packet.serviceType = TM_TYPE_HK;
534 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
619 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
535 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
620 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
536 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
621 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
537 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
622 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
538 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
623 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
539 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
624 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
540 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
625 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
541 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
626 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
542 dummy_hk_packet.sid = SID_HK;
627 dummy_hk_packet.sid = SID_HK;
543
628
544 // init status word
629 // init status word
545 dummy_hk_packet.lfr_status_word[0] = 0xff;
630 dummy_hk_packet.lfr_status_word[0] = 0xff;
546 dummy_hk_packet.lfr_status_word[1] = 0xff;
631 dummy_hk_packet.lfr_status_word[1] = 0xff;
547 // init software version
632 // init software version
548 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
633 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
549 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
634 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
550 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
635 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
551 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
636 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
552 // init fpga version
637 // init fpga version
553 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
638 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
554 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
639 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
555 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
640 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
556 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
641 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
557
642
558 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
643 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
559
644
560 for (i=0; i<100; i++)
645 for (i=0; i<100; i++)
561 {
646 {
562 parameters[i] = 0xff;
647 parameters[i] = 0xff;
563 }
648 }
564
649
565 get_message_queue_id_send( &queue_id );
650 get_message_queue_id_send( &queue_id );
566
651
567 rtems_message_queue_send( queue_id, &dummy_hk_packet,
652 rtems_message_queue_send( queue_id, &dummy_hk_packet,
568 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
653 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
569 }
654 }
570
655
571 void get_temperatures( unsigned char *temperatures )
656 void get_temperatures( unsigned char *temperatures )
572 {
657 {
573 unsigned char* temp_scm_ptr;
658 unsigned char* temp_scm_ptr;
574 unsigned char* temp_pcb_ptr;
659 unsigned char* temp_pcb_ptr;
575 unsigned char* temp_fpga_ptr;
660 unsigned char* temp_fpga_ptr;
576
661
577 // SEL1 SEL0
662 // SEL1 SEL0
578 // 0 0 => PCB
663 // 0 0 => PCB
579 // 0 1 => FPGA
664 // 0 1 => FPGA
580 // 1 0 => SCM
665 // 1 0 => SCM
581
666
582 temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm;
667 temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm;
583 temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb;
668 temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb;
584 temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga;
669 temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga;
585
670
586 temperatures[0] = temp_scm_ptr[2];
671 temperatures[0] = temp_scm_ptr[2];
587 temperatures[1] = temp_scm_ptr[3];
672 temperatures[1] = temp_scm_ptr[3];
588 temperatures[2] = temp_pcb_ptr[2];
673 temperatures[2] = temp_pcb_ptr[2];
589 temperatures[3] = temp_pcb_ptr[3];
674 temperatures[3] = temp_pcb_ptr[3];
590 temperatures[4] = temp_fpga_ptr[2];
675 temperatures[4] = temp_fpga_ptr[2];
591 temperatures[5] = temp_fpga_ptr[3];
676 temperatures[5] = temp_fpga_ptr[3];
592 }
677 }
593
678
594 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
679 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
595 {
680 {
596 unsigned char* v_ptr;
681 unsigned char* v_ptr;
597 unsigned char* e1_ptr;
682 unsigned char* e1_ptr;
598 unsigned char* e2_ptr;
683 unsigned char* e2_ptr;
599
684
600 v_ptr = (unsigned char *) &waveform_picker_regs->v;
685 v_ptr = (unsigned char *) &waveform_picker_regs->v;
601 e1_ptr = (unsigned char *) &waveform_picker_regs->e1;
686 e1_ptr = (unsigned char *) &waveform_picker_regs->e1;
602 e2_ptr = (unsigned char *) &waveform_picker_regs->e2;
687 e2_ptr = (unsigned char *) &waveform_picker_regs->e2;
603
688
604 spacecraft_potential[0] = v_ptr[2];
689 spacecraft_potential[0] = v_ptr[2];
605 spacecraft_potential[1] = v_ptr[3];
690 spacecraft_potential[1] = v_ptr[3];
606 spacecraft_potential[2] = e1_ptr[2];
691 spacecraft_potential[2] = e1_ptr[2];
607 spacecraft_potential[3] = e1_ptr[3];
692 spacecraft_potential[3] = e1_ptr[3];
608 spacecraft_potential[4] = e2_ptr[2];
693 spacecraft_potential[4] = e2_ptr[2];
609 spacecraft_potential[5] = e2_ptr[3];
694 spacecraft_potential[5] = e2_ptr[3];
610 }
695 }
611
696
612 void get_cpu_load( unsigned char *resource_statistics )
697 void get_cpu_load( unsigned char *resource_statistics )
613 {
698 {
614 unsigned char cpu_load;
699 unsigned char cpu_load;
615
700
616 cpu_load = lfr_rtems_cpu_usage_report();
701 cpu_load = lfr_rtems_cpu_usage_report();
617
702
618 // HK_LFR_CPU_LOAD
703 // HK_LFR_CPU_LOAD
619 resource_statistics[0] = cpu_load;
704 resource_statistics[0] = cpu_load;
620
705
621 // HK_LFR_CPU_LOAD_MAX
706 // HK_LFR_CPU_LOAD_MAX
622 if (cpu_load > resource_statistics[1])
707 if (cpu_load > resource_statistics[1])
623 {
708 {
624 resource_statistics[1] = cpu_load;
709 resource_statistics[1] = cpu_load;
625 }
710 }
626
711
627 // CPU_LOAD_AVE
712 // CPU_LOAD_AVE
628 resource_statistics[2] = 0;
713 resource_statistics[2] = 0;
629
714
630 #ifndef PRINT_TASK_STATISTICS
715 #ifndef PRINT_TASK_STATISTICS
631 rtems_cpu_usage_reset();
716 rtems_cpu_usage_reset();
632 #endif
717 #endif
633
718
634 }
719 }
635
720
636 void set_hk_lfr_sc_potential_flag( bool state )
721 void set_hk_lfr_sc_potential_flag( bool state )
637 {
722 {
638 if (state == true)
723 if (state == true)
639 {
724 {
640 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000]
725 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000]
641 }
726 }
642 else
727 else
643 {
728 {
644 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111]
729 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111]
645 }
730 }
646 }
731 }
647
732
648 void set_sy_lfr_pas_filter_enabled( bool state )
733 void set_sy_lfr_pas_filter_enabled( bool state )
649 {
734 {
650 if (state == true)
735 if (state == true)
651 {
736 {
652 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000]
737 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000]
653 }
738 }
654 else
739 else
655 {
740 {
656 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xdf; // [1101 1111]
741 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xdf; // [1101 1111]
657 }
742 }
658 }
743 }
659
744
660 void set_sy_lfr_watchdog_enabled( bool state )
745 void set_sy_lfr_watchdog_enabled( bool state )
661 {
746 {
662 if (state == true)
747 if (state == true)
663 {
748 {
664 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x10; // [0001 0000]
749 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x10; // [0001 0000]
665 }
750 }
666 else
751 else
667 {
752 {
668 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xef; // [1110 1111]
753 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xef; // [1110 1111]
669 }
754 }
670 }
755 }
671
756
672 void set_hk_lfr_calib_enable( bool state )
757 void set_hk_lfr_calib_enable( bool state )
673 {
758 {
674 if (state == true)
759 if (state == true)
675 {
760 {
676 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000]
761 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000]
677 }
762 }
678 else
763 else
679 {
764 {
680 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111]
765 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111]
681 }
766 }
682 }
767 }
683
768
684 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause )
769 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause )
685 {
770 {
686 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf8; // [1111 1000]
771 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf8; // [1111 1000]
687
772
688 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
773 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
689 | (lfr_reset_cause & 0x07 ); // [0000 0111]
774 | (lfr_reset_cause & 0x07 ); // [0000 0111]
690
775
691 }
776 }
692
777
693 void hk_lfr_le_me_he_update()
778 void hk_lfr_le_me_he_update()
694 {
779 {
695 unsigned int hk_lfr_le_cnt;
780 unsigned int hk_lfr_le_cnt;
696 unsigned int hk_lfr_me_cnt;
781 unsigned int hk_lfr_me_cnt;
697 unsigned int hk_lfr_he_cnt;
782 unsigned int hk_lfr_he_cnt;
698 unsigned int current_hk_lfr_le_cnt;
783 unsigned int current_hk_lfr_le_cnt;
699 unsigned int current_hk_lfr_me_cnt;
784 unsigned int current_hk_lfr_me_cnt;
700 unsigned int current_hk_lfr_he_cnt;
785 unsigned int current_hk_lfr_he_cnt;
701
786
702 hk_lfr_le_cnt = 0;
787 hk_lfr_le_cnt = 0;
703 hk_lfr_me_cnt = 0;
788 hk_lfr_me_cnt = 0;
704 hk_lfr_he_cnt = 0;
789 hk_lfr_he_cnt = 0;
705 current_hk_lfr_le_cnt = ((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * 256 + housekeeping_packet.hk_lfr_le_cnt[1];
790 current_hk_lfr_le_cnt = ((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * 256 + housekeeping_packet.hk_lfr_le_cnt[1];
706 current_hk_lfr_me_cnt = ((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * 256 + housekeeping_packet.hk_lfr_me_cnt[1];
791 current_hk_lfr_me_cnt = ((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * 256 + housekeeping_packet.hk_lfr_me_cnt[1];
707 current_hk_lfr_he_cnt = ((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256 + housekeeping_packet.hk_lfr_he_cnt[1];
792 current_hk_lfr_he_cnt = ((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256 + housekeeping_packet.hk_lfr_he_cnt[1];
708
793
709 //update the low severity error counter
794 //update the low severity error counter
710 hk_lfr_le_cnt =
795 hk_lfr_le_cnt =
711 current_hk_lfr_le_cnt
796 current_hk_lfr_le_cnt
712 + housekeeping_packet.hk_lfr_dpu_spw_parity
797 + housekeeping_packet.hk_lfr_dpu_spw_parity
713 + housekeeping_packet.hk_lfr_dpu_spw_disconnect
798 + housekeeping_packet.hk_lfr_dpu_spw_disconnect
714 + housekeeping_packet.hk_lfr_dpu_spw_escape
799 + housekeeping_packet.hk_lfr_dpu_spw_escape
715 + housekeeping_packet.hk_lfr_dpu_spw_credit
800 + housekeeping_packet.hk_lfr_dpu_spw_credit
716 + housekeeping_packet.hk_lfr_dpu_spw_write_sync
801 + housekeeping_packet.hk_lfr_dpu_spw_write_sync
717 + housekeeping_packet.hk_lfr_timecode_erroneous
802 + housekeeping_packet.hk_lfr_timecode_erroneous
718 + housekeeping_packet.hk_lfr_timecode_missing
803 + housekeeping_packet.hk_lfr_timecode_missing
719 + housekeeping_packet.hk_lfr_timecode_invalid
804 + housekeeping_packet.hk_lfr_timecode_invalid
720 + housekeeping_packet.hk_lfr_time_timecode_it
805 + housekeeping_packet.hk_lfr_time_timecode_it
721 + housekeeping_packet.hk_lfr_time_not_synchro
806 + housekeeping_packet.hk_lfr_time_not_synchro
722 + housekeeping_packet.hk_lfr_time_timecode_ctr
807 + housekeeping_packet.hk_lfr_time_timecode_ctr
723 + housekeeping_packet.hk_lfr_ahb_correctable;
808 + housekeeping_packet.hk_lfr_ahb_correctable;
724 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver
809 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver
725 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver
810 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver
726
811
727 //update the medium severity error counter
812 //update the medium severity error counter
728 hk_lfr_me_cnt =
813 hk_lfr_me_cnt =
729 current_hk_lfr_me_cnt
814 current_hk_lfr_me_cnt
730 + housekeeping_packet.hk_lfr_dpu_spw_early_eop
815 + housekeeping_packet.hk_lfr_dpu_spw_early_eop
731 + housekeeping_packet.hk_lfr_dpu_spw_invalid_addr
816 + housekeeping_packet.hk_lfr_dpu_spw_invalid_addr
732 + housekeeping_packet.hk_lfr_dpu_spw_eep
817 + housekeeping_packet.hk_lfr_dpu_spw_eep
733 + housekeeping_packet.hk_lfr_dpu_spw_rx_too_big;
818 + housekeeping_packet.hk_lfr_dpu_spw_rx_too_big;
734
819
735 //update the high severity error counter
820 //update the high severity error counter
736 hk_lfr_he_cnt = 0;
821 hk_lfr_he_cnt = 0;
737
822
738 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
823 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
739 // LE
824 // LE
740 housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((hk_lfr_le_cnt & 0xff00) >> 8);
825 housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((hk_lfr_le_cnt & 0xff00) >> 8);
741 housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (hk_lfr_le_cnt & 0x00ff);
826 housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (hk_lfr_le_cnt & 0x00ff);
742 // ME
827 // ME
743 housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((hk_lfr_me_cnt & 0xff00) >> 8);
828 housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((hk_lfr_me_cnt & 0xff00) >> 8);
744 housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (hk_lfr_me_cnt & 0x00ff);
829 housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (hk_lfr_me_cnt & 0x00ff);
745 // HE
830 // HE
746 housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & 0xff00) >> 8);
831 housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & 0xff00) >> 8);
747 housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & 0x00ff);
832 housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & 0x00ff);
748
833
749 }
834 }
750
835
751 void set_hk_lfr_time_not_synchro()
836 void set_hk_lfr_time_not_synchro()
752 {
837 {
753 static unsigned char synchroLost = 1;
838 static unsigned char synchroLost = 1;
754 int synchronizationBit;
839 int synchronizationBit;
755
840
756 // get the synchronization bit
841 // get the synchronization bit
757 synchronizationBit = (time_management_regs->coarse_time & 0x80000000) >> 31; // 1000 0000 0000 0000
842 synchronizationBit = (time_management_regs->coarse_time & 0x80000000) >> 31; // 1000 0000 0000 0000
758
843
759 switch (synchronizationBit)
844 switch (synchronizationBit)
760 {
845 {
761 case 0:
846 case 0:
762 if (synchroLost == 1)
847 if (synchroLost == 1)
763 {
848 {
764 synchroLost = 0;
849 synchroLost = 0;
765 }
850 }
766 break;
851 break;
767 case 1:
852 case 1:
768 if (synchroLost == 0 )
853 if (synchroLost == 0 )
769 {
854 {
770 synchroLost = 1;
855 synchroLost = 1;
771 increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro);
856 increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro);
772 update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO );
857 update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO );
773 }
858 }
774 break;
859 break;
775 default:
860 default:
776 PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit);
861 PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit);
777 break;
862 break;
778 }
863 }
779
864
780 }
865 }
781
866
782 void set_hk_lfr_ahb_correctable() // CRITICITY L
867 void set_hk_lfr_ahb_correctable() // CRITICITY L
783 {
868 {
784 /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided
869 /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided
785 * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the
870 * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the
786 * detected errors in the cache, in the integer unit and in the floating point unit.
871 * detected errors in the cache, in the integer unit and in the floating point unit.
787 *
872 *
788 * @param void
873 * @param void
789 *
874 *
790 * @return void
875 * @return void
791 *
876 *
792 * All errors are summed to set the value of the hk_lfr_ahb_correctable counter.
877 * All errors are summed to set the value of the hk_lfr_ahb_correctable counter.
793 *
878 *
794 */
879 */
795
880
796 unsigned int ahb_correctable;
881 unsigned int ahb_correctable;
797 unsigned int instructionErrorCounter;
882 unsigned int instructionErrorCounter;
798 unsigned int dataErrorCounter;
883 unsigned int dataErrorCounter;
799 unsigned int fprfErrorCounter;
884 unsigned int fprfErrorCounter;
800 unsigned int iurfErrorCounter;
885 unsigned int iurfErrorCounter;
801
886
802 CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter);
887 CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter);
803 ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter);
888 ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter);
804
889
805 ahb_correctable = instructionErrorCounter
890 ahb_correctable = instructionErrorCounter
806 + dataErrorCounter
891 + dataErrorCounter
807 + fprfErrorCounter
892 + fprfErrorCounter
808 + iurfErrorCounter
893 + iurfErrorCounter
809 + housekeeping_packet.hk_lfr_ahb_correctable;
894 + housekeeping_packet.hk_lfr_ahb_correctable;
810
895
811 housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & 0xff); // [1111 1111]
896 housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & 0xff); // [1111 1111]
812
897
813 }
898 }
General Comments 0
You need to be logged in to leave comments. Login now