@@ -1,14 +1,14 | |||||
1 |
cmake_minimum_required (VERSION |
|
1 | cmake_minimum_required (VERSION 3.6) | |
2 | project (LFR_FSW) |
|
2 | project (LFR_FSW) | |
3 |
|
3 | |||
4 | if(NOT CMAKE_BUILD_TYPE) |
|
4 | if(NOT CMAKE_BUILD_TYPE) | |
5 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING |
|
5 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING | |
6 | "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) |
|
6 | "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) | |
7 | endif(NOT CMAKE_BUILD_TYPE) |
|
7 | endif(NOT CMAKE_BUILD_TYPE) | |
8 |
|
8 | |||
9 | set(LFR_BP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/LFR_basic-parameters/basic_parameters.c) |
|
9 | set(LFR_BP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/LFR_basic-parameters/basic_parameters.c) | |
10 |
|
10 | |||
11 | SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/sparc") |
|
11 | SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/sparc") | |
12 |
|
12 | |||
13 | add_subdirectory(libgcov) |
|
13 | add_subdirectory(libgcov) | |
14 | add_subdirectory(src) |
|
14 | add_subdirectory(src) |
@@ -1,17 +1,20 | |||||
1 | cmake_minimum_required(VERSION 3.6) |
|
1 | cmake_minimum_required(VERSION 3.6) | |
2 | project(libgcov C) |
|
2 | project(libgcov C) | |
3 | include(sparc-rtems) |
|
3 | include(sparc-rtems) | |
4 | include(cppcheck) |
|
4 | include(cppcheck) | |
5 |
|
5 | |||
6 | set(LIB_GCOV_SOURCES |
|
6 | set(LIB_GCOV_SOURCES | |
7 | gcov-io.c |
|
7 | gcov-io.c | |
8 | gcov-io.h |
|
8 | gcov-io.h | |
9 | gcov-iov.h |
|
9 | gcov-iov.h | |
10 | libgcov.c |
|
10 | libgcov.c | |
11 | ) |
|
11 | ) | |
12 |
|
12 | if(Coverage) | ||
|
13 | # add_definitions(-DGCOV_USE_EXIT) | |||
|
14 | add_definitions(-DGCOV_ENABLED) | |||
|
15 | endif() | |||
13 | add_library(gcov STATIC ${LIB_GCOV_SOURCES}) |
|
16 | add_library(gcov STATIC ${LIB_GCOV_SOURCES}) | |
14 |
|
17 | |||
15 | add_custom_target(gcovr |
|
18 | add_custom_target(gcovr | |
16 | COMMAND gcovr --exclude='.*gcov.*' --gcov-executable=${rtems_dir}/bin/sparc-rtems-gcov --object-directory ${CMAKE_BINARY_DIR} -r ${CMAKE_SOURCE_DIR} --html --html-details -o ${CMAKE_CURRENT_BINARY_DIR}/gcov.html && xdg-open ${CMAKE_CURRENT_BINARY_DIR}/gcov.html |
|
19 | COMMAND gcovr --exclude='.*gcov.*' --gcov-executable=${rtems_dir}/bin/sparc-rtems-gcov --object-directory ${CMAKE_BINARY_DIR} -r ${CMAKE_SOURCE_DIR} --html --html-details -o ${CMAKE_CURRENT_BINARY_DIR}/gcov.html && xdg-open ${CMAKE_CURRENT_BINARY_DIR}/gcov.html | |
17 | ) |
|
20 | ) |
@@ -1,488 +1,490 | |||||
1 | /* Test for GCC >= 3.4.4 && <= 4.4.6 */ |
|
1 | /* Test for GCC >= 3.4.4 && <= 4.4.6 */ | |
2 | //#if ( ( __GNUC__ > 3 ) || \ |
|
2 | //#if ( ( __GNUC__ > 3 ) || \ | |
3 | // ( __GNUC__ == 3 && __GNUC_MINOR__ > 4 )|| \ |
|
3 | // ( __GNUC__ == 3 && __GNUC_MINOR__ > 4 )|| \ | |
4 | // ( __GNUC__ == 3 && __GNUC_MINOR__ == 4 && __GNUC_PATCHLEVEL__ >= 4 ) ) && \ |
|
4 | // ( __GNUC__ == 3 && __GNUC_MINOR__ == 4 && __GNUC_PATCHLEVEL__ >= 4 ) ) && \ | |
5 | // ( ( __GNUC__ < 4 ) || \ |
|
5 | // ( ( __GNUC__ < 4 ) || \ | |
6 | // ( __GNUC__ == 4 && __GNUC_MINOR__ < 4 )|| \ |
|
6 | // ( __GNUC__ == 4 && __GNUC_MINOR__ < 4 )|| \ | |
7 | // ( __GNUC__ == 4 && __GNUC_MINOR__ == 4 && __GNUC_PATCHLEVEL__ <= 6 ) ) |
|
7 | // ( __GNUC__ == 4 && __GNUC_MINOR__ == 4 && __GNUC_PATCHLEVEL__ <= 6 ) ) | |
8 | /* |
|
8 | /* | |
9 | * ===================================================================================== |
|
9 | * ===================================================================================== | |
10 | * |
|
10 | * | |
11 | * Filename: gcov-io.c |
|
11 | * Filename: gcov-io.c | |
12 | * |
|
12 | * | |
13 | * Description: This is the I/O file for embedded systems |
|
13 | * Description: This is the I/O file for embedded systems | |
14 | * |
|
14 | * | |
15 | * Version: 1.0 |
|
15 | * Version: 1.0 | |
16 | * Created: 03/04/08 09:51:59 |
|
16 | * Created: 03/04/08 09:51:59 | |
17 | * Revision: none |
|
17 | * Revision: none | |
18 | * Compiler: gcc |
|
18 | * Compiler: gcc | |
19 | * |
|
19 | * | |
20 | * Author: Aitor Viana Sanchez (avs), aitor.viana.sanchez@esa.int |
|
20 | * Author: Aitor Viana Sanchez (avs), aitor.viana.sanchez@esa.int | |
21 | * Company: European Space Agency (ESA-ESTEC) |
|
21 | * Company: European Space Agency (ESA-ESTEC) | |
22 | * |
|
22 | * | |
23 | * ===================================================================================== |
|
23 | * ===================================================================================== | |
24 | */ |
|
24 | */ | |
25 |
|
25 | |||
26 | /* File format for coverage information |
|
26 | /* File format for coverage information | |
27 | Copyright (C) 1996, 1997, 1998, 2000, 2002, |
|
27 | Copyright (C) 1996, 1997, 1998, 2000, 2002, | |
28 | 2003 Free Software Foundation, Inc. |
|
28 | 2003 Free Software Foundation, Inc. | |
29 | Contributed by Bob Manson <manson@cygnus.com>. |
|
29 | Contributed by Bob Manson <manson@cygnus.com>. | |
30 | Completely remangled by Nathan Sidwell <nathan@codesourcery.com>. |
|
30 | Completely remangled by Nathan Sidwell <nathan@codesourcery.com>. | |
31 |
|
31 | |||
32 | This file is part of GCC. |
|
32 | This file is part of GCC. | |
33 |
|
33 | |||
34 | GCC is free software; you can redistribute it and/or modify it under |
|
34 | GCC is free software; you can redistribute it and/or modify it under | |
35 | the terms of the GNU General Public License as published by the Free |
|
35 | the terms of the GNU General Public License as published by the Free | |
36 | Software Foundation; either version 2, or (at your option) any later |
|
36 | Software Foundation; either version 2, or (at your option) any later | |
37 | version. |
|
37 | version. | |
38 |
|
38 | |||
39 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
|
39 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
40 | WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
40 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
41 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
41 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
42 | for more details. |
|
42 | for more details. | |
43 |
|
43 | |||
44 | You should have received a copy of the GNU General Public License |
|
44 | You should have received a copy of the GNU General Public License | |
45 | along with GCC; see the file COPYING. If not, write to the Free |
|
45 | along with GCC; see the file COPYING. If not, write to the Free | |
46 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|
46 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
47 | 02111-1307, USA. */ |
|
47 | 02111-1307, USA. */ | |
48 |
|
48 | |||
49 | #include <stdio.h> |
|
49 | #include <stdio.h> | |
50 | #include <stdlib.h> /* for atexit() */ |
|
50 | #include <stdlib.h> /* for atexit() */ | |
51 | #include <string.h> |
|
51 | #include <string.h> | |
52 | #include "gcov-io.h" |
|
52 | #include "gcov-io.h" | |
53 |
|
53 | |||
54 | /* Routines declared in gcov-io.h. This file should be #included by |
|
54 | /* Routines declared in gcov-io.h. This file should be #included by | |
55 | another source file, after having #included gcov-io.h. */ |
|
55 | another source file, after having #included gcov-io.h. */ | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | /* This function shall be defined somewhere else */ |
|
58 | /* This function shall be defined somewhere else */ | |
59 | //int send_data(unsigned char * buffer, unsigned int size); |
|
59 | //int send_data(unsigned char * buffer, unsigned int size); | |
60 |
|
60 | |||
61 | /*----------------------------------------------------------------------------- |
|
61 | /*----------------------------------------------------------------------------- | |
62 | * PRIVATE INTERFACE |
|
62 | * PRIVATE INTERFACE | |
63 | *-----------------------------------------------------------------------------*/ |
|
63 | *-----------------------------------------------------------------------------*/ | |
64 |
|
64 | |||
65 | static void gcov_write_block (unsigned); |
|
65 | static void gcov_write_block (unsigned); | |
66 | static gcov_unsigned_t *gcov_write_words (unsigned); |
|
66 | static gcov_unsigned_t *gcov_write_words (unsigned); | |
67 | GCOV_LINKAGE int gcov_send (void); |
|
67 | GCOV_LINKAGE int gcov_send (void); | |
68 | GCOV_LINKAGE int gcov_close(void); |
|
68 | GCOV_LINKAGE int gcov_close(void); | |
69 |
|
69 | |||
70 | extern struct gcov_info * gcov_list; |
|
70 | extern struct gcov_info * gcov_list; | |
71 | extern gcov_unsigned_t gcov_crc32; |
|
71 | extern gcov_unsigned_t gcov_crc32; | |
72 |
|
72 | |||
73 | int dev_id = 0; |
|
73 | int dev_id = 0; | |
74 |
|
74 | |||
75 | /* |
|
75 | /* | |
76 | * === FUNCTION ====================================================================== |
|
76 | * === FUNCTION ====================================================================== | |
77 | * Name: from_file |
|
77 | * Name: from_file | |
78 | * Description: This function just return the given parameter |
|
78 | * Description: This function just return the given parameter | |
79 | * ===================================================================================== |
|
79 | * ===================================================================================== | |
80 | */ |
|
80 | */ | |
81 | static inline gcov_unsigned_t from_file (gcov_unsigned_t value) |
|
81 | static inline gcov_unsigned_t from_file (gcov_unsigned_t value) | |
82 | { |
|
82 | { | |
83 | return value; |
|
83 | return value; | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | /* |
|
86 | /* | |
87 | * === FUNCTION ====================================================================== |
|
87 | * === FUNCTION ====================================================================== | |
88 | * Name: gcov_version |
|
88 | * Name: gcov_version | |
89 | * Description: This function returns TRUE (1) if the gcov version is the |
|
89 | * Description: This function returns TRUE (1) if the gcov version is the | |
90 | * version expected. The function returns FALSE (0) in any other case. |
|
90 | * version expected. The function returns FALSE (0) in any other case. | |
91 | * ===================================================================================== |
|
91 | * ===================================================================================== | |
92 | */ |
|
92 | */ | |
93 | static int gcov_version (struct gcov_info *ptr, gcov_unsigned_t version) |
|
93 | static int gcov_version (struct gcov_info *ptr, gcov_unsigned_t version) | |
94 | { |
|
94 | { | |
95 | if (version != GCOV_VERSION) |
|
95 | if (version != GCOV_VERSION) | |
96 | { |
|
96 | { | |
97 | char v[4], e[4]; |
|
97 | char v[4], e[4]; | |
98 |
|
98 | |||
99 | GCOV_UNSIGNED2STRING (v, version); |
|
99 | GCOV_UNSIGNED2STRING (v, version); | |
100 | GCOV_UNSIGNED2STRING (e, GCOV_VERSION); |
|
100 | GCOV_UNSIGNED2STRING (e, GCOV_VERSION); | |
101 |
|
101 | |||
102 | printf ("profiling:%s:Version mismatch - expected %.4s got %.4s\n", |
|
102 | printf ("profiling:%s:Version mismatch - expected %.4s got %.4s\n", | |
103 | ptr->filename, e, v); |
|
103 | ptr->filename, e, v); | |
104 |
|
104 | |||
105 | return 0; |
|
105 | return 0; | |
106 | } |
|
106 | } | |
107 | return 1; |
|
107 | return 1; | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 |
|
110 | |||
111 | /*----------------------------------------------------------------------------- |
|
111 | /*----------------------------------------------------------------------------- | |
112 | * PUBLIC INTERFACE |
|
112 | * PUBLIC INTERFACE | |
113 | *-----------------------------------------------------------------------------*/ |
|
113 | *-----------------------------------------------------------------------------*/ | |
114 |
|
114 | |||
115 | /* Dump the coverage counts. We merge with existing counts when |
|
115 | /* Dump the coverage counts. We merge with existing counts when | |
116 | possible, to avoid growing the .da files ad infinitum. We use this |
|
116 | possible, to avoid growing the .da files ad infinitum. We use this | |
117 | program's checksum to make sure we only accumulate whole program |
|
117 | program's checksum to make sure we only accumulate whole program | |
118 | statistics to the correct summary. An object file might be embedded |
|
118 | statistics to the correct summary. An object file might be embedded | |
119 | in two separate programs, and we must keep the two program |
|
119 | in two separate programs, and we must keep the two program | |
120 | summaries separate. */ |
|
120 | summaries separate. */ | |
121 |
|
121 | |||
122 | /* |
|
122 | /* | |
123 | * === FUNCTION ====================================================================== |
|
123 | * === FUNCTION ====================================================================== | |
124 | * Name: gcov_exit |
|
124 | * Name: gcov_exit | |
125 | * Description: This function dumps the coverage couns. The merging with |
|
125 | * Description: This function dumps the coverage couns. The merging with | |
126 | * existing counts is not done in embedded systems. |
|
126 | * existing counts is not done in embedded systems. | |
127 | * ===================================================================================== |
|
127 | * ===================================================================================== | |
128 | */ |
|
128 | */ | |
129 | void gcov_exit (void) |
|
129 | void gcov_exit (void) | |
130 | { |
|
130 | { | |
131 | struct gcov_info *gi_ptr; |
|
131 | struct gcov_info *gi_ptr; | |
132 | struct gcov_summary this_program; |
|
132 | struct gcov_summary this_program; | |
133 | struct gcov_summary all; |
|
133 | struct gcov_summary all; | |
134 | struct gcov_ctr_summary *cs_ptr; |
|
134 | struct gcov_ctr_summary *cs_ptr; | |
135 | const struct gcov_ctr_info *ci_ptr; |
|
135 | const struct gcov_ctr_info *ci_ptr; | |
136 | unsigned t_ix; |
|
136 | unsigned t_ix; | |
137 | gcov_unsigned_t c_num; |
|
137 | gcov_unsigned_t c_num; | |
138 | unsigned long coreId = 0; |
|
138 | unsigned long coreId = 0; | |
139 |
|
139 | |||
140 | /* retrieve the id of the CPU the program is running on */ |
|
140 | /* retrieve the id of the CPU the program is running on */ | |
141 | #ifdef LEON3 |
|
141 | #ifdef LEON3 | |
142 | __asm__ __volatile__("rd %%asr17,%0\n\t" |
|
142 | __asm__ __volatile__("rd %%asr17,%0\n\t" | |
143 | "srl %0,28,%0" : |
|
143 | "srl %0,28,%0" : | |
144 | "=&r" (coreId) : ); |
|
144 | "=&r" (coreId) : ); | |
145 | #endif |
|
145 | #endif | |
146 |
|
146 | |||
147 | printf("_GCOVEXIT_BEGIN_,core%d\n", coreId); /* see also _GCOVEXIT_END_ */ |
|
147 | printf("_GCOVEXIT_BEGIN_,core%d\n", coreId); /* see also _GCOVEXIT_END_ */ | |
148 |
|
148 | |||
149 | if(gcov_list == (void*)0x0) |
|
149 | if(gcov_list == (void*)0x0) | |
150 | printf("%s: gcov_list == NULL\n", __func__); |
|
150 | printf("%s: gcov_list == NULL\n", __func__); | |
151 |
|
151 | |||
152 | memset (&all, 0, sizeof (all)); |
|
152 | memset (&all, 0, sizeof (all)); | |
153 | /* Find the totals for this execution. */ |
|
153 | /* Find the totals for this execution. */ | |
154 | memset (&this_program, 0, sizeof (this_program)); |
|
154 | memset (&this_program, 0, sizeof (this_program)); | |
155 | for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) |
|
155 | for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) | |
156 | { |
|
156 | { | |
157 |
|
157 | |||
158 | ci_ptr = gi_ptr->counts; |
|
158 | ci_ptr = gi_ptr->counts; | |
159 | for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++) |
|
159 | for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++) | |
160 | { |
|
160 | { | |
161 | if (!((1 << t_ix) & gi_ptr->ctr_mask)) |
|
161 | if (!((1 << t_ix) & gi_ptr->ctr_mask)) | |
162 | continue; |
|
162 | continue; | |
163 |
|
163 | |||
164 | cs_ptr = &this_program.ctrs[t_ix]; |
|
164 | cs_ptr = &this_program.ctrs[t_ix]; | |
165 | cs_ptr->num += ci_ptr->num; |
|
165 | cs_ptr->num += ci_ptr->num; | |
166 | for (c_num = 0; c_num < ci_ptr->num; c_num++) |
|
166 | for (c_num = 0; c_num < ci_ptr->num; c_num++) | |
167 | { |
|
167 | { | |
168 | cs_ptr->sum_all += ci_ptr->values[c_num]; |
|
168 | cs_ptr->sum_all += ci_ptr->values[c_num]; | |
169 | if (cs_ptr->run_max < ci_ptr->values[c_num]) |
|
169 | if (cs_ptr->run_max < ci_ptr->values[c_num]) | |
170 | cs_ptr->run_max = ci_ptr->values[c_num]; |
|
170 | cs_ptr->run_max = ci_ptr->values[c_num]; | |
171 | } |
|
171 | } | |
172 | ci_ptr++; |
|
172 | ci_ptr++; | |
173 | } |
|
173 | } | |
174 | } |
|
174 | } | |
175 | /* Now merge each file. */ |
|
175 | /* Now merge each file. */ | |
176 | for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) |
|
176 | for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) | |
177 | { |
|
177 | { | |
178 |
|
178 | |||
179 | struct gcov_summary program; |
|
179 | struct gcov_summary program; | |
180 | gcov_type *values[GCOV_COUNTERS]; |
|
180 | gcov_type *values[GCOV_COUNTERS]; | |
181 | const struct gcov_fn_info *fi_ptr; |
|
181 | const struct gcov_fn_info *fi_ptr; | |
182 | unsigned fi_stride; |
|
182 | unsigned fi_stride; | |
183 | unsigned c_ix, f_ix, n_counts; |
|
183 | unsigned c_ix, f_ix, n_counts; | |
184 |
|
184 | |||
185 | c_ix = 0; |
|
185 | c_ix = 0; | |
186 | for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++) |
|
186 | for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++) | |
187 | if ((1 << t_ix) & gi_ptr->ctr_mask) |
|
187 | if ((1 << t_ix) & gi_ptr->ctr_mask) | |
188 | { |
|
188 | { | |
189 | values[c_ix] = gi_ptr->counts[c_ix].values; |
|
189 | values[c_ix] = gi_ptr->counts[c_ix].values; | |
190 | c_ix++; |
|
190 | c_ix++; | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | /* Calculate the function_info stride. This depends on the |
|
193 | /* Calculate the function_info stride. This depends on the | |
194 | number of counter types being measured. */ |
|
194 | number of counter types being measured. */ | |
195 | fi_stride = sizeof (struct gcov_fn_info) + c_ix * sizeof (unsigned); |
|
195 | fi_stride = sizeof (struct gcov_fn_info) + c_ix * sizeof (unsigned); | |
196 | if (__alignof__ (struct gcov_fn_info) > sizeof (unsigned)) |
|
196 | if (__alignof__ (struct gcov_fn_info) > sizeof (unsigned)) | |
197 | { |
|
197 | { | |
198 | fi_stride += __alignof__ (struct gcov_fn_info) - 1; |
|
198 | fi_stride += __alignof__ (struct gcov_fn_info) - 1; | |
199 | fi_stride &= ~(__alignof__ (struct gcov_fn_info) - 1); |
|
199 | fi_stride &= ~(__alignof__ (struct gcov_fn_info) - 1); | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | if (!gcov_open (gi_ptr->filename)) |
|
202 | if (!gcov_open (gi_ptr->filename)) | |
203 | { |
|
203 | { | |
204 | printf ("profiling:%s:Cannot open\n", gi_ptr->filename); |
|
204 | printf ("profiling:%s:Cannot open\n", gi_ptr->filename); | |
205 | continue; |
|
205 | continue; | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | program.checksum = gcov_crc32; |
|
208 | program.checksum = gcov_crc32; | |
209 |
|
209 | |||
210 | /* Write out the data. */ |
|
210 | /* Write out the data. */ | |
211 | gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION); |
|
211 | gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION); | |
212 | gcov_write_unsigned (gi_ptr->stamp); |
|
212 | gcov_write_unsigned (gi_ptr->stamp); | |
213 |
|
213 | |||
214 | /* Write execution counts for each function. */ |
|
214 | /* Write execution counts for each function. */ | |
215 | for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++) |
|
215 | for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++) | |
216 | { |
|
216 | { | |
217 | fi_ptr = (const struct gcov_fn_info *) |
|
217 | fi_ptr = (const struct gcov_fn_info *) | |
218 | ((const char *) gi_ptr->functions + f_ix * fi_stride); |
|
218 | ((const char *) gi_ptr->functions + f_ix * fi_stride); | |
219 |
|
219 | |||
220 | /* Announce function. */ |
|
220 | /* Announce function. */ | |
221 | gcov_write_tag_length (GCOV_TAG_FUNCTION, GCOV_TAG_FUNCTION_LENGTH); |
|
221 | gcov_write_tag_length (GCOV_TAG_FUNCTION, GCOV_TAG_FUNCTION_LENGTH); | |
222 | gcov_write_unsigned (fi_ptr->ident); |
|
222 | gcov_write_unsigned (fi_ptr->ident); | |
223 | gcov_write_unsigned (fi_ptr->checksum); |
|
223 | gcov_write_unsigned (fi_ptr->checksum); | |
224 |
|
224 | |||
225 | c_ix = 0; |
|
225 | c_ix = 0; | |
226 | for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++) |
|
226 | for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++) | |
227 | { |
|
227 | { | |
228 | gcov_type *c_ptr; |
|
228 | gcov_type *c_ptr; | |
229 |
|
229 | |||
230 | if (!((1 << t_ix) & gi_ptr->ctr_mask)) |
|
230 | if (!((1 << t_ix) & gi_ptr->ctr_mask)) | |
231 | continue; |
|
231 | continue; | |
232 |
|
232 | |||
233 | n_counts = fi_ptr->n_ctrs[c_ix]; |
|
233 | n_counts = fi_ptr->n_ctrs[c_ix]; | |
234 |
|
234 | |||
235 | gcov_write_tag_length (GCOV_TAG_FOR_COUNTER (t_ix), |
|
235 | gcov_write_tag_length (GCOV_TAG_FOR_COUNTER (t_ix), | |
236 | GCOV_TAG_COUNTER_LENGTH (n_counts)); |
|
236 | GCOV_TAG_COUNTER_LENGTH (n_counts)); | |
237 | c_ptr = values[c_ix]; |
|
237 | c_ptr = values[c_ix]; | |
238 | while (n_counts--) |
|
238 | while (n_counts--) | |
239 | gcov_write_counter (*c_ptr++); |
|
239 | gcov_write_counter (*c_ptr++); | |
240 |
|
240 | |||
241 | values[c_ix] = c_ptr; |
|
241 | values[c_ix] = c_ptr; | |
242 | c_ix++; |
|
242 | c_ix++; | |
243 | } |
|
243 | } | |
244 | } |
|
244 | } | |
245 |
|
245 | |||
246 | gcov_send(); |
|
246 | gcov_send(); | |
247 | gcov_close(); |
|
247 | gcov_close(); | |
248 |
|
248 | |||
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | printf("_GCOVEXIT_END_,core%d\n", coreId); |
|
251 | printf("_GCOVEXIT_END_,core%d\n", coreId); | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 |
|
254 | |||
255 | /* Called before fork or exec - write out profile information gathered so |
|
255 | /* Called before fork or exec - write out profile information gathered so | |
256 | far and reset it to zero. This avoids duplication or loss of the |
|
256 | far and reset it to zero. This avoids duplication or loss of the | |
257 | profile information gathered so far. */ |
|
257 | profile information gathered so far. */ | |
258 |
|
258 | |||
259 | void |
|
259 | void | |
260 | __gcov_flush (void) |
|
260 | __gcov_flush (void) | |
261 | { |
|
261 | { | |
262 | const struct gcov_info *gi_ptr; |
|
262 | const struct gcov_info *gi_ptr; | |
263 |
|
263 | |||
264 | gcov_exit (); |
|
264 | gcov_exit (); | |
265 | for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) |
|
265 | for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) | |
266 | { |
|
266 | { | |
267 | unsigned t_ix; |
|
267 | unsigned t_ix; | |
268 | const struct gcov_ctr_info *ci_ptr; |
|
268 | const struct gcov_ctr_info *ci_ptr; | |
269 |
|
269 | |||
270 | for (t_ix = 0, ci_ptr = gi_ptr->counts; t_ix != GCOV_COUNTERS; t_ix++) |
|
270 | for (t_ix = 0, ci_ptr = gi_ptr->counts; t_ix != GCOV_COUNTERS; t_ix++) | |
271 | if ((1 << t_ix) & gi_ptr->ctr_mask) |
|
271 | if ((1 << t_ix) & gi_ptr->ctr_mask) | |
272 | { |
|
272 | { | |
273 | memset (ci_ptr->values, 0, sizeof (gcov_type) * ci_ptr->num); |
|
273 | memset (ci_ptr->values, 0, sizeof (gcov_type) * ci_ptr->num); | |
274 | ci_ptr++; |
|
274 | ci_ptr++; | |
275 | } |
|
275 | } | |
276 | } |
|
276 | } | |
277 | } |
|
277 | } | |
278 |
|
278 | |||
279 |
|
279 | |||
280 |
|
280 | |||
281 | /* Open a gcov file. NAME is the name of the file to open and MODE |
|
281 | /* Open a gcov file. NAME is the name of the file to open and MODE | |
282 | indicates whether a new file should be created, or an existing file |
|
282 | indicates whether a new file should be created, or an existing file | |
283 | opened for modification. If MODE is >= 0 an existing file will be |
|
283 | opened for modification. If MODE is >= 0 an existing file will be | |
284 | opened, if possible, and if MODE is <= 0, a new file will be |
|
284 | opened, if possible, and if MODE is <= 0, a new file will be | |
285 | created. Use MODE=0 to attempt to reopen an existing file and then |
|
285 | created. Use MODE=0 to attempt to reopen an existing file and then | |
286 | fall back on creating a new one. Return zero on failure, >0 on |
|
286 | fall back on creating a new one. Return zero on failure, >0 on | |
287 | opening an existing file and <0 on creating a new one. */ |
|
287 | opening an existing file and <0 on creating a new one. */ | |
288 | GCOV_LINKAGE int gcov_open(const char *name) |
|
288 | GCOV_LINKAGE int gcov_open(const char *name) | |
289 | { |
|
289 | { | |
290 | // gcov_var.start is cleared in the gcov_close function. |
|
290 | // gcov_var.start is cleared in the gcov_close function. | |
291 | // If this variable is not cleared...ERROR |
|
291 | // If this variable is not cleared...ERROR | |
292 | if( gcov_var.start != 0 ) |
|
292 | if( gcov_var.start != 0 ) | |
293 | return 0; |
|
293 | return 0; | |
294 |
|
294 | |||
295 | // Clear everything |
|
295 | // Clear everything | |
296 | gcov_var.start = 0; |
|
296 | gcov_var.start = 0; | |
297 | gcov_var.offset = gcov_var.length = 0; |
|
297 | gcov_var.offset = gcov_var.length = 0; | |
298 | gcov_var.overread = -1u; |
|
298 | gcov_var.overread = -1u; | |
299 | gcov_var.error = 0; |
|
299 | gcov_var.error = 0; | |
300 |
|
300 | |||
301 |
|
301 | |||
302 | // copy the filename in the gcov_var structure |
|
302 | // copy the filename in the gcov_var structure | |
303 | strcpy(gcov_var.filename, name); |
|
303 | strcpy(gcov_var.filename, name); | |
304 |
|
304 | |||
305 |
|
305 | |||
306 | // return 1 means everything is OK |
|
306 | // return 1 means everything is OK | |
307 | return 1; |
|
307 | return 1; | |
308 | } |
|
308 | } | |
309 |
|
309 | |||
310 | /* Close the current gcov file. Flushes data to disk. Returns nonzero |
|
310 | /* Close the current gcov file. Flushes data to disk. Returns nonzero | |
311 | on failure or error flag set. */ |
|
311 | on failure or error flag set. */ | |
312 |
|
312 | |||
313 | GCOV_LINKAGE int gcov_send (void) |
|
313 | GCOV_LINKAGE int gcov_send (void) | |
314 | { |
|
314 | { | |
315 | /*printf("%s: file %s\n", __func__, gcov_var.filename);*/ |
|
315 | /*printf("%s: file %s\n", __func__, gcov_var.filename);*/ | |
316 | if (gcov_var.offset) |
|
316 | if (gcov_var.offset) | |
317 | gcov_write_block (gcov_var.offset); |
|
317 | gcov_write_block (gcov_var.offset); | |
318 |
|
318 | |||
319 | gcov_var.length = 0; |
|
319 | gcov_var.length = 0; | |
320 | return gcov_var.error; |
|
320 | return gcov_var.error; | |
321 | } |
|
321 | } | |
322 |
|
322 | |||
323 | GCOV_LINKAGE int gcov_close(void) |
|
323 | GCOV_LINKAGE int gcov_close(void) | |
324 | { |
|
324 | { | |
325 | memset(gcov_var.filename, 0, strlen(gcov_var.filename)); |
|
325 | memset(gcov_var.filename, 0, strlen(gcov_var.filename)); | |
326 |
|
326 | |||
327 | // Clear the start variable because will be tested in the gcov_open |
|
327 | // Clear the start variable because will be tested in the gcov_open | |
328 | // function |
|
328 | // function | |
329 | gcov_var.start = 0; |
|
329 | gcov_var.start = 0; | |
330 |
|
330 | |||
331 | // Return the error, not sure whether the error is modifed. |
|
331 | // Return the error, not sure whether the error is modifed. | |
332 | return gcov_var.error; |
|
332 | return gcov_var.error; | |
333 | } |
|
333 | } | |
334 |
|
334 | |||
335 |
|
335 | |||
336 | static void gcov_write_block (unsigned size) { |
|
336 | static void gcov_write_block (unsigned size) { | |
337 | unsigned char *buffer = (unsigned char*) gcov_var.buffer; |
|
337 | unsigned char *buffer = (unsigned char*) gcov_var.buffer; | |
338 | unsigned int i; |
|
338 | unsigned int i; | |
339 |
|
339 | |||
340 | printf("_GCOV_,%s,", gcov_var.filename); |
|
340 | printf("_GCOV_,%s,", gcov_var.filename); | |
341 | /* to speed up the printing process, we display bytes 4 by 4 */ |
|
341 | /* to speed up the printing process, we display bytes 4 by 4 */ | |
342 | for(i = 0; i < size; i++) { |
|
342 | for(i = 0; i < size; i++) { | |
343 | printf("%02X%02X%02X%02X", (unsigned int)(buffer[0]), |
|
343 | printf("%02X%02X%02X%02X", (unsigned int)(buffer[0]), | |
344 | (unsigned int)(buffer[1]), |
|
344 | (unsigned int)(buffer[1]), | |
345 | (unsigned int)(buffer[2]), |
|
345 | (unsigned int)(buffer[2]), | |
346 | (unsigned int)(buffer[3])); |
|
346 | (unsigned int)(buffer[3])); | |
347 |
|
347 | |||
348 | buffer += sizeof(gcov_unsigned_t); |
|
348 | buffer += sizeof(gcov_unsigned_t); | |
349 | } |
|
349 | } | |
350 | printf("\n"); |
|
350 | printf("\n"); | |
351 |
|
351 | |||
352 | gcov_var.start += size; |
|
352 | gcov_var.start += size; | |
353 | gcov_var.offset -= size; |
|
353 | gcov_var.offset -= size; | |
354 | } |
|
354 | } | |
355 |
|
355 | |||
356 | /* Allocate space to write BYTES bytes to the gcov file. Return a |
|
356 | /* Allocate space to write BYTES bytes to the gcov file. Return a | |
357 | pointer to those bytes, or NULL on failure. */ |
|
357 | pointer to those bytes, or NULL on failure. */ | |
358 |
|
358 | |||
359 | static gcov_unsigned_t *gcov_write_words (unsigned words) { |
|
359 | static gcov_unsigned_t *gcov_write_words (unsigned words) { | |
360 | gcov_unsigned_t *result; |
|
360 | gcov_unsigned_t *result; | |
361 |
|
361 | |||
362 | GCOV_CHECK_WRITING (); |
|
362 | GCOV_CHECK_WRITING (); | |
363 | if (gcov_var.offset >= GCOV_BLOCK_SIZE) |
|
363 | if (gcov_var.offset >= GCOV_BLOCK_SIZE) | |
364 | { |
|
364 | { | |
365 | gcov_write_block (GCOV_BLOCK_SIZE); |
|
365 | gcov_write_block (GCOV_BLOCK_SIZE); | |
366 | if (gcov_var.offset) |
|
366 | if (gcov_var.offset) | |
367 | { |
|
367 | { | |
368 | GCOV_CHECK (gcov_var.offset == 1); |
|
368 | GCOV_CHECK (gcov_var.offset == 1); | |
369 | memcpy (gcov_var.buffer, gcov_var.buffer + GCOV_BLOCK_SIZE, 4); |
|
369 | memcpy (gcov_var.buffer, gcov_var.buffer + GCOV_BLOCK_SIZE, 4); | |
370 | } |
|
370 | } | |
371 | } |
|
371 | } | |
372 | result = &gcov_var.buffer[gcov_var.offset]; |
|
372 | result = &gcov_var.buffer[gcov_var.offset]; | |
373 | gcov_var.offset += words; |
|
373 | gcov_var.offset += words; | |
374 |
|
374 | |||
375 | return result; |
|
375 | return result; | |
376 | } |
|
376 | } | |
377 |
|
377 | |||
378 | /* Write unsigned VALUE to coverage file. Sets error flag |
|
378 | /* Write unsigned VALUE to coverage file. Sets error flag | |
379 | appropriately. */ |
|
379 | appropriately. */ | |
380 |
|
380 | |||
381 | GCOV_LINKAGE void |
|
381 | GCOV_LINKAGE void | |
382 | gcov_write_unsigned (gcov_unsigned_t value) |
|
382 | gcov_write_unsigned (gcov_unsigned_t value) | |
383 | { |
|
383 | { | |
384 | gcov_unsigned_t *buffer = gcov_write_words (1); |
|
384 | gcov_unsigned_t *buffer = gcov_write_words (1); | |
385 |
|
385 | |||
386 | buffer[0] = value; |
|
386 | buffer[0] = value; | |
387 | } |
|
387 | } | |
388 |
|
388 | |||
389 | /* Write counter VALUE to coverage file. Sets error flag |
|
389 | /* Write counter VALUE to coverage file. Sets error flag | |
390 | appropriately. */ |
|
390 | appropriately. */ | |
391 |
|
391 | |||
392 | GCOV_LINKAGE void |
|
392 | GCOV_LINKAGE void | |
393 | gcov_write_counter (gcov_type value) |
|
393 | gcov_write_counter (gcov_type value) | |
394 | { |
|
394 | { | |
395 | gcov_unsigned_t *buffer = gcov_write_words (2); |
|
395 | gcov_unsigned_t *buffer = gcov_write_words (2); | |
396 |
|
396 | |||
397 | buffer[0] = (gcov_unsigned_t) value; |
|
397 | buffer[0] = (gcov_unsigned_t) value; | |
398 | if (sizeof (value) > sizeof (gcov_unsigned_t)) |
|
398 | if (sizeof (value) > sizeof (gcov_unsigned_t)) | |
399 | buffer[1] = (gcov_unsigned_t) (value >> 32); |
|
399 | buffer[1] = (gcov_unsigned_t) (value >> 32); | |
400 | else |
|
400 | else | |
401 | buffer[1] = 0; |
|
401 | buffer[1] = 0; | |
402 |
|
402 | |||
403 | } |
|
403 | } | |
404 |
|
404 | |||
405 | /* Write a tag TAG and length LENGTH. */ |
|
405 | /* Write a tag TAG and length LENGTH. */ | |
406 |
|
406 | |||
407 | GCOV_LINKAGE void |
|
407 | GCOV_LINKAGE void | |
408 | gcov_write_tag_length (gcov_unsigned_t tag, gcov_unsigned_t length) |
|
408 | gcov_write_tag_length (gcov_unsigned_t tag, gcov_unsigned_t length) | |
409 | { |
|
409 | { | |
410 | gcov_unsigned_t *buffer = gcov_write_words (2); |
|
410 | gcov_unsigned_t *buffer = gcov_write_words (2); | |
411 |
|
411 | |||
412 | buffer[0] = tag; |
|
412 | buffer[0] = tag; | |
413 | buffer[1] = length; |
|
413 | buffer[1] = length; | |
414 | } |
|
414 | } | |
415 |
|
415 | |||
416 | /* Write a summary structure to the gcov file. Return nonzero on |
|
416 | /* Write a summary structure to the gcov file. Return nonzero on | |
417 | overflow. */ |
|
417 | overflow. */ | |
418 |
|
418 | |||
419 | GCOV_LINKAGE void |
|
419 | GCOV_LINKAGE void | |
420 | gcov_write_summary (gcov_unsigned_t tag, const struct gcov_summary *summary) |
|
420 | gcov_write_summary (gcov_unsigned_t tag, const struct gcov_summary *summary) | |
421 | { |
|
421 | { | |
422 | unsigned ix; |
|
422 | unsigned ix; | |
423 | const struct gcov_ctr_summary *csum; |
|
423 | const struct gcov_ctr_summary *csum; | |
424 |
|
424 | |||
425 | gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH); |
|
425 | gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH); | |
426 | gcov_write_unsigned (summary->checksum); |
|
426 | gcov_write_unsigned (summary->checksum); | |
427 | for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++) |
|
427 | for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++) | |
428 | { |
|
428 | { | |
429 | gcov_write_unsigned (csum->num); |
|
429 | gcov_write_unsigned (csum->num); | |
430 | gcov_write_unsigned (csum->runs); |
|
430 | gcov_write_unsigned (csum->runs); | |
431 | gcov_write_counter (csum->sum_all); |
|
431 | gcov_write_counter (csum->sum_all); | |
432 | gcov_write_counter (csum->run_max); |
|
432 | gcov_write_counter (csum->run_max); | |
433 | gcov_write_counter (csum->sum_max); |
|
433 | gcov_write_counter (csum->sum_max); | |
434 | } |
|
434 | } | |
435 | } |
|
435 | } | |
436 |
|
436 | |||
437 | GCOV_LINKAGE gcov_type |
|
437 | GCOV_LINKAGE gcov_type | |
438 | gcov_read_counter (void) |
|
438 | gcov_read_counter (void) | |
439 | { |
|
439 | { | |
440 | return 0; |
|
440 | return 0; | |
441 | } |
|
441 | } | |
442 |
|
442 | |||
443 | /* Add a new object file onto the bb chain. Invoked automatically |
|
443 | /* Add a new object file onto the bb chain. Invoked automatically | |
444 | when running an object file's global ctors. */ |
|
444 | when running an object file's global ctors. */ | |
445 |
|
445 | |||
446 | void |
|
446 | void | |
447 | __gcov_init (struct gcov_info *info) |
|
447 | __gcov_init (struct gcov_info *info) | |
448 | { |
|
448 | { | |
449 | if (!info->version) |
|
449 | if (!info->version) | |
450 | return; |
|
450 | return; | |
451 | if (gcov_version (info, info->version)) |
|
451 | if (gcov_version (info, info->version)) | |
452 | { |
|
452 | { | |
453 | const char *ptr = info->filename; |
|
453 | const char *ptr = info->filename; | |
454 | gcov_unsigned_t crc32 = gcov_crc32; |
|
454 | gcov_unsigned_t crc32 = gcov_crc32; | |
455 |
|
455 | |||
456 | /* Added by LESIA*/ |
|
456 | /* Added by LESIA*/ | |
457 | printf("Covered file: %s\n", info->filename); |
|
457 | printf("Covered file: %s\n", info->filename); | |
458 | /* End of Added by LESIA*/ |
|
458 | /* End of Added by LESIA*/ | |
459 |
|
459 | |||
460 | do |
|
460 | do | |
461 | { |
|
461 | { | |
462 | unsigned ix; |
|
462 | unsigned ix; | |
463 | gcov_unsigned_t value = *ptr << 24; |
|
463 | gcov_unsigned_t value = *ptr << 24; | |
464 |
|
464 | |||
465 | for (ix = 8; ix--; value <<= 1) |
|
465 | for (ix = 8; ix--; value <<= 1) | |
466 | { |
|
466 | { | |
467 | gcov_unsigned_t feedback; |
|
467 | gcov_unsigned_t feedback; | |
468 |
|
468 | |||
469 | feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0; |
|
469 | feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0; | |
470 | crc32 <<= 1; |
|
470 | crc32 <<= 1; | |
471 | crc32 ^= feedback; |
|
471 | crc32 ^= feedback; | |
472 | } |
|
472 | } | |
473 | } |
|
473 | } | |
474 | while (*ptr++); |
|
474 | while (*ptr++); | |
475 |
|
475 | |||
476 | gcov_crc32 = crc32; |
|
476 | gcov_crc32 = crc32; | |
477 |
|
477 | |||
|
478 | #ifdef GCOV_USE_EXIT | |||
478 | if (!gcov_list) |
|
479 | if (!gcov_list) | |
479 | atexit (gcov_exit); |
|
480 | atexit (gcov_exit); | |
|
481 | #endif | |||
480 |
|
482 | |||
481 | info->next = gcov_list; |
|
483 | info->next = gcov_list; | |
482 | gcov_list = info; |
|
484 | gcov_list = info; | |
483 | } |
|
485 | } | |
484 | else |
|
486 | else | |
485 | printf("%s: Version mismatch\n", "WARNING"); |
|
487 | printf("%s: Version mismatch\n", "WARNING"); | |
486 | info->version = 0; |
|
488 | info->version = 0; | |
487 | } |
|
489 | } | |
488 | //#endif /* __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ */ |
|
490 | //#endif /* __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ */ |
@@ -1,39 +1,39 | |||||
1 | set(rtems_dir /opt/rtems-4.10/) |
|
1 | set(rtems_dir /opt/rtems-4.10/) | |
2 |
|
2 | |||
3 | set(CMAKE_SYSTEM_NAME rtems) |
|
3 | set(CMAKE_SYSTEM_NAME rtems) | |
4 | set(CMAKE_C_COMPILER ${rtems_dir}/bin/sparc-rtems-gcc) |
|
4 | set(CMAKE_C_COMPILER ${rtems_dir}/bin/sparc-rtems-gcc) | |
5 | set(CMAKE_CXX_COMPILER ${rtems_dir}/bin/sparc-rtems-g++) |
|
5 | set(CMAKE_CXX_COMPILER ${rtems_dir}/bin/sparc-rtems-g++) | |
6 | set(CMAKE_LINKER ${rtems_dir}/bin/sparc-rtems-g++) |
|
6 | set(CMAKE_LINKER ${rtems_dir}/bin/sparc-rtems-g++) | |
7 | SET(CMAKE_EXE_LINKER_FLAGS "-static") |
|
7 | SET(CMAKE_EXE_LINKER_FLAGS "-static") | |
8 | option(fix-b2bst "Activate -mfix-b2bst switch to mitigate \"LEON3FT Stale Cache Entry After Store with Data Tag Parity Error\" errata, GRLIB-TN-0009" ON) |
|
8 | option(fix-b2bst "Activate -mfix-b2bst switch to mitigate \"LEON3FT Stale Cache Entry After Store with Data Tag Parity Error\" errata, GRLIB-TN-0009" ON) | |
9 |
|
9 | |||
10 | option(Coverage "Enables code coverage" OFF) |
|
10 | option(Coverage "Enables code coverage" OFF) | |
11 |
|
11 | |||
12 |
|
12 | |||
13 |
set(CMAKE_C_FLAGS_RELEASE "-O |
|
13 | set(CMAKE_C_FLAGS_RELEASE "-O2") | |
14 |
set(CMAKE_C_FLAGS_DEBUG "-O |
|
14 | set(CMAKE_C_FLAGS_DEBUG "-O2 -g -fno-inline") | |
15 |
|
15 | |||
16 |
|
16 | |||
17 | if(fix-b2bst) |
|
17 | if(fix-b2bst) | |
18 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfix-b2bst") |
|
18 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfix-b2bst") | |
19 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -mfix-b2bst") |
|
19 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -mfix-b2bst") | |
20 | endif() |
|
20 | endif() | |
21 |
|
21 | |||
22 |
|
22 | |||
23 | set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <FLAGS> -Xlinker -Map=<TARGET>.map <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") |
|
23 | set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <FLAGS> -Xlinker -Map=<TARGET>.map <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") | |
24 |
|
24 | |||
25 | include_directories("${rtems_dir}/sparc-rtems/leon3/lib/include") |
|
25 | include_directories("${rtems_dir}/sparc-rtems/leon3/lib/include") | |
26 |
|
26 | |||
27 | function (check_b2bst target bin) |
|
27 | function (check_b2bst target bin) | |
28 | add_custom_command(TARGET ${target} |
|
28 | add_custom_command(TARGET ${target} | |
29 | POST_BUILD |
|
29 | POST_BUILD | |
30 | COMMAND ${rtems_dir}/bin/sparc-rtems-objdump -d ${bin}/${target} | ${CMAKE_SOURCE_DIR}/sparc/leon3ft-b2bst-scan.tcl |
|
30 | COMMAND ${rtems_dir}/bin/sparc-rtems-objdump -d ${bin}/${target} | ${CMAKE_SOURCE_DIR}/sparc/leon3ft-b2bst-scan.tcl | |
31 | ) |
|
31 | ) | |
32 | endfunction() |
|
32 | endfunction() | |
33 |
|
33 | |||
34 | function (build_srec target bin rev) |
|
34 | function (build_srec target bin rev) | |
35 | add_custom_command(TARGET ${target} |
|
35 | add_custom_command(TARGET ${target} | |
36 | POST_BUILD |
|
36 | POST_BUILD | |
37 | COMMAND ${rtems_dir}/bin/sparc-rtems-objcopy -j .data -F srec ${bin}/${target} RpwLfrApp_XXXX_data_rev-${rev}.srec && ${rtems_dir}/bin/sparc-rtems-objcopy -j .text -F srec ${bin}/${target} RpwLfrApp_XXXX_text_rev-${rev}.srec |
|
37 | COMMAND ${rtems_dir}/bin/sparc-rtems-objcopy -j .data -F srec ${bin}/${target} RpwLfrApp_XXXX_data_rev-${rev}.srec && ${rtems_dir}/bin/sparc-rtems-objcopy -j .text -F srec ${bin}/${target} RpwLfrApp_XXXX_text_rev-${rev}.srec | |
38 | ) |
|
38 | ) | |
39 | endfunction() |
|
39 | endfunction() |
@@ -1,130 +1,130 | |||||
1 |
cmake_minimum_required (VERSION |
|
1 | cmake_minimum_required (VERSION 3.6) | |
2 | project (fsw) |
|
2 | project (fsw) | |
3 |
|
3 | |||
4 | include(sparc-rtems) |
|
4 | include(sparc-rtems) | |
5 | include(cppcheck) |
|
5 | include(cppcheck) | |
6 |
|
6 | |||
7 | include_directories("../header" |
|
7 | include_directories("../header" | |
8 | "../header/lfr_common_headers" |
|
8 | "../header/lfr_common_headers" | |
9 | "../header/processing" |
|
9 | "../header/processing" | |
10 | "../LFR_basic-parameters" |
|
10 | "../LFR_basic-parameters" | |
11 | "../src") |
|
11 | "../src") | |
12 |
|
12 | |||
13 | set(SOURCES wf_handler.c |
|
13 | set(SOURCES wf_handler.c | |
14 | tc_handler.c |
|
14 | tc_handler.c | |
15 | fsw_misc.c |
|
15 | fsw_misc.c | |
16 | fsw_init.c |
|
16 | fsw_init.c | |
17 | fsw_globals.c |
|
17 | fsw_globals.c | |
18 | fsw_spacewire.c |
|
18 | fsw_spacewire.c | |
19 | tc_load_dump_parameters.c |
|
19 | tc_load_dump_parameters.c | |
20 | tm_lfr_tc_exe.c |
|
20 | tm_lfr_tc_exe.c | |
21 | tc_acceptance.c |
|
21 | tc_acceptance.c | |
22 | processing/fsw_processing.c |
|
22 | processing/fsw_processing.c | |
23 | processing/avf0_prc0.c |
|
23 | processing/avf0_prc0.c | |
24 | processing/avf1_prc1.c |
|
24 | processing/avf1_prc1.c | |
25 | processing/avf2_prc2.c |
|
25 | processing/avf2_prc2.c | |
26 | lfr_cpu_usage_report.c |
|
26 | lfr_cpu_usage_report.c | |
27 | ${LFR_BP_SRC} |
|
27 | ${LFR_BP_SRC} | |
28 | ../header/wf_handler.h |
|
28 | ../header/wf_handler.h | |
29 | ../header/tc_handler.h |
|
29 | ../header/tc_handler.h | |
30 | ../header/grlib_regs.h |
|
30 | ../header/grlib_regs.h | |
31 | ../header/fsw_misc.h |
|
31 | ../header/fsw_misc.h | |
32 | ../header/fsw_init.h |
|
32 | ../header/fsw_init.h | |
33 | ../header/fsw_spacewire.h |
|
33 | ../header/fsw_spacewire.h | |
34 | ../header/tc_load_dump_parameters.h |
|
34 | ../header/tc_load_dump_parameters.h | |
35 | ../header/tm_lfr_tc_exe.h |
|
35 | ../header/tm_lfr_tc_exe.h | |
36 | ../header/tc_acceptance.h |
|
36 | ../header/tc_acceptance.h | |
37 | ../header/processing/fsw_processing.h |
|
37 | ../header/processing/fsw_processing.h | |
38 | ../header/processing/avf0_prc0.h |
|
38 | ../header/processing/avf0_prc0.h | |
39 | ../header/processing/avf1_prc1.h |
|
39 | ../header/processing/avf1_prc1.h | |
40 | ../header/processing/avf2_prc2.h |
|
40 | ../header/processing/avf2_prc2.h | |
41 | ../header/fsw_params_wf_handler.h |
|
41 | ../header/fsw_params_wf_handler.h | |
42 | ../header/lfr_cpu_usage_report.h |
|
42 | ../header/lfr_cpu_usage_report.h | |
43 | ../header/lfr_common_headers/ccsds_types.h |
|
43 | ../header/lfr_common_headers/ccsds_types.h | |
44 | ../header/lfr_common_headers/fsw_params.h |
|
44 | ../header/lfr_common_headers/fsw_params.h | |
45 | ../header/lfr_common_headers/fsw_params_nb_bytes.h |
|
45 | ../header/lfr_common_headers/fsw_params_nb_bytes.h | |
46 | ../header/lfr_common_headers/fsw_params_processing.h |
|
46 | ../header/lfr_common_headers/fsw_params_processing.h | |
47 | ../header/lfr_common_headers/tm_byte_positions.h |
|
47 | ../header/lfr_common_headers/tm_byte_positions.h | |
48 | ../LFR_basic-parameters/basic_parameters.h |
|
48 | ../LFR_basic-parameters/basic_parameters.h | |
49 | ../LFR_basic-parameters/basic_parameters_params.h |
|
49 | ../LFR_basic-parameters/basic_parameters_params.h | |
50 | ../header/GscMemoryLPP.hpp |
|
50 | ../header/GscMemoryLPP.hpp | |
51 | ) |
|
51 | ) | |
52 |
|
52 | |||
53 |
|
53 | |||
54 | option(FSW_verbose "Enable verbose LFR" OFF) |
|
54 | option(FSW_verbose "Enable verbose LFR" OFF) | |
55 | option(FSW_boot_messages "Enable LFR boot messages" OFF) |
|
55 | option(FSW_boot_messages "Enable LFR boot messages" OFF) | |
56 | option(FSW_debug_messages "Enable LFR debug messages" OFF) |
|
56 | option(FSW_debug_messages "Enable LFR debug messages" OFF) | |
57 | option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF) |
|
57 | option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF) | |
58 | option(FSW_stack_report "Enable LFR stack report" OFF) |
|
58 | option(FSW_stack_report "Enable LFR stack report" OFF) | |
59 | option(FSW_vhdl_dev "?" OFF) |
|
59 | option(FSW_vhdl_dev "?" OFF) | |
60 | option(FSW_lpp_dpu_destid "Set to debug at LPP" OFF) |
|
60 | option(FSW_lpp_dpu_destid "Set to debug at LPP" OFF) | |
61 | option(FSW_debug_watchdog "Enable debug watchdog" OFF) |
|
61 | option(FSW_debug_watchdog "Enable debug watchdog" OFF) | |
62 | option(FSW_debug_tch "?" OFF) |
|
62 | option(FSW_debug_tch "?" OFF) | |
63 | option(FSW_Instrument_Scrubbing "Enable scrubbing counter" OFF) |
|
63 | option(FSW_Instrument_Scrubbing "Enable scrubbing counter" OFF) | |
64 |
|
64 | |||
65 | set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE) |
|
65 | set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE) | |
66 | set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE) |
|
66 | set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE) | |
67 | set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE) |
|
67 | set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE) | |
68 |
set(SW_VERSION_N4 "2 |
|
68 | set(SW_VERSION_N4 "22" CACHE STRING "Choose N4 FSW Version." FORCE) | |
69 |
|
69 | |||
70 | if(FSW_verbose) |
|
70 | if(FSW_verbose) | |
71 | add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) |
|
71 | add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) | |
72 | endif() |
|
72 | endif() | |
73 | if(FSW_boot_messages) |
|
73 | if(FSW_boot_messages) | |
74 | add_definitions(-DBOOT_MESSAGES) |
|
74 | add_definitions(-DBOOT_MESSAGES) | |
75 | endif() |
|
75 | endif() | |
76 | if(FSW_debug_messages) |
|
76 | if(FSW_debug_messages) | |
77 | add_definitions(-DDEBUG_MESSAGES) |
|
77 | add_definitions(-DDEBUG_MESSAGES) | |
78 | endif() |
|
78 | endif() | |
79 | if(FSW_cpu_usage_report) |
|
79 | if(FSW_cpu_usage_report) | |
80 | add_definitions(-DPRINT_TASK_STATISTICS) |
|
80 | add_definitions(-DPRINT_TASK_STATISTICS) | |
81 | endif() |
|
81 | endif() | |
82 | if(FSW_stack_report) |
|
82 | if(FSW_stack_report) | |
83 | add_definitions(-DPRINT_STACK_REPORT) |
|
83 | add_definitions(-DPRINT_STACK_REPORT) | |
84 | endif() |
|
84 | endif() | |
85 | if(FSW_vhdl_dev) |
|
85 | if(FSW_vhdl_dev) | |
86 | add_definitions(-DVHDL_DEV) |
|
86 | add_definitions(-DVHDL_DEV) | |
87 | endif() |
|
87 | endif() | |
88 | if(FSW_lpp_dpu_destid) |
|
88 | if(FSW_lpp_dpu_destid) | |
89 | add_definitions(-DLPP_DPU_DESTID) |
|
89 | add_definitions(-DLPP_DPU_DESTID) | |
90 | endif() |
|
90 | endif() | |
91 | if(FSW_debug_watchdog) |
|
91 | if(FSW_debug_watchdog) | |
92 | add_definitions(-DDEBUG_WATCHDOG) |
|
92 | add_definitions(-DDEBUG_WATCHDOG) | |
93 | endif() |
|
93 | endif() | |
94 | if(FSW_debug_tch) |
|
94 | if(FSW_debug_tch) | |
95 | add_definitions(-DDEBUG_TCH) |
|
95 | add_definitions(-DDEBUG_TCH) | |
96 | endif() |
|
96 | endif() | |
97 |
|
97 | |||
98 |
|
98 | |||
99 |
|
99 | |||
100 | add_definitions(-DMSB_FIRST_TCH) |
|
100 | add_definitions(-DMSB_FIRST_TCH) | |
101 |
|
101 | |||
102 | add_definitions(-DSWVERSION=-1-0) |
|
102 | add_definitions(-DSWVERSION=-1-0) | |
103 | add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1}) |
|
103 | add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1}) | |
104 | add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2}) |
|
104 | add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2}) | |
105 | add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3}) |
|
105 | add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3}) | |
106 | add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4}) |
|
106 | add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4}) | |
107 |
|
107 | |||
108 | add_executable(fsw ${SOURCES}) |
|
108 | add_executable(fsw ${SOURCES}) | |
109 |
|
109 | |||
110 | if(FSW_Instrument_Scrubbing) |
|
110 | if(FSW_Instrument_Scrubbing) | |
111 | add_definitions(-DENABLE_SCRUBBING_COUNTER) |
|
111 | add_definitions(-DENABLE_SCRUBBING_COUNTER) | |
112 | endif() |
|
112 | endif() | |
113 |
|
113 | |||
114 | if(Coverage) |
|
114 | if(Coverage) | |
115 | target_link_libraries(fsw gcov) |
|
115 | target_link_libraries(fsw gcov) | |
116 | SET_TARGET_PROPERTIES(fsw PROPERTIES COMPILE_FLAGS "-fprofile-arcs -ftest-coverage") |
|
116 | SET_TARGET_PROPERTIES(fsw PROPERTIES COMPILE_FLAGS "-fprofile-arcs -ftest-coverage") | |
117 | endif() |
|
117 | endif() | |
118 |
|
118 | |||
119 |
|
119 | |||
120 | if(fix-b2bst) |
|
120 | if(fix-b2bst) | |
121 | check_b2bst(fsw ${CMAKE_CURRENT_BINARY_DIR}) |
|
121 | check_b2bst(fsw ${CMAKE_CURRENT_BINARY_DIR}) | |
122 | endif() |
|
122 | endif() | |
123 |
|
123 | |||
124 | if(NOT FSW_lpp_dpu_destid) |
|
124 | if(NOT FSW_lpp_dpu_destid) | |
125 | build_srec(fsw ${CMAKE_CURRENT_BINARY_DIR} "${SW_VERSION_N1}-${SW_VERSION_N2}-${SW_VERSION_N3}-${SW_VERSION_N4}") |
|
125 | build_srec(fsw ${CMAKE_CURRENT_BINARY_DIR} "${SW_VERSION_N1}-${SW_VERSION_N2}-${SW_VERSION_N3}-${SW_VERSION_N4}") | |
126 | endif() |
|
126 | endif() | |
127 |
|
127 | |||
128 |
|
128 | |||
129 | add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE) |
|
129 | #add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE) | |
130 |
|
130 |
@@ -1,1696 +1,1702 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- Solar Orbiter's Low Frequency Receiver Flight Software (LFR FSW), |
|
2 | -- Solar Orbiter's Low Frequency Receiver Flight Software (LFR FSW), | |
3 | -- This file is a part of the LFR FSW |
|
3 | -- This file is a part of the LFR FSW | |
4 | -- Copyright (C) 2012-2018, Plasma Physics Laboratory - CNRS |
|
4 | -- Copyright (C) 2012-2018, Plasma Physics Laboratory - CNRS | |
5 | -- |
|
5 | -- | |
6 | -- This program is free software; you can redistribute it and/or modify |
|
6 | -- This program is free software; you can redistribute it and/or modify | |
7 | -- it under the terms of the GNU General Public License as published by |
|
7 | -- it under the terms of the GNU General Public License as published by | |
8 | -- the Free Software Foundation; either version 2 of the License, or |
|
8 | -- the Free Software Foundation; either version 2 of the License, or | |
9 | -- (at your option) any later version. |
|
9 | -- (at your option) any later version. | |
10 | -- |
|
10 | -- | |
11 | -- This program is distributed in the hope that it will be useful, |
|
11 | -- This program is distributed in the hope that it will be useful, | |
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | -- GNU General Public License for more details. |
|
14 | -- GNU General Public License for more details. | |
15 | -- |
|
15 | -- | |
16 | -- You should have received a copy of the GNU General Public License |
|
16 | -- You should have received a copy of the GNU General Public License | |
17 | -- along with this program; if not, write to the Free Software |
|
17 | -- along with this program; if not, write to the Free Software | |
18 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 | -------------------------------------------------------------------------------*/ |
|
19 | -------------------------------------------------------------------------------*/ | |
20 | /*-- Author : Paul Leroy |
|
20 | /*-- Author : Paul Leroy | |
21 | -- Contact : Alexis Jeandet |
|
21 | -- Contact : Alexis Jeandet | |
22 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
22 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
23 | ----------------------------------------------------------------------------*/ |
|
23 | ----------------------------------------------------------------------------*/ | |
24 | /** Functions and tasks related to TeleCommand handling. |
|
24 | /** Functions and tasks related to TeleCommand handling. | |
25 | * |
|
25 | * | |
26 | * @file |
|
26 | * @file | |
27 | * @author P. LEROY |
|
27 | * @author P. LEROY | |
28 | * |
|
28 | * | |
29 | * A group of functions to handle TeleCommands:\n |
|
29 | * A group of functions to handle TeleCommands:\n | |
30 | * action launching\n |
|
30 | * action launching\n | |
31 | * TC parsing\n |
|
31 | * TC parsing\n | |
32 | * ... |
|
32 | * ... | |
33 | * |
|
33 | * | |
34 | */ |
|
34 | */ | |
35 |
|
35 | |||
36 | #include "tc_handler.h" |
|
36 | #include "tc_handler.h" | |
37 | #include "math.h" |
|
37 | #include "math.h" | |
38 |
|
38 | |||
39 | //*********** |
|
39 | //*********** | |
40 | // RTEMS TASK |
|
40 | // RTEMS TASK | |
41 |
|
41 | |||
42 | rtems_task actn_task( rtems_task_argument unused ) |
|
42 | rtems_task actn_task( rtems_task_argument unused ) | |
43 | { |
|
43 | { | |
44 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
44 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. | |
45 | * |
|
45 | * | |
46 | * @param unused is the starting argument of the RTEMS task |
|
46 | * @param unused is the starting argument of the RTEMS task | |
47 | * |
|
47 | * | |
48 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
48 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending | |
49 | * on the incoming TeleCommand. |
|
49 | * on the incoming TeleCommand. | |
50 | * |
|
50 | * | |
51 | */ |
|
51 | */ | |
52 |
|
52 | |||
53 | int result; |
|
53 | int result; | |
54 | rtems_status_code status; // RTEMS status code |
|
54 | rtems_status_code status; // RTEMS status code | |
55 | ccsdsTelecommandPacket_t __attribute__((aligned(4))) TC; // TC sent to the ACTN task |
|
55 | ccsdsTelecommandPacket_t __attribute__((aligned(4))) TC; // TC sent to the ACTN task | |
56 | size_t size; // size of the incoming TC packet |
|
56 | size_t size; // size of the incoming TC packet | |
57 | unsigned char subtype; // subtype of the current TC packet |
|
57 | unsigned char subtype; // subtype of the current TC packet | |
58 | unsigned char time[BYTES_PER_TIME]; |
|
58 | unsigned char time[BYTES_PER_TIME]; | |
59 | rtems_id queue_rcv_id; |
|
59 | rtems_id queue_rcv_id; | |
60 | rtems_id queue_snd_id; |
|
60 | rtems_id queue_snd_id; | |
61 |
|
61 | |||
62 | memset(&TC, 0, sizeof(ccsdsTelecommandPacket_t)); |
|
62 | memset(&TC, 0, sizeof(ccsdsTelecommandPacket_t)); | |
63 | size = 0; |
|
63 | size = 0; | |
64 | queue_rcv_id = RTEMS_ID_NONE; |
|
64 | queue_rcv_id = RTEMS_ID_NONE; | |
65 | queue_snd_id = RTEMS_ID_NONE; |
|
65 | queue_snd_id = RTEMS_ID_NONE; | |
66 |
|
66 | |||
67 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
67 | status = get_message_queue_id_recv( &queue_rcv_id ); | |
68 | if (status != RTEMS_SUCCESSFUL) |
|
68 | if (status != RTEMS_SUCCESSFUL) | |
69 | { |
|
69 | { | |
70 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
70 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | status = get_message_queue_id_send( &queue_snd_id ); |
|
73 | status = get_message_queue_id_send( &queue_snd_id ); | |
74 | if (status != RTEMS_SUCCESSFUL) |
|
74 | if (status != RTEMS_SUCCESSFUL) | |
75 | { |
|
75 | { | |
76 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
76 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | result = LFR_SUCCESSFUL; |
|
79 | result = LFR_SUCCESSFUL; | |
80 | subtype = 0; // subtype of the current TC packet |
|
80 | subtype = 0; // subtype of the current TC packet | |
81 |
|
81 | |||
82 | BOOT_PRINTF("in ACTN *** \n"); |
|
82 | BOOT_PRINTF("in ACTN *** \n"); | |
83 |
|
83 | |||
84 | while(1) |
|
84 | while(1) | |
85 | { |
|
85 | { | |
86 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
86 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, | |
87 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
87 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); | |
88 | getTime( time ); // set time to the current time |
|
88 | getTime( time ); // set time to the current time | |
89 | if (status!=RTEMS_SUCCESSFUL) |
|
89 | if (status!=RTEMS_SUCCESSFUL) | |
90 | { |
|
90 | { | |
91 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
91 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) | |
92 | } |
|
92 | } | |
93 | else |
|
93 | else | |
94 | { |
|
94 | { | |
95 | subtype = TC.serviceSubType; |
|
95 | subtype = TC.serviceSubType; | |
96 | switch(subtype) |
|
96 | switch(subtype) | |
97 | { |
|
97 | { | |
98 | case TC_SUBTYPE_RESET: |
|
98 | case TC_SUBTYPE_RESET: | |
99 | result = action_reset( &TC, queue_snd_id, time ); |
|
99 | result = action_reset( &TC, queue_snd_id, time ); | |
100 | close_action( &TC, result, queue_snd_id ); |
|
100 | close_action( &TC, result, queue_snd_id ); | |
101 | break; |
|
101 | break; | |
102 | case TC_SUBTYPE_LOAD_COMM: |
|
102 | case TC_SUBTYPE_LOAD_COMM: | |
103 | result = action_load_common_par( &TC ); |
|
103 | result = action_load_common_par( &TC ); | |
104 | close_action( &TC, result, queue_snd_id ); |
|
104 | close_action( &TC, result, queue_snd_id ); | |
105 | break; |
|
105 | break; | |
106 | case TC_SUBTYPE_LOAD_NORM: |
|
106 | case TC_SUBTYPE_LOAD_NORM: | |
107 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
107 | result = action_load_normal_par( &TC, queue_snd_id, time ); | |
108 | close_action( &TC, result, queue_snd_id ); |
|
108 | close_action( &TC, result, queue_snd_id ); | |
109 | break; |
|
109 | break; | |
110 | case TC_SUBTYPE_LOAD_BURST: |
|
110 | case TC_SUBTYPE_LOAD_BURST: | |
111 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
111 | result = action_load_burst_par( &TC, queue_snd_id, time ); | |
112 | close_action( &TC, result, queue_snd_id ); |
|
112 | close_action( &TC, result, queue_snd_id ); | |
113 | break; |
|
113 | break; | |
114 | case TC_SUBTYPE_LOAD_SBM1: |
|
114 | case TC_SUBTYPE_LOAD_SBM1: | |
115 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
115 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); | |
116 | close_action( &TC, result, queue_snd_id ); |
|
116 | close_action( &TC, result, queue_snd_id ); | |
117 | break; |
|
117 | break; | |
118 | case TC_SUBTYPE_LOAD_SBM2: |
|
118 | case TC_SUBTYPE_LOAD_SBM2: | |
119 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
119 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); | |
120 | close_action( &TC, result, queue_snd_id ); |
|
120 | close_action( &TC, result, queue_snd_id ); | |
121 | break; |
|
121 | break; | |
122 | case TC_SUBTYPE_DUMP: |
|
122 | case TC_SUBTYPE_DUMP: | |
123 | result = action_dump_par( &TC, queue_snd_id ); |
|
123 | result = action_dump_par( &TC, queue_snd_id ); | |
124 | close_action( &TC, result, queue_snd_id ); |
|
124 | close_action( &TC, result, queue_snd_id ); | |
125 | break; |
|
125 | break; | |
126 | case TC_SUBTYPE_ENTER: |
|
126 | case TC_SUBTYPE_ENTER: | |
127 | result = action_enter_mode( &TC, queue_snd_id ); |
|
127 | result = action_enter_mode( &TC, queue_snd_id ); | |
128 | close_action( &TC, result, queue_snd_id ); |
|
128 | close_action( &TC, result, queue_snd_id ); | |
129 | break; |
|
129 | break; | |
130 | case TC_SUBTYPE_UPDT_INFO: |
|
130 | case TC_SUBTYPE_UPDT_INFO: | |
131 | result = action_update_info( &TC, queue_snd_id ); |
|
131 | result = action_update_info( &TC, queue_snd_id ); | |
132 | close_action( &TC, result, queue_snd_id ); |
|
132 | close_action( &TC, result, queue_snd_id ); | |
133 | break; |
|
133 | break; | |
134 | case TC_SUBTYPE_EN_CAL: |
|
134 | case TC_SUBTYPE_EN_CAL: | |
135 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
135 | result = action_enable_calibration( &TC, queue_snd_id, time ); | |
136 | close_action( &TC, result, queue_snd_id ); |
|
136 | close_action( &TC, result, queue_snd_id ); | |
137 | break; |
|
137 | break; | |
138 | case TC_SUBTYPE_DIS_CAL: |
|
138 | case TC_SUBTYPE_DIS_CAL: | |
139 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
139 | result = action_disable_calibration( &TC, queue_snd_id, time ); | |
140 | close_action( &TC, result, queue_snd_id ); |
|
140 | close_action( &TC, result, queue_snd_id ); | |
141 | break; |
|
141 | break; | |
142 | case TC_SUBTYPE_LOAD_K: |
|
142 | case TC_SUBTYPE_LOAD_K: | |
143 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); |
|
143 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); | |
144 | close_action( &TC, result, queue_snd_id ); |
|
144 | close_action( &TC, result, queue_snd_id ); | |
145 | break; |
|
145 | break; | |
146 | case TC_SUBTYPE_DUMP_K: |
|
146 | case TC_SUBTYPE_DUMP_K: | |
147 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); |
|
147 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); | |
148 | close_action( &TC, result, queue_snd_id ); |
|
148 | close_action( &TC, result, queue_snd_id ); | |
149 | break; |
|
149 | break; | |
150 | case TC_SUBTYPE_LOAD_FBINS: |
|
150 | case TC_SUBTYPE_LOAD_FBINS: | |
151 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); |
|
151 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); | |
152 | close_action( &TC, result, queue_snd_id ); |
|
152 | close_action( &TC, result, queue_snd_id ); | |
153 | break; |
|
153 | break; | |
154 | case TC_SUBTYPE_LOAD_FILTER_PAR: |
|
154 | case TC_SUBTYPE_LOAD_FILTER_PAR: | |
155 | result = action_load_filter_par( &TC, queue_snd_id, time ); |
|
155 | result = action_load_filter_par( &TC, queue_snd_id, time ); | |
156 | close_action( &TC, result, queue_snd_id ); |
|
156 | close_action( &TC, result, queue_snd_id ); | |
157 | break; |
|
157 | break; | |
158 | case TC_SUBTYPE_UPDT_TIME: |
|
158 | case TC_SUBTYPE_UPDT_TIME: | |
159 | result = action_update_time( &TC ); |
|
159 | result = action_update_time( &TC ); | |
160 | close_action( &TC, result, queue_snd_id ); |
|
160 | close_action( &TC, result, queue_snd_id ); | |
161 | break; |
|
161 | break; | |
162 | default: |
|
162 | default: | |
163 | break; |
|
163 | break; | |
164 | } |
|
164 | } | |
165 | } |
|
165 | } | |
166 | } |
|
166 | } | |
167 | } |
|
167 | } | |
168 |
|
168 | |||
169 | //*********** |
|
169 | //*********** | |
170 | // TC ACTIONS |
|
170 | // TC ACTIONS | |
171 |
|
171 | |||
172 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
172 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
173 | { |
|
173 | { | |
174 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
174 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. | |
175 | * |
|
175 | * | |
176 | * @param TC points to the TeleCommand packet that is being processed |
|
176 | * @param TC points to the TeleCommand packet that is being processed | |
177 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
177 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
178 | * |
|
178 | * | |
179 | */ |
|
179 | */ | |
180 |
|
180 | |||
181 | PRINTF("this is the end!!!\n"); |
|
181 | PRINTF("this is the end!!!\n"); | |
|
182 | #ifdef GCOV_ENABLED | |||
|
183 | #ifndef GCOV_USE_EXIT | |||
|
184 | extern void gcov_exit (void); | |||
|
185 | gcov_exit(); | |||
|
186 | #endif | |||
|
187 | #endif | |||
182 | exit(0); |
|
188 | exit(0); | |
183 |
|
189 | |||
184 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
190 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
185 |
|
191 | |||
186 | return LFR_DEFAULT; |
|
192 | return LFR_DEFAULT; | |
187 | } |
|
193 | } | |
188 |
|
194 | |||
189 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
195 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
190 | { |
|
196 | { | |
191 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
197 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. | |
192 | * |
|
198 | * | |
193 | * @param TC points to the TeleCommand packet that is being processed |
|
199 | * @param TC points to the TeleCommand packet that is being processed | |
194 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
200 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
195 | * |
|
201 | * | |
196 | */ |
|
202 | */ | |
197 |
|
203 | |||
198 | rtems_status_code status; |
|
204 | rtems_status_code status; | |
199 | unsigned char requestedMode; |
|
205 | unsigned char requestedMode; | |
200 | unsigned int transitionCoarseTime; |
|
206 | unsigned int transitionCoarseTime; | |
201 | unsigned char * bytePosPtr; |
|
207 | unsigned char * bytePosPtr; | |
202 |
|
208 | |||
203 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
209 | bytePosPtr = (unsigned char *) &TC->packetID; | |
204 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
210 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; | |
205 | copyInt32ByChar( (char*) &transitionCoarseTime, &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); |
|
211 | copyInt32ByChar( (char*) &transitionCoarseTime, &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); | |
206 | transitionCoarseTime = transitionCoarseTime & COARSE_TIME_MASK; |
|
212 | transitionCoarseTime = transitionCoarseTime & COARSE_TIME_MASK; | |
207 | status = check_mode_value( requestedMode ); |
|
213 | status = check_mode_value( requestedMode ); | |
208 |
|
214 | |||
209 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
215 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent | |
210 | { |
|
216 | { | |
211 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); |
|
217 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); | |
212 | } |
|
218 | } | |
213 |
|
219 | |||
214 | else // the mode value is valid, check the transition |
|
220 | else // the mode value is valid, check the transition | |
215 | { |
|
221 | { | |
216 | status = check_mode_transition(requestedMode); |
|
222 | status = check_mode_transition(requestedMode); | |
217 | if (status != LFR_SUCCESSFUL) |
|
223 | if (status != LFR_SUCCESSFUL) | |
218 | { |
|
224 | { | |
219 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
225 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") | |
220 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
226 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
221 | } |
|
227 | } | |
222 | } |
|
228 | } | |
223 |
|
229 | |||
224 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date |
|
230 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date | |
225 | { |
|
231 | { | |
226 | status = check_transition_date( transitionCoarseTime ); |
|
232 | status = check_transition_date( transitionCoarseTime ); | |
227 | if (status != LFR_SUCCESSFUL) |
|
233 | if (status != LFR_SUCCESSFUL) | |
228 | { |
|
234 | { | |
229 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n"); |
|
235 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n"); | |
230 | send_tm_lfr_tc_exe_not_executable(TC, queue_id ); |
|
236 | send_tm_lfr_tc_exe_not_executable(TC, queue_id ); | |
231 | } |
|
237 | } | |
232 | } |
|
238 | } | |
233 |
|
239 | |||
234 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
240 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode | |
235 | { |
|
241 | { | |
236 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
242 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); | |
237 |
|
243 | |||
238 | switch(requestedMode) |
|
244 | switch(requestedMode) | |
239 | { |
|
245 | { | |
240 | case LFR_MODE_STANDBY: |
|
246 | case LFR_MODE_STANDBY: | |
241 | status = enter_mode_standby(); |
|
247 | status = enter_mode_standby(); | |
242 | break; |
|
248 | break; | |
243 | case LFR_MODE_NORMAL: |
|
249 | case LFR_MODE_NORMAL: | |
244 | status = enter_mode_normal( transitionCoarseTime ); |
|
250 | status = enter_mode_normal( transitionCoarseTime ); | |
245 | break; |
|
251 | break; | |
246 | case LFR_MODE_BURST: |
|
252 | case LFR_MODE_BURST: | |
247 | status = enter_mode_burst( transitionCoarseTime ); |
|
253 | status = enter_mode_burst( transitionCoarseTime ); | |
248 | break; |
|
254 | break; | |
249 | case LFR_MODE_SBM1: |
|
255 | case LFR_MODE_SBM1: | |
250 | status = enter_mode_sbm1( transitionCoarseTime ); |
|
256 | status = enter_mode_sbm1( transitionCoarseTime ); | |
251 | break; |
|
257 | break; | |
252 | case LFR_MODE_SBM2: |
|
258 | case LFR_MODE_SBM2: | |
253 | status = enter_mode_sbm2( transitionCoarseTime ); |
|
259 | status = enter_mode_sbm2( transitionCoarseTime ); | |
254 | break; |
|
260 | break; | |
255 | default: |
|
261 | default: | |
256 | break; |
|
262 | break; | |
257 | } |
|
263 | } | |
258 |
|
264 | |||
259 | if (status != RTEMS_SUCCESSFUL) |
|
265 | if (status != RTEMS_SUCCESSFUL) | |
260 | { |
|
266 | { | |
261 | status = LFR_EXE_ERROR; |
|
267 | status = LFR_EXE_ERROR; | |
262 | } |
|
268 | } | |
263 | } |
|
269 | } | |
264 |
|
270 | |||
265 | return status; |
|
271 | return status; | |
266 | } |
|
272 | } | |
267 |
|
273 | |||
268 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
274 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
269 | { |
|
275 | { | |
270 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
276 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
271 | * |
|
277 | * | |
272 | * @param TC points to the TeleCommand packet that is being processed |
|
278 | * @param TC points to the TeleCommand packet that is being processed | |
273 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
279 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
274 | * |
|
280 | * | |
275 | * @return LFR directive status code: |
|
281 | * @return LFR directive status code: | |
276 | * - LFR_DEFAULT |
|
282 | * - LFR_DEFAULT | |
277 | * - LFR_SUCCESSFUL |
|
283 | * - LFR_SUCCESSFUL | |
278 | * |
|
284 | * | |
279 | */ |
|
285 | */ | |
280 |
|
286 | |||
281 | unsigned int val; |
|
287 | unsigned int val; | |
282 | unsigned int status; |
|
288 | unsigned int status; | |
283 | unsigned char mode; |
|
289 | unsigned char mode; | |
284 | unsigned char * bytePosPtr; |
|
290 | unsigned char * bytePosPtr; | |
285 | int pos; |
|
291 | int pos; | |
286 | float value; |
|
292 | float value; | |
287 |
|
293 | |||
288 | pos = INIT_CHAR; |
|
294 | pos = INIT_CHAR; | |
289 | value = INIT_FLOAT; |
|
295 | value = INIT_FLOAT; | |
290 |
|
296 | |||
291 | status = LFR_DEFAULT; |
|
297 | status = LFR_DEFAULT; | |
292 |
|
298 | |||
293 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
299 | bytePosPtr = (unsigned char *) &TC->packetID; | |
294 |
|
300 | |||
295 | // check LFR mode |
|
301 | // check LFR mode | |
296 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & BITS_LFR_MODE) >> SHIFT_LFR_MODE; |
|
302 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & BITS_LFR_MODE) >> SHIFT_LFR_MODE; | |
297 | status = check_update_info_hk_lfr_mode( mode ); |
|
303 | status = check_update_info_hk_lfr_mode( mode ); | |
298 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
304 | if (status == LFR_SUCCESSFUL) // check TDS mode | |
299 | { |
|
305 | { | |
300 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_TDS_MODE) >> SHIFT_TDS_MODE; |
|
306 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_TDS_MODE) >> SHIFT_TDS_MODE; | |
301 | status = check_update_info_hk_tds_mode( mode ); |
|
307 | status = check_update_info_hk_tds_mode( mode ); | |
302 | } |
|
308 | } | |
303 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
309 | if (status == LFR_SUCCESSFUL) // check THR mode | |
304 | { |
|
310 | { | |
305 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_THR_MODE); |
|
311 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_THR_MODE); | |
306 | status = check_update_info_hk_thr_mode( mode ); |
|
312 | status = check_update_info_hk_thr_mode( mode ); | |
307 | } |
|
313 | } | |
308 | if (status == LFR_SUCCESSFUL) // check reaction wheels frequencies |
|
314 | if (status == LFR_SUCCESSFUL) // check reaction wheels frequencies | |
309 | { |
|
315 | { | |
310 | status = check_all_sy_lfr_rw_f(TC, &pos, &value); |
|
316 | status = check_all_sy_lfr_rw_f(TC, &pos, &value); | |
311 | } |
|
317 | } | |
312 |
|
318 | |||
313 | // if the parameters checking succeeds, udpate all parameters |
|
319 | // if the parameters checking succeeds, udpate all parameters | |
314 | if (status == LFR_SUCCESSFUL) |
|
320 | if (status == LFR_SUCCESSFUL) | |
315 | { |
|
321 | { | |
316 | // pa_bia_status_info |
|
322 | // pa_bia_status_info | |
317 | // => pa_bia_mode_mux_set 3 bits |
|
323 | // => pa_bia_mode_mux_set 3 bits | |
318 | // => pa_bia_mode_hv_enabled 1 bit |
|
324 | // => pa_bia_mode_hv_enabled 1 bit | |
319 | // => pa_bia_mode_bias1_enabled 1 bit |
|
325 | // => pa_bia_mode_bias1_enabled 1 bit | |
320 | // => pa_bia_mode_bias2_enabled 1 bit |
|
326 | // => pa_bia_mode_bias2_enabled 1 bit | |
321 | // => pa_bia_mode_bias3_enabled 1 bit |
|
327 | // => pa_bia_mode_bias3_enabled 1 bit | |
322 | // => pa_bia_on_off (cp_dpu_bias_on_off) |
|
328 | // => pa_bia_on_off (cp_dpu_bias_on_off) | |
323 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & BITS_BIA; // [1111 1110] |
|
329 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & BITS_BIA; // [1111 1110] | |
324 | pa_bia_status_info = pa_bia_status_info |
|
330 | pa_bia_status_info = pa_bia_status_info | |
325 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 1); |
|
331 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 1); | |
326 |
|
332 | |||
327 | // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets) |
|
333 | // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets) | |
328 | getReactionWheelsFrequencies( TC ); |
|
334 | getReactionWheelsFrequencies( TC ); | |
329 | set_hk_lfr_sc_rw_f_flags(); |
|
335 | set_hk_lfr_sc_rw_f_flags(); | |
330 | build_sy_lfr_rw_masks(); |
|
336 | build_sy_lfr_rw_masks(); | |
331 |
|
337 | |||
332 | // once the masks are built, they have to be merged with the fbins_mask |
|
338 | // once the masks are built, they have to be merged with the fbins_mask | |
333 | merge_fbins_masks(); |
|
339 | merge_fbins_masks(); | |
334 |
|
340 | |||
335 | // increase the TC_LFR_UPDATE_INFO counter |
|
341 | // increase the TC_LFR_UPDATE_INFO counter | |
336 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
342 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful | |
337 | { |
|
343 | { | |
338 | val = (housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * CONST_256) |
|
344 | val = (housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * CONST_256) | |
339 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
345 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
340 | val++; |
|
346 | val++; | |
341 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); |
|
347 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); | |
342 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
348 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
343 | } |
|
349 | } | |
344 | } |
|
350 | } | |
345 |
|
351 | |||
346 | return status; |
|
352 | return status; | |
347 | } |
|
353 | } | |
348 |
|
354 | |||
349 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
355 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
350 | { |
|
356 | { | |
351 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
357 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
352 | * |
|
358 | * | |
353 | * @param TC points to the TeleCommand packet that is being processed |
|
359 | * @param TC points to the TeleCommand packet that is being processed | |
354 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
360 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
355 | * |
|
361 | * | |
356 | */ |
|
362 | */ | |
357 |
|
363 | |||
358 | int result; |
|
364 | int result; | |
359 |
|
365 | |||
360 | result = LFR_DEFAULT; |
|
366 | result = LFR_DEFAULT; | |
361 |
|
367 | |||
362 | setCalibration( true ); |
|
368 | setCalibration( true ); | |
363 |
|
369 | |||
364 | result = LFR_SUCCESSFUL; |
|
370 | result = LFR_SUCCESSFUL; | |
365 |
|
371 | |||
366 | return result; |
|
372 | return result; | |
367 | } |
|
373 | } | |
368 |
|
374 | |||
369 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
375 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
370 | { |
|
376 | { | |
371 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
377 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
372 | * |
|
378 | * | |
373 | * @param TC points to the TeleCommand packet that is being processed |
|
379 | * @param TC points to the TeleCommand packet that is being processed | |
374 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
380 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
375 | * |
|
381 | * | |
376 | */ |
|
382 | */ | |
377 |
|
383 | |||
378 | int result; |
|
384 | int result; | |
379 |
|
385 | |||
380 | result = LFR_DEFAULT; |
|
386 | result = LFR_DEFAULT; | |
381 |
|
387 | |||
382 | setCalibration( false ); |
|
388 | setCalibration( false ); | |
383 |
|
389 | |||
384 | result = LFR_SUCCESSFUL; |
|
390 | result = LFR_SUCCESSFUL; | |
385 |
|
391 | |||
386 | return result; |
|
392 | return result; | |
387 | } |
|
393 | } | |
388 |
|
394 | |||
389 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
395 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
390 | { |
|
396 | { | |
391 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
397 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
392 | * |
|
398 | * | |
393 | * @param TC points to the TeleCommand packet that is being processed |
|
399 | * @param TC points to the TeleCommand packet that is being processed | |
394 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
400 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
395 | * |
|
401 | * | |
396 | * @return LFR_SUCCESSFUL |
|
402 | * @return LFR_SUCCESSFUL | |
397 | * |
|
403 | * | |
398 | */ |
|
404 | */ | |
399 |
|
405 | |||
400 | unsigned int val; |
|
406 | unsigned int val; | |
401 |
|
407 | |||
402 | time_management_regs->coarse_time_load = (TC->dataAndCRC[BYTE_0] << SHIFT_3_BYTES) |
|
408 | time_management_regs->coarse_time_load = (TC->dataAndCRC[BYTE_0] << SHIFT_3_BYTES) | |
403 | + (TC->dataAndCRC[BYTE_1] << SHIFT_2_BYTES) |
|
409 | + (TC->dataAndCRC[BYTE_1] << SHIFT_2_BYTES) | |
404 | + (TC->dataAndCRC[BYTE_2] << SHIFT_1_BYTE) |
|
410 | + (TC->dataAndCRC[BYTE_2] << SHIFT_1_BYTE) | |
405 | + TC->dataAndCRC[BYTE_3]; |
|
411 | + TC->dataAndCRC[BYTE_3]; | |
406 |
|
412 | |||
407 | val = (housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * CONST_256) |
|
413 | val = (housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * CONST_256) | |
408 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
414 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
409 | val++; |
|
415 | val++; | |
410 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); |
|
416 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); | |
411 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
417 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
412 |
|
418 | |||
413 | oneTcLfrUpdateTimeReceived = 1; |
|
419 | oneTcLfrUpdateTimeReceived = 1; | |
414 |
|
420 | |||
415 | return LFR_SUCCESSFUL; |
|
421 | return LFR_SUCCESSFUL; | |
416 | } |
|
422 | } | |
417 |
|
423 | |||
418 | //******************* |
|
424 | //******************* | |
419 | // ENTERING THE MODES |
|
425 | // ENTERING THE MODES | |
420 | int check_mode_value( unsigned char requestedMode ) |
|
426 | int check_mode_value( unsigned char requestedMode ) | |
421 | { |
|
427 | { | |
422 | int status; |
|
428 | int status; | |
423 |
|
429 | |||
424 | status = LFR_DEFAULT; |
|
430 | status = LFR_DEFAULT; | |
425 |
|
431 | |||
426 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
432 | if ( (requestedMode != LFR_MODE_STANDBY) | |
427 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
433 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
428 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
434 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
429 | { |
|
435 | { | |
430 | status = LFR_DEFAULT; |
|
436 | status = LFR_DEFAULT; | |
431 | } |
|
437 | } | |
432 | else |
|
438 | else | |
433 | { |
|
439 | { | |
434 | status = LFR_SUCCESSFUL; |
|
440 | status = LFR_SUCCESSFUL; | |
435 | } |
|
441 | } | |
436 |
|
442 | |||
437 | return status; |
|
443 | return status; | |
438 | } |
|
444 | } | |
439 |
|
445 | |||
440 | int check_mode_transition( unsigned char requestedMode ) |
|
446 | int check_mode_transition( unsigned char requestedMode ) | |
441 | { |
|
447 | { | |
442 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
448 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
443 | * |
|
449 | * | |
444 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
450 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
445 | * |
|
451 | * | |
446 | * @return LFR directive status codes: |
|
452 | * @return LFR directive status codes: | |
447 | * - LFR_SUCCESSFUL - the transition is authorized |
|
453 | * - LFR_SUCCESSFUL - the transition is authorized | |
448 | * - LFR_DEFAULT - the transition is not authorized |
|
454 | * - LFR_DEFAULT - the transition is not authorized | |
449 | * |
|
455 | * | |
450 | */ |
|
456 | */ | |
451 |
|
457 | |||
452 | int status; |
|
458 | int status; | |
453 |
|
459 | |||
454 | switch (requestedMode) |
|
460 | switch (requestedMode) | |
455 | { |
|
461 | { | |
456 | case LFR_MODE_STANDBY: |
|
462 | case LFR_MODE_STANDBY: | |
457 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
463 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
458 | status = LFR_DEFAULT; |
|
464 | status = LFR_DEFAULT; | |
459 | } |
|
465 | } | |
460 | else |
|
466 | else | |
461 | { |
|
467 | { | |
462 | status = LFR_SUCCESSFUL; |
|
468 | status = LFR_SUCCESSFUL; | |
463 | } |
|
469 | } | |
464 | break; |
|
470 | break; | |
465 | case LFR_MODE_NORMAL: |
|
471 | case LFR_MODE_NORMAL: | |
466 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
472 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
467 | status = LFR_DEFAULT; |
|
473 | status = LFR_DEFAULT; | |
468 | } |
|
474 | } | |
469 | else { |
|
475 | else { | |
470 | status = LFR_SUCCESSFUL; |
|
476 | status = LFR_SUCCESSFUL; | |
471 | } |
|
477 | } | |
472 | break; |
|
478 | break; | |
473 | case LFR_MODE_BURST: |
|
479 | case LFR_MODE_BURST: | |
474 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
480 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
475 | status = LFR_DEFAULT; |
|
481 | status = LFR_DEFAULT; | |
476 | } |
|
482 | } | |
477 | else { |
|
483 | else { | |
478 | status = LFR_SUCCESSFUL; |
|
484 | status = LFR_SUCCESSFUL; | |
479 | } |
|
485 | } | |
480 | break; |
|
486 | break; | |
481 | case LFR_MODE_SBM1: |
|
487 | case LFR_MODE_SBM1: | |
482 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
488 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
483 | status = LFR_DEFAULT; |
|
489 | status = LFR_DEFAULT; | |
484 | } |
|
490 | } | |
485 | else { |
|
491 | else { | |
486 | status = LFR_SUCCESSFUL; |
|
492 | status = LFR_SUCCESSFUL; | |
487 | } |
|
493 | } | |
488 | break; |
|
494 | break; | |
489 | case LFR_MODE_SBM2: |
|
495 | case LFR_MODE_SBM2: | |
490 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
496 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
491 | status = LFR_DEFAULT; |
|
497 | status = LFR_DEFAULT; | |
492 | } |
|
498 | } | |
493 | else { |
|
499 | else { | |
494 | status = LFR_SUCCESSFUL; |
|
500 | status = LFR_SUCCESSFUL; | |
495 | } |
|
501 | } | |
496 | break; |
|
502 | break; | |
497 | default: |
|
503 | default: | |
498 | status = LFR_DEFAULT; |
|
504 | status = LFR_DEFAULT; | |
499 | break; |
|
505 | break; | |
500 | } |
|
506 | } | |
501 |
|
507 | |||
502 | return status; |
|
508 | return status; | |
503 | } |
|
509 | } | |
504 |
|
510 | |||
505 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ) |
|
511 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ) | |
506 | { |
|
512 | { | |
507 | if (transitionCoarseTime == 0) |
|
513 | if (transitionCoarseTime == 0) | |
508 | { |
|
514 | { | |
509 | lastValidEnterModeTime = time_management_regs->coarse_time + 1; |
|
515 | lastValidEnterModeTime = time_management_regs->coarse_time + 1; | |
510 | PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime); |
|
516 | PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime); | |
511 | } |
|
517 | } | |
512 | else |
|
518 | else | |
513 | { |
|
519 | { | |
514 | lastValidEnterModeTime = transitionCoarseTime; |
|
520 | lastValidEnterModeTime = transitionCoarseTime; | |
515 | PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime); |
|
521 | PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime); | |
516 | } |
|
522 | } | |
517 | } |
|
523 | } | |
518 |
|
524 | |||
519 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
525 | int check_transition_date( unsigned int transitionCoarseTime ) | |
520 | { |
|
526 | { | |
521 | int status; |
|
527 | int status; | |
522 | unsigned int localCoarseTime; |
|
528 | unsigned int localCoarseTime; | |
523 | unsigned int deltaCoarseTime; |
|
529 | unsigned int deltaCoarseTime; | |
524 |
|
530 | |||
525 | status = LFR_SUCCESSFUL; |
|
531 | status = LFR_SUCCESSFUL; | |
526 |
|
532 | |||
527 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
533 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition | |
528 | { |
|
534 | { | |
529 | status = LFR_SUCCESSFUL; |
|
535 | status = LFR_SUCCESSFUL; | |
530 | } |
|
536 | } | |
531 | else |
|
537 | else | |
532 | { |
|
538 | { | |
533 | localCoarseTime = time_management_regs->coarse_time & COARSE_TIME_MASK; |
|
539 | localCoarseTime = time_management_regs->coarse_time & COARSE_TIME_MASK; | |
534 |
|
540 | |||
535 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime); |
|
541 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime); | |
536 |
|
542 | |||
537 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
543 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 | |
538 | { |
|
544 | { | |
539 | status = LFR_DEFAULT; |
|
545 | status = LFR_DEFAULT; | |
540 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n"); |
|
546 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n"); | |
541 | } |
|
547 | } | |
542 |
|
548 | |||
543 | if (status == LFR_SUCCESSFUL) |
|
549 | if (status == LFR_SUCCESSFUL) | |
544 | { |
|
550 | { | |
545 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
551 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; | |
546 | if ( deltaCoarseTime > MAX_DELTA_COARSE_TIME ) // SSS-CP-EQS-323 |
|
552 | if ( deltaCoarseTime > MAX_DELTA_COARSE_TIME ) // SSS-CP-EQS-323 | |
547 | { |
|
553 | { | |
548 | status = LFR_DEFAULT; |
|
554 | status = LFR_DEFAULT; | |
549 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
555 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) | |
550 | } |
|
556 | } | |
551 | } |
|
557 | } | |
552 | } |
|
558 | } | |
553 |
|
559 | |||
554 | return status; |
|
560 | return status; | |
555 | } |
|
561 | } | |
556 |
|
562 | |||
557 | int restart_asm_activities( unsigned char lfrRequestedMode ) |
|
563 | int restart_asm_activities( unsigned char lfrRequestedMode ) | |
558 | { |
|
564 | { | |
559 | rtems_status_code status; |
|
565 | rtems_status_code status; | |
560 |
|
566 | |||
561 | status = stop_spectral_matrices(); |
|
567 | status = stop_spectral_matrices(); | |
562 |
|
568 | |||
563 | thisIsAnASMRestart = 1; |
|
569 | thisIsAnASMRestart = 1; | |
564 |
|
570 | |||
565 | status = restart_asm_tasks( lfrRequestedMode ); |
|
571 | status = restart_asm_tasks( lfrRequestedMode ); | |
566 |
|
572 | |||
567 | launch_spectral_matrix(); |
|
573 | launch_spectral_matrix(); | |
568 |
|
574 | |||
569 | return status; |
|
575 | return status; | |
570 | } |
|
576 | } | |
571 |
|
577 | |||
572 | int stop_spectral_matrices( void ) |
|
578 | int stop_spectral_matrices( void ) | |
573 | { |
|
579 | { | |
574 | /** This function stops and restarts the current mode average spectral matrices activities. |
|
580 | /** This function stops and restarts the current mode average spectral matrices activities. | |
575 | * |
|
581 | * | |
576 | * @return RTEMS directive status codes: |
|
582 | * @return RTEMS directive status codes: | |
577 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
583 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
578 | * - RTEMS_INVALID_ID - task id invalid |
|
584 | * - RTEMS_INVALID_ID - task id invalid | |
579 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
585 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
580 | * |
|
586 | * | |
581 | */ |
|
587 | */ | |
582 |
|
588 | |||
583 | rtems_status_code status; |
|
589 | rtems_status_code status; | |
584 |
|
590 | |||
585 | status = RTEMS_SUCCESSFUL; |
|
591 | status = RTEMS_SUCCESSFUL; | |
586 |
|
592 | |||
587 | // (1) mask interruptions |
|
593 | // (1) mask interruptions | |
588 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt |
|
594 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt | |
589 |
|
595 | |||
590 | // (2) reset spectral matrices registers |
|
596 | // (2) reset spectral matrices registers | |
591 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
597 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
592 | reset_sm_status(); |
|
598 | reset_sm_status(); | |
593 |
|
599 | |||
594 | // (3) clear interruptions |
|
600 | // (3) clear interruptions | |
595 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
601 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
596 |
|
602 | |||
597 | // suspend several tasks |
|
603 | // suspend several tasks | |
598 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
604 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
599 | status = suspend_asm_tasks(); |
|
605 | status = suspend_asm_tasks(); | |
600 | } |
|
606 | } | |
601 |
|
607 | |||
602 | if (status != RTEMS_SUCCESSFUL) |
|
608 | if (status != RTEMS_SUCCESSFUL) | |
603 | { |
|
609 | { | |
604 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
610 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
605 | } |
|
611 | } | |
606 |
|
612 | |||
607 | return status; |
|
613 | return status; | |
608 | } |
|
614 | } | |
609 |
|
615 | |||
610 | int stop_current_mode( void ) |
|
616 | int stop_current_mode( void ) | |
611 | { |
|
617 | { | |
612 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
618 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
613 | * |
|
619 | * | |
614 | * @return RTEMS directive status codes: |
|
620 | * @return RTEMS directive status codes: | |
615 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
621 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
616 | * - RTEMS_INVALID_ID - task id invalid |
|
622 | * - RTEMS_INVALID_ID - task id invalid | |
617 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
623 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
618 | * |
|
624 | * | |
619 | */ |
|
625 | */ | |
620 |
|
626 | |||
621 | rtems_status_code status; |
|
627 | rtems_status_code status; | |
622 |
|
628 | |||
623 | status = RTEMS_SUCCESSFUL; |
|
629 | status = RTEMS_SUCCESSFUL; | |
624 |
|
630 | |||
625 | // (1) mask interruptions |
|
631 | // (1) mask interruptions | |
626 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
632 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
627 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
633 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
628 |
|
634 | |||
629 | // (2) reset waveform picker registers |
|
635 | // (2) reset waveform picker registers | |
630 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
636 | reset_wfp_burst_enable(); // reset burst and enable bits | |
631 | reset_wfp_status(); // reset all the status bits |
|
637 | reset_wfp_status(); // reset all the status bits | |
632 |
|
638 | |||
633 | // (3) reset spectral matrices registers |
|
639 | // (3) reset spectral matrices registers | |
634 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
640 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
635 | reset_sm_status(); |
|
641 | reset_sm_status(); | |
636 |
|
642 | |||
637 | // reset lfr VHDL module |
|
643 | // reset lfr VHDL module | |
638 | reset_lfr(); |
|
644 | reset_lfr(); | |
639 |
|
645 | |||
640 | reset_extractSWF(); // reset the extractSWF flag to false |
|
646 | reset_extractSWF(); // reset the extractSWF flag to false | |
641 |
|
647 | |||
642 | // (4) clear interruptions |
|
648 | // (4) clear interruptions | |
643 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
649 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
644 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
650 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
645 |
|
651 | |||
646 | // suspend several tasks |
|
652 | // suspend several tasks | |
647 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
653 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
648 | status = suspend_science_tasks(); |
|
654 | status = suspend_science_tasks(); | |
649 | } |
|
655 | } | |
650 |
|
656 | |||
651 | if (status != RTEMS_SUCCESSFUL) |
|
657 | if (status != RTEMS_SUCCESSFUL) | |
652 | { |
|
658 | { | |
653 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
659 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
654 | } |
|
660 | } | |
655 |
|
661 | |||
656 | return status; |
|
662 | return status; | |
657 | } |
|
663 | } | |
658 |
|
664 | |||
659 | int enter_mode_standby( void ) |
|
665 | int enter_mode_standby( void ) | |
660 | { |
|
666 | { | |
661 | /** This function is used to put LFR in the STANDBY mode. |
|
667 | /** This function is used to put LFR in the STANDBY mode. | |
662 | * |
|
668 | * | |
663 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
669 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
664 | * |
|
670 | * | |
665 | * @return RTEMS directive status codes: |
|
671 | * @return RTEMS directive status codes: | |
666 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
672 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
667 | * - RTEMS_INVALID_ID - task id invalid |
|
673 | * - RTEMS_INVALID_ID - task id invalid | |
668 | * - RTEMS_INCORRECT_STATE - task never started |
|
674 | * - RTEMS_INCORRECT_STATE - task never started | |
669 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
675 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
670 | * |
|
676 | * | |
671 | * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE |
|
677 | * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE | |
672 | * is immediate. |
|
678 | * is immediate. | |
673 | * |
|
679 | * | |
674 | */ |
|
680 | */ | |
675 |
|
681 | |||
676 | int status; |
|
682 | int status; | |
677 |
|
683 | |||
678 | status = stop_current_mode(); // STOP THE CURRENT MODE |
|
684 | status = stop_current_mode(); // STOP THE CURRENT MODE | |
679 |
|
685 | |||
680 | #ifdef PRINT_TASK_STATISTICS |
|
686 | #ifdef PRINT_TASK_STATISTICS | |
681 | rtems_cpu_usage_report(); |
|
687 | rtems_cpu_usage_report(); | |
682 | #endif |
|
688 | #endif | |
683 |
|
689 | |||
684 | #ifdef PRINT_STACK_REPORT |
|
690 | #ifdef PRINT_STACK_REPORT | |
685 | PRINTF("stack report selected\n") |
|
691 | PRINTF("stack report selected\n") | |
686 | rtems_stack_checker_report_usage(); |
|
692 | rtems_stack_checker_report_usage(); | |
687 | #endif |
|
693 | #endif | |
688 |
|
694 | |||
689 | return status; |
|
695 | return status; | |
690 | } |
|
696 | } | |
691 |
|
697 | |||
692 | int enter_mode_normal( unsigned int transitionCoarseTime ) |
|
698 | int enter_mode_normal( unsigned int transitionCoarseTime ) | |
693 | { |
|
699 | { | |
694 | /** This function is used to start the NORMAL mode. |
|
700 | /** This function is used to start the NORMAL mode. | |
695 | * |
|
701 | * | |
696 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
702 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
697 | * |
|
703 | * | |
698 | * @return RTEMS directive status codes: |
|
704 | * @return RTEMS directive status codes: | |
699 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
705 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
700 | * - RTEMS_INVALID_ID - task id invalid |
|
706 | * - RTEMS_INVALID_ID - task id invalid | |
701 | * - RTEMS_INCORRECT_STATE - task never started |
|
707 | * - RTEMS_INCORRECT_STATE - task never started | |
702 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
708 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
703 | * |
|
709 | * | |
704 | * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2, |
|
710 | * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2, | |
705 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. |
|
711 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. | |
706 | * |
|
712 | * | |
707 | */ |
|
713 | */ | |
708 |
|
714 | |||
709 | int status; |
|
715 | int status; | |
710 |
|
716 | |||
711 | #ifdef PRINT_TASK_STATISTICS |
|
717 | #ifdef PRINT_TASK_STATISTICS | |
712 | rtems_cpu_usage_reset(); |
|
718 | rtems_cpu_usage_reset(); | |
713 | #endif |
|
719 | #endif | |
714 |
|
720 | |||
715 | status = RTEMS_UNSATISFIED; |
|
721 | status = RTEMS_UNSATISFIED; | |
716 |
|
722 | |||
717 | switch( lfrCurrentMode ) |
|
723 | switch( lfrCurrentMode ) | |
718 | { |
|
724 | { | |
719 | case LFR_MODE_STANDBY: |
|
725 | case LFR_MODE_STANDBY: | |
720 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks |
|
726 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks | |
721 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
727 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
722 | { |
|
728 | { | |
723 | launch_spectral_matrix( ); |
|
729 | launch_spectral_matrix( ); | |
724 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
730 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
725 | } |
|
731 | } | |
726 | break; |
|
732 | break; | |
727 | case LFR_MODE_BURST: |
|
733 | case LFR_MODE_BURST: | |
728 | status = stop_current_mode(); // stop the current mode |
|
734 | status = stop_current_mode(); // stop the current mode | |
729 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks |
|
735 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks | |
730 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
736 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
731 | { |
|
737 | { | |
732 | launch_spectral_matrix( ); |
|
738 | launch_spectral_matrix( ); | |
733 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
739 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
734 | } |
|
740 | } | |
735 | break; |
|
741 | break; | |
736 | case LFR_MODE_SBM1: |
|
742 | case LFR_MODE_SBM1: | |
737 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters |
|
743 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters | |
738 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
744 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
739 | update_last_valid_transition_date( transitionCoarseTime ); |
|
745 | update_last_valid_transition_date( transitionCoarseTime ); | |
740 | break; |
|
746 | break; | |
741 | case LFR_MODE_SBM2: |
|
747 | case LFR_MODE_SBM2: | |
742 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters |
|
748 | status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters | |
743 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
749 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
744 | update_last_valid_transition_date( transitionCoarseTime ); |
|
750 | update_last_valid_transition_date( transitionCoarseTime ); | |
745 | break; |
|
751 | break; | |
746 | default: |
|
752 | default: | |
747 | break; |
|
753 | break; | |
748 | } |
|
754 | } | |
749 |
|
755 | |||
750 | if (status != RTEMS_SUCCESSFUL) |
|
756 | if (status != RTEMS_SUCCESSFUL) | |
751 | { |
|
757 | { | |
752 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) |
|
758 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) | |
753 | status = RTEMS_UNSATISFIED; |
|
759 | status = RTEMS_UNSATISFIED; | |
754 | } |
|
760 | } | |
755 |
|
761 | |||
756 | return status; |
|
762 | return status; | |
757 | } |
|
763 | } | |
758 |
|
764 | |||
759 | int enter_mode_burst( unsigned int transitionCoarseTime ) |
|
765 | int enter_mode_burst( unsigned int transitionCoarseTime ) | |
760 | { |
|
766 | { | |
761 | /** This function is used to start the BURST mode. |
|
767 | /** This function is used to start the BURST mode. | |
762 | * |
|
768 | * | |
763 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
769 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
764 | * |
|
770 | * | |
765 | * @return RTEMS directive status codes: |
|
771 | * @return RTEMS directive status codes: | |
766 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
772 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
767 | * - RTEMS_INVALID_ID - task id invalid |
|
773 | * - RTEMS_INVALID_ID - task id invalid | |
768 | * - RTEMS_INCORRECT_STATE - task never started |
|
774 | * - RTEMS_INCORRECT_STATE - task never started | |
769 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
775 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
770 | * |
|
776 | * | |
771 | * The way the BURST mode is started does not depend on the LFR current mode. |
|
777 | * The way the BURST mode is started does not depend on the LFR current mode. | |
772 | * |
|
778 | * | |
773 | */ |
|
779 | */ | |
774 |
|
780 | |||
775 |
|
781 | |||
776 | int status; |
|
782 | int status; | |
777 |
|
783 | |||
778 | #ifdef PRINT_TASK_STATISTICS |
|
784 | #ifdef PRINT_TASK_STATISTICS | |
779 | rtems_cpu_usage_reset(); |
|
785 | rtems_cpu_usage_reset(); | |
780 | #endif |
|
786 | #endif | |
781 |
|
787 | |||
782 | status = stop_current_mode(); // stop the current mode |
|
788 | status = stop_current_mode(); // stop the current mode | |
783 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks |
|
789 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks | |
784 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
790 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
785 | { |
|
791 | { | |
786 | launch_spectral_matrix( ); |
|
792 | launch_spectral_matrix( ); | |
787 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); |
|
793 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); | |
788 | } |
|
794 | } | |
789 |
|
795 | |||
790 | if (status != RTEMS_SUCCESSFUL) |
|
796 | if (status != RTEMS_SUCCESSFUL) | |
791 | { |
|
797 | { | |
792 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) |
|
798 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) | |
793 | status = RTEMS_UNSATISFIED; |
|
799 | status = RTEMS_UNSATISFIED; | |
794 | } |
|
800 | } | |
795 |
|
801 | |||
796 | return status; |
|
802 | return status; | |
797 | } |
|
803 | } | |
798 |
|
804 | |||
799 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) |
|
805 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) | |
800 | { |
|
806 | { | |
801 | /** This function is used to start the SBM1 mode. |
|
807 | /** This function is used to start the SBM1 mode. | |
802 | * |
|
808 | * | |
803 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
809 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
804 | * |
|
810 | * | |
805 | * @return RTEMS directive status codes: |
|
811 | * @return RTEMS directive status codes: | |
806 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
812 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
807 | * - RTEMS_INVALID_ID - task id invalid |
|
813 | * - RTEMS_INVALID_ID - task id invalid | |
808 | * - RTEMS_INCORRECT_STATE - task never started |
|
814 | * - RTEMS_INCORRECT_STATE - task never started | |
809 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
815 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
810 | * |
|
816 | * | |
811 | * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2, |
|
817 | * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2, | |
812 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other |
|
818 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other | |
813 | * cases, the acquisition is completely restarted. |
|
819 | * cases, the acquisition is completely restarted. | |
814 | * |
|
820 | * | |
815 | */ |
|
821 | */ | |
816 |
|
822 | |||
817 | int status; |
|
823 | int status; | |
818 |
|
824 | |||
819 | #ifdef PRINT_TASK_STATISTICS |
|
825 | #ifdef PRINT_TASK_STATISTICS | |
820 | rtems_cpu_usage_reset(); |
|
826 | rtems_cpu_usage_reset(); | |
821 | #endif |
|
827 | #endif | |
822 |
|
828 | |||
823 | status = RTEMS_UNSATISFIED; |
|
829 | status = RTEMS_UNSATISFIED; | |
824 |
|
830 | |||
825 | switch( lfrCurrentMode ) |
|
831 | switch( lfrCurrentMode ) | |
826 | { |
|
832 | { | |
827 | case LFR_MODE_STANDBY: |
|
833 | case LFR_MODE_STANDBY: | |
828 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks |
|
834 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks | |
829 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
835 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
830 | { |
|
836 | { | |
831 | launch_spectral_matrix( ); |
|
837 | launch_spectral_matrix( ); | |
832 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
838 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
833 | } |
|
839 | } | |
834 | break; |
|
840 | break; | |
835 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action |
|
841 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action | |
836 | status = restart_asm_activities( LFR_MODE_SBM1 ); |
|
842 | status = restart_asm_activities( LFR_MODE_SBM1 ); | |
837 | status = LFR_SUCCESSFUL; |
|
843 | status = LFR_SUCCESSFUL; | |
838 | update_last_valid_transition_date( transitionCoarseTime ); |
|
844 | update_last_valid_transition_date( transitionCoarseTime ); | |
839 | break; |
|
845 | break; | |
840 | case LFR_MODE_BURST: |
|
846 | case LFR_MODE_BURST: | |
841 | status = stop_current_mode(); // stop the current mode |
|
847 | status = stop_current_mode(); // stop the current mode | |
842 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks |
|
848 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks | |
843 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
849 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
844 | { |
|
850 | { | |
845 | launch_spectral_matrix( ); |
|
851 | launch_spectral_matrix( ); | |
846 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
852 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
847 | } |
|
853 | } | |
848 | break; |
|
854 | break; | |
849 | case LFR_MODE_SBM2: |
|
855 | case LFR_MODE_SBM2: | |
850 | status = restart_asm_activities( LFR_MODE_SBM1 ); |
|
856 | status = restart_asm_activities( LFR_MODE_SBM1 ); | |
851 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
857 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
852 | update_last_valid_transition_date( transitionCoarseTime ); |
|
858 | update_last_valid_transition_date( transitionCoarseTime ); | |
853 | break; |
|
859 | break; | |
854 | default: |
|
860 | default: | |
855 | break; |
|
861 | break; | |
856 | } |
|
862 | } | |
857 |
|
863 | |||
858 | if (status != RTEMS_SUCCESSFUL) |
|
864 | if (status != RTEMS_SUCCESSFUL) | |
859 | { |
|
865 | { | |
860 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status); |
|
866 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status); | |
861 | status = RTEMS_UNSATISFIED; |
|
867 | status = RTEMS_UNSATISFIED; | |
862 | } |
|
868 | } | |
863 |
|
869 | |||
864 | return status; |
|
870 | return status; | |
865 | } |
|
871 | } | |
866 |
|
872 | |||
867 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) |
|
873 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) | |
868 | { |
|
874 | { | |
869 | /** This function is used to start the SBM2 mode. |
|
875 | /** This function is used to start the SBM2 mode. | |
870 | * |
|
876 | * | |
871 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
877 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
872 | * |
|
878 | * | |
873 | * @return RTEMS directive status codes: |
|
879 | * @return RTEMS directive status codes: | |
874 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
880 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
875 | * - RTEMS_INVALID_ID - task id invalid |
|
881 | * - RTEMS_INVALID_ID - task id invalid | |
876 | * - RTEMS_INCORRECT_STATE - task never started |
|
882 | * - RTEMS_INCORRECT_STATE - task never started | |
877 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
883 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
878 | * |
|
884 | * | |
879 | * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1, |
|
885 | * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1, | |
880 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other |
|
886 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other | |
881 | * cases, the acquisition is completely restarted. |
|
887 | * cases, the acquisition is completely restarted. | |
882 | * |
|
888 | * | |
883 | */ |
|
889 | */ | |
884 |
|
890 | |||
885 | int status; |
|
891 | int status; | |
886 |
|
892 | |||
887 | #ifdef PRINT_TASK_STATISTICS |
|
893 | #ifdef PRINT_TASK_STATISTICS | |
888 | rtems_cpu_usage_reset(); |
|
894 | rtems_cpu_usage_reset(); | |
889 | #endif |
|
895 | #endif | |
890 |
|
896 | |||
891 | status = RTEMS_UNSATISFIED; |
|
897 | status = RTEMS_UNSATISFIED; | |
892 |
|
898 | |||
893 | switch( lfrCurrentMode ) |
|
899 | switch( lfrCurrentMode ) | |
894 | { |
|
900 | { | |
895 | case LFR_MODE_STANDBY: |
|
901 | case LFR_MODE_STANDBY: | |
896 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks |
|
902 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks | |
897 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
903 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
898 | { |
|
904 | { | |
899 | launch_spectral_matrix( ); |
|
905 | launch_spectral_matrix( ); | |
900 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
906 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
901 | } |
|
907 | } | |
902 | break; |
|
908 | break; | |
903 | case LFR_MODE_NORMAL: |
|
909 | case LFR_MODE_NORMAL: | |
904 | status = restart_asm_activities( LFR_MODE_SBM2 ); |
|
910 | status = restart_asm_activities( LFR_MODE_SBM2 ); | |
905 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
911 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
906 | update_last_valid_transition_date( transitionCoarseTime ); |
|
912 | update_last_valid_transition_date( transitionCoarseTime ); | |
907 | break; |
|
913 | break; | |
908 | case LFR_MODE_BURST: |
|
914 | case LFR_MODE_BURST: | |
909 | status = stop_current_mode(); // stop the current mode |
|
915 | status = stop_current_mode(); // stop the current mode | |
910 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks |
|
916 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks | |
911 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
917 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
912 | { |
|
918 | { | |
913 | launch_spectral_matrix( ); |
|
919 | launch_spectral_matrix( ); | |
914 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
920 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
915 | } |
|
921 | } | |
916 | break; |
|
922 | break; | |
917 | case LFR_MODE_SBM1: |
|
923 | case LFR_MODE_SBM1: | |
918 | status = restart_asm_activities( LFR_MODE_SBM2 ); |
|
924 | status = restart_asm_activities( LFR_MODE_SBM2 ); | |
919 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
925 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
920 | update_last_valid_transition_date( transitionCoarseTime ); |
|
926 | update_last_valid_transition_date( transitionCoarseTime ); | |
921 | break; |
|
927 | break; | |
922 | default: |
|
928 | default: | |
923 | break; |
|
929 | break; | |
924 | } |
|
930 | } | |
925 |
|
931 | |||
926 | if (status != RTEMS_SUCCESSFUL) |
|
932 | if (status != RTEMS_SUCCESSFUL) | |
927 | { |
|
933 | { | |
928 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) |
|
934 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) | |
929 | status = RTEMS_UNSATISFIED; |
|
935 | status = RTEMS_UNSATISFIED; | |
930 | } |
|
936 | } | |
931 |
|
937 | |||
932 | return status; |
|
938 | return status; | |
933 | } |
|
939 | } | |
934 |
|
940 | |||
935 | int restart_science_tasks( unsigned char lfrRequestedMode ) |
|
941 | int restart_science_tasks( unsigned char lfrRequestedMode ) | |
936 | { |
|
942 | { | |
937 | /** This function is used to restart all science tasks. |
|
943 | /** This function is used to restart all science tasks. | |
938 | * |
|
944 | * | |
939 | * @return RTEMS directive status codes: |
|
945 | * @return RTEMS directive status codes: | |
940 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
946 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
941 | * - RTEMS_INVALID_ID - task id invalid |
|
947 | * - RTEMS_INVALID_ID - task id invalid | |
942 | * - RTEMS_INCORRECT_STATE - task never started |
|
948 | * - RTEMS_INCORRECT_STATE - task never started | |
943 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
949 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
944 | * |
|
950 | * | |
945 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
951 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 | |
946 | * |
|
952 | * | |
947 | */ |
|
953 | */ | |
948 |
|
954 | |||
949 | rtems_status_code status[NB_SCIENCE_TASKS]; |
|
955 | rtems_status_code status[NB_SCIENCE_TASKS]; | |
950 | rtems_status_code ret; |
|
956 | rtems_status_code ret; | |
951 |
|
957 | |||
952 | ret = RTEMS_SUCCESSFUL; |
|
958 | ret = RTEMS_SUCCESSFUL; | |
953 |
|
959 | |||
954 | status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
960 | status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
955 | if (status[STATUS_0] != RTEMS_SUCCESSFUL) |
|
961 | if (status[STATUS_0] != RTEMS_SUCCESSFUL) | |
956 | { |
|
962 | { | |
957 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0]) |
|
963 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0]) | |
958 | } |
|
964 | } | |
959 |
|
965 | |||
960 | status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
966 | status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
961 | if (status[STATUS_1] != RTEMS_SUCCESSFUL) |
|
967 | if (status[STATUS_1] != RTEMS_SUCCESSFUL) | |
962 | { |
|
968 | { | |
963 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1]) |
|
969 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1]) | |
964 | } |
|
970 | } | |
965 |
|
971 | |||
966 | status[STATUS_2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
972 | status[STATUS_2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
967 | if (status[STATUS_2] != RTEMS_SUCCESSFUL) |
|
973 | if (status[STATUS_2] != RTEMS_SUCCESSFUL) | |
968 | { |
|
974 | { | |
969 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[STATUS_2]) |
|
975 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[STATUS_2]) | |
970 | } |
|
976 | } | |
971 |
|
977 | |||
972 | status[STATUS_3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
978 | status[STATUS_3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
973 | if (status[STATUS_3] != RTEMS_SUCCESSFUL) |
|
979 | if (status[STATUS_3] != RTEMS_SUCCESSFUL) | |
974 | { |
|
980 | { | |
975 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[STATUS_3]) |
|
981 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[STATUS_3]) | |
976 | } |
|
982 | } | |
977 |
|
983 | |||
978 | status[STATUS_4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
984 | status[STATUS_4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
979 | if (status[STATUS_4] != RTEMS_SUCCESSFUL) |
|
985 | if (status[STATUS_4] != RTEMS_SUCCESSFUL) | |
980 | { |
|
986 | { | |
981 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[STATUS_4]) |
|
987 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[STATUS_4]) | |
982 | } |
|
988 | } | |
983 |
|
989 | |||
984 | status[STATUS_5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
990 | status[STATUS_5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
985 | if (status[STATUS_5] != RTEMS_SUCCESSFUL) |
|
991 | if (status[STATUS_5] != RTEMS_SUCCESSFUL) | |
986 | { |
|
992 | { | |
987 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[STATUS_5]) |
|
993 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[STATUS_5]) | |
988 | } |
|
994 | } | |
989 |
|
995 | |||
990 | status[STATUS_6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
996 | status[STATUS_6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
991 | if (status[STATUS_6] != RTEMS_SUCCESSFUL) |
|
997 | if (status[STATUS_6] != RTEMS_SUCCESSFUL) | |
992 | { |
|
998 | { | |
993 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_6]) |
|
999 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_6]) | |
994 | } |
|
1000 | } | |
995 |
|
1001 | |||
996 | status[STATUS_7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
1002 | status[STATUS_7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
997 | if (status[STATUS_7] != RTEMS_SUCCESSFUL) |
|
1003 | if (status[STATUS_7] != RTEMS_SUCCESSFUL) | |
998 | { |
|
1004 | { | |
999 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_7]) |
|
1005 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_7]) | |
1000 | } |
|
1006 | } | |
1001 |
|
1007 | |||
1002 | status[STATUS_8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
1008 | status[STATUS_8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
1003 | if (status[STATUS_8] != RTEMS_SUCCESSFUL) |
|
1009 | if (status[STATUS_8] != RTEMS_SUCCESSFUL) | |
1004 | { |
|
1010 | { | |
1005 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_8]) |
|
1011 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_8]) | |
1006 | } |
|
1012 | } | |
1007 |
|
1013 | |||
1008 | status[STATUS_9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
1014 | status[STATUS_9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
1009 | if (status[STATUS_9] != RTEMS_SUCCESSFUL) |
|
1015 | if (status[STATUS_9] != RTEMS_SUCCESSFUL) | |
1010 | { |
|
1016 | { | |
1011 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_9]) |
|
1017 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_9]) | |
1012 | } |
|
1018 | } | |
1013 |
|
1019 | |||
1014 | if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) || |
|
1020 | if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) || | |
1015 | (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) || |
|
1021 | (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) || | |
1016 | (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) || |
|
1022 | (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) || | |
1017 | (status[STATUS_6] != RTEMS_SUCCESSFUL) || (status[STATUS_7] != RTEMS_SUCCESSFUL) || |
|
1023 | (status[STATUS_6] != RTEMS_SUCCESSFUL) || (status[STATUS_7] != RTEMS_SUCCESSFUL) || | |
1018 | (status[STATUS_8] != RTEMS_SUCCESSFUL) || (status[STATUS_9] != RTEMS_SUCCESSFUL) ) |
|
1024 | (status[STATUS_8] != RTEMS_SUCCESSFUL) || (status[STATUS_9] != RTEMS_SUCCESSFUL) ) | |
1019 | { |
|
1025 | { | |
1020 | ret = RTEMS_UNSATISFIED; |
|
1026 | ret = RTEMS_UNSATISFIED; | |
1021 | } |
|
1027 | } | |
1022 |
|
1028 | |||
1023 | return ret; |
|
1029 | return ret; | |
1024 | } |
|
1030 | } | |
1025 |
|
1031 | |||
1026 | int restart_asm_tasks( unsigned char lfrRequestedMode ) |
|
1032 | int restart_asm_tasks( unsigned char lfrRequestedMode ) | |
1027 | { |
|
1033 | { | |
1028 | /** This function is used to restart average spectral matrices tasks. |
|
1034 | /** This function is used to restart average spectral matrices tasks. | |
1029 | * |
|
1035 | * | |
1030 | * @return RTEMS directive status codes: |
|
1036 | * @return RTEMS directive status codes: | |
1031 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1037 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1032 | * - RTEMS_INVALID_ID - task id invalid |
|
1038 | * - RTEMS_INVALID_ID - task id invalid | |
1033 | * - RTEMS_INCORRECT_STATE - task never started |
|
1039 | * - RTEMS_INCORRECT_STATE - task never started | |
1034 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
1040 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
1035 | * |
|
1041 | * | |
1036 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 |
|
1042 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 | |
1037 | * |
|
1043 | * | |
1038 | */ |
|
1044 | */ | |
1039 |
|
1045 | |||
1040 | rtems_status_code status[NB_ASM_TASKS]; |
|
1046 | rtems_status_code status[NB_ASM_TASKS]; | |
1041 | rtems_status_code ret; |
|
1047 | rtems_status_code ret; | |
1042 |
|
1048 | |||
1043 | ret = RTEMS_SUCCESSFUL; |
|
1049 | ret = RTEMS_SUCCESSFUL; | |
1044 |
|
1050 | |||
1045 | status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
1051 | status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
1046 | if (status[STATUS_0] != RTEMS_SUCCESSFUL) |
|
1052 | if (status[STATUS_0] != RTEMS_SUCCESSFUL) | |
1047 | { |
|
1053 | { | |
1048 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0]) |
|
1054 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0]) | |
1049 | } |
|
1055 | } | |
1050 |
|
1056 | |||
1051 | status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
1057 | status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
1052 | if (status[STATUS_1] != RTEMS_SUCCESSFUL) |
|
1058 | if (status[STATUS_1] != RTEMS_SUCCESSFUL) | |
1053 | { |
|
1059 | { | |
1054 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1]) |
|
1060 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1]) | |
1055 | } |
|
1061 | } | |
1056 |
|
1062 | |||
1057 | status[STATUS_2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
1063 | status[STATUS_2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
1058 | if (status[STATUS_2] != RTEMS_SUCCESSFUL) |
|
1064 | if (status[STATUS_2] != RTEMS_SUCCESSFUL) | |
1059 | { |
|
1065 | { | |
1060 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_2]) |
|
1066 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_2]) | |
1061 | } |
|
1067 | } | |
1062 |
|
1068 | |||
1063 | status[STATUS_3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
1069 | status[STATUS_3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
1064 | if (status[STATUS_3] != RTEMS_SUCCESSFUL) |
|
1070 | if (status[STATUS_3] != RTEMS_SUCCESSFUL) | |
1065 | { |
|
1071 | { | |
1066 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_3]) |
|
1072 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_3]) | |
1067 | } |
|
1073 | } | |
1068 |
|
1074 | |||
1069 | status[STATUS_4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
1075 | status[STATUS_4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
1070 | if (status[STATUS_4] != RTEMS_SUCCESSFUL) |
|
1076 | if (status[STATUS_4] != RTEMS_SUCCESSFUL) | |
1071 | { |
|
1077 | { | |
1072 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_4]) |
|
1078 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_4]) | |
1073 | } |
|
1079 | } | |
1074 |
|
1080 | |||
1075 | status[STATUS_5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
1081 | status[STATUS_5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
1076 | if (status[STATUS_5] != RTEMS_SUCCESSFUL) |
|
1082 | if (status[STATUS_5] != RTEMS_SUCCESSFUL) | |
1077 | { |
|
1083 | { | |
1078 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_5]) |
|
1084 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_5]) | |
1079 | } |
|
1085 | } | |
1080 |
|
1086 | |||
1081 | if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) || |
|
1087 | if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) || | |
1082 | (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) || |
|
1088 | (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) || | |
1083 | (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) ) |
|
1089 | (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) ) | |
1084 | { |
|
1090 | { | |
1085 | ret = RTEMS_UNSATISFIED; |
|
1091 | ret = RTEMS_UNSATISFIED; | |
1086 | } |
|
1092 | } | |
1087 |
|
1093 | |||
1088 | return ret; |
|
1094 | return ret; | |
1089 | } |
|
1095 | } | |
1090 |
|
1096 | |||
1091 | int suspend_science_tasks( void ) |
|
1097 | int suspend_science_tasks( void ) | |
1092 | { |
|
1098 | { | |
1093 | /** This function suspends the science tasks. |
|
1099 | /** This function suspends the science tasks. | |
1094 | * |
|
1100 | * | |
1095 | * @return RTEMS directive status codes: |
|
1101 | * @return RTEMS directive status codes: | |
1096 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1102 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1097 | * - RTEMS_INVALID_ID - task id invalid |
|
1103 | * - RTEMS_INVALID_ID - task id invalid | |
1098 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1104 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
1099 | * |
|
1105 | * | |
1100 | */ |
|
1106 | */ | |
1101 |
|
1107 | |||
1102 | rtems_status_code status; |
|
1108 | rtems_status_code status; | |
1103 |
|
1109 | |||
1104 | PRINTF("in suspend_science_tasks\n") |
|
1110 | PRINTF("in suspend_science_tasks\n") | |
1105 |
|
1111 | |||
1106 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
1112 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
1107 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1113 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1108 | { |
|
1114 | { | |
1109 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1115 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
1110 | } |
|
1116 | } | |
1111 | else |
|
1117 | else | |
1112 | { |
|
1118 | { | |
1113 | status = RTEMS_SUCCESSFUL; |
|
1119 | status = RTEMS_SUCCESSFUL; | |
1114 | } |
|
1120 | } | |
1115 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
1121 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
1116 | { |
|
1122 | { | |
1117 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
1123 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
1118 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1124 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1119 | { |
|
1125 | { | |
1120 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
1126 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
1121 | } |
|
1127 | } | |
1122 | else |
|
1128 | else | |
1123 | { |
|
1129 | { | |
1124 | status = RTEMS_SUCCESSFUL; |
|
1130 | status = RTEMS_SUCCESSFUL; | |
1125 | } |
|
1131 | } | |
1126 | } |
|
1132 | } | |
1127 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
1133 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
1128 | { |
|
1134 | { | |
1129 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
1135 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
1130 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1136 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1131 | { |
|
1137 | { | |
1132 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
1138 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
1133 | } |
|
1139 | } | |
1134 | else |
|
1140 | else | |
1135 | { |
|
1141 | { | |
1136 | status = RTEMS_SUCCESSFUL; |
|
1142 | status = RTEMS_SUCCESSFUL; | |
1137 | } |
|
1143 | } | |
1138 | } |
|
1144 | } | |
1139 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
1145 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
1140 | { |
|
1146 | { | |
1141 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
1147 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
1142 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1148 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1143 | { |
|
1149 | { | |
1144 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
1150 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
1145 | } |
|
1151 | } | |
1146 | else |
|
1152 | else | |
1147 | { |
|
1153 | { | |
1148 | status = RTEMS_SUCCESSFUL; |
|
1154 | status = RTEMS_SUCCESSFUL; | |
1149 | } |
|
1155 | } | |
1150 | } |
|
1156 | } | |
1151 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
1157 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
1152 | { |
|
1158 | { | |
1153 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
1159 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
1154 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1160 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1155 | { |
|
1161 | { | |
1156 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
1162 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
1157 | } |
|
1163 | } | |
1158 | else |
|
1164 | else | |
1159 | { |
|
1165 | { | |
1160 | status = RTEMS_SUCCESSFUL; |
|
1166 | status = RTEMS_SUCCESSFUL; | |
1161 | } |
|
1167 | } | |
1162 | } |
|
1168 | } | |
1163 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1169 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1164 | { |
|
1170 | { | |
1165 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1171 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1166 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1172 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1167 | { |
|
1173 | { | |
1168 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1174 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1169 | } |
|
1175 | } | |
1170 | else |
|
1176 | else | |
1171 | { |
|
1177 | { | |
1172 | status = RTEMS_SUCCESSFUL; |
|
1178 | status = RTEMS_SUCCESSFUL; | |
1173 | } |
|
1179 | } | |
1174 | } |
|
1180 | } | |
1175 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
1181 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
1176 | { |
|
1182 | { | |
1177 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
1183 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
1178 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1184 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1179 | { |
|
1185 | { | |
1180 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
1186 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
1181 | } |
|
1187 | } | |
1182 | else |
|
1188 | else | |
1183 | { |
|
1189 | { | |
1184 | status = RTEMS_SUCCESSFUL; |
|
1190 | status = RTEMS_SUCCESSFUL; | |
1185 | } |
|
1191 | } | |
1186 | } |
|
1192 | } | |
1187 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
1193 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
1188 | { |
|
1194 | { | |
1189 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
1195 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
1190 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1196 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1191 | { |
|
1197 | { | |
1192 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
1198 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
1193 | } |
|
1199 | } | |
1194 | else |
|
1200 | else | |
1195 | { |
|
1201 | { | |
1196 | status = RTEMS_SUCCESSFUL; |
|
1202 | status = RTEMS_SUCCESSFUL; | |
1197 | } |
|
1203 | } | |
1198 | } |
|
1204 | } | |
1199 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
1205 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
1200 | { |
|
1206 | { | |
1201 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
1207 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
1202 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1208 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1203 | { |
|
1209 | { | |
1204 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
1210 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
1205 | } |
|
1211 | } | |
1206 | else |
|
1212 | else | |
1207 | { |
|
1213 | { | |
1208 | status = RTEMS_SUCCESSFUL; |
|
1214 | status = RTEMS_SUCCESSFUL; | |
1209 | } |
|
1215 | } | |
1210 | } |
|
1216 | } | |
1211 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
1217 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
1212 | { |
|
1218 | { | |
1213 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
1219 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
1214 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1220 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1215 | { |
|
1221 | { | |
1216 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
1222 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
1217 | } |
|
1223 | } | |
1218 | else |
|
1224 | else | |
1219 | { |
|
1225 | { | |
1220 | status = RTEMS_SUCCESSFUL; |
|
1226 | status = RTEMS_SUCCESSFUL; | |
1221 | } |
|
1227 | } | |
1222 | } |
|
1228 | } | |
1223 |
|
1229 | |||
1224 | return status; |
|
1230 | return status; | |
1225 | } |
|
1231 | } | |
1226 |
|
1232 | |||
1227 | int suspend_asm_tasks( void ) |
|
1233 | int suspend_asm_tasks( void ) | |
1228 | { |
|
1234 | { | |
1229 | /** This function suspends the science tasks. |
|
1235 | /** This function suspends the science tasks. | |
1230 | * |
|
1236 | * | |
1231 | * @return RTEMS directive status codes: |
|
1237 | * @return RTEMS directive status codes: | |
1232 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1238 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1233 | * - RTEMS_INVALID_ID - task id invalid |
|
1239 | * - RTEMS_INVALID_ID - task id invalid | |
1234 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1240 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
1235 | * |
|
1241 | * | |
1236 | */ |
|
1242 | */ | |
1237 |
|
1243 | |||
1238 | rtems_status_code status; |
|
1244 | rtems_status_code status; | |
1239 |
|
1245 | |||
1240 | PRINTF("in suspend_science_tasks\n") |
|
1246 | PRINTF("in suspend_science_tasks\n") | |
1241 |
|
1247 | |||
1242 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
1248 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
1243 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1249 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1244 | { |
|
1250 | { | |
1245 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1251 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
1246 | } |
|
1252 | } | |
1247 | else |
|
1253 | else | |
1248 | { |
|
1254 | { | |
1249 | status = RTEMS_SUCCESSFUL; |
|
1255 | status = RTEMS_SUCCESSFUL; | |
1250 | } |
|
1256 | } | |
1251 |
|
1257 | |||
1252 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
1258 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
1253 | { |
|
1259 | { | |
1254 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
1260 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
1255 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1261 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1256 | { |
|
1262 | { | |
1257 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
1263 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
1258 | } |
|
1264 | } | |
1259 | else |
|
1265 | else | |
1260 | { |
|
1266 | { | |
1261 | status = RTEMS_SUCCESSFUL; |
|
1267 | status = RTEMS_SUCCESSFUL; | |
1262 | } |
|
1268 | } | |
1263 | } |
|
1269 | } | |
1264 |
|
1270 | |||
1265 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
1271 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
1266 | { |
|
1272 | { | |
1267 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
1273 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
1268 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1274 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1269 | { |
|
1275 | { | |
1270 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
1276 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
1271 | } |
|
1277 | } | |
1272 | else |
|
1278 | else | |
1273 | { |
|
1279 | { | |
1274 | status = RTEMS_SUCCESSFUL; |
|
1280 | status = RTEMS_SUCCESSFUL; | |
1275 | } |
|
1281 | } | |
1276 | } |
|
1282 | } | |
1277 |
|
1283 | |||
1278 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
1284 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
1279 | { |
|
1285 | { | |
1280 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
1286 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
1281 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1287 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1282 | { |
|
1288 | { | |
1283 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
1289 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
1284 | } |
|
1290 | } | |
1285 | else |
|
1291 | else | |
1286 | { |
|
1292 | { | |
1287 | status = RTEMS_SUCCESSFUL; |
|
1293 | status = RTEMS_SUCCESSFUL; | |
1288 | } |
|
1294 | } | |
1289 | } |
|
1295 | } | |
1290 |
|
1296 | |||
1291 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
1297 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
1292 | { |
|
1298 | { | |
1293 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
1299 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
1294 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1300 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1295 | { |
|
1301 | { | |
1296 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
1302 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
1297 | } |
|
1303 | } | |
1298 | else |
|
1304 | else | |
1299 | { |
|
1305 | { | |
1300 | status = RTEMS_SUCCESSFUL; |
|
1306 | status = RTEMS_SUCCESSFUL; | |
1301 | } |
|
1307 | } | |
1302 | } |
|
1308 | } | |
1303 |
|
1309 | |||
1304 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1310 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1305 | { |
|
1311 | { | |
1306 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1312 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1307 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1313 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1308 | { |
|
1314 | { | |
1309 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1315 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1310 | } |
|
1316 | } | |
1311 | else |
|
1317 | else | |
1312 | { |
|
1318 | { | |
1313 | status = RTEMS_SUCCESSFUL; |
|
1319 | status = RTEMS_SUCCESSFUL; | |
1314 | } |
|
1320 | } | |
1315 | } |
|
1321 | } | |
1316 |
|
1322 | |||
1317 | return status; |
|
1323 | return status; | |
1318 | } |
|
1324 | } | |
1319 |
|
1325 | |||
1320 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
1326 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) | |
1321 | { |
|
1327 | { | |
1322 |
|
1328 | |||
1323 | WFP_reset_current_ring_nodes(); |
|
1329 | WFP_reset_current_ring_nodes(); | |
1324 |
|
1330 | |||
1325 | reset_waveform_picker_regs(); |
|
1331 | reset_waveform_picker_regs(); | |
1326 |
|
1332 | |||
1327 | set_wfp_burst_enable_register( mode ); |
|
1333 | set_wfp_burst_enable_register( mode ); | |
1328 |
|
1334 | |||
1329 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1335 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
1330 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1336 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
1331 |
|
1337 | |||
1332 | if (transitionCoarseTime == 0) |
|
1338 | if (transitionCoarseTime == 0) | |
1333 | { |
|
1339 | { | |
1334 | // instant transition means transition on the next valid date |
|
1340 | // instant transition means transition on the next valid date | |
1335 | // this is mandatory to have a good snapshot period and a good correction of the snapshot period |
|
1341 | // this is mandatory to have a good snapshot period and a good correction of the snapshot period | |
1336 | waveform_picker_regs->start_date = time_management_regs->coarse_time + 1; |
|
1342 | waveform_picker_regs->start_date = time_management_regs->coarse_time + 1; | |
1337 | } |
|
1343 | } | |
1338 | else |
|
1344 | else | |
1339 | { |
|
1345 | { | |
1340 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
1346 | waveform_picker_regs->start_date = transitionCoarseTime; | |
1341 | } |
|
1347 | } | |
1342 |
|
1348 | |||
1343 | update_last_valid_transition_date(waveform_picker_regs->start_date); |
|
1349 | update_last_valid_transition_date(waveform_picker_regs->start_date); | |
1344 |
|
1350 | |||
1345 | } |
|
1351 | } | |
1346 |
|
1352 | |||
1347 | void launch_spectral_matrix( void ) |
|
1353 | void launch_spectral_matrix( void ) | |
1348 | { |
|
1354 | { | |
1349 | SM_reset_current_ring_nodes(); |
|
1355 | SM_reset_current_ring_nodes(); | |
1350 |
|
1356 | |||
1351 | reset_spectral_matrix_regs(); |
|
1357 | reset_spectral_matrix_regs(); | |
1352 |
|
1358 | |||
1353 | reset_nb_sm(); |
|
1359 | reset_nb_sm(); | |
1354 |
|
1360 | |||
1355 | set_sm_irq_onNewMatrix( 1 ); |
|
1361 | set_sm_irq_onNewMatrix( 1 ); | |
1356 |
|
1362 | |||
1357 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1363 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1358 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1364 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1359 |
|
1365 | |||
1360 | } |
|
1366 | } | |
1361 |
|
1367 | |||
1362 | void set_sm_irq_onNewMatrix( unsigned char value ) |
|
1368 | void set_sm_irq_onNewMatrix( unsigned char value ) | |
1363 | { |
|
1369 | { | |
1364 | if (value == 1) |
|
1370 | if (value == 1) | |
1365 | { |
|
1371 | { | |
1366 | spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_NEW_MATRIX; |
|
1372 | spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_NEW_MATRIX; | |
1367 | } |
|
1373 | } | |
1368 | else |
|
1374 | else | |
1369 | { |
|
1375 | { | |
1370 | spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_NEW_MATRIX; // 1110 |
|
1376 | spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_NEW_MATRIX; // 1110 | |
1371 | } |
|
1377 | } | |
1372 | } |
|
1378 | } | |
1373 |
|
1379 | |||
1374 | void set_sm_irq_onError( unsigned char value ) |
|
1380 | void set_sm_irq_onError( unsigned char value ) | |
1375 | { |
|
1381 | { | |
1376 | if (value == 1) |
|
1382 | if (value == 1) | |
1377 | { |
|
1383 | { | |
1378 | spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_ERROR; |
|
1384 | spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_ERROR; | |
1379 | } |
|
1385 | } | |
1380 | else |
|
1386 | else | |
1381 | { |
|
1387 | { | |
1382 | spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_ERROR; // 1101 |
|
1388 | spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_ERROR; // 1101 | |
1383 | } |
|
1389 | } | |
1384 | } |
|
1390 | } | |
1385 |
|
1391 | |||
1386 | //***************************** |
|
1392 | //***************************** | |
1387 | // CONFIGURE CALIBRATION SIGNAL |
|
1393 | // CONFIGURE CALIBRATION SIGNAL | |
1388 | void setCalibrationPrescaler( unsigned int prescaler ) |
|
1394 | void setCalibrationPrescaler( unsigned int prescaler ) | |
1389 | { |
|
1395 | { | |
1390 | // prescaling of the master clock (25 MHz) |
|
1396 | // prescaling of the master clock (25 MHz) | |
1391 | // master clock is divided by 2^prescaler |
|
1397 | // master clock is divided by 2^prescaler | |
1392 | time_management_regs->calPrescaler = prescaler; |
|
1398 | time_management_regs->calPrescaler = prescaler; | |
1393 | } |
|
1399 | } | |
1394 |
|
1400 | |||
1395 | void setCalibrationDivisor( unsigned int divisionFactor ) |
|
1401 | void setCalibrationDivisor( unsigned int divisionFactor ) | |
1396 | { |
|
1402 | { | |
1397 | // division of the prescaled clock by the division factor |
|
1403 | // division of the prescaled clock by the division factor | |
1398 | time_management_regs->calDivisor = divisionFactor; |
|
1404 | time_management_regs->calDivisor = divisionFactor; | |
1399 | } |
|
1405 | } | |
1400 |
|
1406 | |||
1401 | void setCalibrationData( void ) |
|
1407 | void setCalibrationData( void ) | |
1402 | { |
|
1408 | { | |
1403 | /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal |
|
1409 | /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal | |
1404 | * |
|
1410 | * | |
1405 | * @param void |
|
1411 | * @param void | |
1406 | * |
|
1412 | * | |
1407 | * @return void |
|
1413 | * @return void | |
1408 | * |
|
1414 | * | |
1409 | */ |
|
1415 | */ | |
1410 |
|
1416 | |||
1411 | unsigned int k; |
|
1417 | unsigned int k; | |
1412 | unsigned short data; |
|
1418 | unsigned short data; | |
1413 | float val; |
|
1419 | float val; | |
1414 | float Ts; |
|
1420 | float Ts; | |
1415 |
|
1421 | |||
1416 | time_management_regs->calDataPtr = INIT_CHAR; |
|
1422 | time_management_regs->calDataPtr = INIT_CHAR; | |
1417 |
|
1423 | |||
1418 | Ts = 1 / CAL_FS; |
|
1424 | Ts = 1 / CAL_FS; | |
1419 |
|
1425 | |||
1420 | // build the signal for the SCM calibration |
|
1426 | // build the signal for the SCM calibration | |
1421 | for (k = 0; k < CAL_NB_PTS; k++) |
|
1427 | for (k = 0; k < CAL_NB_PTS; k++) | |
1422 | { |
|
1428 | { | |
1423 | val = CAL_A0 * sin( CAL_W0 * k * Ts ) |
|
1429 | val = CAL_A0 * sin( CAL_W0 * k * Ts ) | |
1424 | + CAL_A1 * sin( CAL_W1 * k * Ts ); |
|
1430 | + CAL_A1 * sin( CAL_W1 * k * Ts ); | |
1425 | data = (unsigned short) ((val * CAL_SCALE_FACTOR) + CONST_2048); |
|
1431 | data = (unsigned short) ((val * CAL_SCALE_FACTOR) + CONST_2048); | |
1426 | time_management_regs->calData = data & CAL_DATA_MASK; |
|
1432 | time_management_regs->calData = data & CAL_DATA_MASK; | |
1427 | } |
|
1433 | } | |
1428 | } |
|
1434 | } | |
1429 |
|
1435 | |||
1430 | void setCalibrationDataInterleaved( void ) |
|
1436 | void setCalibrationDataInterleaved( void ) | |
1431 | { |
|
1437 | { | |
1432 | /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal |
|
1438 | /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal | |
1433 | * |
|
1439 | * | |
1434 | * @param void |
|
1440 | * @param void | |
1435 | * |
|
1441 | * | |
1436 | * @return void |
|
1442 | * @return void | |
1437 | * |
|
1443 | * | |
1438 | * In interleaved mode, one can store more values than in normal mode. |
|
1444 | * In interleaved mode, one can store more values than in normal mode. | |
1439 | * The data are stored in bunch of 18 bits, 12 bits from one sample and 6 bits from another sample. |
|
1445 | * The data are stored in bunch of 18 bits, 12 bits from one sample and 6 bits from another sample. | |
1440 | * T store 3 values, one need two write operations. |
|
1446 | * T store 3 values, one need two write operations. | |
1441 | * s1 [ b11 b10 b9 b8 b7 b6 ] s0 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ] |
|
1447 | * s1 [ b11 b10 b9 b8 b7 b6 ] s0 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ] | |
1442 | * s1 [ b5 b4 b3 b2 b1 b0 ] s2 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ] |
|
1448 | * s1 [ b5 b4 b3 b2 b1 b0 ] s2 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ] | |
1443 | * |
|
1449 | * | |
1444 | */ |
|
1450 | */ | |
1445 |
|
1451 | |||
1446 | unsigned int k; |
|
1452 | unsigned int k; | |
1447 | float val; |
|
1453 | float val; | |
1448 | float Ts; |
|
1454 | float Ts; | |
1449 | unsigned short data[CAL_NB_PTS_INTER]; |
|
1455 | unsigned short data[CAL_NB_PTS_INTER]; | |
1450 | unsigned char *dataPtr; |
|
1456 | unsigned char *dataPtr; | |
1451 |
|
1457 | |||
1452 | Ts = 1 / CAL_FS_INTER; |
|
1458 | Ts = 1 / CAL_FS_INTER; | |
1453 |
|
1459 | |||
1454 | time_management_regs->calDataPtr = INIT_CHAR; |
|
1460 | time_management_regs->calDataPtr = INIT_CHAR; | |
1455 |
|
1461 | |||
1456 | // build the signal for the SCM calibration |
|
1462 | // build the signal for the SCM calibration | |
1457 | for (k=0; k<CAL_NB_PTS_INTER; k++) |
|
1463 | for (k=0; k<CAL_NB_PTS_INTER; k++) | |
1458 | { |
|
1464 | { | |
1459 | val = sin( 2 * pi * CAL_F0 * k * Ts ) |
|
1465 | val = sin( 2 * pi * CAL_F0 * k * Ts ) | |
1460 | + sin( 2 * pi * CAL_F1 * k * Ts ); |
|
1466 | + sin( 2 * pi * CAL_F1 * k * Ts ); | |
1461 | data[k] = (unsigned short) ((val * CONST_512) + CONST_2048); |
|
1467 | data[k] = (unsigned short) ((val * CONST_512) + CONST_2048); | |
1462 | } |
|
1468 | } | |
1463 |
|
1469 | |||
1464 | // write the signal in interleaved mode |
|
1470 | // write the signal in interleaved mode | |
1465 | for (k=0; k < STEPS_FOR_STORAGE_INTER; k++) |
|
1471 | for (k=0; k < STEPS_FOR_STORAGE_INTER; k++) | |
1466 | { |
|
1472 | { | |
1467 | dataPtr = (unsigned char*) &data[ (k * BYTES_FOR_2_SAMPLES) + 2 ]; |
|
1473 | dataPtr = (unsigned char*) &data[ (k * BYTES_FOR_2_SAMPLES) + 2 ]; | |
1468 | time_management_regs->calData = ( data[ k * BYTES_FOR_2_SAMPLES ] & CAL_DATA_MASK ) |
|
1474 | time_management_regs->calData = ( data[ k * BYTES_FOR_2_SAMPLES ] & CAL_DATA_MASK ) | |
1469 | + ( (dataPtr[0] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER); |
|
1475 | + ( (dataPtr[0] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER); | |
1470 | time_management_regs->calData = ( data[(k * BYTES_FOR_2_SAMPLES) + 1] & CAL_DATA_MASK ) |
|
1476 | time_management_regs->calData = ( data[(k * BYTES_FOR_2_SAMPLES) + 1] & CAL_DATA_MASK ) | |
1471 | + ( (dataPtr[1] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER); |
|
1477 | + ( (dataPtr[1] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER); | |
1472 | } |
|
1478 | } | |
1473 | } |
|
1479 | } | |
1474 |
|
1480 | |||
1475 | void setCalibrationReload( bool state) |
|
1481 | void setCalibrationReload( bool state) | |
1476 | { |
|
1482 | { | |
1477 | if (state == true) |
|
1483 | if (state == true) | |
1478 | { |
|
1484 | { | |
1479 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_RELOAD; // [0001 0000] |
|
1485 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_RELOAD; // [0001 0000] | |
1480 | } |
|
1486 | } | |
1481 | else |
|
1487 | else | |
1482 | { |
|
1488 | { | |
1483 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_RELOAD; // [1110 1111] |
|
1489 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_RELOAD; // [1110 1111] | |
1484 | } |
|
1490 | } | |
1485 | } |
|
1491 | } | |
1486 |
|
1492 | |||
1487 | void setCalibrationEnable( bool state ) |
|
1493 | void setCalibrationEnable( bool state ) | |
1488 | { |
|
1494 | { | |
1489 | // this bit drives the multiplexer |
|
1495 | // this bit drives the multiplexer | |
1490 | if (state == true) |
|
1496 | if (state == true) | |
1491 | { |
|
1497 | { | |
1492 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_ENABLE; // [0100 0000] |
|
1498 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_ENABLE; // [0100 0000] | |
1493 | } |
|
1499 | } | |
1494 | else |
|
1500 | else | |
1495 | { |
|
1501 | { | |
1496 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_ENABLE; // [1011 1111] |
|
1502 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_ENABLE; // [1011 1111] | |
1497 | } |
|
1503 | } | |
1498 | } |
|
1504 | } | |
1499 |
|
1505 | |||
1500 | void setCalibrationInterleaved( bool state ) |
|
1506 | void setCalibrationInterleaved( bool state ) | |
1501 | { |
|
1507 | { | |
1502 | // this bit drives the multiplexer |
|
1508 | // this bit drives the multiplexer | |
1503 | if (state == true) |
|
1509 | if (state == true) | |
1504 | { |
|
1510 | { | |
1505 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_SET_INTERLEAVED; // [0010 0000] |
|
1511 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_SET_INTERLEAVED; // [0010 0000] | |
1506 | } |
|
1512 | } | |
1507 | else |
|
1513 | else | |
1508 | { |
|
1514 | { | |
1509 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_SET_INTERLEAVED; // [1101 1111] |
|
1515 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_SET_INTERLEAVED; // [1101 1111] | |
1510 | } |
|
1516 | } | |
1511 | } |
|
1517 | } | |
1512 |
|
1518 | |||
1513 | void setCalibration( bool state ) |
|
1519 | void setCalibration( bool state ) | |
1514 | { |
|
1520 | { | |
1515 | if (state == true) |
|
1521 | if (state == true) | |
1516 | { |
|
1522 | { | |
1517 | setCalibrationEnable( true ); |
|
1523 | setCalibrationEnable( true ); | |
1518 | setCalibrationReload( false ); |
|
1524 | setCalibrationReload( false ); | |
1519 | set_hk_lfr_calib_enable( true ); |
|
1525 | set_hk_lfr_calib_enable( true ); | |
1520 | } |
|
1526 | } | |
1521 | else |
|
1527 | else | |
1522 | { |
|
1528 | { | |
1523 | setCalibrationEnable( false ); |
|
1529 | setCalibrationEnable( false ); | |
1524 | setCalibrationReload( true ); |
|
1530 | setCalibrationReload( true ); | |
1525 | set_hk_lfr_calib_enable( false ); |
|
1531 | set_hk_lfr_calib_enable( false ); | |
1526 | } |
|
1532 | } | |
1527 | } |
|
1533 | } | |
1528 |
|
1534 | |||
1529 | void configureCalibration( bool interleaved ) |
|
1535 | void configureCalibration( bool interleaved ) | |
1530 | { |
|
1536 | { | |
1531 | setCalibration( false ); |
|
1537 | setCalibration( false ); | |
1532 | if ( interleaved == true ) |
|
1538 | if ( interleaved == true ) | |
1533 | { |
|
1539 | { | |
1534 | setCalibrationInterleaved( true ); |
|
1540 | setCalibrationInterleaved( true ); | |
1535 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1541 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1536 | setCalibrationDivisor( CAL_F_DIVISOR_INTER ); // => 240 384 |
|
1542 | setCalibrationDivisor( CAL_F_DIVISOR_INTER ); // => 240 384 | |
1537 | setCalibrationDataInterleaved(); |
|
1543 | setCalibrationDataInterleaved(); | |
1538 | } |
|
1544 | } | |
1539 | else |
|
1545 | else | |
1540 | { |
|
1546 | { | |
1541 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1547 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1542 | setCalibrationDivisor( CAL_F_DIVISOR ); // => 160 256 (39 - 1) |
|
1548 | setCalibrationDivisor( CAL_F_DIVISOR ); // => 160 256 (39 - 1) | |
1543 | setCalibrationData(); |
|
1549 | setCalibrationData(); | |
1544 | } |
|
1550 | } | |
1545 | } |
|
1551 | } | |
1546 |
|
1552 | |||
1547 | //**************** |
|
1553 | //**************** | |
1548 | // CLOSING ACTIONS |
|
1554 | // CLOSING ACTIONS | |
1549 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1555 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1550 | { |
|
1556 | { | |
1551 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
1557 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
1552 | * |
|
1558 | * | |
1553 | * @param TC points to the TC being processed |
|
1559 | * @param TC points to the TC being processed | |
1554 | * @param time is the time used to date the TC execution |
|
1560 | * @param time is the time used to date the TC execution | |
1555 | * |
|
1561 | * | |
1556 | */ |
|
1562 | */ | |
1557 |
|
1563 | |||
1558 | unsigned int val; |
|
1564 | unsigned int val; | |
1559 |
|
1565 | |||
1560 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1566 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
1561 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1567 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
1562 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = INIT_CHAR; |
|
1568 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = INIT_CHAR; | |
1563 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1569 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
1564 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = INIT_CHAR; |
|
1570 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = INIT_CHAR; | |
1565 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1571 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
1566 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_0] = time[BYTE_0]; |
|
1572 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_0] = time[BYTE_0]; | |
1567 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_1] = time[BYTE_1]; |
|
1573 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_1] = time[BYTE_1]; | |
1568 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_2] = time[BYTE_2]; |
|
1574 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_2] = time[BYTE_2]; | |
1569 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_3] = time[BYTE_3]; |
|
1575 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_3] = time[BYTE_3]; | |
1570 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_4] = time[BYTE_4]; |
|
1576 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_4] = time[BYTE_4]; | |
1571 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_5] = time[BYTE_5]; |
|
1577 | housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_5] = time[BYTE_5]; | |
1572 |
|
1578 | |||
1573 | val = (housekeeping_packet.hk_lfr_exe_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
1579 | val = (housekeeping_packet.hk_lfr_exe_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
1574 | val++; |
|
1580 | val++; | |
1575 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); |
|
1581 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); | |
1576 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
1582 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
1577 | } |
|
1583 | } | |
1578 |
|
1584 | |||
1579 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1585 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1580 | { |
|
1586 | { | |
1581 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
1587 | /** This function is used to update the HK packets statistics after a TC rejection. | |
1582 | * |
|
1588 | * | |
1583 | * @param TC points to the TC being processed |
|
1589 | * @param TC points to the TC being processed | |
1584 | * @param time is the time used to date the TC rejection |
|
1590 | * @param time is the time used to date the TC rejection | |
1585 | * |
|
1591 | * | |
1586 | */ |
|
1592 | */ | |
1587 |
|
1593 | |||
1588 | unsigned int val; |
|
1594 | unsigned int val; | |
1589 |
|
1595 | |||
1590 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1596 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
1591 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1597 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
1592 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = INIT_CHAR; |
|
1598 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = INIT_CHAR; | |
1593 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1599 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
1594 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = INIT_CHAR; |
|
1600 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = INIT_CHAR; | |
1595 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1601 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
1596 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_0] = time[BYTE_0]; |
|
1602 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_0] = time[BYTE_0]; | |
1597 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_1] = time[BYTE_1]; |
|
1603 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_1] = time[BYTE_1]; | |
1598 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_2] = time[BYTE_2]; |
|
1604 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_2] = time[BYTE_2]; | |
1599 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_3] = time[BYTE_3]; |
|
1605 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_3] = time[BYTE_3]; | |
1600 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_4] = time[BYTE_4]; |
|
1606 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_4] = time[BYTE_4]; | |
1601 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_5] = time[BYTE_5]; |
|
1607 | housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_5] = time[BYTE_5]; | |
1602 |
|
1608 | |||
1603 | val = (housekeeping_packet.hk_lfr_rej_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
1609 | val = (housekeeping_packet.hk_lfr_rej_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
1604 | val++; |
|
1610 | val++; | |
1605 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); |
|
1611 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE); | |
1606 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
1612 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
1607 | } |
|
1613 | } | |
1608 |
|
1614 | |||
1609 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
1615 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) | |
1610 | { |
|
1616 | { | |
1611 | /** This function is the last step of the TC execution workflow. |
|
1617 | /** This function is the last step of the TC execution workflow. | |
1612 | * |
|
1618 | * | |
1613 | * @param TC points to the TC being processed |
|
1619 | * @param TC points to the TC being processed | |
1614 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
1620 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
1615 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
1621 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
1616 | * @param time is the time used to date the TC execution |
|
1622 | * @param time is the time used to date the TC execution | |
1617 | * |
|
1623 | * | |
1618 | */ |
|
1624 | */ | |
1619 |
|
1625 | |||
1620 | unsigned char requestedMode; |
|
1626 | unsigned char requestedMode; | |
1621 |
|
1627 | |||
1622 | if (result == LFR_SUCCESSFUL) |
|
1628 | if (result == LFR_SUCCESSFUL) | |
1623 | { |
|
1629 | { | |
1624 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
1630 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
1625 | & |
|
1631 | & | |
1626 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
1632 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
1627 | ) |
|
1633 | ) | |
1628 | { |
|
1634 | { | |
1629 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1635 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
1630 | } |
|
1636 | } | |
1631 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
1637 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) | |
1632 | { |
|
1638 | { | |
1633 | //********************************** |
|
1639 | //********************************** | |
1634 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
1640 | // UPDATE THE LFRMODE LOCAL VARIABLE | |
1635 | requestedMode = TC->dataAndCRC[1]; |
|
1641 | requestedMode = TC->dataAndCRC[1]; | |
1636 | updateLFRCurrentMode( requestedMode ); |
|
1642 | updateLFRCurrentMode( requestedMode ); | |
1637 | } |
|
1643 | } | |
1638 | } |
|
1644 | } | |
1639 | else if (result == LFR_EXE_ERROR) |
|
1645 | else if (result == LFR_EXE_ERROR) | |
1640 | { |
|
1646 | { | |
1641 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
1647 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
1642 | } |
|
1648 | } | |
1643 | } |
|
1649 | } | |
1644 |
|
1650 | |||
1645 | //*************************** |
|
1651 | //*************************** | |
1646 | // Interrupt Service Routines |
|
1652 | // Interrupt Service Routines | |
1647 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1653 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
1648 | { |
|
1654 | { | |
1649 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1655 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1650 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") |
|
1656 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") | |
1651 | } |
|
1657 | } | |
1652 | } |
|
1658 | } | |
1653 |
|
1659 | |||
1654 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1660 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
1655 | { |
|
1661 | { | |
1656 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1662 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1657 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") |
|
1663 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") | |
1658 | } |
|
1664 | } | |
1659 | } |
|
1665 | } | |
1660 |
|
1666 | |||
1661 | //**************** |
|
1667 | //**************** | |
1662 | // OTHER FUNCTIONS |
|
1668 | // OTHER FUNCTIONS | |
1663 | void updateLFRCurrentMode( unsigned char requestedMode ) |
|
1669 | void updateLFRCurrentMode( unsigned char requestedMode ) | |
1664 | { |
|
1670 | { | |
1665 | /** This function updates the value of the global variable lfrCurrentMode. |
|
1671 | /** This function updates the value of the global variable lfrCurrentMode. | |
1666 | * |
|
1672 | * | |
1667 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
1673 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
1668 | * |
|
1674 | * | |
1669 | */ |
|
1675 | */ | |
1670 |
|
1676 | |||
1671 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
1677 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
1672 | housekeeping_packet.lfr_status_word[0] = (housekeeping_packet.lfr_status_word[0] & STATUS_WORD_LFR_MODE_MASK) |
|
1678 | housekeeping_packet.lfr_status_word[0] = (housekeeping_packet.lfr_status_word[0] & STATUS_WORD_LFR_MODE_MASK) | |
1673 | + (unsigned char) ( requestedMode << STATUS_WORD_LFR_MODE_SHIFT ); |
|
1679 | + (unsigned char) ( requestedMode << STATUS_WORD_LFR_MODE_SHIFT ); | |
1674 | lfrCurrentMode = requestedMode; |
|
1680 | lfrCurrentMode = requestedMode; | |
1675 | } |
|
1681 | } | |
1676 |
|
1682 | |||
1677 | void set_lfr_soft_reset( unsigned char value ) |
|
1683 | void set_lfr_soft_reset( unsigned char value ) | |
1678 | { |
|
1684 | { | |
1679 | if (value == 1) |
|
1685 | if (value == 1) | |
1680 | { |
|
1686 | { | |
1681 | time_management_regs->ctrl = time_management_regs->ctrl | BIT_SOFT_RESET; // [0100] |
|
1687 | time_management_regs->ctrl = time_management_regs->ctrl | BIT_SOFT_RESET; // [0100] | |
1682 | } |
|
1688 | } | |
1683 | else |
|
1689 | else | |
1684 | { |
|
1690 | { | |
1685 | time_management_regs->ctrl = time_management_regs->ctrl & MASK_SOFT_RESET; // [1011] |
|
1691 | time_management_regs->ctrl = time_management_regs->ctrl & MASK_SOFT_RESET; // [1011] | |
1686 | } |
|
1692 | } | |
1687 | } |
|
1693 | } | |
1688 |
|
1694 | |||
1689 | void reset_lfr( void ) |
|
1695 | void reset_lfr( void ) | |
1690 | { |
|
1696 | { | |
1691 | set_lfr_soft_reset( 1 ); |
|
1697 | set_lfr_soft_reset( 1 ); | |
1692 |
|
1698 | |||
1693 | set_lfr_soft_reset( 0 ); |
|
1699 | set_lfr_soft_reset( 0 ); | |
1694 |
|
1700 | |||
1695 | set_hk_lfr_sc_potential_flag( true ); |
|
1701 | set_hk_lfr_sc_potential_flag( true ); | |
1696 | } |
|
1702 | } |
General Comments 0
You need to be logged in to leave comments.
Login now