2022-03-26 20:51:40 +08:00
|
|
|
|
/********************************** (C) COPYRIGHT *******************************
|
|
|
|
|
* File Name : RTC.c
|
|
|
|
|
* Author : WCH
|
|
|
|
|
* Version : V1.2
|
|
|
|
|
* Date : 2022/01/18
|
|
|
|
|
* Description : RTC<EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
/* ͷ<>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
#include "HAL.h"
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
|
* CONSTANTS
|
|
|
|
|
*/
|
|
|
|
|
#define RTC_INIT_TIME_HOUR 0
|
|
|
|
|
#define RTC_INIT_TIME_MINUTE 0
|
|
|
|
|
#define RTC_INIT_TIME_SECEND 0
|
|
|
|
|
|
|
|
|
|
/***************************************************
|
|
|
|
|
* Global variables
|
|
|
|
|
*/
|
|
|
|
|
volatile uint32_t RTCTigFlag;
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
* @fn RTC_SetTignTime
|
|
|
|
|
*
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>RTC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
|
*
|
|
|
|
|
* @param time - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>.
|
|
|
|
|
*
|
|
|
|
|
* @return None.
|
|
|
|
|
*/
|
|
|
|
|
void RTC_SetTignTime(uint32_t time)
|
|
|
|
|
{
|
|
|
|
|
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG1;
|
|
|
|
|
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG2;
|
|
|
|
|
SAFEOPERATE;
|
|
|
|
|
R32_RTC_TRIG = time;
|
|
|
|
|
RTCTigFlag = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
* @fn RTC_IRQHandler
|
|
|
|
|
*
|
|
|
|
|
* @brief RTC<EFBFBD>жϴ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*
|
|
|
|
|
* @param None.
|
|
|
|
|
*
|
|
|
|
|
* @return None.
|
|
|
|
|
*/
|
|
|
|
|
__INTERRUPT
|
|
|
|
|
__HIGH_CODE
|
|
|
|
|
void RTC_IRQHandler(void)
|
|
|
|
|
{
|
|
|
|
|
R8_RTC_FLAG_CTRL = (RB_RTC_TMR_CLR | RB_RTC_TRIG_CLR);
|
|
|
|
|
RTCTigFlag = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
* @fn HAL_Time0Init
|
|
|
|
|
*
|
|
|
|
|
* @brief ϵͳ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
*
|
|
|
|
|
* @param None.
|
|
|
|
|
*
|
|
|
|
|
* @return None.
|
|
|
|
|
*/
|
|
|
|
|
void HAL_TimeInit(void)
|
|
|
|
|
{
|
|
|
|
|
#if(CLK_OSC32K)
|
2022-05-23 17:05:37 +08:00
|
|
|
|
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG1;
|
|
|
|
|
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG2;
|
|
|
|
|
SAFEOPERATE;
|
2022-03-26 20:51:40 +08:00
|
|
|
|
R8_CK32K_CONFIG &= ~(RB_CLK_OSC32K_XT | RB_CLK_XT32K_PON);
|
|
|
|
|
R8_CK32K_CONFIG |= RB_CLK_INT32K_PON;
|
2022-05-23 17:05:37 +08:00
|
|
|
|
R8_SAFE_ACCESS_SIG = 0;
|
2022-03-26 20:51:40 +08:00
|
|
|
|
Lib_Calibration_LSI();
|
|
|
|
|
#else
|
2022-05-23 17:05:37 +08:00
|
|
|
|
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG1;
|
|
|
|
|
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG2;
|
|
|
|
|
SAFEOPERATE;
|
2022-03-26 20:51:40 +08:00
|
|
|
|
R8_CK32K_CONFIG |= RB_CLK_OSC32K_XT | RB_CLK_INT32K_PON | RB_CLK_XT32K_PON;
|
|
|
|
|
R8_SAFE_ACCESS_SIG = 0;
|
|
|
|
|
#endif
|
|
|
|
|
RTC_InitTime(2020, 1, 1, 0, 0, 0); //RTCʱ<43>ӳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ǰʱ<C7B0><CAB1>
|
|
|
|
|
TMOS_TimerInit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************** endfile @ time ******************************/
|