foxBMS - Unit Tests  1.4.0
The foxBMS Unit Tests API Documentation
ftask.h
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.h
44  * @author foxBMS Team
45  * @date 2019-08-27 (date of creation)
46  * @updated 2022-07-28 (date of last update)
47  * @version v1.4.0
48  * @ingroup TASK
49  * @prefix FTSK
50  *
51  * @brief Header of task driver implementation
52  * @details Declars the functions that are need to needed to initialize the
53  * operating system. This includes ques, mutexes, events and tasks.
54  */
55 
56 #ifndef FOXBMS__FTASK_H_
57 #define FOXBMS__FTASK_H_
58 
59 /*========== Includes =======================================================*/
60 #include "ftask_cfg.h"
61 
62 #include "os.h"
63 
64 /*========== Macros and Definitions =========================================*/
65 /** Length of queue that is used in the database */
66 #define FTSK_DATABASE_QUEUE_LENGTH (1u)
67 
68 /** Size of queue item that is used in the database */
69 #define FTSK_DATABASE_QUEUE_ITEM_SIZE_IN_BYTES (sizeof(DATA_QUEUE_MESSAGE_s))
70 
71 /** Length of queue that is used in the insulation measurement device (IMD) */
72 #define FTSK_IMD_QUEUE_LENGTH (5u)
73 /** Size of queue item that is used in the IMD driver */
74 #define FTSK_IMD_QUEUE_ITEM_SIZE_IN_BYTES (sizeof(CAN_BUFFERELEMENT_s))
75 
76 /** Length of queue that is used in the can module for receiving messages */
77 #define FTSK_CAN_RX_QUEUE_LENGTH (50u)
78 /** Size of queue item that is used in the can driver */
79 #define FTSK_CAN_RX_QUEUE_ITEM_SIZE_IN_BYTES (sizeof(CAN_BUFFERELEMENT_s))
80 
81 /*========== Extern Constant and Variable Declarations ======================*/
82 /** handle of the database queue */
83 extern OS_QUEUE ftsk_databaseQueue;
84 
85 /** handle of the imd can data queue */
86 extern OS_QUEUE ftsk_imdCanDataQueue;
87 
88 /** handle of the can driver data queue */
89 extern OS_QUEUE ftsk_canRxQueue;
90 
91 /** indicator whether the queues have successfully been initialized to be used
92  * in other parts of the software */
93 extern volatile bool ftsk_allQueuesCreated;
94 
95 /*========== Extern Function Prototypes =====================================*/
96 /**
97  * @brief Creates all queues
98  * @details Creates all queues. Is called after the hardware is initialized
99  * and before the scheduler starts. Queues, Mutexes and Events are
100  * already initialized.
101  */
102 extern void FTSK_CreateQueues(void);
103 
104 /**
105  * @brief Creates all tasks of the group
106  * @details Creates all tasks. Is called after the hardware is initialized
107  * and before the scheduler starts. Queues, Mutexes and Events are
108  * already initialized.
109  */
110 extern void FTSK_CreateTasks(void);
111 
112 /**
113  * @brief Database-Task
114  * @details The task manages the data exchange with the database and must have
115  * a higher task priority than any task using the database.
116  * @ingroup API_OS
117  */
118 extern void FTSK_CreateTaskEngine(void *const pvParameters);
119 
120 /**
121  * @brief Creation of cyclic 1 ms task
122  * @details Then the Task is delayed by a phase as defined in
123  * ftsk_taskDefinitionCyclic1ms.phase (in milliseconds). After the
124  * phase delay, the cyclic execution starts, the entry time is saved
125  * in current_time. After one cycle, the Task is set to sleep until
126  * entry time + ftsk_taskDefinitionCyclic1ms.cycleTime (in
127  * milliseconds).
128  */
129 extern void FTSK_CreateTaskCyclic1ms(void *const pvParameters);
130 
131 /**
132  * @brief Creation of cyclic 10 ms task
133  * @details Task is delayed by a phase as defined in
134  * ftsk_taskDefinitionCyclic10ms.phase (in milliseconds). After
135  * the phase delay, the cyclic execution starts, the entry time is
136  * saved in current_time. After one cycle, the Task is set to sleep
137  * until entry time + ftsk_taskDefinitionCyclic10ms.cycleTime (in
138  * milliseconds).
139  */
140 extern void FTSK_CreateTaskCyclic10ms(void *const pvParameters);
141 
142 /**
143  * @brief Creation of cyclic 100 ms task
144  * @details Task is delayed by a phase as defined in
145  * ftsk_taskDefinitionCyclic100ms.phase (in milliseconds). After the
146  * phase delay, the cyclic execution starts, the entry time is saved
147  * in current_time. After one cycle, the Task is set to sleep until
148  * entry time + ftsk_taskDefinitionCyclic100ms.cycleTime (in
149  * milliseconds).
150  */
151 extern void FTSK_CreateTaskCyclic100ms(void *const pvParameters);
152 
153 /**
154  * @brief Creation of cyclic 100 ms algorithm task
155  * @details Task is delayed by a phase as defined in
156  * ftsk_taskDefinitionCyclicAlgorithm100ms.Phase (in milliseconds).
157  * After the phase delay, the cyclic execution starts, the entry time
158  * is saved in current_time. After one cycle, the Task is set to sleep
159  * until entry
160  * time + ftsk_taskDefinitionCyclicAlgorithm100ms.CycleTime (in
161  * milliseconds).
162  */
163 extern void FTSK_CreateTaskCyclicAlgorithm100ms(void *const pvParameters);
164 
165 /**
166  * @brief Creation of continuously running task for AFEs
167  */
168 extern void FTSK_CreateTaskAfe(void *const pvParameters);
169 
170 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
171 
172 #endif /* FOXBMS__FTASK_H_ */
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:186
void FTSK_CreateTaskCyclic100ms(void *const pvParameters)
Creation of cyclic 100 ms task.
Definition: ftask.c:157
void FTSK_CreateTaskCyclic10ms(void *const pvParameters)
Creation of cyclic 10 ms task.
Definition: ftask.c:128
OS_QUEUE ftsk_imdCanDataQueue
volatile bool ftsk_allQueuesCreated
void FTSK_CreateTaskAfe(void *const pvParameters)
Creation of continuously running task for AFEs.
Definition: ftask.c:217
void FTSK_CreateTaskCyclic1ms(void *const pvParameters)
Creation of cyclic 1 ms task.
Definition: ftask.c:96
void FTSK_CreateTasks(void)
Creates all tasks of the group.
OS_QUEUE ftsk_canRxQueue
OS_QUEUE ftsk_databaseQueue
void FTSK_CreateQueues(void)
Creates all queues.
Task configuration header.
Declaration of the OS wrapper interface.