foxBMS
1.5.1
The foxBMS Battery Management System API Documentation
|
Implementation of the RTC driver. More...
#include "rtc.h"
#include "database.h"
#include "diag.h"
#include "foxmath.h"
#include "fstd_types.h"
#include "ftask.h"
#include "i2c.h"
#include <stdint.h>
#include <time.h>
Go to the source code of this file.
Data Structures | |
struct | RTC_SYSTEM_TIMER_EPOCH_s |
Functions | |
static RTC_TIME_DATA_s | RTC_ReadTime (void) |
Reads the time from the RTC IC. More... | |
static void | RTC_WriteTime (RTC_TIME_DATA_s rtcTime) |
Write the time to the RTC IC. More... | |
static void | RTC_SetOverCanMessage (void) |
Check if a CAN message was received to set the RTC time. More... | |
static void | RTC_AdjustTime (void) |
Adjust RTC system timer with time from RTC IC. More... | |
static void | RTC_CheckBatteryLowVoltageAlert (void) |
Read bit for battery voltage low flag. More... | |
static void | RTC_SetSystemTimeEpochFormat (time_t timeEpochFormat, uint16_t milliseconds) |
Set the RTC system timer value. More... | |
static RTC_SYSTEM_TIMER_EPOCH_s | RTC_GetSystemTimeEpochFormat (void) |
Get the RTC system timer value. More... | |
static struct tm | RTC_rtcFormatToTmFormat (RTC_TIME_DATA_s timeRtcFormat) |
Convert time from RTC_TIME_DATA_s to struct tm format. More... | |
static RTC_TIME_DATA_s | RTC_tmFormatToRtcFormat (struct tm timeTmFormat) |
Convert time from struct tm to RTC_TIME_DATA_s format. More... | |
void | RTC_Trigger (void) |
trigger function for the RTC driver. More... | |
STD_RETURN_TYPE_e | RTC_Initialize (void) |
initialization of the RTC IC. More... | |
void | RTC_InitializeSystemTimeWithRtc (void) |
initialize system time with RTC time. More... | |
void | RTC_IncrementSystemTime (void) |
increment the RTC system timer. More... | |
void | RTC_SetSystemTimeRtcFormat (RTC_TIME_DATA_s timeRtcFormat) |
set the RTC system timer. More... | |
RTC_TIME_DATA_s | RTC_GetSystemTimeRtcFormat (void) |
get the RTC system timer. More... | |
Variables | |
static uint8_t | rtc_i2cWriteBuffer [RTC_MAX_I2C_TRANSACTION_SIZE_IN_BYTES] = {0} |
static uint8_t | rtc_i2cReadBuffer [RTC_MAX_I2C_TRANSACTION_SIZE_IN_BYTES] = {0} |
static RTC_SYSTEM_TIMER_EPOCH_s | rtc_SystemTime = {0} |
Implementation of the RTC 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:
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:
Uses the NXP PCF2131 RTC over I2C
Definition in file rtc.c.
|
static |
|
static |
|
static |
Get the RTC system timer value.
This function gets the timer value directly. It is called by RTC_GetSystemTimeRtcFormat() which returns a RTC_TIME_DATA_s parameter.
Definition at line 301 of file rtc.c.
RTC_TIME_DATA_s RTC_GetSystemTimeRtcFormat | ( | void | ) |
void RTC_IncrementSystemTime | ( | void | ) |
STD_RETURN_TYPE_e RTC_Initialize | ( | void | ) |
void RTC_InitializeSystemTimeWithRtc | ( | void | ) |
initialize system time with RTC time.
This function is called once at the startup of the system. It reads the time from the RTC IC over I2C and sets the RTC system timer with this value. It must be called once the 1ms task is already running, otherwise the RTC system timer will not be incremented and there will be a discrepancy between the RTC IC time and the RTC system timer.
Definition at line 577 of file rtc.c.
|
static |
|
static |
Convert time from RTC_TIME_DATA_s to struct tm format.
timeRtcFormat | time in RTC_TIME_DATA_s format |
|
static |
Check if a CAN message was received to set the RTC time.
When a CAN message to set the RTC time is received, it is written in the dedicated queue. This function check if an element is present in the queue. If yes, the time is first written to the RTC IC over I2C, then to the RTC system timer.
Definition at line 195 of file rtc.c.
|
static |
Set the RTC system timer value.
This function sets the timer value directly. It is called by RTC_SetSystemTimeRtcFormat() which takes a RTC_TIME_DATA_s parameter as input.
timeEpochFormat | RTC system timer value to set, main value in seconds |
milliseconds | RTC system timer value to set, secondary value in milliseconds |
Definition at line 285 of file rtc.c.
void RTC_SetSystemTimeRtcFormat | ( | RTC_TIME_DATA_s | timeRtcFormat | ) |
set the RTC system timer.
This function is used to set the RTC system timer with RTC time data. It is called at startup by RTC_InitializeSystemTimeWithRtc().
timeRtcFormat | time data to set the RTC system timer |
Definition at line 595 of file rtc.c.
|
static |
Convert time from struct tm to RTC_TIME_DATA_s format.
timeTmFormat | time in struct tm format |
void RTC_Trigger | ( | void | ) |
trigger function for the RTC driver.
This function uses RTC_SetOverCanMessage() to check in the RTC queue for requests to set the RTC time. If a request was made, the time of the RTC IC is set over I2C and the RTC system timer is set.
Definition at line 414 of file rtc.c.
|
static |
|
static |
|
static |
|
static |