foxBMS - Unit Tests  1.1.0
The foxBMS Unit Tests API Documentation
ftask.c File Reference

Implementation of engine task driver. More...

#include "ftask.h"
#include "can_cfg.h"
#include "FreeRTOS.h"
#include "stream_buffer.h"
#include "database.h"
#include "sys_mon.h"
Include dependency graph for ftask.c:

Go to the source code of this file.

Macros

#define FTSK_DATABASE_QUEUE_LENGTH   (1u)
 
#define FTSK_DATABASE_QUEUE_ITEM_SIZE   (sizeof(DATA_QUEUE_MESSAGE_s))
 
#define FTSK_IMD_QUEUE_LENGTH   (5u)
 
#define FTSK_IMD_QUEUE_ITEM_SIZE   (sizeof(CAN_BUFFERELEMENT_s))
 
#define FTSK_CAN_RX_QUEUE_LENGTH   (50u)
 
#define FTSK_CAN_RX_QUEUE_ITEM_SIZE   (sizeof(CAN_BUFFERELEMENT_s))
 

Functions

static void FTSK_CreateTaskEngine (void)
 Database-Task. More...
 
static void FTSK_CreateTaskCyclic1ms (void)
 Creation of cyclic 1 ms task. More...
 
static void FTSK_CreateTaskCyclic10ms (void)
 Creation of cyclic 10 ms task. More...
 
static void FTSK_CreateTaskCyclic100ms (void)
 Creation of cyclic 100 ms task. More...
 
static void FTSK_CreateTaskCyclicAlgorithm100ms (void)
 Creation of cyclic 100 ms algorithm task. More...
 
void FTSK_CreateQueues (void)
 Creates all queues. More...
 
void FTSK_CreateTasks (void)
 Creates all tasks of the group. More...
 

Variables

static uint8_t ftsk_databaseQueueStorageArea [FTSK_DATABASE_QUEUE_LENGTH *FTSK_DATABASE_QUEUE_ITEM_SIZE]
 size of storage area for the database queue More...
 
static StaticQueue_t ftsk_databaseQueueStructure
 
static uint8_t ftsk_imdQueueStorageArea [FTSK_IMD_QUEUE_LENGTH *FTSK_IMD_QUEUE_ITEM_SIZE]
 size of storage area for the IMD queue More...
 
static StaticQueue_t ftsk_imdQueueStructure
 
static StaticQueue_t ftsk_canRxQueueStructure = {0}
 
static uint8_t ftsk_canRxQueueStorageArea [FTSK_CAN_RX_QUEUE_LENGTH *FTSK_CAN_RX_QUEUE_ITEM_SIZE] = {0}
 size of storage area for the CAN Rx queue More...
 
static TaskHandle_t ftsk_taskHandleEngine
 
static StaticTask_t ftsk_taskEngine
 
static StackType_t ftsk_stackSizeEngine [FTSK_TASK_ENGINE_STACK_SIZE]
 
static TaskHandle_t ftsk_taskHandleCyclic1ms
 
static StaticTask_t ftsk_taskCyclic1ms
 
static StackType_t ftsk_stackSizeCyclic1ms [FTSK_TASK_CYCLIC_1MS_STACK_SIZE]
 
static TaskHandle_t ftsk_taskHandleCyclic10ms
 
static StaticTask_t ftsk_taskCyclic10ms
 
static StackType_t ftsk_stackSizeCyclic10ms [FTSK_TASK_CYCLIC_10MS_STACK_SIZE]
 
static TaskHandle_t ftsk_taskHandleCyclic100ms
 
static StaticTask_t ftsk_taskCyclic100ms
 
static StackType_t ftsk_stackSizeCyclic100ms [FTSK_TASK_CYCLIC_100MS_STACK_SIZE]
 
static TaskHandle_t ftsk_taskHandleCyclicAlgorithm100ms
 
static StaticTask_t ftsk_taskCyclicAlgorithm100ms
 
static StackType_t ftsk_stackSizeCyclicAlgorithm100ms [FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACKSIZE]
 
volatile bool ftsk_allQueuesCreated = false
 
QueueHandle_t ftsk_databaseQueue = NULL_PTR
 
QueueHandle_t ftsk_imdCanDataQueue = NULL_PTR
 
QueueHandle_t ftsk_canRxQueue = NULL_PTR
 

Detailed Description

Implementation of engine task driver.

SPDX-License-Identifier: BSD-3-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:

  • ″This product uses parts of foxBMS®″
  • ″This product includes parts of foxBMS®″
  • ″This product is derived from foxBMS®″
Author
foxBMS Team
Date
2019-08-27 (date of creation)
Updated
2021-07-23 (date of last update)
Prefix
FTSK

TODO

Definition in file ftask.c.

Macro Definition Documentation

◆ FTSK_CAN_RX_QUEUE_ITEM_SIZE

#define FTSK_CAN_RX_QUEUE_ITEM_SIZE   (sizeof(CAN_BUFFERELEMENT_s))

Size of queue item that is used in the can driver

Definition at line 80 of file ftask.c.

◆ FTSK_CAN_RX_QUEUE_LENGTH

#define FTSK_CAN_RX_QUEUE_LENGTH   (50u)

Length of queue that is used in the can module for receiving messages

Definition at line 78 of file ftask.c.

◆ FTSK_DATABASE_QUEUE_ITEM_SIZE

#define FTSK_DATABASE_QUEUE_ITEM_SIZE   (sizeof(DATA_QUEUE_MESSAGE_s))

Size of queue item that is used in the database

Definition at line 70 of file ftask.c.

◆ FTSK_DATABASE_QUEUE_LENGTH

#define FTSK_DATABASE_QUEUE_LENGTH   (1u)

Length of queue that is used in the database

Definition at line 67 of file ftask.c.

◆ FTSK_IMD_QUEUE_ITEM_SIZE

#define FTSK_IMD_QUEUE_ITEM_SIZE   (sizeof(CAN_BUFFERELEMENT_s))

Size of queue item that is used in the IMD driver

Definition at line 75 of file ftask.c.

◆ FTSK_IMD_QUEUE_LENGTH

#define FTSK_IMD_QUEUE_LENGTH   (5u)

Length of queue that is used in the insulation measurement device (IMD)

Definition at line 73 of file ftask.c.

Function Documentation

◆ FTSK_CreateQueues()

void FTSK_CreateQueues ( void  )

Creates all queues.

Creates all queues. Is called after the hardware is initialized and before the scheduler starts. Queues, Mutexes and Events are already initialized.

Definition at line 340 of file ftask.c.

Here is the call graph for this function:

◆ FTSK_CreateTaskCyclic100ms()

static void FTSK_CreateTaskCyclic100ms ( void  )
static

Creation of cyclic 100 ms task.

Task is delayed by a phase as defined in ftsk_tskdef_cyclic_100ms.phase (in milliseconds). After the phase delay, the cyclic execution starts, the entry time is saved in current_time. After one cycle, the Task is set to sleep until entry time + ftsk_tskdef_cyclic_100ms.cycleTime (in milliseconds).

Definition at line 296 of file ftask.c.

Here is the call graph for this function:

◆ FTSK_CreateTaskCyclic10ms()

static void FTSK_CreateTaskCyclic10ms ( void  )
static

Creation of cyclic 10 ms task.

Task is delayed by a phase as defined in ftsk_tskdef_cyclic_10ms.phase (in milliseconds). After the phase delay, the cyclic execution starts, the entry time is saved in current_time. After one cycle, the Task is set to sleep until entry time + ftsk_tskdef_cyclic_10ms.cycleTime (in milliseconds).

Definition at line 274 of file ftask.c.

Here is the call graph for this function:

◆ FTSK_CreateTaskCyclic1ms()

static void FTSK_CreateTaskCyclic1ms ( void  )
static

Creation of cyclic 1 ms task.

The Task calls OsStartUp() in the very beginning, this is the first active Task. Then the Task is delayed by a phase as defined in ftsk_tskdef_cyclic_1ms.phase (in milliseconds). After the phase delay, the cyclic execution starts, the entry time is saved in current_time. After one cycle, the Task is set to sleep until entry time + ftsk_tskdef_cyclic_1ms.cycleTime (in milliseconds).

Definition at line 249 of file ftask.c.

Here is the call graph for this function:

◆ FTSK_CreateTaskCyclicAlgorithm100ms()

static void FTSK_CreateTaskCyclicAlgorithm100ms ( void  )
static

Creation of cyclic 100 ms algorithm task.

Task is delayed by a phase as defined in ftsk_taskDefinitionCyclicAlgorithm100ms.Phase (in milliseconds). After the phase delay, the cyclic execution starts, the entry time is saved in current_time. After one cycle, the Task is set to sleep until entry time + ftsk_taskDefinitionCyclicAlgorithm100ms.CycleTime (in milliseconds).

Definition at line 318 of file ftask.c.

Here is the call graph for this function:

◆ FTSK_CreateTaskEngine()

static void FTSK_CreateTaskEngine ( void  )
static

Database-Task.

The task manages the data exchange with the database and must have a higher task priority than any task using the database.

Definition at line 231 of file ftask.c.

Here is the call graph for this function:

◆ FTSK_CreateTasks()

void FTSK_CreateTasks ( void  )

Creates all tasks of the group.

Creates all tasks. Is called after the hardware is initialized and before the scheduler starts. Queues, Mutexes and Events are already initialized.

Definition at line 363 of file ftask.c.

Here is the call graph for this function:

Variable Documentation

◆ ftsk_allQueuesCreated

volatile bool ftsk_allQueuesCreated = false

indicator wether the queues have successfully been initialized to be used in other parts of the software

Definition at line 166 of file ftask.c.

◆ ftsk_canRxQueue

QueueHandle_t ftsk_canRxQueue = NULL_PTR

handle of the can driver data queue

Definition at line 173 of file ftask.c.

◆ ftsk_canRxQueueStorageArea

uint8_t ftsk_canRxQueueStorageArea[FTSK_CAN_RX_QUEUE_LENGTH *FTSK_CAN_RX_QUEUE_ITEM_SIZE] = {0}
static

size of storage area for the CAN Rx queue

The array that is used for the queue's storage area. This must be at least FTSK_CAN_RX_QUEUE_LENGTH * FTSK_CAN_RX_QUEUE_ITEM_SIZE

Definition at line 112 of file ftask.c.

◆ ftsk_canRxQueueStructure

StaticQueue_t ftsk_canRxQueueStructure = {0}
static

structure for static data queue

Definition at line 105 of file ftask.c.

◆ ftsk_databaseQueue

QueueHandle_t ftsk_databaseQueue = NULL_PTR

handle of the database queue

Definition at line 168 of file ftask.c.

◆ ftsk_databaseQueueStorageArea

uint8_t ftsk_databaseQueueStorageArea[FTSK_DATABASE_QUEUE_LENGTH *FTSK_DATABASE_QUEUE_ITEM_SIZE]
static

size of storage area for the database queue

The array that is used for the queue's storage area. This must be at least FTSK_DATABASE_QUEUE_LENGTH * FTSK_DATABASE_QUEUE_ITEM_SIZE

Definition at line 89 of file ftask.c.

◆ ftsk_databaseQueueStructure

StaticQueue_t ftsk_databaseQueueStructure
static

structure for static database queue

Definition at line 91 of file ftask.c.

◆ ftsk_imdCanDataQueue

QueueHandle_t ftsk_imdCanDataQueue = NULL_PTR

handle of the imd can data queue

Definition at line 170 of file ftask.c.

◆ ftsk_imdQueueStorageArea

uint8_t ftsk_imdQueueStorageArea[FTSK_IMD_QUEUE_LENGTH *FTSK_IMD_QUEUE_ITEM_SIZE]
static

size of storage area for the IMD queue

The array that is used for the queue's storage area. This must be at least FTSK_IMD_QUEUE_LENGTH * FTSK_IMD_QUEUE_ITEM_SIZE

Definition at line 99 of file ftask.c.

◆ ftsk_imdQueueStructure

StaticQueue_t ftsk_imdQueueStructure
static

structure for static data queue

Definition at line 101 of file ftask.c.

◆ ftsk_stackSizeCyclic100ms

StackType_t ftsk_stackSizeCyclic100ms[FTSK_TASK_CYCLIC_100MS_STACK_SIZE]
static

Stack of ftsk_taskHandleCyclic100ms

Definition at line 153 of file ftask.c.

◆ ftsk_stackSizeCyclic10ms

StackType_t ftsk_stackSizeCyclic10ms[FTSK_TASK_CYCLIC_10MS_STACK_SIZE]
static

Stack of ftsk_taskHandleCyclic10ms

Definition at line 143 of file ftask.c.

◆ ftsk_stackSizeCyclic1ms

StackType_t ftsk_stackSizeCyclic1ms[FTSK_TASK_CYCLIC_1MS_STACK_SIZE]
static

Stack of ftsk_taskHandleCyclic1ms

Definition at line 133 of file ftask.c.

◆ ftsk_stackSizeCyclicAlgorithm100ms

StackType_t ftsk_stackSizeCyclicAlgorithm100ms[FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACKSIZE]
static

Stack of ftsk_taskHandleCyclicAlgorithm100ms

Definition at line 163 of file ftask.c.

◆ ftsk_stackSizeEngine

StackType_t ftsk_stackSizeEngine[FTSK_TASK_ENGINE_STACK_SIZE]
static

Stack of ftsk_taskHandleEngine

Definition at line 123 of file ftask.c.

◆ ftsk_taskCyclic100ms

StaticTask_t ftsk_taskCyclic100ms
static

Task Struct for ftsk_taskHandleCyclic100ms

Definition at line 150 of file ftask.c.

◆ ftsk_taskCyclic10ms

StaticTask_t ftsk_taskCyclic10ms
static

Task Struct for ftsk_taskHandleCyclic10ms

Definition at line 140 of file ftask.c.

◆ ftsk_taskCyclic1ms

StaticTask_t ftsk_taskCyclic1ms
static

Task Struct for ftsk_taskHandleCyclic1ms

Definition at line 130 of file ftask.c.

◆ ftsk_taskCyclicAlgorithm100ms

StaticTask_t ftsk_taskCyclicAlgorithm100ms
static

Task Struct for ftsk_taskHandleCyclicAlgorithm100ms

Definition at line 160 of file ftask.c.

◆ ftsk_taskEngine

StaticTask_t ftsk_taskEngine
static

Task Struct for ftsk_taskHandleEngine

Definition at line 120 of file ftask.c.

◆ ftsk_taskHandleCyclic100ms

TaskHandle_t ftsk_taskHandleCyclic100ms
static

Definition of task handle for the cyclic 100 ms task

Definition at line 147 of file ftask.c.

◆ ftsk_taskHandleCyclic10ms

TaskHandle_t ftsk_taskHandleCyclic10ms
static

Definition of task handle for the cyclic 10 ms task

Definition at line 137 of file ftask.c.

◆ ftsk_taskHandleCyclic1ms

TaskHandle_t ftsk_taskHandleCyclic1ms
static

Definition of task handle for the cyclic 1 ms task

Definition at line 127 of file ftask.c.

◆ ftsk_taskHandleCyclicAlgorithm100ms

TaskHandle_t ftsk_taskHandleCyclicAlgorithm100ms
static

Definition of task handle for the cyclic 100 ms task for algorithms

Definition at line 157 of file ftask.c.

◆ ftsk_taskHandleEngine

TaskHandle_t ftsk_taskHandleEngine
static

Definition of task handle of the engine task

Definition at line 117 of file ftask.c.