2022-10-19 22:44:15 +08:00

414 lines
17 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.

/******************************************************************************************************************************************
* <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: SWM320_rtc.c
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: SWM320<32><30>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD>RTC<54><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>: http://www.synwit.com.cn/e/tool/gbook/?bid=1
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
* <20><EFBFBD><E6B1BE><EFBFBD><EFBFBD>: V1.1.0 2017<31><37>10<31><30>25<32><35>
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼:
*
*
*******************************************************************************************************************************************
* @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, SYNWIT 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 CONN-
* -ECTION WITH THEIR PRODUCTS.
*
* COPYRIGHT 2012 Synwit Technology
*******************************************************************************************************************************************/
#include "SWM320.h"
#include "SWM320_rtc.h"
static uint32_t calcWeekDay(uint32_t year, uint32_t month, uint32_t date);
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_Init()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: RTC<54><43>ʼ<EFBFBD><CABC>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>RTC
* RTC_InitStructure * initStruct <20><><EFBFBD><EFBFBD>RTC<54><43><EFBFBD><EFBFBD><EFBFBD>趨ֵ<E8B6A8>Ľṹ<C4BD><E1B9B9>
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_Init(RTC_TypeDef * RTCx, RTC_InitStructure * initStruct)
{
SYS->CLKEN |= (1 << SYS_CLKEN_RTCBKP_Pos);
SYS->LRCCR &= ~(1 << SYS_LRCCR_OFF_Pos); //RTCʹ<43><CAB9>32KHz RCʱ<43><CAB1>
SYS->CLKEN |= (1 << SYS_CLKEN_RTC_Pos) |
((uint32_t)1 << SYS_CLKEN_ALIVE_Pos);
RTC_Stop(RTCx);
while(RTCx->CFGABLE == 0);
RTCx->MINSEC = (initStruct->Second << RTC_MINSEC_SEC_Pos) |
(initStruct->Minute << RTC_MINSEC_MIN_Pos);
RTCx->DATHUR = (initStruct->Hour << RTC_DATHUR_HOUR_Pos) |
(initStruct->Date << RTC_DATHUR_DATE_Pos);
RTCx->MONDAY = (calcWeekDay(initStruct->Year, initStruct->Month, initStruct->Date) << RTC_MONDAY_DAY_Pos) |
(initStruct->Month << RTC_MONDAY_MON_Pos);
RTCx->YEAR = initStruct->Year - 1901;
RTCx->LOAD = 1 << RTC_LOAD_TIME_Pos;
RTCx->IF = 0x1F;
RTCx->IE = (initStruct->SecondIEn << RTC_IE_SEC_Pos) |
(initStruct->MinuteIEn << RTC_IE_MIN_Pos);
if(initStruct->SecondIEn | initStruct->MinuteIEn)
{
NVIC_EnableIRQ(RTC_IRQn);
}
else
{
NVIC_DisableIRQ(RTC_IRQn);
}
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_Start()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD>RTC
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_Start(RTC_TypeDef * RTCx)
{
RTCx->EN = 1;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_Stop()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: ֹͣRTC
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_Stop(RTC_TypeDef * RTCx)
{
RTCx->EN = 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_GetDateTime()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>RTC
* RTC_DateTime * dateTime <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A1A2><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ָ<EFBFBD><D6B8><EFBFBD>Ľṹ<C4BD><E1B9B9>
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_GetDateTime(RTC_TypeDef * RTCx, RTC_DateTime * dateTime)
{
dateTime->Year = RTCx->YEAR + 1901;
dateTime->Month = (RTCx->MONDAY & RTC_MONDAY_MON_Msk) >> RTC_MONDAY_MON_Pos;
dateTime->Date = (RTCx->DATHUR & RTC_DATHUR_DATE_Msk) >> RTC_DATHUR_DATE_Pos;
dateTime->Day = 1 << ((RTCx->MONDAY & RTC_MONDAY_DAY_Msk) >> RTC_MONDAY_DAY_Pos);
dateTime->Hour = (RTCx->DATHUR & RTC_DATHUR_HOUR_Msk) >> RTC_DATHUR_HOUR_Pos;
dateTime->Minute = (RTCx->MINSEC & RTC_MINSEC_MIN_Msk) >> RTC_MINSEC_MIN_Pos;
dateTime->Second = (RTCx->MINSEC & RTC_MINSEC_SEC_Msk) >> RTC_MINSEC_SEC_Pos;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_AlarmSetup()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: RTC<54><43><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>RTC
* RTC_AlarmStructure * alarmStruct <20><><EFBFBD><EFBFBD>RTC<54><43><EFBFBD><EFBFBD><EFBFBD>趨ֵ<E8B6A8>Ľṹ<C4BD><E1B9B9>
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_AlarmSetup(RTC_TypeDef * RTCx, RTC_AlarmStructure * alarmStruct)
{
while(RTCx->CFGABLE == 0);
RTCx->MINSECAL = (alarmStruct->Second << RTC_MINSECAL_SEC_Pos) |
(alarmStruct->Minute << RTC_MINSECAL_MIN_Pos);
RTCx->DAYHURAL = (alarmStruct->Hour << RTC_DAYHURAL_HOUR_Pos) |
(alarmStruct->Days << RTC_DAYHURAL_SUN_Pos);
RTCx->LOAD = 1 << RTC_LOAD_ALARM_Pos;
while(RTCx->LOAD & RTC_LOAD_ALARM_Msk);
RTCx->IF = (1 << RTC_IF_ALARM_Pos);
RTCx->IE &= ~RTC_IE_ALARM_Msk;
RTCx->IE |= (alarmStruct->AlarmIEn << RTC_IE_ALARM_Pos);
if(alarmStruct->AlarmIEn) NVIC_EnableIRQ(RTC_IRQn);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: calcWeekDay()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>¡<EFBFBD><C2A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>
* <20><> <20><>: uint32_t year <09><>
* uint32_t month <09><>
* uint32_t date <09><>
* <20><> <20><>: uint32_t 0 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD>һ ... ... 6 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
static uint32_t calcWeekDay(uint32_t year, uint32_t month, uint32_t date)
{
uint32_t i, cnt = 0;
const uint32_t daysOfMonth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for(i = 1; i < month; i++) cnt += daysOfMonth[i];
cnt += date;
if((year%4 == 0) && ((year%100 != 0) || (year%400 == 0)) && (month >= 3)) cnt += 1;
cnt += (year - 1901) * 365;
for(i = 1901; i < year; i++)
{
if((i%4 == 0) && ((i%100 != 0) || (i%400 == 0))) cnt += 1;
}
return (cnt+1) % 7;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntSecondEn()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntSecondEn(RTC_TypeDef * RTCx)
{
RTCx->IE |= (1 << RTC_IE_SEC_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntSecondDis()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>жϽ<D0B6>ֹ
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntSecondDis(RTC_TypeDef * RTCx)
{
RTCx->IE &= ~(1 << RTC_IE_SEC_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntSecondClr()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntSecondClr(RTC_TypeDef * RTCx)
{
RTCx->IF = (1 << RTC_IF_SEC_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntSecondStat()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>ж<EFBFBD>״̬
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: uint32_t 1 <20><><EFBFBD>жϷ<D0B6><CFB7><EFBFBD> 0 <20><><EFBFBD>ж<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t RTC_IntSecondStat(RTC_TypeDef * RTCx)
{
return (RTCx->IF & RTC_IF_SEC_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntMinuteEn()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntMinuteEn(RTC_TypeDef * RTCx)
{
RTCx->IE |= (1 << RTC_IE_MIN_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntMinuteDis()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>жϽ<D0B6>ֹ
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntMinuteDis(RTC_TypeDef * RTCx)
{
RTCx->IE &= ~(1 << RTC_IE_MIN_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntMinuteClr()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntMinuteClr(RTC_TypeDef * RTCx)
{
RTCx->IF = (1 << RTC_IF_MIN_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntMinuteStat()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>ж<EFBFBD>״̬
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: uint32_t 1 <20><><EFBFBD>жϷ<D0B6><CFB7><EFBFBD> 0 <20><><EFBFBD>ж<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t RTC_IntMinuteStat(RTC_TypeDef * RTCx)
{
return (RTCx->IF & RTC_IF_MIN_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntHourEn()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: ʱ<>ж<EFBFBD>ʹ<EFBFBD><CAB9>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntHourEn(RTC_TypeDef * RTCx)
{
RTCx->IE |= (1 << RTC_IE_HOUR_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntHourDis()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: ʱ<>жϽ<D0B6>ֹ
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntHourDis(RTC_TypeDef * RTCx)
{
RTCx->IE &= ~(1 << RTC_IE_HOUR_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntHourClr()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: ʱ<>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntHourClr(RTC_TypeDef * RTCx)
{
RTCx->IF = (1 << RTC_IF_HOUR_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntHourStat()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: ʱ<>ж<EFBFBD>״̬
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: uint32_t 1 ʱ<>жϷ<D0B6><CFB7><EFBFBD> 0 ʱ<>ж<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t RTC_IntHourStat(RTC_TypeDef * RTCx)
{
return (RTCx->IF & RTC_IF_HOUR_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntDateEn()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntDateEn(RTC_TypeDef * RTCx)
{
RTCx->IE |= (1 << RTC_IE_DATE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntDateDis()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>жϽ<D0B6>ֹ
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntDateDis(RTC_TypeDef * RTCx)
{
RTCx->IE &= ~(1 << RTC_IE_DATE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntDateClr()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntDateClr(RTC_TypeDef * RTCx)
{
RTCx->IF = (1 << RTC_IF_DATE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntDateStat()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>ж<EFBFBD>״̬
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: uint32_t 1 <20><><EFBFBD>жϷ<D0B6><CFB7><EFBFBD> 0 <20><><EFBFBD>ж<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t RTC_IntDateStat(RTC_TypeDef * RTCx)
{
return (RTCx->IF & RTC_IF_DATE_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntAlarmEn()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntAlarmEn(RTC_TypeDef * RTCx)
{
RTCx->IE |= (1 << RTC_IE_ALARM_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntAlarmDis()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD><EFBFBD>жϽ<D0B6>ֹ
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntAlarmDis(RTC_TypeDef * RTCx)
{
RTCx->IE &= ~(1 << RTC_IE_ALARM_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntAlarmClr()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void RTC_IntAlarmClr(RTC_TypeDef * RTCx)
{
RTCx->IF = (1 << RTC_IF_ALARM_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RTC_IntAlarmStat()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>״̬
* <20><> <20><>: RTC_TypeDef * RTCx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>RTC
* <20><> <20><>: uint32_t 1 <20><><EFBFBD><EFBFBD><EFBFBD>жϷ<D0B6><CFB7><EFBFBD> 0 <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t RTC_IntAlarmStat(RTC_TypeDef * RTCx)
{
return (RTCx->IF & RTC_IF_ALARM_Msk) ? 1 : 0;
}