stm32_ota/SYSTEM/RTC/rtc.h

70 lines
2.4 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef __RTC_H
#define __RTC_H
#include "stm32f10x.h"
#include "stm32f10x_it.h"
#include "syslib.h"
/*****************************************
*自定义数据类型
****************************************/
typedef struct //2017-09-21 14:40:35
{ //公历日月年周
vu8 w_year[4] ; //"2017"
vu8 dash1 ; //"-"
vu8 w_month[2] ; //"09"
vu8 dash2 ; //"-"
vu8 w_date[2] ; //“21”
vu8 spacing ; //" "
vu8 hour[2] ; //"14"
vu8 colon1 ; //":"
vu8 min[2] ; //"40"
vu8 colon2 ; //":"
vu8 sec[2] ; //"35"
//vu8 week ;
}Calendar_s ; //Calendar_s结构体纪录实时时间
#define CALENDAR_LEN sizeof(Calendar_s) //Calendar_s结构体字节长度
typedef union uBytes19
{
Calendar_s sCalendar ;
uint8_t bytes[CALENDAR_LEN] ;
}Calendar_u ; //Calendar_u共用体纪录实时时间
typedef void (*RTCFP)(void) ; //定义函数指针类型变量
/****************************************************************************/
/*****************************************
*供外部使用的常变量
****************************************/
extern Calendar_u uCalendar ;
/********************************************************************************
*供内部使用的函数声明
*********************************************************************************/
void RTC_IRQHandler(void) ; //RTC中断处理函数
uint8_t CheckLeepYear(uint16_t year) ; //平年,闰年判断
uint8_t RTC_Get_Week(uint16_t year, uint8_t month, uint8_t day) ; //根据日期获取星期
void Rtc_Hook(uint16_t rtcIt) ; //RTC中断回调函数钩子函数
void Rtc_Sec_Callback(void) ; //RTC 秒中断回调函数
/********************************************************************************
*对外接口函数声明
*********************************************************************************/
extern RTCFP Rtc_RegHookCallback(uint16_t rtcIt, RTCFP pCallback) ; //RTC中断回调函数注册函数
extern RunResult RTC_Init(IntPriority_e ePriority) ; //初始化RTC
extern RunResult RTC_Get(Calendar_u *getCalendar) ; //更新时间
extern RunResult RTC_Set(Calendar_u *setCalendar); //设置时间
extern RunResult RTC_Alarm_Set(Calendar_u *setCalendar) ; //设置RTC闹钟时间点
#endif