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

Implementation of the tasks and resources 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.

Functions

void OS_InitializeOperatingSystem (void)
 Initialization the RTOS interface. More...
 
void OS_IncrementTimer (void)
 Increments the system timer os_timer. More...
 
bool OS_CheckTimeHasPassedWithTimestamp (uint32_t oldTimeStamp_ms, uint32_t currentTimeStamp_ms, uint32_t timeToPass_ms)
 This function checks if timeToPass has passed since the last timestamp to now. More...
 
bool OS_CheckTimeHasPassed (uint32_t oldTimeStamp_ms, uint32_t timeToPass_ms)
 This function checks if timeToPass has passed since the last timestamp to now. More...
 
STD_RETURN_TYPE_e OS_CheckTimeHasPassedSelfTest (void)
 Does a self check if the OS_CheckTimeHasPassedWithTimestamp works as expected. More...
 
OS_TIMER_sTEST_OS_GetOsTimer ()
 

Variables

static OS_TIMER_s os_timer = {0u, 0u, 0u, 0u, 0u, 0u, 0u}
 
volatile OS_BOOT_STATE_e os_boot = OS_OFF
 
uint32_t os_schedulerStartTime = 0u
 Scheduler "zero" time for task phase control. More...
 

Detailed Description

Implementation of the tasks and resources used by the system.

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
2022-05-30 (date of last update)
Version
v1.3.0
Prefix
OS

Definition in file os.c.

Function Documentation

◆ OS_CheckTimeHasPassed()

bool OS_CheckTimeHasPassed ( uint32_t  oldTimeStamp_ms,
uint32_t  timeToPass_ms 
)

This function checks if timeToPass has passed since the last timestamp to now.

This function retrieves the current time stamp with OS_GetTickCount(), compares it to the oldTimestamp_ms and checks if more or equal of timetoPass_ms timer increments have passed.

Parameters
[in]oldTimeStamp_mstimestamp that shall be compared to the current time in ms
[in]timeToPass_mstimer increments (in ms) that shall pass between oldTimeStamp_ms and now
Returns
true in the case that more than timeToPass_ms timer increments have passed, otherwise false

Definition at line 144 of file os.c.

Here is the call graph for this function:

◆ OS_CheckTimeHasPassedSelfTest()

STD_RETURN_TYPE_e OS_CheckTimeHasPassedSelfTest ( void  )

Does a self check if the OS_CheckTimeHasPassedWithTimestamp works as expected.

This functions tests some values with OS_CheckTimeHasPassedWithTimestamp(). It is intended to be side-effect free and to be callable any time to verify from the running program if this portion of the software is working as expected. returns STD_OK if the self check passes successfully, STD_NOT_OK otherwise

Definition at line 148 of file os.c.

Here is the call graph for this function:

◆ OS_CheckTimeHasPassedWithTimestamp()

bool OS_CheckTimeHasPassedWithTimestamp ( uint32_t  oldTimeStamp_ms,
uint32_t  currentTimeStamp_ms,
uint32_t  timeToPass_ms 
)

This function checks if timeToPass has passed since the last timestamp to now.

This function is passed the current time stamp as argument currentTimeStamp_ms, compares it to the oldTimestamp_ms and checks if more or equal of timetoPass_ms timer increments have passed.

Parameters
[in]oldTimeStamp_mstimestamp that shall be compared to the current time in ms
[in]currentTimeStamp_mstimestamp of the current time in ms
[in]timeToPass_mstimer increments (in ms) that shall pass between oldTimeStamp_ms and now
Returns
true in the case that more than timeToPass_ms timer increments have passed, otherwise false

Definition at line 118 of file os.c.

◆ OS_IncrementTimer()

void OS_IncrementTimer ( void  )

Increments the system timer os_timer.

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

Definition at line 94 of file os.c.

◆ OS_InitializeOperatingSystem()

void OS_InitializeOperatingSystem ( void  )

Initialization the RTOS interface.

This function initializes the scheduler and then creates queues and tasks.

Definition at line 79 of file os.c.

Here is the call graph for this function:

◆ TEST_OS_GetOsTimer()

OS_TIMER_s* TEST_OS_GetOsTimer ( )

Definition at line 181 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 69 of file os.c.

◆ os_schedulerStartTime

uint32_t os_schedulerStartTime = 0u

Scheduler "zero" time for task phase control.

timestamp of the scheduler start

Definition at line 71 of file os.c.

◆ os_timer

OS_TIMER_s os_timer = {0u, 0u, 0u, 0u, 0u, 0u, 0u}
static

timer counter since the 1ms task has started

Definition at line 65 of file os.c.