foxBMS-UnitTests  1.0.0
The foxBMS Unit Tests API Documentation
os.c File Reference

Implementation of the tasks used by the system. More...

#include "os.h"
#include "ftask.h"
Include dependency graph for os.c:

Go to the source code of this file.

Macros

#define OS_IDLE_TASK_SIZE   configMINIMAL_STACK_SIZE
 

Functions

void OS_StartScheduler (void)
 Starts the operating system scheduler. More...
 
void OS_InitializeTasks (void)
 Initialization the RTOS interface. More...
 
void vApplicationGetIdleTaskMemory (StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize)
 Supplies the memory for the idle task. More...
 
void vApplicationIdleHook (void)
 Hook function for the idle task. More...
 
void vApplicationStackOverflowHook (TaskHandle_t xTask, signed char *pcTaskName)
 Hook function for StackOverflowHandling. More...
 
void OS_TriggerTimer (volatile OS_TIMER_s *timer)
 Increments the system timer os_timer. More...
 
void OS_EnterTaskCritical (void)
 Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR. More...
 
void OS_ExitTaskCritical (void)
 Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR. More...
 
uint32_t OS_GetTickCount (void)
 Returns OS based system tick value. More...
 
void OS_DelayTask (uint32_t delay_ms)
 Delays a task in milliseconds. More...
 
void OS_DelayTaskUntil (uint32_t *pPreviousWakeTime, uint32_t milliseconds)
 Delay a task until a specified time. More...
 
void OS_SystemTickHandler (void)
 Handles the tick increment of operating systick timer. More...
 

Variables

volatile OS_BOOT_STATE_e os_boot = OS_OFF
 
volatile OS_TIMER_s os_timer = {0, 0, 0, 0, 0, 0, 0}
 
uint32_t os_schedulerStartTime = 0
 Scheduler "zero" time for task phase control. More...
 
static StaticTask_t os_idleTaskTcbBuffer
 
static StackType_t os_idleStack [OS_IDLE_TASK_SIZE]
 Stack for the Idle task. More...
 

Detailed Description

Implementation of the tasks used by the system.

BSD 3-Clause License 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
2020-01-21 (date of last update)
Prefix
OS

Definition in file os.c.

Macro Definition Documentation

◆ OS_IDLE_TASK_SIZE

#define OS_IDLE_TASK_SIZE   configMINIMAL_STACK_SIZE

stack size of the idle task

Definition at line 62 of file os.c.

Function Documentation

◆ OS_DelayTask()

void OS_DelayTask ( uint32_t  delay_ms)

Delays a task in milliseconds.

TODO

Parameters
delay_mstime delay value

Definition at line 186 of file os.c.

◆ OS_DelayTaskUntil()

void OS_DelayTaskUntil ( uint32_t *  pPreviousWakeTime,
uint32_t  milliseconds 
)

Delay a task until a specified time.

TODO

Parameters
pPreviousWakeTimePointer to a variable that holds the time at which the task was last unblocked. PreviousWakeTime must be initialized with the current time prior to its first use (PreviousWakeTime = OS_osSysTick()).
millisecondstime delay value in milliseconds

Definition at line 196 of file os.c.

◆ OS_EnterTaskCritical()

void OS_EnterTaskCritical ( void  )

Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.

checks the function context (task/thread mode or interrupt (handler) mode) and calls the corresponding enter-critical function

Definition at line 174 of file os.c.

◆ OS_ExitTaskCritical()

void OS_ExitTaskCritical ( void  )

Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.

Checks the function context (task/thread mode or interrupt (handler) mode) and calls the corresponding exit-critical function

Definition at line 178 of file os.c.

◆ OS_GetTickCount()

uint32_t OS_GetTickCount ( void  )

Returns OS based system tick value.

TODO

Returns
time stamp in milliseconds, based on the operating system time.

Definition at line 182 of file os.c.

◆ OS_InitializeTasks()

void OS_InitializeTasks ( void  )

Initialization the RTOS interface.

This function initializes the mutexes, eventgroups and tasks.

Definition at line 100 of file os.c.

Here is the call graph for this function:

◆ OS_StartScheduler()

void OS_StartScheduler ( void  )

Starts the operating system scheduler.

Definition at line 96 of file os.c.

◆ OS_SystemTickHandler()

void OS_SystemTickHandler ( void  )

Handles the tick increment of operating systick timer.

TODO

Definition at line 206 of file os.c.

◆ OS_TriggerTimer()

void OS_TriggerTimer ( volatile OS_TIMER_s timer)

Increments the system timer os_timer.

The os_timer is a runtime-counter, counting the time since the last reset.

Parameters
timerTODO

Definition at line 141 of file os.c.

◆ vApplicationGetIdleTaskMemory()

void vApplicationGetIdleTaskMemory ( StaticTask_t **  ppxIdleTaskTCBBuffer,
StackType_t **  ppxIdleTaskStackBuffer,
uint32_t *  pulIdleTaskStackSize 
)

Supplies the memory for the idle task.

This is needed due to the usage of configSUPPORT_STATIC_ALLOCATION. This is an FreeRTOS function an does not adhere to foxBMS function naming convetions.

Parameters
ppxIdleTaskTCBBufferTODO
ppxIdleTaskStackBufferTODO
pulIdleTaskStackSizeTODO

Definition at line 113 of file os.c.

◆ vApplicationIdleHook()

void vApplicationIdleHook ( void  )

Hook function for the idle task.

This is an FreeRTOS function an does not adhere to foxBMS function naming convetions

Definition at line 133 of file os.c.

Here is the call graph for this function:

◆ vApplicationStackOverflowHook()

void vApplicationStackOverflowHook ( TaskHandle_t  xTask,
signed char *  pcTaskName 
)

Hook function for StackOverflowHandling.

This handler is used when the operation system encounters a stackoverflow in a task. This is an FreeRTOS function an does not adhere to foxBMS function naming convetions

Parameters
xTaskTODO
pcTaskNameTODO

Definition at line 137 of file os.c.

Variable Documentation

◆ os_boot

volatile OS_BOOT_STATE_e os_boot = OS_OFF

boot state of the OS

Definition at line 68 of file os.c.

◆ os_idleStack

StackType_t os_idleStack[OS_IDLE_TASK_SIZE]
static

Stack for the Idle task.

Definition at line 78 of file os.c.

◆ os_idleTaskTcbBuffer

StaticTask_t os_idleTaskTcbBuffer
static

Buffer for the Idle Task's structure

Definition at line 75 of file os.c.

◆ os_schedulerStartTime

uint32_t os_schedulerStartTime = 0

Scheduler "zero" time for task phase control.

timestamp of the scheduler start

Definition at line 72 of file os.c.

◆ os_timer

volatile OS_TIMER_s os_timer = {0, 0, 0, 0, 0, 0, 0}

system timer variable

Definition at line 70 of file os.c.