81 #pragma SET_DATA_SECTION(".sharedRAM")
86 #pragma SET_DATA_SECTION()
216 time_t rtcTimeFromTimerEpochFormat = 0;
217 time_t rtcTimeFromIcEpochFormat = 0;
218 struct tm rtcTimeFromTimerTmFormat = {0};
219 struct tm rtcTimeFromIcTmFormat = {0};
225 rtcTimeFromIcEpochFormat = mktime(&rtcTimeFromIcTmFormat);
231 rtcTimeFromTimerEpochFormat = mktime(&rtcTimeFromTimerTmFormat);
306 return systemTimerValueEpoch;
316 struct tm timeTmFormat = {0};
320 timeTmFormat.tm_mday = timeRtcFormat.day;
321 timeTmFormat.tm_hour = timeRtcFormat.hours;
322 timeTmFormat.tm_min = timeRtcFormat.minutes;
323 timeTmFormat.tm_sec = timeRtcFormat.seconds;
324 timeTmFormat.tm_wday = timeRtcFormat.weekday;
340 timeRtcFormat.
day = timeTmFormat.tm_mday;
341 timeRtcFormat.
hours = timeTmFormat.tm_hour;
342 timeRtcFormat.
minutes = timeTmFormat.tm_min;
343 timeRtcFormat.
seconds = timeTmFormat.tm_sec;
344 timeRtcFormat.
weekday = timeTmFormat.tm_wday;
346 return timeRtcFormat;
415 static uint32_t initialTimeBatteryLowCheck = 0u;
416 static uint32_t initialTimeAdjustCheck = 0u;
423 if (initFinished ==
STD_OK) {
427 if ((currentTime - initialTimeBatteryLowCheck) >=
433 if ((currentTime - initialTimeAdjustCheck) >=
446 uint8_t otprBit = 1u;
448 static uint32_t initTime = 0u;
451 switch (rtcInitState) {
596 time_t systemTimeEpochFormat = 0;
597 struct tm systemTimeTmFormat = {0};
602 systemTimeEpochFormat = mktime(&systemTimeTmFormat);
609 struct tm systemTimeTmFormat = {0};
620 return systemTimeRtcFormat;
625 #ifdef UNITY_UNIT_TEST
DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diagId, DIAG_EVENT_e event, DIAG_IMPACT_LEVEL_e impact, uint32_t data)
DIAG_Handler provides generic error handling, based on diagnosis group.
@ DIAG_ID_RTC_CLOCK_INTEGRITY_ERROR
@ DIAG_ID_RTC_BATTERY_LOW_ERROR
math library for often used math functions
Definition of foxBMS standard types.
Header of task driver implementation.
OS_QUEUE ftsk_rtcSetTimeQueue
STD_RETURN_TYPE_e I2C_ReadDma(i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *readData)
reads from an I2C slave, no register address written first, using DMA.
STD_RETURN_TYPE_e I2C_Read(i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *readData)
reads from an I2C slave, no register address written first, blocking.
STD_RETURN_TYPE_e I2C_Write(i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *writeData)
writes to an I2C slave, no register address written first, blocking.
STD_RETURN_TYPE_e I2C_WriteDma(i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *writeData)
writes to an I2C slave, no register address written first, using DMA.
Header for the driver for the I2C module.
OS_STD_RETURN_e OS_ReceiveFromQueue(OS_QUEUE xQueue, void *const pvBuffer, uint32_t ticksToWait)
Receive an item from a queue.
void OS_DelayTaskUntil(uint32_t *pPreviousWakeTime, uint32_t milliseconds)
Delay a task until a specified time.
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
uint32_t OS_GetTickCount(void)
Returns OS based system tick value.
void RTC_IncrementSystemTime(void)
increment the RTC system timer.
void RTC_InitializeSystemTimeWithRtc(void)
initialize system time with RTC time.
static void RTC_AdjustTime(void)
Adjust RTC system timer with time from RTC IC.
void RTC_SetSystemTimeRtcFormat(RTC_TIME_DATA_s timeRtcFormat)
set the RTC system timer.
static RTC_TIME_DATA_s RTC_ReadTime(void)
Reads the time from the RTC IC.
static void RTC_SetOverCanMessage(void)
Check if a CAN message was received to set the RTC time.
static void RTC_WriteTime(RTC_TIME_DATA_s rtcTime)
Write the time to the RTC IC.
static RTC_SYSTEM_TIMER_EPOCH_s rtc_SystemTime
void RTC_Trigger(void)
trigger function for the RTC driver.
static void RTC_SetSystemTimeEpochFormat(time_t timeEpochFormat, uint16_t milliseconds)
Set the RTC system timer value.
static RTC_TIME_DATA_s RTC_tmFormatToRtcFormat(struct tm timeTmFormat)
Convert time from struct tm to RTC_TIME_DATA_s format.
STD_RETURN_TYPE_e RTC_Initialize(void)
initialization of the RTC IC.
static void RTC_CheckBatteryLowVoltageAlert(void)
Read bit for battery voltage low flag.
static RTC_SYSTEM_TIMER_EPOCH_s RTC_GetSystemTimeEpochFormat(void)
Get the RTC system timer value.
static uint8_t rtc_i2cWriteBuffer[RTC_MAX_I2C_TRANSACTION_SIZE_IN_BYTES]
RTC_TIME_DATA_s RTC_GetSystemTimeRtcFormat(void)
get the RTC system timer.
static struct tm RTC_rtcFormatToTmFormat(RTC_TIME_DATA_s timeRtcFormat)
Convert time from RTC_TIME_DATA_s to struct tm format.
static uint8_t rtc_i2cReadBuffer[RTC_MAX_I2C_TRANSACTION_SIZE_IN_BYTES]
Header file of the RTC driver.
#define RTC_TENS_PLACE_OFFSET
#define RTC_REG_TIME_START_ADDR
#define RTC_DAYS_TENS_PLACE_MASK
#define RTC_HOURS_TENS_PLACE_MASK
#define RTC_OTPR_BIT_WAIT_TIMEOUT_ms
#define RTC_NUMBER_OF_TIMEDATA_BYTES
#define RTC_UNITS_PLACE_MASK
#define RTC_SECONDS_OFFSET
#define RTC_CTRL3_BATTERY_LOW_FLAG_BIT_POSITION
#define RTC_TIME_BETWEEN_BLF_FLAG_CHECK_min
#define RTC_CTRL1_12_24HOUR_MODE_BIT_MASK
#define RTC_YEARS_TENS_PLACE_MASK
#define RTC_CTRL3_PWRMNG_DIRECTSWITCH_LOWDETECTIONENABLE_MODE
#define RTC_CLKOUT_CTL_OTPR_BIT_MASK
#define RTC_I2C_INTERFACE
#define RTC_HUNDREDTH_OF_SECONDS_TENS_PLACE_MASK
#define RTC_CTIME_MONTH_START
#define RTC_TENS_PLACE_FACTOR
#define RTC_MAX_I2C_TRANSACTION_SIZE_IN_BYTES
#define RTC_WRITE_REGISTER_I2C_TRANSACTION_SIZE_IN_BYTES
#define RTC_REG_CONTROL_3_ADDR
#define RTC_CTIME_YEAR_START
#define RTC_MINUTES_OFFSET
#define RTC_MINUTES_TENS_PLACE_MASK
#define RTC_REG_CLKOUT_CTL_ADDR
#define RTC_SWRESET_CLEARPRESCALER
#define RTC_SECONDS_TENS_PLACE_MASK
#define RTC_REG_SOFTWARE_RESET_ADDR
#define RTC_WEEKDAYS_OFFSET
#define RTC_REG_CONTROL_1_ADDR
#define RTC_MAX_DIFFERENCE_BETWEEN_TIMER_AND_IC_s
#define RTC_MONTHS_OFFSET
#define RTC_CTRL3_BATTERY_LOW_FLAG_BIT_MASK
#define RTC_SECONDS_OSF_BIT_POSITION
#define RTC_100TH_OF_SECONDS_OFFSET
#define RTC_WEEKDAYS_UNITS_PLACE_MASK
#define RTC_CTRL1_STOP_BIT_MASK
#define RTC_FACTOR_MIN_TO_MS
#define RTC_MONTHS_TENS_PLACE_MASK
#define RTC_TIME_BETWEEN_RTC_TIMER_ADJUSTMENT_min
#define RTC_CLKOUT_CTL_OTPR_BIT_POSITION
#define RTC_SECONDS_OSF_BIT_MASK
#define RTC_CTRL3_BATTERY_PWRMNG_BITS_POSITION
uint8_t hundredthOfSeconds