?? mx21_rtc.h
字號:
/**********************************************************************
*
* (C) COPYRIGHT 2004 FREESCALE, INC.
* ALL RIGHTS RESERVED
*
*
* Group/Division: WMSG/MMDO
*
* Description:
*
* Related Specifications:
*
* Errata:
*
* File Name: MX21_RTC.h
* Revision Number: 0.1
* Author(s): Sharad Kumar
* Date created: 30Apr2004
* Revision History:
* Date Rev Description
* ---- --- -----------
* 30Apr04 0.1 First draft
*
**********************************************************************/
#ifndef _MX21_RTC_H
#define _MX21_RTC_H
#include "MX21_MemMap.h"
#include "MX21_Macros.h"
#include "MX21_DataTypes.h"
#include "MX21_Common.h"
/********************************************************************
M A C R O S
*********************************************************************/
#define RTC_SWR_SET 0x1 // software reset bit
#define RTC_ENABLE 0x1 // enable bit
#define RTC_DISABLE 0x0 // disable bit
// typdef for RTC interrupts
typedef enum
{
RTC_SAM7 = 15,
RTC_SAM6 = 14,
RTC_SAM5 = 13,
RTC_SAM4 = 12,
RTC_SAM3 = 11,
RTC_SAM2 = 10,
RTC_SAM1 = 9,
RTC_SAM0 = 8,
RTC_2HZ = 7,
RTC_HR = 5,
RTC_1HZ = 4,
RTC_DAY = 3,
RTC_ALM = 2,
RTC_MIN = 1,
RTC_SW = 0,
RTC_VEC = 32
} rtc_int_type;
/********************************************************************
R T C F U N C T I O N S
*********************************************************************/
//---------------------------------------------------
// issue a soft reset to the RTC by writing the
// SWR bit of the RTC control register to 1
//---------------------------------------------------
void
Rtc_SoftReset(void);
//---------------------------------------------------
// enable the RTC by writing a 1 to the EN
// bit of the RTC control register
//---------------------------------------------------
void
Rtc_Enable(void);
//---------------------------------------------------
// disable the RTC by writing a 0 to the EN
// bit of the RTC control register
//---------------------------------------------------
void
Rtc_Disable(void);
//---------------------------------------------------
// select the proper crystal frequency by
// writing to the XTL bits. Specify:
// 0x0, 0x60 for 32.768 Khz,
// 0x40 for 32 Khz
// 0x60 for 32.768 Khz
//---------------------------------------------------
void
Rtc_SetXTLBits(uint32_t); // bits specify the crystal
// frequency in Hertz
//---------------------------------------------------
// set time of day by specifying
// days, hours, mins, and seconds
//---------------------------------------------------
void
Rtc_SetTime(uint32_t, // days
uint32_t, // hours
uint32_t, // mins
uint32_t); // seconds
//---------------------------------------------------
// set the RTC stop watch counter
//---------------------------------------------------
void
Rtc_SetStpwch(uint32_t); // stop watch count
// in half minutes
//---------------------------------------------------
// set the alarm by specifying the
// time of alarm in days, hours,mins, seconds
// in a 32 bit register format
//---------------------------------------------------
void
Rtc_SetAlarm(uint32_t, // alarm day
uint32_t, // alarm hours
uint32_t, // alarm minutes
uint32_t); // alarm seconds
//---------------------------------------------------
// enable a selected interrupt type
//---------------------------------------------------
void
Rtc_EnableInterrupts(rtc_int_type, // interrupt type
uint32_t); // interrupt vector
//---------------------------------------------------
// disble a selected interrupt type
//---------------------------------------------------
void
Rtc_DisInterrupts(rtc_int_type, // interrupt type
uint32_t); // interrupt vector
//---------------------------------------------------
// check status of selected interrupt
//---------------------------------------------------
uint32_t // status, legal= {0,1}
Rtc_ChkIntStatus(rtc_int_type); // interrupt type
//---------------------------------------------------
// clear the selected interrupt
//---------------------------------------------------
void
Rtc_ClrIntStatus(rtc_int_type); // interrupt type
//---------------------------------------------------
// sample MX21 initialization routine
// to setup the real time clock.
//---------------------------------------------------
void Rtc_setup(uint32_t, // rtc day
uint32_t, // rtc hrs
uint32_t, // rtc mins
uint32_t, // rtc secs
uint32_t, // alarm day
uint32_t, // alarm hrs
uint32_t, // alram mins
uint32_t, // alarm seconds
uint32_t, // stop watch time
rtc_int_type, // rtc interrupt type
uint32_t // interrupt reg vector
);
//---------------------------------------------------
// in this example the RTC interrupt type is specified to be
// of type SAM0. If multiple interrupts need to be simultaneously
// enabled, chose an int of type RTC_VEC for interrupt type, and
// specify the 32 bit enable vector in the vector field.
//---------------------------------------------------
void
rtc_demo();
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -