132 lines
3.6 KiB
C
132 lines
3.6 KiB
C
/**
|
|
******************************************************************************
|
|
* @file brtc.h
|
|
* @author AMG Energy Solution Team
|
|
* @version V1.0.0
|
|
* @date 07-Feb-2022
|
|
* @brief This file provides all the header of the board realtime clock.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
|
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
|
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
|
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
|
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
|
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
|
*
|
|
* <h2><center>© COPYRIGHT 2022 AMG</center></h2>
|
|
******************************************************************************
|
|
*/
|
|
|
|
/** @addtogroup mBMS2
|
|
* @{
|
|
*/
|
|
|
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
#ifndef _BRTC_H_
|
|
#define _BRTC_H_
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "hc32_ddl.h"
|
|
|
|
/* Exported types ------------------------------------------------------------*/
|
|
typedef struct
|
|
{
|
|
uint32_t sub_sec;
|
|
uint16_t year;
|
|
uint8_t month;
|
|
uint8_t date;
|
|
uint8_t wday; /* week */
|
|
uint8_t hour;
|
|
uint8_t min;
|
|
uint8_t sec;
|
|
} _TTIME, *_PTIME;
|
|
|
|
/*
|
|
Field Octets Contents Range
|
|
1 1-2 year 0..65536
|
|
1 3 month 1..12
|
|
1 4 day 1..31
|
|
1 5 hour 0..23
|
|
1 6 minutes 0..59
|
|
1 7 seconds (use 60 for leap-second) 0..60
|
|
1 8 deci-seconds 0..9
|
|
1 9 direction from UTC '+' / '-'
|
|
1 10 hours from UTC 0..13
|
|
1 11 minutes from UTC 0..59
|
|
*/
|
|
typedef struct
|
|
{
|
|
uint16_t year;
|
|
uint8_t month;
|
|
uint8_t day;
|
|
uint8_t hour;
|
|
uint8_t minutes;
|
|
uint8_t seconds;
|
|
uint8_t deci_seconds;
|
|
uint8_t UTC_direction; // '+' / '-'
|
|
uint8_t UTC_hours;
|
|
uint8_t UTC_minutes;
|
|
} DateAndTime;
|
|
|
|
/* Exported constants --------------------------------------------------------*/
|
|
#define RTC_TMR_PERIOD_TIME 10 // 10ms
|
|
#define WARMING_UP_TIME 10000 // 10sec
|
|
|
|
/* Exported macro ------------------------------------------------------------*/
|
|
/* Exported functions ------------------------------------------------------- */
|
|
void InitTimer(void);
|
|
|
|
void AppTaskRTC(void);
|
|
|
|
void SYSCLKConfig_STOP(void);
|
|
|
|
void ChangeToStopMode(void);
|
|
|
|
int rtc_gettime (_TTIME* rtc);
|
|
|
|
uint32_t GetBuildTimeStamp(void);
|
|
int8_t Set_Time(uint8_t *time_str);
|
|
void Get_TimeStr(uint8_t *text);
|
|
|
|
uint8_t GET_RTC_DATA(uint16_t addr);
|
|
|
|
void Get_Time(void);
|
|
|
|
void Time_Update(void *ptmr, void *parg);
|
|
uint32_t Get_Local_Time(void);
|
|
void Set_Local_Time(uint32_t localtime);
|
|
|
|
uint16_t GetTimeYear(void);
|
|
uint16_t GetTimeMonth(void);
|
|
uint16_t GetTimeDate(void);
|
|
uint16_t GetTimeHour(void);
|
|
uint16_t GetTimeMinute(void);
|
|
uint16_t GetTimeSec(void);
|
|
uint16_t GetTimeSubSec(void);
|
|
uint32_t GetTimeStamp(void);
|
|
|
|
uint32_t GetLastRebootReason(void);
|
|
|
|
void RTC_TimeSet(_TTIME *aTIME);
|
|
|
|
void *GetDateAndTimeEx(void);
|
|
|
|
void ODisplayDateTime(uint8_t p);
|
|
void SDisplayDateTime(uint8_t p);
|
|
|
|
uint32_t GetWarmingUp(void);
|
|
|
|
extern _TTIME DEVICE_TIME;
|
|
|
|
extern uint8_t bak_sec;
|
|
|
|
extern uint32_t UnixTimeStamp, BakUnixTimeStamp;
|
|
extern uint32_t BuildTimeStamp;
|
|
extern uint32_t OptimeStamp, disOptimeStamp;
|
|
|
|
#endif
|
|
|
|
/*******************(C)COPYRIGHT 2022 AMG ********************END OF FILE******/
|