foxBMS - Unit Tests  1.3.0
The foxBMS Unit Tests API Documentation
ftask.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2022, 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.c
44  * @author foxBMS Team
45  * @date 2019-08-27 (date of creation)
46  * @updated 2022-05-30 (date of last update)
47  * @version v1.3.0
48  * @ingroup TASK
49  * @prefix FTSK
50  *
51  * @brief Implementation of OS-independent task creators
52  * @details TODO
53  */
54 
55 /*========== Includes =======================================================*/
56 #include "ftask.h"
57 
58 #include "sys_mon.h"
59 
60 /*========== Macros and Definitions =========================================*/
61 
62 /*========== Static Constant and Variable Definitions =======================*/
63 
64 /*========== Extern Constant and Variable Definitions =======================*/
65 
66 /*========== Static Function Prototypes =====================================*/
67 
68 /*========== Static Function Implementations ================================*/
69 
70 /*========== Extern Function Implementations ================================*/
71 /* AXIVION Next Line Style MisraC2012Directive-1.1 MisraC2012-1.2 FaultDetection-DeadBranches: tell the CCS compiler
72  * that this function is a task, context save not necessary */
73 #pragma TASK(FTSK_CreateTaskEngine)
74 extern void FTSK_CreateTaskEngine(void *const pvParameters) {
75  FAS_ASSERT(pvParameters == NULL_PTR);
80 
81  /* AXIVION Next Line Style MisraC2012-2.2 FaultDetection-DeadBranches: FreeRTOS task setup requires an infinite
82  * loop for the user code (see www.freertos.org/a00125.html)*/
83  while (true) {
84  /* notify system monitoring that task will be called */
86  /* user code implemention */
88  /* notify system monitoring that task has been called */
90  }
91 }
92 
93 /* AXIVION Next Line Style MisraC2012Directive-1.1 MisraC2012-1.2 FaultDetection-DeadBranches: tell the CCS compiler
94  * that this function is a task, context save not necessary */
95 #pragma TASK(FTSK_CreateTaskCyclic1ms)
96 extern void FTSK_CreateTaskCyclic1ms(void *const pvParameters) {
97  FAS_ASSERT(pvParameters == NULL_PTR);
99  uint32_t currentTimeCreateTaskCyclic1ms = 0;
100 
101  while (os_boot != OS_ENGINE_RUNNING) {
102  }
103 
106 
107  /* cycle time (1ms) equals the minimum tick time (1ms),
108  * therefore it is not possible to configure a phase for this task */
109  currentTimeCreateTaskCyclic1ms = OS_GetTickCount();
110  /* AXIVION Next Line Style MisraC2012-2.2 FaultDetection-DeadBranches: FreeRTOS task setup requires an infinite
111  * loop for the user code (see www.freertos.org/a00125.html)*/
112  while (true) {
113  /* notify system monitoring that task will be called */
115  /* user code implementation */
117  /* notify system monitoring that task has been called */
119  /* let task sleep until it is due again */
120  OS_DelayTaskUntil(&currentTimeCreateTaskCyclic1ms, ftsk_taskDefinitionCyclic1ms.cycleTime);
121  }
122 }
123 
124 /* AXIVION Next Line Style MisraC2012Directive-1.1 MisraC2012-1.2 FaultDetection-DeadBranches: tell the CCS compiler
125  * that this function is a task, context save not necessary */
126 #pragma TASK(FTSK_CreateTaskCyclic10ms)
127 extern void FTSK_CreateTaskCyclic10ms(void *const pvParameters) {
128  FAS_ASSERT(pvParameters == NULL_PTR);
130  uint32_t currentTimeCreateTaskCyclic10ms = 0;
131 
133  }
134 
136  currentTimeCreateTaskCyclic10ms = OS_GetTickCount();
137  /* AXIVION Next Line Style MisraC2012-2.2 FaultDetection-DeadBranches: FreeRTOS task setup requires an infinite
138  * loop for the user code (see www.freertos.org/a00125.html)*/
139  while (true) {
140  /* notify system monitoring that task will be called */
142  /* user code implementation */
144  /* notify system monitoring that task has been called */
146  /* let task sleep until it is due again */
147  OS_DelayTaskUntil(&currentTimeCreateTaskCyclic10ms, ftsk_taskDefinitionCyclic10ms.cycleTime);
148  }
149 }
150 
151 /* AXIVION Next Line Style MisraC2012Directive-1.1 MisraC2012-1.2 FaultDetection-DeadBranches: tell the CCS compiler
152  * that this function is a task, context save not necessary */
153 #pragma TASK(FTSK_CreateTaskCyclic100ms)
154 extern void FTSK_CreateTaskCyclic100ms(void *const pvParameters) {
155  FAS_ASSERT(pvParameters == NULL_PTR);
157  uint32_t currentTimeCreateTaskCyclic100ms = 0;
158 
160  }
161 
163  currentTimeCreateTaskCyclic100ms = OS_GetTickCount();
164  /* AXIVION Next Line Style MisraC2012-2.2 FaultDetection-DeadBranches: FreeRTOS task setup requires an infinite
165  * loop for the user code (see www.freertos.org/a00125.html)*/
166  while (true) {
167  /* notify system monitoring that task will be called */
169  /* user code implementation */
171  /* notify system monitoring that task has been called */
173  /* let task sleep until it is due again */
174  OS_DelayTaskUntil(&currentTimeCreateTaskCyclic100ms, ftsk_taskDefinitionCyclic100ms.cycleTime);
175  }
176 }
177 
178 /* AXIVION Next Line Style MisraC2012Directive-1.1 MisraC2012-1.2 FaultDetection-DeadBranches: tell the CCS compiler
179  * that this function is a task, context save not necessary */
180 #pragma TASK(FTSK_CreateTaskCyclicAlgorithm100ms)
181 extern void FTSK_CreateTaskCyclicAlgorithm100ms(void *const pvParameters) {
182  FAS_ASSERT(pvParameters == NULL_PTR);
184  uint32_t currentTimeCreateTaskCyclicAlgorithms100ms = 0;
185 
187  }
188 
191  currentTimeCreateTaskCyclicAlgorithms100ms = OS_GetTickCount();
192  /* AXIVION Next Line Style MisraC2012-2.2 FaultDetection-DeadBranches: FreeRTOS task setup requires an infinite
193  * loop for the user code (see www.freertos.org/a00125.html)*/
194  while (true) {
195  /* notify system monitoring that task will be called */
197  /* user code implementation */
199  /* notify system monitoring that task has been called */
201  /* let task sleep until it is due again */
203  &currentTimeCreateTaskCyclicAlgorithms100ms, ftsk_taskDefinitionCyclicAlgorithm100ms.cycleTime);
204  }
205 }
206 
207 /* AXIVION Next Line Style MisraC2012Directive-1.1 MisraC2012-1.2 FaultDetection-DeadBranches: tell the CCS compiler
208  * tell compiler this function is a task, context save not necessary */
209 #pragma TASK(FTSK_CreateTaskAfe)
210 extern void FTSK_CreateTaskAfe(void *const pvParameters) {
211  FAS_ASSERT(pvParameters == NULL_PTR);
213 
215  }
216 
217  /* AXIVION Next Line Style MisraC2012-2.2 FaultDetection-DeadBranches: FreeRTOS task setup requires an infinite
218  * loop for the user code (see www.freertos.org/a00125.html)*/
219  while (true) {
220  /* user code implementation */
222  }
223 }
224 
225 /*========== Externalized Static Function Implementations (Unit Test) =======*/
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:237
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:76
void FTSK_CreateTaskEngine(void *const pvParameters)
Database-Task.
Definition: ftask.c:74
void FTSK_CreateTaskCyclicAlgorithm100ms(void *const pvParameters)
Creation of cyclic 100 ms algorithm task.
Definition: ftask.c:181
void FTSK_CreateTaskCyclic100ms(void *const pvParameters)
Creation of cyclic 100 ms task.
Definition: ftask.c:154
void FTSK_CreateTaskCyclic10ms(void *const pvParameters)
Creation of cyclic 10 ms task.
Definition: ftask.c:127
void FTSK_CreateTaskAfe(void *const pvParameters)
Creation of continuously running task for AFEs.
Definition: ftask.c:210
void FTSK_CreateTaskCyclic1ms(void *const pvParameters)
Creation of cyclic 1 ms task.
Definition: ftask.c:96
Header of task driver implementation.
OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic100ms
Task configuration of the cyclic 100 ms task.
Definition: ftask_cfg.c:124
void FTSK_RunUserCodeAfe(void)
Continuously running task for AFEs.
Definition: ftask_cfg.c:278
void FTSK_InitializeUserCodeEngine(void)
Initializes the database.
Definition: ftask_cfg.c:148
void FTSK_RunUserCodeEngine(void)
Engine task for the database and the system monitoring module.
Definition: ftask_cfg.c:175
OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic1ms
Task configuration of the cyclic 1 ms task.
Definition: ftask_cfg.c:112
OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclicAlgorithm100ms
Task configuration of the cyclic 100 ms task for algorithms.
Definition: ftask_cfg.c:130
void FTSK_RunUserCodeCyclic100ms(void)
Cyclic 100 ms task.
Definition: ftask_cfg.c:249
void FTSK_InitializeUserCodePreCyclicTasks(void)
Initialization function before all tasks started.
Definition: ftask_cfg.c:184
void FTSK_RunUserCodeCyclic10ms(void)
Cyclic 10 ms task.
Definition: ftask_cfg.c:226
void FTSK_RunUserCodeCyclic1ms(void)
Cyclic 1 ms task.
Definition: ftask_cfg.c:216
OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic10ms
Task configuration of the cyclic 10 ms task.
Definition: ftask_cfg.c:118
void FTSK_RunUserCodeCyclicAlgorithm100ms(void)
Cyclic 100 ms task for algorithms.
Definition: ftask_cfg.c:269
uint32_t os_schedulerStartTime
Scheduler "zero" time for task phase control.
Definition: os.c:71
volatile OS_BOOT_STATE_e os_boot
Definition: os.c:69
@ OS_PRECYCLIC_INIT_HAS_FINISHED
Definition: os.h:108
@ OS_SCHEDULER_RUNNING
Definition: os.h:106
@ OS_ENGINE_RUNNING
Definition: os.h:107
@ OS_SYSTEM_RUNNING
Definition: os.h:109
void OS_DelayTaskUntil(uint32_t *pPreviousWakeTime, uint32_t milliseconds)
Delay a task until a specified time.
Definition: os_freertos.c:143
void OS_MarkTaskAsRequiringFpuContext(void)
Marks the current task as requiring FPU context.
Definition: os_freertos.c:153
uint32_t OS_GetTickCount(void)
Returns OS based system tick value.
Definition: os_freertos.c:139
uint32_t cycleTime
Definition: os.h:130
uint32_t phase
Definition: os.h:129
void SYSM_Notify(SYSM_TASK_ID_e taskId, SYSM_NOTIFY_TYPE_e state, uint32_t timestamp)
Sets needed bits to indicate that a task is running.
Definition: sys_mon.c:183
system monitoring module
@ SYSM_NOTIFY_ENTER
Definition: sys_mon.h:65
@ SYSM_NOTIFY_EXIT
Definition: sys_mon.h:66
@ SYSM_TASK_ID_CYCLIC_10ms
Definition: sys_mon_cfg.h:76
@ SYSM_TASK_ID_CYCLIC_ALGORITHM_100ms
Definition: sys_mon_cfg.h:78
@ SYSM_TASK_ID_CYCLIC_100ms
Definition: sys_mon_cfg.h:77
@ SYSM_TASK_ID_CYCLIC_1ms
Definition: sys_mon_cfg.h:75
@ SYSM_TASK_ID_ENGINE
Definition: sys_mon_cfg.h:74