📄 lpc_rtc.h
字号:
#ifndef __LPC_RTC_H
#define __LPC_RTC_H
/***********************************************************************
* BU MMS China, Philips Semiconductor Software Support
* Embest info&Tech Co. Software Support
*---------------------------------------------------------------------------
* The software is delivered "AS IS" without warranty or condition of any
* kind, either express, implied or statutory. Everybody can use it as
* it is opened and without copyright. We will not take any law responsibility
* for any problem produced by using this software.
*---------------------------------------------------------------------------
* File name: LPC_Rtc.h
* Description: Define RTC structure and relative micro
*
* History:
* 1. Date: Nov 20, 2004
* Author: Shawn Zhang
* Description: Create
*
* $Revision: 1.0 $
**********************************************************************/
#include "LPC_Base.h"
#include "LPC_Type.h"
#include "LPC_Lib.h"
#include "LPC_SysControl.h"
#define RTC_CountPerSec 32768
#define RTC_YEARMIN 1901
#define RTC_YEARMAX 2099
/* Base day (1901.1.1 DOW = 2), which is used for day calculate */
#define RTC_BASEYEAR 1901
#define RTC_BASEMONTH 1
#define RTC_BASEDAY 1
#define RTC_BASEDOW 2
/* RTC Interrupt location register bit descriptions */
#define ILR_CIF_BIT 0
#define ILR_ALF_BIT 1
/* RTC Clock control register bit descriptions */
#define CCR_CLKEN_BIT 0
#define CCR_CTCRST_BIT 1
/* RTC Increment Interrupt Type */
#define IncIntType_SEC 0x1
#define IncIntType_MIN 0x2
#define IncIntType_HOUR 0x4
#define IncIntType_DAY 0x8
#define IncIntType_MON 0x40
#define IncIntType_YEAR 0x80
#define IncIntType_DOW 0x10
#define IncIntType_DOY 0x20
/* RTC Alarm Interrupt Type */
#define AlarmIntType_SEC 0x1
#define AlarmIntType_MIN 0x2
#define AlarmIntType_HOUR 0x4
#define AlarmIntType_DAY 0x8
#define AlarmIntType_MON 0x40
#define AlarmIntType_YEAR 0x80
#define AlarmIntType_DOW 0x10
#define AlarmIntType_DOY 0x20
/* RTC interrupt type */
#define RTCIncrementInt 0x1
#define RTCAlarmInt 0x2
#define RTCALLInt 0x3
typedef struct {
lpc_uint16 year; // year value
lpc_uint8 month; // month value
lpc_uint8 day; // day value
/* the below member is used in get-operation */
lpc_uint8 DOW; // Day of week
lpc_uint8 DOY; // Day of year
} LPC_Rtc_Date_t;
typedef struct {
lpc_uint8 hour; // hour value
lpc_uint8 minute; // minute value
lpc_uint8 second; // second value
} LPC_Rtc_Time_t;
typedef struct {
lpc_uint16 year; // year value
lpc_uint8 month; // month value
lpc_uint8 day; // day value
lpc_uint8 hour; // hour value
lpc_uint8 minute; // minute value
lpc_uint8 second; // second value
/* the below member is used in get-operation */
lpc_uint8 DOW; // Day of week
lpc_uint8 DOY; // Day of year
} LPC_Rtc_DateTime_t;
/* Declare functions */
void RTC_Enable(void);
void RTC_Disable(void);
int RTC_Init(void);
#if (RTC_SetDate_EN == 1)
int RTC_SetDate (LPC_Rtc_Date_t *pDate);
#endif
#if (RTC_SetTime_EN == 1)
int RTC_SetTime (LPC_Rtc_Time_t *pTime);
#endif
#if (RTC_SetDateTime_EN == 1)
int RTC_SetDateTime (LPC_Rtc_DateTime_t *pDateTime);
#endif
#if (RTC_GetDate_EN == 1)
void RTC_GetDate (LPC_Rtc_Date_t *pDate);
#endif
#if (RTC_GetTime_EN == 1)
void RTC_GetTime (LPC_Rtc_Time_t *pTime);
#endif
#if (RTC_GetDateTime_EN == 1)
void RTC_GetDateTime (LPC_Rtc_DateTime_t *pDateTime);
#endif
#if (RTC_SetIncInt_EN == 1)
void RTC_SetIncInt (lpc_uint8 IncIntType);
#endif
#if (RTC_DisableIncInt_EN == 1)
void RTC_DisableIncInt(void);
#endif
#if (RTC_SetAlarmInt_EN == 1)
void RTC_SetAlarmInt (lpc_uint8 AlarmIntType);
#endif
#if (RTC_DisableAlarmInt_EN == 1)
void RTC_DisableAlarmInt(void);
#endif
#if (RTC_SetAlarmDateTime_EN == 1)
int RTC_SetAlarmDateTime (LPC_Rtc_DateTime_t *pDateTime);
#endif
#if (RTC_ClearInt_EN == 1)
int RTC_ClearInt(unsigned long IntType);
#endif
#if (RTC_CheckIntType_EN == 1)
unsigned long RTC_CheckIntType(void);
#endif
bool IsValidDay (lpc_int16 year, lpc_int8 month, lpc_int8 day);
#if (FormatDate_EN == 1)
void FormatDate (int Type, LPC_Rtc_Date_t *pDate, char *s);
#endif
#if (FormatTime_EN == 1)
void FormatTime (int Type, LPC_Rtc_Time_t *pTime, char *s);
#endif
#if (FormatDateTime_EN == 1)
void FormatDateTime (int Type, LPC_Rtc_DateTime_t *pDateTime, char *s);
#endif
#endif // __LPC_RTC_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -