rtc.h

来自「arm(str710)usb功能的实现」· C头文件 代码 · 共 194 行

H
194
字号
/****************************************Copyright (c)**************************************************
**                                      
**                                          STR710 development team
**                                          
**
**                                 
**
**--------------文件信息--------------------------------------------------------------------------------
** 文 件 名: rtc.h
** 创 建 人: lhl
** 创建日期: 2006年5月10日
** 描    述: 该文件包含了所有RTC功能函数原型与所需要的常量
**
**--------------历史版本--------------------------------------------------------------------------------
** 创 建 人: lhl
** 版    本: V1.0
** 日   期: 2006年5月10日
** 描   述: 原始版本
**
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#ifndef __RTC_H__
#define __RTC_H__


#include "types.h"
#include "str710.h"
#include "cpu_cfg.h"

#if EN_ARM_RTC > 0		//决定是否编译该文件

/************************************** 宏定义,常量定义 ******************************************/


#define RTC_RTOFF_Mask 		0x0020		//detect the status about RT reg
#define RTC_RTCNF_Mask 		0x0010		//make RT unit enter into config mode 
#define RTC_RTGEN_Mask 		0x0008		
#define RTC_RTOWEN_Mask 		0x0004
#define RTC_RTAEN_Mask 		0x0002
#define RTC_RTSEN_Mask			0x0001

/************************************** 结构体类型定义  ******************************************/

/*中断序号定义*/
typedef enum
{
RTC_SEC_INT	=	 0,
RTC_ALM_INT,
RTC_OWEN_INT,
RTC_GLB_INT
}Rtc_INT_TYPE_T;

/*时间类型定义,UNIX时间格式*/
typedef UINT32 Time_T;

/*时间类型定义*/
typedef struct
{
UINT16 year;
UINT8  month;
UINT8  day;
UINT8  hour;
UINT8  minute;
UINT8  second;
}RTC_Time_T;

/*RTC定时器中断回调函数类型*/
typedef void (*RTC_CALLBACK_T)(void *para);

/*存储回调函数和参数*/
typedef struct 
{
RTC_CALLBACK_T rtc_callback;
void * callback_para;
}RTC_CB_Save_T;
/********************************** 全局外部函数原型声明 *****************************************/

void RTC_Init(UINT32 prescale);
void RTC_SetTime(Time_T time);
Time_T RTC_GetTime(void);
void RTC_Time2String(Time_T time,RTC_Time_T *rtc_time);
Time_T RTC_String2Time(RTC_Time_T *rtc_time);
void RTC_SetAlarm(RTC_Time_T *rtc_time,RTC_CALLBACK_T rtc_cb);
void RTC_ClrAlarm(void);
void RTC_SetSecInt(RTC_CALLBACK_T rtc_cb);
void RTC_ClrSecInt(void);
void RTC_SetOverflowInt(RTC_CALLBACK_T rtc_cb);
void RTC_ClrOverflowInt(void);
void RTC_InterruptEnter(void);

#endif
/***************************************** end of file *******************************************/
/****************************************Copyright (c)**************************************************
**                                      
**                                          STR710 development team
**                                          
**
**                                 
**
**--------------文件信息--------------------------------------------------------------------------------
** 文 件 名: rtc.h
** 创 建 人: lhl
** 创建日期: 2006年5月10日
** 描    述: 该文件包含了所有RTC功能函数原型与所需要的常量
**
**--------------历史版本--------------------------------------------------------------------------------
** 创 建 人: lhl
** 版    本: V1.0
** 日   期: 2006年5月10日
** 描   述: 原始版本
**
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#ifndef __RTC_H__
#define __RTC_H__


#include "cpu_cfg.h"

    #ifdef __cplusplus
    extern "C" {
    #endif


/************************************** 宏定义,常量定义 ******************************************/


#define RTC_RTOFF_Mask 		0x0020		//detect the status about RT reg
#define RTC_RTCNF_Mask 		0x0010		//make RT unit enter into config mode 
#define RTC_RTGEN_Mask 		0x0008		
#define RTC_RTOWEN_Mask 		0x0004
#define RTC_RTAEN_Mask 		0x0002
#define RTC_RTSEN_Mask			0x0001

/************************************** 结构体类型定义  ******************************************/

/*中断序号定义*/
typedef enum
{
RTC_SEC_INT	=	 0,
RTC_ALM_INT,
RTC_OWEN_INT,
RTC_GLB_INT
}Rtc_INT_TYPE_T;

/*时间类型定义,UNIX时间格式*/
typedef UINT32 Time_T;

/*时间类型定义*/
typedef struct
{
UINT16 year;
UINT8  month;
UINT8  day;
UINT8  hour;
UINT8  minute;
UINT8  second;
}RTC_Time_T;

/*RTC定时器中断回调函数类型*/
typedef void (*RTC_CALLBACK_T)(void *para);

/*存储回调函数和参数*/
typedef struct 
{
RTC_CALLBACK_T rtc_callback;
void * callback_para;
}RTC_CB_Save_T;
/********************************** 全局外部函数原型声明 *****************************************/

void RTC_Init(UINT32 prescale);
void RTC_SetTime(Time_T time);
Time_T RTC_GetTime(void);
void RTC_Time2String(Time_T time,RTC_Time_T *rtc_time);
Time_T RTC_String2Time(RTC_Time_T *rtc_time);
void RTC_SetAlarm(RTC_Time_T *rtc_time,RTC_CALLBACK_T rtc_cb);
void RTC_ClrAlarm(void);
void RTC_SetSecInt(RTC_CALLBACK_T rtc_cb);
void RTC_ClrSecInt(void);
void RTC_SetOverflowInt(RTC_CALLBACK_T rtc_cb);
void RTC_ClrOverflowInt(void);
void RTC_InterruptEnter(void);

#endif	//EN_ARM_RTC > 0	


    #ifdef __cplusplus
    }
    #endif


#endif
/***************************************** end of file *******************************************/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?