@@ -1,1005 +1,1005 | |||||
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 | int16_t hk_lfr_sc_v_f3_as_int16 = 0; |
|
10 | int16_t hk_lfr_sc_v_f3_as_int16 = 0; | |
11 | int16_t hk_lfr_sc_e1_f3_as_int16 = 0; |
|
11 | int16_t hk_lfr_sc_e1_f3_as_int16 = 0; | |
12 | int16_t hk_lfr_sc_e2_f3_as_int16 = 0; |
|
12 | int16_t hk_lfr_sc_e2_f3_as_int16 = 0; | |
13 |
|
13 | |||
14 | void timer_configure(unsigned char timer, unsigned int clock_divider, |
|
14 | void timer_configure(unsigned char timer, unsigned int clock_divider, | |
15 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
15 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) | |
16 | { |
|
16 | { | |
17 | /** This function configures a GPTIMER timer instantiated in the VHDL design. |
|
17 | /** This function configures a GPTIMER timer instantiated in the VHDL design. | |
18 | * |
|
18 | * | |
19 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
19 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
20 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
20 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
21 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
21 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
22 | * @param interrupt_level is the interrupt level that the timer drives. |
|
22 | * @param interrupt_level is the interrupt level that the timer drives. | |
23 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. |
|
23 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. | |
24 | * |
|
24 | * | |
25 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 |
|
25 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 | |
26 | * |
|
26 | * | |
27 | */ |
|
27 | */ | |
28 |
|
28 | |||
29 | rtems_status_code status; |
|
29 | rtems_status_code status; | |
30 | rtems_isr_entry old_isr_handler; |
|
30 | rtems_isr_entry old_isr_handler; | |
31 |
|
31 | |||
32 | old_isr_handler = NULL; |
|
32 | old_isr_handler = NULL; | |
33 |
|
33 | |||
34 | gptimer_regs->timer[timer].ctrl = INIT_CHAR; // reset the control register |
|
34 | gptimer_regs->timer[timer].ctrl = INIT_CHAR; // reset the control register | |
35 |
|
35 | |||
36 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
36 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels | |
37 | if (status!=RTEMS_SUCCESSFUL) |
|
37 | if (status!=RTEMS_SUCCESSFUL) | |
38 | { |
|
38 | { | |
39 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") |
|
39 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | timer_set_clock_divider( timer, clock_divider); |
|
42 | timer_set_clock_divider( timer, clock_divider); | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | void timer_start(unsigned char timer) |
|
45 | void timer_start(unsigned char timer) | |
46 | { |
|
46 | { | |
47 | /** This function starts a GPTIMER timer. |
|
47 | /** This function starts a GPTIMER timer. | |
48 | * |
|
48 | * | |
49 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
49 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
50 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
50 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
51 | * |
|
51 | * | |
52 | */ |
|
52 | */ | |
53 |
|
53 | |||
54 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; |
|
54 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; | |
55 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_LD; |
|
55 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_LD; | |
56 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_EN; |
|
56 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_EN; | |
57 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_RS; |
|
57 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_RS; | |
58 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_IE; |
|
58 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_IE; | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | void timer_stop(unsigned char timer) |
|
61 | void timer_stop(unsigned char timer) | |
62 | { |
|
62 | { | |
63 | /** This function stops a GPTIMER timer. |
|
63 | /** This function stops a GPTIMER timer. | |
64 | * |
|
64 | * | |
65 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
65 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
66 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
66 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
67 | * |
|
67 | * | |
68 | */ |
|
68 | */ | |
69 |
|
69 | |||
70 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_EN_MASK; |
|
70 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_EN_MASK; | |
71 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_IE_MASK; |
|
71 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_IE_MASK; | |
72 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; |
|
72 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider) |
|
75 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider) | |
76 | { |
|
76 | { | |
77 | /** This function sets the clock divider of a GPTIMER timer. |
|
77 | /** This function sets the clock divider of a GPTIMER timer. | |
78 | * |
|
78 | * | |
79 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
79 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
80 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
80 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
81 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
81 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
82 | * |
|
82 | * | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
85 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | // WATCHDOG |
|
88 | // WATCHDOG | |
89 |
|
89 | |||
90 | rtems_isr watchdog_isr( rtems_vector_number vector ) |
|
90 | rtems_isr watchdog_isr( rtems_vector_number vector ) | |
91 | { |
|
91 | { | |
92 | rtems_status_code status_code; |
|
92 | rtems_status_code status_code; | |
93 |
|
93 | |||
94 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 ); |
|
94 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 ); | |
95 |
|
95 | |||
96 | PRINTF("watchdog_isr *** this is the end, exit(0)\n"); |
|
96 | PRINTF("watchdog_isr *** this is the end, exit(0)\n"); | |
97 |
|
97 | |||
98 | exit(0); |
|
98 | exit(0); | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | void watchdog_configure(void) |
|
101 | void watchdog_configure(void) | |
102 | { |
|
102 | { | |
103 | /** This function configure the watchdog. |
|
103 | /** This function configure the watchdog. | |
104 | * |
|
104 | * | |
105 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
105 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
106 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
106 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
107 | * |
|
107 | * | |
108 | * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB. |
|
108 | * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB. | |
109 | * |
|
109 | * | |
110 | */ |
|
110 | */ | |
111 |
|
111 | |||
112 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration |
|
112 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration | |
113 |
|
113 | |||
114 | timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr ); |
|
114 | timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr ); | |
115 |
|
115 | |||
116 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt |
|
116 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | void watchdog_stop(void) |
|
119 | void watchdog_stop(void) | |
120 | { |
|
120 | { | |
121 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line |
|
121 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line | |
122 | timer_stop( TIMER_WATCHDOG ); |
|
122 | timer_stop( TIMER_WATCHDOG ); | |
123 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt |
|
123 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt | |
124 | } |
|
124 | } | |
125 |
|
125 | |||
126 | void watchdog_reload(void) |
|
126 | void watchdog_reload(void) | |
127 | { |
|
127 | { | |
128 | /** This function reloads the watchdog timer counter with the timer reload value. |
|
128 | /** This function reloads the watchdog timer counter with the timer reload value. | |
129 | * |
|
129 | * | |
130 | * @param void |
|
130 | * @param void | |
131 | * |
|
131 | * | |
132 | * @return void |
|
132 | * @return void | |
133 | * |
|
133 | * | |
134 | */ |
|
134 | */ | |
135 |
|
135 | |||
136 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; |
|
136 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | void watchdog_start(void) |
|
139 | void watchdog_start(void) | |
140 | { |
|
140 | { | |
141 | /** This function starts the watchdog timer. |
|
141 | /** This function starts the watchdog timer. | |
142 | * |
|
142 | * | |
143 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
143 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
144 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
144 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
145 | * |
|
145 | * | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); |
|
148 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); | |
149 |
|
149 | |||
150 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_CLEAR_IRQ; |
|
150 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_CLEAR_IRQ; | |
151 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; |
|
151 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; | |
152 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_EN; |
|
152 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_EN; | |
153 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_IE; |
|
153 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_IE; | |
154 |
|
154 | |||
155 | LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG ); |
|
155 | LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG ); | |
156 |
|
156 | |||
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register |
|
159 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register | |
160 | { |
|
160 | { | |
161 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
161 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
162 |
|
162 | |||
163 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; |
|
163 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; | |
164 |
|
164 | |||
165 | return 0; |
|
165 | return 0; | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) |
|
168 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) | |
169 | { |
|
169 | { | |
170 | /** This function sets the scaler reload register of the apbuart module |
|
170 | /** This function sets the scaler reload register of the apbuart module | |
171 | * |
|
171 | * | |
172 | * @param regs is the address of the apbuart registers in memory |
|
172 | * @param regs is the address of the apbuart registers in memory | |
173 | * @param value is the value that will be stored in the scaler register |
|
173 | * @param value is the value that will be stored in the scaler register | |
174 | * |
|
174 | * | |
175 | * The value shall be set by the software to get data on the serial interface. |
|
175 | * The value shall be set by the software to get data on the serial interface. | |
176 | * |
|
176 | * | |
177 | */ |
|
177 | */ | |
178 |
|
178 | |||
179 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; |
|
179 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; | |
180 |
|
180 | |||
181 | apbuart_regs->scaler = value; |
|
181 | apbuart_regs->scaler = value; | |
182 |
|
182 | |||
183 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) |
|
183 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) | |
184 | } |
|
184 | } | |
185 |
|
185 | |||
186 | //************ |
|
186 | //************ | |
187 | // RTEMS TASKS |
|
187 | // RTEMS TASKS | |
188 |
|
188 | |||
189 | rtems_task load_task(rtems_task_argument argument) |
|
189 | rtems_task load_task(rtems_task_argument argument) | |
190 | { |
|
190 | { | |
191 | BOOT_PRINTF("in LOAD *** \n") |
|
191 | BOOT_PRINTF("in LOAD *** \n") | |
192 |
|
192 | |||
193 | rtems_status_code status; |
|
193 | rtems_status_code status; | |
194 | unsigned int i; |
|
194 | unsigned int i; | |
195 | unsigned int j; |
|
195 | unsigned int j; | |
196 | rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic |
|
196 | rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic | |
197 | rtems_id watchdog_period_id; // id of the watchdog rate monotonic period |
|
197 | rtems_id watchdog_period_id; // id of the watchdog rate monotonic period | |
198 |
|
198 | |||
199 | watchdog_period_id = RTEMS_ID_NONE; |
|
199 | watchdog_period_id = RTEMS_ID_NONE; | |
200 |
|
200 | |||
201 | name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' ); |
|
201 | name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' ); | |
202 |
|
202 | |||
203 | status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id ); |
|
203 | status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id ); | |
204 | if( status != RTEMS_SUCCESSFUL ) { |
|
204 | if( status != RTEMS_SUCCESSFUL ) { | |
205 | PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
205 | PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status ) | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | i = 0; |
|
208 | i = 0; | |
209 | j = 0; |
|
209 | j = 0; | |
210 |
|
210 | |||
211 | watchdog_configure(); |
|
211 | watchdog_configure(); | |
212 |
|
212 | |||
213 | watchdog_start(); |
|
213 | watchdog_start(); | |
214 |
|
214 | |||
215 | set_sy_lfr_watchdog_enabled( true ); |
|
215 | set_sy_lfr_watchdog_enabled( true ); | |
216 |
|
216 | |||
217 | while(1){ |
|
217 | while(1){ | |
218 | status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD ); |
|
218 | status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD ); | |
219 | watchdog_reload(); |
|
219 | watchdog_reload(); | |
220 | i = i + 1; |
|
220 | i = i + 1; | |
221 | if ( i == WATCHDOG_LOOP_PRINTF ) |
|
221 | if ( i == WATCHDOG_LOOP_PRINTF ) | |
222 | { |
|
222 | { | |
223 | i = 0; |
|
223 | i = 0; | |
224 | j = j + 1; |
|
224 | j = j + 1; | |
225 | PRINTF1("%d\n", j) |
|
225 | PRINTF1("%d\n", j) | |
226 | } |
|
226 | } | |
227 | #ifdef DEBUG_WATCHDOG |
|
227 | #ifdef DEBUG_WATCHDOG | |
228 | if (j == WATCHDOG_LOOP_DEBUG ) |
|
228 | if (j == WATCHDOG_LOOP_DEBUG ) | |
229 | { |
|
229 | { | |
230 | status = rtems_task_delete(RTEMS_SELF); |
|
230 | status = rtems_task_delete(RTEMS_SELF); | |
231 | } |
|
231 | } | |
232 | #endif |
|
232 | #endif | |
233 | } |
|
233 | } | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | rtems_task hous_task(rtems_task_argument argument) |
|
236 | rtems_task hous_task(rtems_task_argument argument) | |
237 | { |
|
237 | { | |
238 | rtems_status_code status; |
|
238 | rtems_status_code status; | |
239 | rtems_status_code spare_status; |
|
239 | rtems_status_code spare_status; | |
240 | rtems_id queue_id; |
|
240 | rtems_id queue_id; | |
241 | rtems_rate_monotonic_period_status period_status; |
|
241 | rtems_rate_monotonic_period_status period_status; | |
242 | bool isSynchronized; |
|
242 | bool isSynchronized; | |
243 |
|
243 | |||
244 | queue_id = RTEMS_ID_NONE; |
|
244 | queue_id = RTEMS_ID_NONE; | |
245 | memset(&period_status, 0, sizeof(rtems_rate_monotonic_period_status)); |
|
245 | memset(&period_status, 0, sizeof(rtems_rate_monotonic_period_status)); | |
246 | isSynchronized = false; |
|
246 | isSynchronized = false; | |
247 |
|
247 | |||
248 | status = get_message_queue_id_send( &queue_id ); |
|
248 | status = get_message_queue_id_send( &queue_id ); | |
249 | if (status != RTEMS_SUCCESSFUL) |
|
249 | if (status != RTEMS_SUCCESSFUL) | |
250 | { |
|
250 | { | |
251 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
251 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 | BOOT_PRINTF("in HOUS ***\n"); |
|
254 | BOOT_PRINTF("in HOUS ***\n"); | |
255 |
|
255 | |||
256 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { |
|
256 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { | |
257 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); |
|
257 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); | |
258 | if( status != RTEMS_SUCCESSFUL ) { |
|
258 | if( status != RTEMS_SUCCESSFUL ) { | |
259 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); |
|
259 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); | |
260 | } |
|
260 | } | |
261 | } |
|
261 | } | |
262 |
|
262 | |||
263 | status = rtems_rate_monotonic_cancel(HK_id); |
|
263 | status = rtems_rate_monotonic_cancel(HK_id); | |
264 | if( status != RTEMS_SUCCESSFUL ) { |
|
264 | if( status != RTEMS_SUCCESSFUL ) { | |
265 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ); |
|
265 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ); | |
266 | } |
|
266 | } | |
267 | else { |
|
267 | else { | |
268 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n"); |
|
268 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n"); | |
269 | } |
|
269 | } | |
270 |
|
270 | |||
271 | // startup phase |
|
271 | // startup phase | |
272 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); |
|
272 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); | |
273 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
273 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
274 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
274 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
275 | while( (period_status.state != RATE_MONOTONIC_EXPIRED) |
|
275 | while( (period_status.state != RATE_MONOTONIC_EXPIRED) | |
276 | && (isSynchronized == false) ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway |
|
276 | && (isSynchronized == false) ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway | |
277 | { |
|
277 | { | |
278 | if ((time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) == INT32_ALL_0) // check time synchronization |
|
278 | if ((time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) == INT32_ALL_0) // check time synchronization | |
279 | { |
|
279 | { | |
280 | isSynchronized = true; |
|
280 | isSynchronized = true; | |
281 | } |
|
281 | } | |
282 | else |
|
282 | else | |
283 | { |
|
283 | { | |
284 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
284 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
285 |
|
285 | |||
286 | status = rtems_task_wake_after( HK_SYNC_WAIT ); // wait HK_SYNCH_WAIT 100 ms = 10 * 10 ms |
|
286 | status = rtems_task_wake_after( HK_SYNC_WAIT ); // wait HK_SYNCH_WAIT 100 ms = 10 * 10 ms | |
287 | } |
|
287 | } | |
288 | } |
|
288 | } | |
289 | status = rtems_rate_monotonic_cancel(HK_id); |
|
289 | status = rtems_rate_monotonic_cancel(HK_id); | |
290 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
290 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
291 |
|
291 | |||
292 | set_hk_lfr_reset_cause( POWER_ON ); |
|
292 | set_hk_lfr_reset_cause( POWER_ON ); | |
293 |
|
293 | |||
294 | while(1){ // launch the rate monotonic task |
|
294 | while(1){ // launch the rate monotonic task | |
295 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); |
|
295 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); | |
296 | if ( status != RTEMS_SUCCESSFUL ) { |
|
296 | if ( status != RTEMS_SUCCESSFUL ) { | |
297 | PRINTF1( "in HOUS *** ERR period: %d\n", status); |
|
297 | PRINTF1( "in HOUS *** ERR period: %d\n", status); | |
298 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); |
|
298 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); | |
299 | } |
|
299 | } | |
300 | else { |
|
300 | else { | |
301 | housekeeping_packet.packetSequenceControl[BYTE_0] = (unsigned char) (sequenceCounterHK >> SHIFT_1_BYTE); |
|
301 | housekeeping_packet.packetSequenceControl[BYTE_0] = (unsigned char) (sequenceCounterHK >> SHIFT_1_BYTE); | |
302 | housekeeping_packet.packetSequenceControl[BYTE_1] = (unsigned char) (sequenceCounterHK ); |
|
302 | housekeeping_packet.packetSequenceControl[BYTE_1] = (unsigned char) (sequenceCounterHK ); | |
303 | increment_seq_counter( &sequenceCounterHK ); |
|
303 | increment_seq_counter( &sequenceCounterHK ); | |
304 |
|
304 | |||
305 | housekeeping_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
305 | housekeeping_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
306 | housekeeping_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
306 | housekeeping_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
307 | housekeeping_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
307 | housekeeping_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
308 | housekeeping_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
308 | housekeeping_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
309 | housekeeping_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
309 | housekeeping_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
310 | housekeeping_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
310 | housekeeping_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
311 |
|
311 | |||
312 | spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] ); |
|
312 | spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] ); | |
313 |
|
313 | |||
314 | spacewire_read_statistics(); |
|
314 | spacewire_read_statistics(); | |
315 |
|
315 | |||
316 | update_hk_with_grspw_stats(); |
|
316 | update_hk_with_grspw_stats(); | |
317 |
|
317 | |||
318 | set_hk_lfr_time_not_synchro(); |
|
318 | set_hk_lfr_time_not_synchro(); | |
319 |
|
319 | |||
320 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; |
|
320 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; | |
321 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; |
|
321 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; | |
322 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; |
|
322 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; | |
323 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; |
|
323 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; | |
324 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; |
|
324 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; | |
325 |
|
325 | |||
326 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; |
|
326 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; | |
327 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
327 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
328 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); |
|
328 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); | |
329 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); |
|
329 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); | |
330 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); |
|
330 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); | |
331 |
|
331 | |||
332 | hk_lfr_le_me_he_update(); |
|
332 | hk_lfr_le_me_he_update(); | |
333 |
|
333 | |||
334 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = cp_rpw_sc_rw1_rw2_f_flags; |
|
334 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = cp_rpw_sc_rw1_rw2_f_flags; | |
335 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = cp_rpw_sc_rw3_rw4_f_flags; |
|
335 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = cp_rpw_sc_rw3_rw4_f_flags; | |
336 |
|
336 | |||
337 | // SEND PACKET |
|
337 | // SEND PACKET | |
338 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, |
|
338 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, | |
339 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
339 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
340 | if (status != RTEMS_SUCCESSFUL) { |
|
340 | if (status != RTEMS_SUCCESSFUL) { | |
341 | PRINTF1("in HOUS *** ERR send: %d\n", status) |
|
341 | PRINTF1("in HOUS *** ERR send: %d\n", status) | |
342 | } |
|
342 | } | |
343 | } |
|
343 | } | |
344 | } |
|
344 | } | |
345 |
|
345 | |||
346 | PRINTF("in HOUS *** deleting task\n") |
|
346 | PRINTF("in HOUS *** deleting task\n") | |
347 |
|
347 | |||
348 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
348 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
349 |
|
349 | |||
350 | return; |
|
350 | return; | |
351 | } |
|
351 | } | |
352 |
|
352 | |||
353 | rtems_task avgv_task(rtems_task_argument argument) |
|
353 | rtems_task avgv_task(rtems_task_argument argument) | |
354 | { |
|
354 | { | |
355 | #define MOVING_AVERAGE 16 |
|
355 | #define MOVING_AVERAGE 16 | |
356 | rtems_status_code status; |
|
356 | rtems_status_code status; | |
357 | static unsigned int v[MOVING_AVERAGE] = {0}; |
|
357 | static unsigned int v[MOVING_AVERAGE] = {0}; | |
358 | static unsigned int e1[MOVING_AVERAGE] = {0}; |
|
358 | static unsigned int e1[MOVING_AVERAGE] = {0}; | |
359 | static unsigned int e2[MOVING_AVERAGE] = {0}; |
|
359 | static unsigned int e2[MOVING_AVERAGE] = {0}; | |
360 | float average_v; |
|
360 | float average_v; | |
361 | float average_e1; |
|
361 | float average_e1; | |
362 | float average_e2; |
|
362 | float average_e2; | |
363 | float newValue_v; |
|
363 | float newValue_v; | |
364 | float newValue_e1; |
|
364 | float newValue_e1; | |
365 | float newValue_e2; |
|
365 | float newValue_e2; | |
366 | unsigned char k; |
|
366 | unsigned char k; | |
367 | unsigned char indexOfOldValue; |
|
367 | unsigned char indexOfOldValue; | |
368 |
|
368 | |||
369 | BOOT_PRINTF("in AVGV ***\n"); |
|
369 | BOOT_PRINTF("in AVGV ***\n"); | |
370 |
|
370 | |||
371 | if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { |
|
371 | if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { | |
372 | status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id ); |
|
372 | status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id ); | |
373 | if( status != RTEMS_SUCCESSFUL ) { |
|
373 | if( status != RTEMS_SUCCESSFUL ) { | |
374 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); |
|
374 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); | |
375 | } |
|
375 | } | |
376 | } |
|
376 | } | |
377 |
|
377 | |||
378 | status = rtems_rate_monotonic_cancel(AVGV_id); |
|
378 | status = rtems_rate_monotonic_cancel(AVGV_id); | |
379 | if( status != RTEMS_SUCCESSFUL ) { |
|
379 | if( status != RTEMS_SUCCESSFUL ) { | |
380 | PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status ); |
|
380 | PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status ); | |
381 | } |
|
381 | } | |
382 | else { |
|
382 | else { | |
383 | DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n"); |
|
383 | DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n"); | |
384 | } |
|
384 | } | |
385 |
|
385 | |||
386 | // initialize values |
|
386 | // initialize values | |
387 | indexOfOldValue = MOVING_AVERAGE - 1; |
|
387 | indexOfOldValue = MOVING_AVERAGE - 1; | |
388 | average_v = INIT_FLOAT; |
|
388 | average_v = INIT_FLOAT; | |
389 | average_e1 = INIT_FLOAT; |
|
389 | average_e1 = INIT_FLOAT; | |
390 | average_e2 = INIT_FLOAT; |
|
390 | average_e2 = INIT_FLOAT; | |
391 | newValue_v = INIT_FLOAT; |
|
391 | newValue_v = INIT_FLOAT; | |
392 | newValue_e1 = INIT_FLOAT; |
|
392 | newValue_e1 = INIT_FLOAT; | |
393 | newValue_e2 = INIT_FLOAT; |
|
393 | newValue_e2 = INIT_FLOAT; | |
394 |
|
394 | |||
395 | k = INIT_CHAR; |
|
395 | k = INIT_CHAR; | |
396 |
|
396 | |||
397 | while(1) |
|
397 | while(1) | |
398 | { // launch the rate monotonic task |
|
398 | { // launch the rate monotonic task | |
399 | status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD ); |
|
399 | status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD ); | |
400 | if ( status != RTEMS_SUCCESSFUL ) |
|
400 | if ( status != RTEMS_SUCCESSFUL ) | |
401 | { |
|
401 | { | |
402 | PRINTF1( "in AVGV *** ERR period: %d\n", status); |
|
402 | PRINTF1( "in AVGV *** ERR period: %d\n", status); | |
403 | } |
|
403 | } | |
404 | else |
|
404 | else | |
405 | { |
|
405 | { | |
406 | // get new values |
|
406 | // get new values | |
407 | newValue_v = waveform_picker_regs->v; |
|
407 | newValue_v = waveform_picker_regs->v; | |
408 | newValue_e1 = waveform_picker_regs->e1; |
|
408 | newValue_e1 = waveform_picker_regs->e1; | |
409 | newValue_e2 = waveform_picker_regs->e2; |
|
409 | newValue_e2 = waveform_picker_regs->e2; | |
410 |
|
410 | |||
411 | // compute the moving average |
|
411 | // compute the moving average | |
412 | average_v = average_v + newValue_v - v[k]; |
|
412 | average_v = average_v + newValue_v - v[k]; | |
413 | average_e1 = average_e1 + newValue_e1 - e1[k]; |
|
413 | average_e1 = average_e1 + newValue_e1 - e1[k]; | |
414 | average_e2 = average_e2 + newValue_e2 - e2[k]; |
|
414 | average_e2 = average_e2 + newValue_e2 - e2[k]; | |
415 |
|
415 | |||
416 | // store new values in buffers |
|
416 | // store new values in buffers | |
417 | v[k] = newValue_v; |
|
417 | v[k] = newValue_v; | |
418 | e1[k] = newValue_e1; |
|
418 | e1[k] = newValue_e1; | |
419 | e2[k] = newValue_e2; |
|
419 | e2[k] = newValue_e2; | |
420 | } |
|
420 | } | |
421 | if (k == (MOVING_AVERAGE-1)) |
|
421 | if (k == (MOVING_AVERAGE-1)) | |
422 | { |
|
422 | { | |
423 | k = 0; |
|
423 | k = 0; | |
424 | PRINTF("tick\n"); |
|
424 | PRINTF("tick\n"); | |
425 | } |
|
425 | } | |
426 | else |
|
426 | else | |
427 | { |
|
427 | { | |
428 | k++; |
|
428 | k++; | |
429 | } |
|
429 | } | |
430 | //update int16 values |
|
430 | //update int16 values | |
431 | hk_lfr_sc_v_f3_as_int16 = (int16_t) (average_v / ((float) MOVING_AVERAGE) ); |
|
431 | hk_lfr_sc_v_f3_as_int16 = (int16_t) (average_v / ((float) MOVING_AVERAGE) ); | |
432 | hk_lfr_sc_e1_f3_as_int16 = (int16_t) (average_e1 / ((float) MOVING_AVERAGE) ); |
|
432 | hk_lfr_sc_e1_f3_as_int16 = (int16_t) (average_e1 / ((float) MOVING_AVERAGE) ); | |
433 | hk_lfr_sc_e2_f3_as_int16 = (int16_t) (average_e2 / ((float) MOVING_AVERAGE) ); |
|
433 | hk_lfr_sc_e2_f3_as_int16 = (int16_t) (average_e2 / ((float) MOVING_AVERAGE) ); | |
434 | } |
|
434 | } | |
435 |
|
435 | |||
436 | PRINTF("in AVGV *** deleting task\n"); |
|
436 | PRINTF("in AVGV *** deleting task\n"); | |
437 |
|
437 | |||
438 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
438 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
439 |
|
439 | |||
440 | return; |
|
440 | return; | |
441 | } |
|
441 | } | |
442 |
|
442 | |||
443 | rtems_task dumb_task( rtems_task_argument unused ) |
|
443 | rtems_task dumb_task( rtems_task_argument unused ) | |
444 | { |
|
444 | { | |
445 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. |
|
445 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. | |
446 | * |
|
446 | * | |
447 | * @param unused is the starting argument of the RTEMS task |
|
447 | * @param unused is the starting argument of the RTEMS task | |
448 | * |
|
448 | * | |
449 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. |
|
449 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. | |
450 | * |
|
450 | * | |
451 | */ |
|
451 | */ | |
452 |
|
452 | |||
453 | unsigned int i; |
|
453 | unsigned int i; | |
454 | unsigned int intEventOut; |
|
454 | unsigned int intEventOut; | |
455 | unsigned int coarse_time = 0; |
|
455 | unsigned int coarse_time = 0; | |
456 | unsigned int fine_time = 0; |
|
456 | unsigned int fine_time = 0; | |
457 | rtems_event_set event_out; |
|
457 | rtems_event_set event_out; | |
458 |
|
458 | |||
459 | event_out = EVENT_SETS_NONE_PENDING; |
|
459 | event_out = EVENT_SETS_NONE_PENDING; | |
460 |
|
460 | |||
461 | BOOT_PRINTF("in DUMB *** \n") |
|
461 | BOOT_PRINTF("in DUMB *** \n") | |
462 |
|
462 | |||
463 | while(1){ |
|
463 | while(1){ | |
464 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 |
|
464 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | |
465 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 |
|
465 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 | |
466 | | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13 |
|
466 | | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13 | |
467 | | RTEMS_EVENT_14, |
|
467 | | RTEMS_EVENT_14, | |
468 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
468 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT | |
469 | intEventOut = (unsigned int) event_out; |
|
469 | intEventOut = (unsigned int) event_out; | |
470 | for ( i=0; i<NB_RTEMS_EVENTS; i++) |
|
470 | for ( i=0; i<NB_RTEMS_EVENTS; i++) | |
471 | { |
|
471 | { | |
472 | if ( ((intEventOut >> i) & 1) != 0) |
|
472 | if ( ((intEventOut >> i) & 1) != 0) | |
473 | { |
|
473 | { | |
474 | coarse_time = time_management_regs->coarse_time; |
|
474 | coarse_time = time_management_regs->coarse_time; | |
475 | fine_time = time_management_regs->fine_time; |
|
475 | fine_time = time_management_regs->fine_time; | |
476 | if (i==EVENT_12) |
|
476 | if (i==EVENT_12) | |
477 | { |
|
477 | { | |
478 | PRINTF1("%s\n", DUMB_MESSAGE_12) |
|
478 | PRINTF1("%s\n", DUMB_MESSAGE_12) | |
479 | } |
|
479 | } | |
480 | if (i==EVENT_13) |
|
480 | if (i==EVENT_13) | |
481 | { |
|
481 | { | |
482 | PRINTF1("%s\n", DUMB_MESSAGE_13) |
|
482 | PRINTF1("%s\n", DUMB_MESSAGE_13) | |
483 | } |
|
483 | } | |
484 | if (i==EVENT_14) |
|
484 | if (i==EVENT_14) | |
485 | { |
|
485 | { | |
486 | PRINTF1("%s\n", DUMB_MESSAGE_1) |
|
486 | PRINTF1("%s\n", DUMB_MESSAGE_1) | |
487 | } |
|
487 | } | |
488 | } |
|
488 | } | |
489 | } |
|
489 | } | |
490 | } |
|
490 | } | |
491 | } |
|
491 | } | |
492 |
|
492 | |||
493 | //***************************** |
|
493 | //***************************** | |
494 | // init housekeeping parameters |
|
494 | // init housekeeping parameters | |
495 |
|
495 | |||
496 | void init_housekeeping_parameters( void ) |
|
496 | void init_housekeeping_parameters( void ) | |
497 | { |
|
497 | { | |
498 | /** This function initialize the housekeeping_packet global variable with default values. |
|
498 | /** This function initialize the housekeeping_packet global variable with default values. | |
499 | * |
|
499 | * | |
500 | */ |
|
500 | */ | |
501 |
|
501 | |||
502 | unsigned int i = 0; |
|
502 | unsigned int i = 0; | |
503 | unsigned char *parameters; |
|
503 | unsigned char *parameters; | |
504 | unsigned char sizeOfHK; |
|
504 | unsigned char sizeOfHK; | |
505 |
|
505 | |||
506 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); |
|
506 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); | |
507 |
|
507 | |||
508 | parameters = (unsigned char*) &housekeeping_packet; |
|
508 | parameters = (unsigned char*) &housekeeping_packet; | |
509 |
|
509 | |||
510 | for(i = 0; i< sizeOfHK; i++) |
|
510 | for(i = 0; i< sizeOfHK; i++) | |
511 | { |
|
511 | { | |
512 | parameters[i] = INIT_CHAR; |
|
512 | parameters[i] = INIT_CHAR; | |
513 | } |
|
513 | } | |
514 |
|
514 | |||
515 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
515 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
516 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
516 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
517 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
517 | housekeeping_packet.reserved = DEFAULT_RESERVED; | |
518 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
518 | housekeeping_packet.userApplication = CCSDS_USER_APP; | |
519 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); |
|
519 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); | |
520 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
520 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
521 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
521 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
522 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
522 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
523 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); |
|
523 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); | |
524 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
524 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
525 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
525 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
526 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
526 | housekeeping_packet.serviceType = TM_TYPE_HK; | |
527 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
527 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; | |
528 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
528 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
529 | housekeeping_packet.sid = SID_HK; |
|
529 | housekeeping_packet.sid = SID_HK; | |
530 |
|
530 | |||
531 | // init status word |
|
531 | // init status word | |
532 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; |
|
532 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; | |
533 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; |
|
533 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; | |
534 | // init software version |
|
534 | // init software version | |
535 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
535 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
536 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
536 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
537 | housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; |
|
537 | housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; | |
538 | housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; |
|
538 | housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; | |
539 | // init fpga version |
|
539 | // init fpga version | |
540 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
540 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
541 | housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 |
|
541 | housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 | |
542 | housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 |
|
542 | housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 | |
543 | housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 |
|
543 | housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 | |
544 |
|
544 | |||
545 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; |
|
545 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; | |
546 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; |
|
546 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; | |
547 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; |
|
547 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; | |
548 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; |
|
548 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; | |
549 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; |
|
549 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; | |
550 | } |
|
550 | } | |
551 |
|
551 | |||
552 | void increment_seq_counter( unsigned short *packetSequenceControl ) |
|
552 | void increment_seq_counter( unsigned short *packetSequenceControl ) | |
553 | { |
|
553 | { | |
554 | /** This function increment the sequence counter passes in argument. |
|
554 | /** This function increment the sequence counter passes in argument. | |
555 | * |
|
555 | * | |
556 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. |
|
556 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. | |
557 | * |
|
557 | * | |
558 | */ |
|
558 | */ | |
559 |
|
559 | |||
560 | unsigned short segmentation_grouping_flag; |
|
560 | unsigned short segmentation_grouping_flag; | |
561 | unsigned short sequence_cnt; |
|
561 | unsigned short sequence_cnt; | |
562 |
|
562 | |||
563 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; // keep bits 7 downto 6 |
|
563 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; // keep bits 7 downto 6 | |
564 | sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111] |
|
564 | sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111] | |
565 |
|
565 | |||
566 | if ( sequence_cnt < SEQ_CNT_MAX) |
|
566 | if ( sequence_cnt < SEQ_CNT_MAX) | |
567 | { |
|
567 | { | |
568 | sequence_cnt = sequence_cnt + 1; |
|
568 | sequence_cnt = sequence_cnt + 1; | |
569 | } |
|
569 | } | |
570 | else |
|
570 | else | |
571 | { |
|
571 | { | |
572 | sequence_cnt = 0; |
|
572 | sequence_cnt = 0; | |
573 | } |
|
573 | } | |
574 |
|
574 | |||
575 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; |
|
575 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; | |
576 | } |
|
576 | } | |
577 |
|
577 | |||
578 | void getTime( unsigned char *time) |
|
578 | void getTime( unsigned char *time) | |
579 | { |
|
579 | { | |
580 | /** This function write the current local time in the time buffer passed in argument. |
|
580 | /** This function write the current local time in the time buffer passed in argument. | |
581 | * |
|
581 | * | |
582 | */ |
|
582 | */ | |
583 |
|
583 | |||
584 | time[0] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_3_BYTES); |
|
584 | time[0] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_3_BYTES); | |
585 | time[1] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_2_BYTES); |
|
585 | time[1] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_2_BYTES); | |
586 | time[2] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_1_BYTE); |
|
586 | time[2] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_1_BYTE); | |
587 | time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
587 | time[3] = (unsigned char) (time_management_regs->coarse_time); | |
588 | time[4] = (unsigned char) (time_management_regs->fine_time>>SHIFT_1_BYTE); |
|
588 | time[4] = (unsigned char) (time_management_regs->fine_time>>SHIFT_1_BYTE); | |
589 | time[5] = (unsigned char) (time_management_regs->fine_time); |
|
589 | time[5] = (unsigned char) (time_management_regs->fine_time); | |
590 | } |
|
590 | } | |
591 |
|
591 | |||
592 | unsigned long long int getTimeAsUnsignedLongLongInt( ) |
|
592 | unsigned long long int getTimeAsUnsignedLongLongInt( ) | |
593 | { |
|
593 | { | |
594 | /** This function write the current local time in the time buffer passed in argument. |
|
594 | /** This function write the current local time in the time buffer passed in argument. | |
595 | * |
|
595 | * | |
596 | */ |
|
596 | */ | |
597 | unsigned long long int time; |
|
597 | unsigned long long int time; | |
598 |
|
598 | |||
599 | time = ( (unsigned long long int) (time_management_regs->coarse_time & COARSE_TIME_MASK) << SHIFT_2_BYTES ) |
|
599 | time = ( (unsigned long long int) (time_management_regs->coarse_time & COARSE_TIME_MASK) << SHIFT_2_BYTES ) | |
600 | + time_management_regs->fine_time; |
|
600 | + time_management_regs->fine_time; | |
601 |
|
601 | |||
602 | return time; |
|
602 | return time; | |
603 | } |
|
603 | } | |
604 |
|
604 | |||
605 | void send_dumb_hk( void ) |
|
605 | void send_dumb_hk( void ) | |
606 | { |
|
606 | { | |
607 | Packet_TM_LFR_HK_t dummy_hk_packet; |
|
607 | Packet_TM_LFR_HK_t dummy_hk_packet; | |
608 | unsigned char *parameters; |
|
608 | unsigned char *parameters; | |
609 | unsigned int i; |
|
609 | unsigned int i; | |
610 | rtems_id queue_id; |
|
610 | rtems_id queue_id; | |
611 |
|
611 | |||
612 | queue_id = RTEMS_ID_NONE; |
|
612 | queue_id = RTEMS_ID_NONE; | |
613 |
|
613 | |||
614 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
614 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
615 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
615 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
616 | dummy_hk_packet.reserved = DEFAULT_RESERVED; |
|
616 | dummy_hk_packet.reserved = DEFAULT_RESERVED; | |
617 | dummy_hk_packet.userApplication = CCSDS_USER_APP; |
|
617 | dummy_hk_packet.userApplication = CCSDS_USER_APP; | |
618 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); |
|
618 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); | |
619 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
619 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
620 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
620 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
621 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
621 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
622 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); |
|
622 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); | |
623 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
623 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
624 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
624 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
625 | dummy_hk_packet.serviceType = TM_TYPE_HK; |
|
625 | dummy_hk_packet.serviceType = TM_TYPE_HK; | |
626 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; |
|
626 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; | |
627 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
627 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
628 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
628 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
629 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
629 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
630 | dummy_hk_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
630 | dummy_hk_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
631 | dummy_hk_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
631 | dummy_hk_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
632 | dummy_hk_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
632 | dummy_hk_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
633 | dummy_hk_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
633 | dummy_hk_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
634 | dummy_hk_packet.sid = SID_HK; |
|
634 | dummy_hk_packet.sid = SID_HK; | |
635 |
|
635 | |||
636 | // init status word |
|
636 | // init status word | |
637 | dummy_hk_packet.lfr_status_word[0] = INT8_ALL_F; |
|
637 | dummy_hk_packet.lfr_status_word[0] = INT8_ALL_F; | |
638 | dummy_hk_packet.lfr_status_word[1] = INT8_ALL_F; |
|
638 | dummy_hk_packet.lfr_status_word[1] = INT8_ALL_F; | |
639 | // init software version |
|
639 | // init software version | |
640 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
640 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
641 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
641 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
642 | dummy_hk_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; |
|
642 | dummy_hk_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; | |
643 | dummy_hk_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; |
|
643 | dummy_hk_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; | |
644 | // init fpga version |
|
644 | // init fpga version | |
645 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + APB_OFFSET_VHDL_REV); |
|
645 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + APB_OFFSET_VHDL_REV); | |
646 | dummy_hk_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 |
|
646 | dummy_hk_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 | |
647 | dummy_hk_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 |
|
647 | dummy_hk_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 | |
648 | dummy_hk_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 |
|
648 | dummy_hk_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 | |
649 |
|
649 | |||
650 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; |
|
650 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; | |
651 |
|
651 | |||
652 | for (i=0; i<(BYTE_POS_HK_REACTION_WHEELS_FREQUENCY - BYTE_POS_HK_LFR_CPU_LOAD); i++) |
|
652 | for (i=0; i<(BYTE_POS_HK_REACTION_WHEELS_FREQUENCY - BYTE_POS_HK_LFR_CPU_LOAD); i++) | |
653 | { |
|
653 | { | |
654 | parameters[i] = INT8_ALL_F; |
|
654 | parameters[i] = INT8_ALL_F; | |
655 | } |
|
655 | } | |
656 |
|
656 | |||
657 | get_message_queue_id_send( &queue_id ); |
|
657 | get_message_queue_id_send( &queue_id ); | |
658 |
|
658 | |||
659 | rtems_message_queue_send( queue_id, &dummy_hk_packet, |
|
659 | rtems_message_queue_send( queue_id, &dummy_hk_packet, | |
660 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
660 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
661 | } |
|
661 | } | |
662 |
|
662 | |||
663 | void get_temperatures( unsigned char *temperatures ) |
|
663 | void get_temperatures( unsigned char *temperatures ) | |
664 | { |
|
664 | { | |
665 | unsigned char* temp_scm_ptr; |
|
665 | unsigned char* temp_scm_ptr; | |
666 | unsigned char* temp_pcb_ptr; |
|
666 | unsigned char* temp_pcb_ptr; | |
667 | unsigned char* temp_fpga_ptr; |
|
667 | unsigned char* temp_fpga_ptr; | |
668 |
|
668 | |||
669 | // SEL1 SEL0 |
|
669 | // SEL1 SEL0 | |
670 | // 0 0 => PCB |
|
670 | // 0 0 => PCB | |
671 | // 0 1 => FPGA |
|
671 | // 0 1 => FPGA | |
672 | // 1 0 => SCM |
|
672 | // 1 0 => SCM | |
673 |
|
673 | |||
674 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; |
|
674 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; | |
675 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; |
|
675 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; | |
676 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; |
|
676 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; | |
677 |
|
677 | |||
678 | temperatures[ BYTE_0 ] = temp_scm_ptr[ BYTE_2 ]; |
|
678 | temperatures[ BYTE_0 ] = temp_scm_ptr[ BYTE_2 ]; | |
679 | temperatures[ BYTE_1 ] = temp_scm_ptr[ BYTE_3 ]; |
|
679 | temperatures[ BYTE_1 ] = temp_scm_ptr[ BYTE_3 ]; | |
680 | temperatures[ BYTE_2 ] = temp_pcb_ptr[ BYTE_2 ]; |
|
680 | temperatures[ BYTE_2 ] = temp_pcb_ptr[ BYTE_2 ]; | |
681 | temperatures[ BYTE_3 ] = temp_pcb_ptr[ BYTE_3 ]; |
|
681 | temperatures[ BYTE_3 ] = temp_pcb_ptr[ BYTE_3 ]; | |
682 | temperatures[ BYTE_4 ] = temp_fpga_ptr[ BYTE_2 ]; |
|
682 | temperatures[ BYTE_4 ] = temp_fpga_ptr[ BYTE_2 ]; | |
683 | temperatures[ BYTE_5 ] = temp_fpga_ptr[ BYTE_3 ]; |
|
683 | temperatures[ BYTE_5 ] = temp_fpga_ptr[ BYTE_3 ]; | |
684 | } |
|
684 | } | |
685 |
|
685 | |||
686 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) |
|
686 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) | |
687 | { |
|
687 | { | |
688 | unsigned char* v_ptr; |
|
688 | unsigned char* v_ptr; | |
689 | unsigned char* e1_ptr; |
|
689 | unsigned char* e1_ptr; | |
690 | unsigned char* e2_ptr; |
|
690 | unsigned char* e2_ptr; | |
691 |
|
691 | |||
692 | v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16; |
|
692 | v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16; | |
693 | e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16; |
|
693 | e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16; | |
694 | e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16; |
|
694 | e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16; | |
695 |
|
695 | |||
696 | spacecraft_potential[BYTE_0] = v_ptr[0]; |
|
696 | spacecraft_potential[BYTE_0] = v_ptr[0]; | |
697 | spacecraft_potential[BYTE_1] = v_ptr[1]; |
|
697 | spacecraft_potential[BYTE_1] = v_ptr[1]; | |
698 | spacecraft_potential[BYTE_2] = e1_ptr[0]; |
|
698 | spacecraft_potential[BYTE_2] = e1_ptr[0]; | |
699 | spacecraft_potential[BYTE_3] = e1_ptr[1]; |
|
699 | spacecraft_potential[BYTE_3] = e1_ptr[1]; | |
700 | spacecraft_potential[BYTE_4] = e2_ptr[0]; |
|
700 | spacecraft_potential[BYTE_4] = e2_ptr[0]; | |
701 | spacecraft_potential[BYTE_5] = e2_ptr[1]; |
|
701 | spacecraft_potential[BYTE_5] = e2_ptr[1]; | |
702 | } |
|
702 | } | |
703 |
|
703 | |||
704 | void get_cpu_load( unsigned char *resource_statistics ) |
|
704 | void get_cpu_load( unsigned char *resource_statistics ) | |
705 | { |
|
705 | { | |
706 | unsigned char cpu_load; |
|
706 | unsigned char cpu_load; | |
707 |
|
707 | |||
708 | cpu_load = lfr_rtems_cpu_usage_report(); |
|
708 | cpu_load = lfr_rtems_cpu_usage_report(); | |
709 |
|
709 | |||
710 | // HK_LFR_CPU_LOAD |
|
710 | // HK_LFR_CPU_LOAD | |
711 | resource_statistics[0] = cpu_load; |
|
711 | resource_statistics[0] = cpu_load; | |
712 |
|
712 | |||
713 | // HK_LFR_CPU_LOAD_MAX |
|
713 | // HK_LFR_CPU_LOAD_MAX | |
714 | if (cpu_load > resource_statistics[1]) |
|
714 | if (cpu_load > resource_statistics[1]) | |
715 | { |
|
715 | { | |
716 | resource_statistics[1] = cpu_load; |
|
716 | resource_statistics[1] = cpu_load; | |
717 | } |
|
717 | } | |
718 |
|
718 | |||
719 | // CPU_LOAD_AVE |
|
719 | // CPU_LOAD_AVE | |
720 | resource_statistics[BYTE_2] = 0; |
|
720 | resource_statistics[BYTE_2] = 0; | |
721 |
|
721 | |||
722 | #ifndef PRINT_TASK_STATISTICS |
|
722 | #ifndef PRINT_TASK_STATISTICS | |
723 | rtems_cpu_usage_reset(); |
|
723 | rtems_cpu_usage_reset(); | |
724 | #endif |
|
724 | #endif | |
725 |
|
725 | |||
726 | } |
|
726 | } | |
727 |
|
727 | |||
728 | void set_hk_lfr_sc_potential_flag( bool state ) |
|
728 | void set_hk_lfr_sc_potential_flag( bool state ) | |
729 | { |
|
729 | { | |
730 | if (state == true) |
|
730 | if (state == true) | |
731 | { |
|
731 | { | |
732 | housekeeping_packet.lfr_status_word[1] = |
|
732 | housekeeping_packet.lfr_status_word[1] = | |
733 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000] |
|
733 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000] | |
734 | } |
|
734 | } | |
735 | else |
|
735 | else | |
736 | { |
|
736 | { | |
737 | housekeeping_packet.lfr_status_word[1] = |
|
737 | housekeeping_packet.lfr_status_word[1] = | |
738 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111] |
|
738 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111] | |
739 | } |
|
739 | } | |
740 | } |
|
740 | } | |
741 |
|
741 | |||
742 | void set_sy_lfr_pas_filter_enabled( bool state ) |
|
742 | void set_sy_lfr_pas_filter_enabled( bool state ) | |
743 | { |
|
743 | { | |
744 | if (state == true) |
|
744 | if (state == true) | |
745 | { |
|
745 | { | |
746 | housekeeping_packet.lfr_status_word[1] = |
|
746 | housekeeping_packet.lfr_status_word[1] = | |
747 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_PAS_FILTER_ENABLED_BIT; // [0010 0000] |
|
747 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_PAS_FILTER_ENABLED_BIT; // [0010 0000] | |
748 | } |
|
748 | } | |
749 | else |
|
749 | else | |
750 | { |
|
750 | { | |
751 | housekeeping_packet.lfr_status_word[1] = |
|
751 | housekeeping_packet.lfr_status_word[1] = | |
752 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_PAS_FILTER_ENABLED_MASK; // [1101 1111] |
|
752 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_PAS_FILTER_ENABLED_MASK; // [1101 1111] | |
753 | } |
|
753 | } | |
754 | } |
|
754 | } | |
755 |
|
755 | |||
756 | void set_sy_lfr_watchdog_enabled( bool state ) |
|
756 | void set_sy_lfr_watchdog_enabled( bool state ) | |
757 | { |
|
757 | { | |
758 | if (state == true) |
|
758 | if (state == true) | |
759 | { |
|
759 | { | |
760 | housekeeping_packet.lfr_status_word[1] = |
|
760 | housekeeping_packet.lfr_status_word[1] = | |
761 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000] |
|
761 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000] | |
762 | } |
|
762 | } | |
763 | else |
|
763 | else | |
764 | { |
|
764 | { | |
765 | housekeeping_packet.lfr_status_word[1] = |
|
765 | housekeeping_packet.lfr_status_word[1] = | |
766 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111] |
|
766 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111] | |
767 | } |
|
767 | } | |
768 | } |
|
768 | } | |
769 |
|
769 | |||
770 | void set_hk_lfr_calib_enable( bool state ) |
|
770 | void set_hk_lfr_calib_enable( bool state ) | |
771 | { |
|
771 | { | |
772 | if (state == true) |
|
772 | if (state == true) | |
773 | { |
|
773 | { | |
774 | housekeeping_packet.lfr_status_word[1] = |
|
774 | housekeeping_packet.lfr_status_word[1] = | |
775 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000] |
|
775 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000] | |
776 | } |
|
776 | } | |
777 | else |
|
777 | else | |
778 | { |
|
778 | { | |
779 | housekeeping_packet.lfr_status_word[1] = |
|
779 | housekeeping_packet.lfr_status_word[1] = | |
780 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111] |
|
780 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111] | |
781 | } |
|
781 | } | |
782 | } |
|
782 | } | |
783 |
|
783 | |||
784 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) |
|
784 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) | |
785 | { |
|
785 | { | |
786 | housekeeping_packet.lfr_status_word[1] = |
|
786 | housekeeping_packet.lfr_status_word[1] = | |
787 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000] |
|
787 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000] | |
788 |
|
788 | |||
789 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] |
|
789 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | |
790 | | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS ); // [0000 0111] |
|
790 | | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS ); // [0000 0111] | |
791 |
|
791 | |||
792 | } |
|
792 | } | |
793 |
|
793 | |||
794 | void increment_hk_counter( unsigned char newValue, unsigned char oldValue, unsigned int *counter ) |
|
794 | void increment_hk_counter( unsigned char newValue, unsigned char oldValue, unsigned int *counter ) | |
795 | { |
|
795 | { | |
796 | int delta; |
|
796 | int delta; | |
797 |
|
797 | |||
798 | delta = 0; |
|
798 | delta = 0; | |
799 |
|
799 | |||
800 | if (newValue >= oldValue) |
|
800 | if (newValue >= oldValue) | |
801 | { |
|
801 | { | |
802 | delta = newValue - oldValue; |
|
802 | delta = newValue - oldValue; | |
803 | } |
|
803 | } | |
804 | else |
|
804 | else | |
805 | { |
|
805 | { | |
806 |
delta = ( |
|
806 | delta = (CONST_256 - oldValue) + newValue; | |
807 | } |
|
807 | } | |
808 |
|
808 | |||
809 | *counter = *counter + delta; |
|
809 | *counter = *counter + delta; | |
810 | } |
|
810 | } | |
811 |
|
811 | |||
812 | void hk_lfr_le_update( void ) |
|
812 | void hk_lfr_le_update( void ) | |
813 | { |
|
813 | { | |
814 | static hk_lfr_le_t old_hk_lfr_le = {0}; |
|
814 | static hk_lfr_le_t old_hk_lfr_le = {0}; | |
815 | hk_lfr_le_t new_hk_lfr_le; |
|
815 | hk_lfr_le_t new_hk_lfr_le; | |
816 | unsigned int counter; |
|
816 | unsigned int counter; | |
817 |
|
817 | |||
818 | counter = (((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * 256) + housekeeping_packet.hk_lfr_le_cnt[1]; |
|
818 | counter = (((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_le_cnt[1]; | |
819 |
|
819 | |||
820 | // DPU |
|
820 | // DPU | |
821 | new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity; |
|
821 | new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity; | |
822 | new_hk_lfr_le.dpu_spw_disconnect= housekeeping_packet.hk_lfr_dpu_spw_disconnect; |
|
822 | new_hk_lfr_le.dpu_spw_disconnect= housekeeping_packet.hk_lfr_dpu_spw_disconnect; | |
823 | new_hk_lfr_le.dpu_spw_escape = housekeeping_packet.hk_lfr_dpu_spw_escape; |
|
823 | new_hk_lfr_le.dpu_spw_escape = housekeeping_packet.hk_lfr_dpu_spw_escape; | |
824 | new_hk_lfr_le.dpu_spw_credit = housekeeping_packet.hk_lfr_dpu_spw_credit; |
|
824 | new_hk_lfr_le.dpu_spw_credit = housekeeping_packet.hk_lfr_dpu_spw_credit; | |
825 | new_hk_lfr_le.dpu_spw_write_sync= housekeeping_packet.hk_lfr_dpu_spw_write_sync; |
|
825 | new_hk_lfr_le.dpu_spw_write_sync= housekeeping_packet.hk_lfr_dpu_spw_write_sync; | |
826 | // TIMECODE |
|
826 | // TIMECODE | |
827 | new_hk_lfr_le.timecode_erroneous= housekeeping_packet.hk_lfr_timecode_erroneous; |
|
827 | new_hk_lfr_le.timecode_erroneous= housekeeping_packet.hk_lfr_timecode_erroneous; | |
828 | new_hk_lfr_le.timecode_missing = housekeeping_packet.hk_lfr_timecode_missing; |
|
828 | new_hk_lfr_le.timecode_missing = housekeeping_packet.hk_lfr_timecode_missing; | |
829 | new_hk_lfr_le.timecode_invalid = housekeeping_packet.hk_lfr_timecode_invalid; |
|
829 | new_hk_lfr_le.timecode_invalid = housekeeping_packet.hk_lfr_timecode_invalid; | |
830 | // TIME |
|
830 | // TIME | |
831 | new_hk_lfr_le.time_timecode_it = housekeeping_packet.hk_lfr_time_timecode_it; |
|
831 | new_hk_lfr_le.time_timecode_it = housekeeping_packet.hk_lfr_time_timecode_it; | |
832 | new_hk_lfr_le.time_not_synchro = housekeeping_packet.hk_lfr_time_not_synchro; |
|
832 | new_hk_lfr_le.time_not_synchro = housekeeping_packet.hk_lfr_time_not_synchro; | |
833 | new_hk_lfr_le.time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr; |
|
833 | new_hk_lfr_le.time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr; | |
834 | //AHB |
|
834 | //AHB | |
835 | new_hk_lfr_le.ahb_correctable = housekeeping_packet.hk_lfr_ahb_correctable; |
|
835 | new_hk_lfr_le.ahb_correctable = housekeeping_packet.hk_lfr_ahb_correctable; | |
836 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver |
|
836 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver | |
837 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver |
|
837 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver | |
838 |
|
838 | |||
839 | // update the le counter |
|
839 | // update the le counter | |
840 | // DPU |
|
840 | // DPU | |
841 | increment_hk_counter( new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter ); |
|
841 | increment_hk_counter( new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter ); | |
842 | increment_hk_counter( new_hk_lfr_le.dpu_spw_disconnect,old_hk_lfr_le.dpu_spw_disconnect, &counter ); |
|
842 | increment_hk_counter( new_hk_lfr_le.dpu_spw_disconnect,old_hk_lfr_le.dpu_spw_disconnect, &counter ); | |
843 | increment_hk_counter( new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter ); |
|
843 | increment_hk_counter( new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter ); | |
844 | increment_hk_counter( new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter ); |
|
844 | increment_hk_counter( new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter ); | |
845 | increment_hk_counter( new_hk_lfr_le.dpu_spw_write_sync,old_hk_lfr_le.dpu_spw_write_sync, &counter ); |
|
845 | increment_hk_counter( new_hk_lfr_le.dpu_spw_write_sync,old_hk_lfr_le.dpu_spw_write_sync, &counter ); | |
846 | // TIMECODE |
|
846 | // TIMECODE | |
847 | increment_hk_counter( new_hk_lfr_le.timecode_erroneous,old_hk_lfr_le.timecode_erroneous, &counter ); |
|
847 | increment_hk_counter( new_hk_lfr_le.timecode_erroneous,old_hk_lfr_le.timecode_erroneous, &counter ); | |
848 | increment_hk_counter( new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter ); |
|
848 | increment_hk_counter( new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter ); | |
849 | increment_hk_counter( new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter ); |
|
849 | increment_hk_counter( new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter ); | |
850 | // TIME |
|
850 | // TIME | |
851 | increment_hk_counter( new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter ); |
|
851 | increment_hk_counter( new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter ); | |
852 | increment_hk_counter( new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter ); |
|
852 | increment_hk_counter( new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter ); | |
853 | increment_hk_counter( new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter ); |
|
853 | increment_hk_counter( new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter ); | |
854 | // AHB |
|
854 | // AHB | |
855 | increment_hk_counter( new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter ); |
|
855 | increment_hk_counter( new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter ); | |
856 |
|
856 | |||
857 | // DPU |
|
857 | // DPU | |
858 | old_hk_lfr_le.dpu_spw_parity = new_hk_lfr_le.dpu_spw_parity; |
|
858 | old_hk_lfr_le.dpu_spw_parity = new_hk_lfr_le.dpu_spw_parity; | |
859 | old_hk_lfr_le.dpu_spw_disconnect= new_hk_lfr_le.dpu_spw_disconnect; |
|
859 | old_hk_lfr_le.dpu_spw_disconnect= new_hk_lfr_le.dpu_spw_disconnect; | |
860 | old_hk_lfr_le.dpu_spw_escape = new_hk_lfr_le.dpu_spw_escape; |
|
860 | old_hk_lfr_le.dpu_spw_escape = new_hk_lfr_le.dpu_spw_escape; | |
861 | old_hk_lfr_le.dpu_spw_credit = new_hk_lfr_le.dpu_spw_credit; |
|
861 | old_hk_lfr_le.dpu_spw_credit = new_hk_lfr_le.dpu_spw_credit; | |
862 | old_hk_lfr_le.dpu_spw_write_sync= new_hk_lfr_le.dpu_spw_write_sync; |
|
862 | old_hk_lfr_le.dpu_spw_write_sync= new_hk_lfr_le.dpu_spw_write_sync; | |
863 | // TIMECODE |
|
863 | // TIMECODE | |
864 | old_hk_lfr_le.timecode_erroneous= new_hk_lfr_le.timecode_erroneous; |
|
864 | old_hk_lfr_le.timecode_erroneous= new_hk_lfr_le.timecode_erroneous; | |
865 | old_hk_lfr_le.timecode_missing = new_hk_lfr_le.timecode_missing; |
|
865 | old_hk_lfr_le.timecode_missing = new_hk_lfr_le.timecode_missing; | |
866 | old_hk_lfr_le.timecode_invalid = new_hk_lfr_le.timecode_invalid; |
|
866 | old_hk_lfr_le.timecode_invalid = new_hk_lfr_le.timecode_invalid; | |
867 | // TIME |
|
867 | // TIME | |
868 | old_hk_lfr_le.time_timecode_it = new_hk_lfr_le.time_timecode_it; |
|
868 | old_hk_lfr_le.time_timecode_it = new_hk_lfr_le.time_timecode_it; | |
869 | old_hk_lfr_le.time_not_synchro = new_hk_lfr_le.time_not_synchro; |
|
869 | old_hk_lfr_le.time_not_synchro = new_hk_lfr_le.time_not_synchro; | |
870 | old_hk_lfr_le.time_timecode_ctr = new_hk_lfr_le.time_timecode_ctr; |
|
870 | old_hk_lfr_le.time_timecode_ctr = new_hk_lfr_le.time_timecode_ctr; | |
871 | //AHB |
|
871 | //AHB | |
872 | old_hk_lfr_le.ahb_correctable = new_hk_lfr_le.ahb_correctable; |
|
872 | old_hk_lfr_le.ahb_correctable = new_hk_lfr_le.ahb_correctable; | |
873 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver |
|
873 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver | |
874 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver |
|
874 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver | |
875 |
|
875 | |||
876 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
876 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
877 | // LE |
|
877 | // LE | |
878 | housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
878 | housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); | |
879 | housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (counter & BYTE1_MASK); |
|
879 | housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (counter & BYTE1_MASK); | |
880 | } |
|
880 | } | |
881 |
|
881 | |||
882 | void hk_lfr_me_update( void ) |
|
882 | void hk_lfr_me_update( void ) | |
883 | { |
|
883 | { | |
884 | static hk_lfr_me_t old_hk_lfr_me = {0}; |
|
884 | static hk_lfr_me_t old_hk_lfr_me = {0}; | |
885 | hk_lfr_me_t new_hk_lfr_me; |
|
885 | hk_lfr_me_t new_hk_lfr_me; | |
886 | unsigned int counter; |
|
886 | unsigned int counter; | |
887 |
|
887 | |||
888 | counter = (((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * 256) + housekeeping_packet.hk_lfr_me_cnt[1]; |
|
888 | counter = (((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_me_cnt[1]; | |
889 |
|
889 | |||
890 | // get the current values |
|
890 | // get the current values | |
891 | new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop; |
|
891 | new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop; | |
892 | new_hk_lfr_me.dpu_spw_invalid_addr = housekeeping_packet.hk_lfr_dpu_spw_invalid_addr; |
|
892 | new_hk_lfr_me.dpu_spw_invalid_addr = housekeeping_packet.hk_lfr_dpu_spw_invalid_addr; | |
893 | new_hk_lfr_me.dpu_spw_eep = housekeeping_packet.hk_lfr_dpu_spw_eep; |
|
893 | new_hk_lfr_me.dpu_spw_eep = housekeeping_packet.hk_lfr_dpu_spw_eep; | |
894 | new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big; |
|
894 | new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big; | |
895 |
|
895 | |||
896 | // update the me counter |
|
896 | // update the me counter | |
897 | increment_hk_counter( new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter ); |
|
897 | increment_hk_counter( new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter ); | |
898 | increment_hk_counter( new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter ); |
|
898 | increment_hk_counter( new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter ); | |
899 | increment_hk_counter( new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter ); |
|
899 | increment_hk_counter( new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter ); | |
900 | increment_hk_counter( new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter ); |
|
900 | increment_hk_counter( new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter ); | |
901 |
|
901 | |||
902 | // store the counters for the next time |
|
902 | // store the counters for the next time | |
903 | old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop; |
|
903 | old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop; | |
904 | old_hk_lfr_me.dpu_spw_invalid_addr = new_hk_lfr_me.dpu_spw_invalid_addr; |
|
904 | old_hk_lfr_me.dpu_spw_invalid_addr = new_hk_lfr_me.dpu_spw_invalid_addr; | |
905 | old_hk_lfr_me.dpu_spw_eep = new_hk_lfr_me.dpu_spw_eep; |
|
905 | old_hk_lfr_me.dpu_spw_eep = new_hk_lfr_me.dpu_spw_eep; | |
906 | old_hk_lfr_me.dpu_spw_rx_too_big = new_hk_lfr_me.dpu_spw_rx_too_big; |
|
906 | old_hk_lfr_me.dpu_spw_rx_too_big = new_hk_lfr_me.dpu_spw_rx_too_big; | |
907 |
|
907 | |||
908 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
908 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
909 | // ME |
|
909 | // ME | |
910 | housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
910 | housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); | |
911 | housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (counter & BYTE1_MASK); |
|
911 | housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (counter & BYTE1_MASK); | |
912 | } |
|
912 | } | |
913 |
|
913 | |||
914 | void hk_lfr_le_me_he_update() |
|
914 | void hk_lfr_le_me_he_update() | |
915 | { |
|
915 | { | |
916 |
|
916 | |||
917 | unsigned int hk_lfr_he_cnt; |
|
917 | unsigned int hk_lfr_he_cnt; | |
918 |
|
918 | |||
919 | hk_lfr_he_cnt = (((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256) + housekeeping_packet.hk_lfr_he_cnt[1]; |
|
919 | hk_lfr_he_cnt = (((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256) + housekeeping_packet.hk_lfr_he_cnt[1]; | |
920 |
|
920 | |||
921 | //update the low severity error counter |
|
921 | //update the low severity error counter | |
922 | hk_lfr_le_update( ); |
|
922 | hk_lfr_le_update( ); | |
923 |
|
923 | |||
924 | //update the medium severity error counter |
|
924 | //update the medium severity error counter | |
925 | hk_lfr_me_update(); |
|
925 | hk_lfr_me_update(); | |
926 |
|
926 | |||
927 | //update the high severity error counter |
|
927 | //update the high severity error counter | |
928 | hk_lfr_he_cnt = 0; |
|
928 | hk_lfr_he_cnt = 0; | |
929 |
|
929 | |||
930 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
930 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
931 | // HE |
|
931 | // HE | |
932 | housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
932 | housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & BYTE0_MASK) >> SHIFT_1_BYTE); | |
933 | housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & BYTE1_MASK); |
|
933 | housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & BYTE1_MASK); | |
934 |
|
934 | |||
935 | } |
|
935 | } | |
936 |
|
936 | |||
937 | void set_hk_lfr_time_not_synchro() |
|
937 | void set_hk_lfr_time_not_synchro() | |
938 | { |
|
938 | { | |
939 | static unsigned char synchroLost = 1; |
|
939 | static unsigned char synchroLost = 1; | |
940 | int synchronizationBit; |
|
940 | int synchronizationBit; | |
941 |
|
941 | |||
942 | // get the synchronization bit |
|
942 | // get the synchronization bit | |
943 | synchronizationBit = |
|
943 | synchronizationBit = | |
944 | (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000 |
|
944 | (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000 | |
945 |
|
945 | |||
946 | switch (synchronizationBit) |
|
946 | switch (synchronizationBit) | |
947 | { |
|
947 | { | |
948 | case 0: |
|
948 | case 0: | |
949 | if (synchroLost == 1) |
|
949 | if (synchroLost == 1) | |
950 | { |
|
950 | { | |
951 | synchroLost = 0; |
|
951 | synchroLost = 0; | |
952 | } |
|
952 | } | |
953 | break; |
|
953 | break; | |
954 | case 1: |
|
954 | case 1: | |
955 | if (synchroLost == 0 ) |
|
955 | if (synchroLost == 0 ) | |
956 | { |
|
956 | { | |
957 | synchroLost = 1; |
|
957 | synchroLost = 1; | |
958 | increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro); |
|
958 | increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro); | |
959 | update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO ); |
|
959 | update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO ); | |
960 | } |
|
960 | } | |
961 | break; |
|
961 | break; | |
962 | default: |
|
962 | default: | |
963 | PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit); |
|
963 | PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit); | |
964 | break; |
|
964 | break; | |
965 | } |
|
965 | } | |
966 |
|
966 | |||
967 | } |
|
967 | } | |
968 |
|
968 | |||
969 | void set_hk_lfr_ahb_correctable() // CRITICITY L |
|
969 | void set_hk_lfr_ahb_correctable() // CRITICITY L | |
970 | { |
|
970 | { | |
971 | /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided |
|
971 | /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided | |
972 | * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the |
|
972 | * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the | |
973 | * detected errors in the cache, in the integer unit and in the floating point unit. |
|
973 | * detected errors in the cache, in the integer unit and in the floating point unit. | |
974 | * |
|
974 | * | |
975 | * @param void |
|
975 | * @param void | |
976 | * |
|
976 | * | |
977 | * @return void |
|
977 | * @return void | |
978 | * |
|
978 | * | |
979 | * All errors are summed to set the value of the hk_lfr_ahb_correctable counter. |
|
979 | * All errors are summed to set the value of the hk_lfr_ahb_correctable counter. | |
980 | * |
|
980 | * | |
981 | */ |
|
981 | */ | |
982 |
|
982 | |||
983 | unsigned int ahb_correctable; |
|
983 | unsigned int ahb_correctable; | |
984 | unsigned int instructionErrorCounter; |
|
984 | unsigned int instructionErrorCounter; | |
985 | unsigned int dataErrorCounter; |
|
985 | unsigned int dataErrorCounter; | |
986 | unsigned int fprfErrorCounter; |
|
986 | unsigned int fprfErrorCounter; | |
987 | unsigned int iurfErrorCounter; |
|
987 | unsigned int iurfErrorCounter; | |
988 |
|
988 | |||
989 | instructionErrorCounter = 0; |
|
989 | instructionErrorCounter = 0; | |
990 | dataErrorCounter = 0; |
|
990 | dataErrorCounter = 0; | |
991 | fprfErrorCounter = 0; |
|
991 | fprfErrorCounter = 0; | |
992 | iurfErrorCounter = 0; |
|
992 | iurfErrorCounter = 0; | |
993 |
|
993 | |||
994 | CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter); |
|
994 | CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter); | |
995 | ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter); |
|
995 | ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter); | |
996 |
|
996 | |||
997 | ahb_correctable = instructionErrorCounter |
|
997 | ahb_correctable = instructionErrorCounter | |
998 | + dataErrorCounter |
|
998 | + dataErrorCounter | |
999 | + fprfErrorCounter |
|
999 | + fprfErrorCounter | |
1000 | + iurfErrorCounter |
|
1000 | + iurfErrorCounter | |
1001 | + housekeeping_packet.hk_lfr_ahb_correctable; |
|
1001 | + housekeeping_packet.hk_lfr_ahb_correctable; | |
1002 |
|
1002 | |||
1003 | housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & INT8_ALL_F); // [1111 1111] |
|
1003 | housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & INT8_ALL_F); // [1111 1111] | |
1004 |
|
1004 | |||
1005 | } |
|
1005 | } |
General Comments 0
You need to be logged in to leave comments.
Login now