93 lines
2.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/********************************** (C) COPYRIGHT *******************************
* File Name : RTC.c
* Author : WCH
* Version : V1.2
* Date : 2022/01/18
* Description : RTC<54><43><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
* 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 <20><><EFBFBD><EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
*
* @param time - <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>.
*
* @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<54>жϴ<D0B6><CFB4><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 ϵͳ<CFB5><CDB3>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
*
* @param None.
*
* @return None.
*/
void HAL_TimeInit(void)
{
#if(CLK_OSC32K)
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG1;
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG2;
SAFEOPERATE;
R8_CK32K_CONFIG &= ~(RB_CLK_OSC32K_XT | RB_CLK_XT32K_PON);
R8_CK32K_CONFIG |= RB_CLK_INT32K_PON;
R8_SAFE_ACCESS_SIG = 0;
Lib_Calibration_LSI();
#else
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG1;
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG2;
SAFEOPERATE;
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 ******************************/