stm32_ota/RTC/rtc.h

59 lines
1.7 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 "common.h"
/*****************************************/
/****************************************************************************
* RTC相关配置
****************************************************************************/
#define RTC_IRQn_PreemptionPriority 15 //RTC抢占优先级
#define RTC_IRQn_SubPriority 0 //RTC子优先级,使用FreeRTOS时没有子优先级设置为0即可
#define RTCAlarm_IRQn_PreemptionPriority 15 //RTCAlarm抢占优先级
#define RTCAlarm_IRQn_SubPriority 0 //RTCAlarm子优先级,使用FreeRTOS时没有子优先级设置为0即可
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 ;
typedef union uBytes19
{
Calendar calendar ;
uint8_t bytes[19] ;
}Calendar_u ;
extern Calendar_u uCalendar ;
extern RunResult RTC_Init(void) ; //初始化RTC,返回0,失败;1,成功;
extern uint8_t RTC_Get(Calendar_u *getCalendar) ; //更新时间
extern RunResult RTC_Set(Calendar_u *setCalendar); //设置时间
extern RunResult RTC_Alarm_Set(uint16_t syear, uint8_t smon, uint8_t sday, uint8_t hour, uint8_t min,uint8_t sec);
//extern void RTC_IRQHandler(void) ;
uint8_t CheckLeepYear(uint16_t year); //平年,闰年判断
uint8_t RTC_Get_Week(uint16_t year, uint8_t month, uint8_t day);
#endif