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