mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
93 lines
2.4 KiB
C
93 lines
2.4 KiB
C
/********************************** (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 ******************************/
|