foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
ftask_cfg.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2023, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file ftask_cfg.h
44  * @author foxBMS Team
45  * @date 2019-08-26 (date of creation)
46  * @updated 2023-10-12 (date of last update)
47  * @version v1.6.0
48  * @ingroup TASK_CONFIGURATION
49  * @prefix FTSK
50  *
51  * @brief Task configuration header
52  * @details TODO
53  */
54 
55 #ifndef FOXBMS__FTASK_CFG_H_
56 #define FOXBMS__FTASK_CFG_H_
57 
58 /*========== Includes =======================================================*/
59 
60 #include "os.h"
61 
62 #include <stdint.h>
63 
64 /*========== Macros and Definitions =========================================*/
65 /** @brief Stack size of engine task */
66 #define FTSK_TASK_ENGINE_STACK_SIZE_IN_BYTES (1024u)
67 
68 /** @brief Phase of engine task */
69 #define FTSK_TASK_ENGINE_PRIORITY (OS_PRIORITY_REAL_TIME)
70 
71 /** @brief Phase of engine task */
72 #define FTSK_TASK_ENGINE_PHASE (0u)
73 
74 /** @brief Cycle time of engine task */
75 #define FTSK_TASK_ENGINE_CYCLE_TIME (1u)
76 
77 /** @brief Maximum allowed jitter of engine task */
78 #define FTSK_TASK_ENGINE_MAXIMUM_JITTER (1u)
79 
80 /** @brief pvParameters of the engine task */
81 #define FTSK_TASK_ENGINE_PV_PARAMETERS (NULL_PTR)
82 
83 /** @brief Stack size of cyclic 1 ms task */
84 #define FTSK_TASK_CYCLIC_1MS_STACK_SIZE_IN_BYTES (1024u)
85 
86 /** @brief Priority of cyclic 1ms task */
87 #define FTSK_TASK_CYCLIC_1MS_PRIORITY (OS_PRIORITY_VERY_HIGH)
88 
89 /** @brief Phase of cyclic 1ms task */
90 #define FTSK_TASK_CYCLIC_1MS_PHASE (0u)
91 
92 /** @brief Cycle time of 1ms task */
93 #define FTSK_TASK_CYCLIC_1MS_CYCLE_TIME (1u)
94 
95 /** @brief Maximum allowed jitter of 1ms task */
96 #define FTSK_TASK_CYCLIC_1MS_MAXIMUM_JITTER (1u)
97 
98 /** @brief pvParameters of the 1ms task */
99 #define FTSK_TASK_CYCLIC_1MS_PV_PARAMETERS (NULL_PTR)
100 
101 /** @brief Stack size of cyclic 10 ms task */
102 #define FTSK_TASK_CYCLIC_10MS_STACK_SIZE_IN_BYTES (5120u)
103 
104 /** @brief Priority of cyclic 10 ms task */
105 #define FTSK_TASK_CYCLIC_10MS_PRIORITY (OS_PRIORITY_HIGH)
106 
107 /** @brief Phase of cyclic 10 ms task */
108 #define FTSK_TASK_CYCLIC_10MS_PHASE (2u)
109 
110 /** @brief Cycle time of 10 ms task */
111 #define FTSK_TASK_CYCLIC_10MS_CYCLE_TIME (10u)
112 
113 /** @brief Maximum allowed jitter of 10ms task */
114 #define FTSK_TASK_CYCLIC_10MS_MAXIMUM_JITTER (2u)
115 
116 /** @brief pvParameters of the 10ms task */
117 #define FTSK_TASK_CYCLIC_10MS_PV_PARAMETERS (NULL_PTR)
118 
119 /** @brief Stack size of cyclic 100 ms task */
120 #define FTSK_TASK_CYCLIC_100MS_STACK_SIZE_IN_BYTES (1024u)
121 
122 /** @brief Priority of cyclic 100 ms task */
123 #define FTSK_TASK_CYCLIC_100MS_PRIORITY (OS_PRIORITY_ABOVE_NORMAL)
124 
125 /** @brief Phase of cyclic 100 ms task */
126 #define FTSK_TASK_CYCLIC_100MS_PHASE (56u)
127 
128 /** @brief Cycle time of 100ms task */
129 #define FTSK_TASK_CYCLIC_100MS_CYCLE_TIME (100u)
130 
131 /** @brief Maximum allowed jitter of 100ms task */
132 #define FTSK_TASK_CYCLIC_100MS_MAXIMUM_JITTER (5u)
133 
134 /** @brief pvParameters of the 100ms task */
135 #define FTSK_TASK_CYCLIC_100MS_PV_PARAMETERS (NULL_PTR)
136 
137 /** @brief Stack size of cyclic 100 ms task for algorithms */
138 #define FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACK_SIZE_IN_BYTES (1024u)
139 
140 /** @brief Priority of cyclic 100 ms task for algorithms */
141 #define FTSK_TASK_CYCLIC_ALGORITHM_100MS_PRIORITY (OS_PRIORITY_NORMAL)
142 
143 /** @brief Phase of cyclic 100 ms task for algorithms */
144 #define FTSK_TASK_CYCLIC_ALGORITHM_100MS_PHASE (64u)
145 
146 /** @brief Cycle time of 100ms task for algorithms*/
147 #define FTSK_TASK_CYCLIC_ALGORITHM_100MS_CYCLE_TIME (100u)
148 
149 /** @brief Maximum allowed jitter of 100ms task for algorithms */
150 #define FTSK_TASK_CYCLIC_ALGORITHM_100MS_MAXIMUM_JITTER (5u)
151 
152 /** @brief pvParameters of the 100ms task for algorithms */
153 #define FTSK_TASK_CYCLIC_ALGORITHM_100MS_PV_PARAMETERS (NULL_PTR)
154 
155 /** @brief Stack size of continuously running task for I2C */
156 #define FTSK_TASK_I2C_STACK_SIZE_IN_BYTES (2048u)
157 
158 /** @brief Priority of continuously running task for I2C */
159 #define FTSK_TASK_I2C_PRIORITY (FTSK_TASK_CYCLIC_10MS_PRIORITY)
160 
161 /** @brief Phase of continuously running task for I2C */
162 #define FTSK_TASK_I2C_PHASE (0u)
163 
164 /** @brief Cycle time of continuously running task for I2C */
165 #define FTSK_TASK_I2C_CYCLE_TIME (0u)
166 
167 /** @brief pvParameters of the continuously running task for I2C */
168 #define FTSK_TASK_I2C_PV_PARAMETERS (NULL_PTR)
169 
170 /** @brief Stack size of continuously running task for AFEs */
171 #define FTSK_TASK_AFE_STACK_SIZE_IN_BYTES (4096u)
172 
173 /** @brief Priority of continuously running task for AFEs */
174 #define FTSK_TASK_AFE_PRIORITY (OS_PRIORITY_ABOVE_HIGH)
175 
176 /** @brief Phase of continuously running task for AFEs */
177 #define FTSK_TASK_AFE_PHASE (0u)
178 
179 /** @brief Cycle time of continuously running task for AFEs */
180 #define FTSK_TASK_AFE_CYCLE_TIME (0u)
181 
182 /** @brief pvParameters of the continuously running task for AFEs */
183 #define FTSK_TASK_AFE_PV_PARAMETERS (NULL_PTR)
184 
185 /*========== Extern Constant and Variable Declarations ======================*/
186 /**
187  * @brief Task configuration of the engine task
188  * @details Task for database and system monitoring
189  */
191 
192 /**
193  * @brief Task configuration of the cyclic 1 ms task
194  * @details Cyclic 1 ms task
195  */
197 
198 /**
199  * @brief Task configuration of the cyclic 10 ms task
200  * @details Cyclic 10 ms task
201  */
203 
204 /**
205  * @brief Task configuration of the cyclic 100 ms task
206  * @details Cyclic 100 ms task
207  */
209 
210 /**
211  * @brief Task configuration of the cyclic 100 ms task for algorithms
212  * @details Cyclic 100 ms task for algorithms
213  */
215 
216 /**
217  * @brief Task configuration of the continuously running task for MCU I2C communication
218  * @details Continuously running task for MCU I2C communication
219  */
221 
222 /**
223  * @brief Task configuration of the continuously running task for AFEs
224  * @details Continuously running task for AFEs
225  */
227 
228 /**
229  * @brief Definition of task handles
230  */
231 extern TaskHandle_t ftsk_taskHandleI2c;
232 
233 /**
234  * @brief Definition of task handles
235  */
236 extern OS_TASK_HANDLE ftsk_taskHandleAfe;
237 
238 /*========== Extern Function Prototypes =====================================*/
239 /**
240  * @brief Initializes the database
241  * @details Start up after scheduler starts
242  * @warning Do not change the content of this function. This will very likely
243  * break the system. This function is kept in the configuration file
244  * to have a uniform task configuration.
245  */
246 extern void FTSK_InitializeUserCodeEngine(void);
247 
248 /**
249  * @brief Engine task for the database and the system monitoring module
250  * @details Start up after scheduler start. First task to be run, all other
251  * tasks only starts when this task has started
252  * @warning Do not change the content of this function. This will very likely
253  * break the system. This function is kept in the configuration file
254  * to have a uniform task configuration.
255  */
256 extern void FTSK_RunUserCodeEngine(void);
257 
258 /**
259  * @brief Initialization function before all tasks started
260  * @details This function is called after the scheduler started but before any
261  * cyclic task runs. Here modules get initialized that are not used
262  * during the startup process.
263  */
264 extern void FTSK_InitializeUserCodePreCyclicTasks(void);
265 
266 /**
267  * @brief Cyclic 1 ms task
268  * @details TODO
269  */
270 extern void FTSK_RunUserCodeCyclic1ms(void);
271 
272 /**
273  * @brief Cyclic 10 ms task
274  * @details TODO
275  */
276 extern void FTSK_RunUserCodeCyclic10ms(void);
277 
278 /**
279  * @brief Cyclic 100 ms task
280  * @details TODO
281  */
282 extern void FTSK_RunUserCodeCyclic100ms(void);
283 
284 /**
285  * @brief Cyclic 100 ms task for algorithms
286  * @details TODO
287  */
288 extern void FTSK_RunUserCodeCyclicAlgorithm100ms(void);
289 
290 /**
291  * @brief Continuously running task for I2C
292  * @details Implements the MCU communication over I2C
293  */
294 extern void FTSK_RunUserCodeI2c(void);
295 
296 /**
297  * @brief Continuously running task for AFEs
298  * @details Implements the communications with AFEs without state machine.
299  */
300 extern void FTSK_RunUserCodeAfe(void);
301 
302 /**
303  * @brief Idle task
304  * @details Called by #vApplicationIdleHook() if configUSE_IDLE_HOOK in
305  * FreeRTOSConfig.h is enabled. If you do not need this hook, you can
306  * disable it in the FreeRTOS configuration.
307  */
308 extern void FTSK_RunUserCodeIdle(void);
309 
310 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
311 #ifdef UNITY_UNIT_TEST
312 #endif
313 
314 #endif /* FOXBMS__FTASK_CFG_H_ */
OS_TASK_DEFINITION_s ftsk_taskDefinitionAfe
Task configuration of the continuously running task for AFEs.
Definition: ftask_cfg.c:145
OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic100ms
Task configuration of the cyclic 100 ms task.
Definition: ftask_cfg.c:127
void FTSK_RunUserCodeAfe(void)
Continuously running task for AFEs.
Definition: ftask_cfg.c:301
void FTSK_InitializeUserCodeEngine(void)
Initializes the database.
Definition: ftask_cfg.c:157
TaskHandle_t ftsk_taskHandleI2c
Definition of task handles.
void FTSK_RunUserCodeEngine(void)
Engine task for the database and the system monitoring module.
Definition: ftask_cfg.c:184
OS_TASK_DEFINITION_s ftsk_taskDefinitionEngine
Task configuration of the engine task.
Definition: ftask_cfg.c:109
OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic1ms
Task configuration of the cyclic 1 ms task.
Definition: ftask_cfg.c:115
void FTSK_RunUserCodeIdle(void)
Idle task.
Definition: ftask_cfg.c:308
OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclicAlgorithm100ms
Task configuration of the cyclic 100 ms task for algorithms.
Definition: ftask_cfg.c:133
void FTSK_RunUserCodeCyclic100ms(void)
Cyclic 100 ms task.
Definition: ftask_cfg.c:263
void FTSK_RunUserCodeI2c(void)
Continuously running task for I2C.
Definition: ftask_cfg.c:292
void FTSK_InitializeUserCodePreCyclicTasks(void)
Initialization function before all tasks started.
Definition: ftask_cfg.c:193
void FTSK_RunUserCodeCyclic10ms(void)
Cyclic 10 ms task.
Definition: ftask_cfg.c:237
OS_TASK_DEFINITION_s ftsk_taskDefinitionI2c
Task configuration of the continuously running task for MCU I2C communication.
Definition: ftask_cfg.c:139
OS_TASK_HANDLE ftsk_taskHandleAfe
Definition of task handles.
void FTSK_RunUserCodeCyclic1ms(void)
Cyclic 1 ms task.
Definition: ftask_cfg.c:225
OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic10ms
Task configuration of the cyclic 10 ms task.
Definition: ftask_cfg.c:121
void FTSK_RunUserCodeCyclicAlgorithm100ms(void)
Cyclic 100 ms task for algorithms.
Definition: ftask_cfg.c:283
Declaration of the OS wrapper interface.
struct for FreeRTOS task definition
Definition: os.h:135