ShipCentralControl/Anjiehui7_DTU/User/rtc_wakeup.h

65 lines
2.1 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.

/*
*********************************************************************************************************
* IAR Development Kits
* on the
*
* M451
*
* Filename : rtc_wakeup.h
* Version : V1.00
* Programmer(s) : Qian Xianghong
*********************************************************************************************************
*/
#ifndef USER_RTC_WAKEUP_PRESENT
#define USER_RTC_WAKEUP_PRESENT
#include "type.h"
#pragma pack(push, 1)
// 本结构从Nuvoton芯片库移植而来
typedef struct {
uint32_t u32Year; /*!< Year value */
uint32_t u32Month; /*!< Month value */
uint32_t u32Day; /*!< Day value */
uint32_t u32DayOfWeek; /*!< Day of week value */
uint32_t u32Hour; /*!< Hour value */
uint32_t u32Minute; /*!< Minute value */
uint32_t u32Second; /*!< Second value */
uint32_t u32TimeScale; /*!< 12-Hour, 24-Hour */
uint32_t u32AmPm; /*!< Only Time Scale select 12-hr used */
} S_RTC_TIME_DATA_T;
#define RTC_YEAR2000 2000 /*!< RTC Reference */
#define RTC_CLOCK_12 0 /*!< RTC 12 Hour */
#define RTC_CLOCK_24 1 /*!< RTC 24 Hour */
#define RTC_SUNDAY ((uint32_t) 0x00000000) /*!< Day of week is sunday */
// 获取日期时间输出格式为Nuvoton芯片格式
void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sRTC);
#pragma pack(pop)
// RTC初始时间固定为2016-01-01 00:00:00
#define INITIAL_YEAR 2016
// 实际启动时间和INITIAL_YEAR相差的秒数当GPS定位或GPRS连接基站以后设置
extern volatile uint32_t RTC_offsetSeconds;
void Wakeup_Open();
// 计算某月的天数
uint16_t get_month_days(uint16_t year, uint8_t month);
// 计算从某年开始以来经过的秒数
uint32_t Calc_SecondsFromYear(uint16_t startYear, uint16_t year, uint8_t mon, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec);
// 设定下次闹钟唤醒时间
void Wakeup_SetAlarm();
void Wakeup_SetAlarm_B();
// 将从INITIAL_YEAR开始的描述转换成年月日
void Wakeup_CalcUTCTime(uint32_t totalSeconds, S_RTC_TIME_DATA_T *pRTC);
#endif