mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-22 17:12:55 +08:00
90 lines
2.3 KiB
C
90 lines
2.3 KiB
C
|
/********************************** (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)
|
|||
|
R8_SAFE_ACCESS_SIG = 0x57;
|
|||
|
R8_SAFE_ACCESS_SIG = 0xa8;
|
|||
|
R8_CK32K_CONFIG &= ~(RB_CLK_OSC32K_XT | RB_CLK_XT32K_PON);
|
|||
|
R8_CK32K_CONFIG |= RB_CLK_INT32K_PON;
|
|||
|
Lib_Calibration_LSI();
|
|||
|
#else
|
|||
|
R8_SAFE_ACCESS_SIG = 0x57;
|
|||
|
R8_SAFE_ACCESS_SIG = 0xa8;
|
|||
|
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 ******************************/
|