📄 csl_rtcaux.h
字号:
/** ============================================================================
* @file csl_rtcAux.h
*
* @path $(CSLPATH)\arm\rtc\src
*
* @desc API Auxilary header file for Real Time Clock CSL.
*
*/
/* ============================================================================
* Copyright (c) Texas Instruments Inc 2002, 2003, 2004
*
* Use of this software is controlled by the terms and conditions found in the
* license agreement under which this software has been supplied.
* ===========================================================================
*/
/* @(#) PSP/CSL 3.00.01.00[5912] (2004-05-27) */
/* =============================================================================
* Revision History
* ===============
* 16-Jun-2004 Ru File Created.
*
* =============================================================================
*/
#ifndef _CSL_RTCAUX_H_
#define _CSL_RTCAUX_H_
/** Inline Functions */
#include<csl_rtc.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Status Query Functions of RTC
*/
/** Macros for events in RTC Status Register MSB */
#define CSL_RTC_STATUS_EVENT_MSB 5
/** Macros for events in RTC Status Register LSB */
#define CSL_RTC_STATUS_EVENT_LSB 2
/** Macros for interrupts in RTC Interrupt Register MSB */
#define CSL_RTC_INTERRUPTS_PERIOD_MSB 1
/** Macros for interrupts in RTC Interrupt Register LSB */
#define CSL_RTC_INTERRUPTS_PERIOD_LSB 0
/** ============================================================================
* @n@b CSL_rtcIsRtcDisabled
*
* @b Description
* @n This function query's whether the RTC is disabled or not.
*
* @b Arguments
* @verbatim
hRtc Handle to the RTC instance
@endverbatim
*
* <b> Return Value </b> Bool
*
* @li TRUE - If RTC is disabled.
*
* @li FALSE - If RTC is enabled.
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Returns the status of the RTC_Disable bit in the RTC Control Register
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
Bool isDisabled;
isDisabled = CSL_rtcIsRtcDisabled (hRtc);
@endverbatim
* ===========================================================================
*/
static inline
Bool CSL_rtcIsRtcDisabled (
CSL_RtcHandle hRtc
)
{
return (Bool) CSL_FEXT(hRtc->regs->RTC_CTRL_REG, \
RTC_RTC_CTRL_REG_RTC_DISABLE);
}
/** ============================================================================
* @n@b CSL_rtcGetTime
*
* @b Description
* @n This function query's the time structure which contains time and
* calendar register values.
*
* @b Arguments
* @verbatim
hRtc Handle to the RTC instance
@endverbatim
*
* <b> Return Value </b> CSL_RtcHourMode
*
* @li The time structure populated with the values of Time and
* calendar Register.
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Returns the time register information of RTC.
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
CSL_RtcCalTime time;
time = CSL_rtcGetTime (hRtc);
@endverbatim
* ===========================================================================
*/
static inline
CSL_RtcCalTime CSL_rtcGetTime (
CSL_RtcHandle hRtc
)
{
CSL_RtcCalTime tmpTime;
tmpTime.sec = hRtc->regs->SECONDS_REG;
tmpTime.min = hRtc->regs->MINUTES_REG;
tmpTime.hour = (Uint8) CSL_FEXTR(hRtc->regs->HOURS_REG, \
CSL_RTC_HOURS_REG_MSB, CSL_RTC_HOURS_REG_LSB);
tmpTime.day = hRtc->regs->DAYS_REG;
tmpTime.mon = hRtc->regs->MONTHS_REG;
tmpTime.year = hRtc->regs->YEARS_REG;
tmpTime.week = hRtc->regs->WEEKS_REG;
tmpTime.amPm = (CSL_Rtc12HourMode) CSL_FEXT( hRtc->regs->HOURS_REG,\
RTC_HOURS_REG_PM_AM );
return tmpTime;
}
/** ============================================================================
* @n@b CSL_rtcGetAlarmTime
*
* @b Description
* @n This function query's the alarmTime structure which contains time and
* calendar alarm register values.
*
* @b Arguments
* @verbatim
hRtc Handle to the RTC instance
@endverbatim
*
* <b> Return Value </b> CSL_RtcHourMode
*
* @li The alarmTime structure populated with the values of Time and
* calendar alarm Register.
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Returns the alarm register information of RTC.
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
CSL_RtcAlarmCalTime time;
time = CSL_rtcGetAlarmTime (hRtc);
@endverbatim
* ===========================================================================
*/
static inline
CSL_RtcAlarmCalTime CSL_rtcGetAlarmTime (
CSL_RtcHandle hRtc
)
{
CSL_RtcAlarmCalTime tmpAlarmTime;
tmpAlarmTime.sec = hRtc->regs->ALARM_SECONDS_REG;
tmpAlarmTime.min = hRtc->regs->ALARM_MINUTES_REG;
tmpAlarmTime.hour = (Uint8)CSL_FEXTR(hRtc->regs->ALARM_HOURS_REG, \
CSL_RTC_HOURS_REG_MSB, CSL_RTC_HOURS_REG_LSB);
tmpAlarmTime.day = hRtc->regs->ALARM_DAYS_REG;
tmpAlarmTime.mon = hRtc->regs->ALARM_MONTHS_REG;
tmpAlarmTime.year = hRtc->regs->ALARM_YEARS_REG;
tmpAlarmTime.amPm = \
(CSL_Rtc12HourMode) CSL_FEXT(hRtc->regs->ALARM_HOURS_REG,\
RTC_ALARM_HOURS_REG_ALARM_PM_AM);
return tmpAlarmTime;
}
/** ============================================================================
* @n@b CSL_rtcGetHourModeInfo
*
* @b Description
* @n This function query's the hour mode information of the RTC.
*
* @b Arguments
* @verbatim
hRtc Handle to the RTC instance
@endverbatim
*
* <b> Return Value </b> CSL_RtcHourMode
*
* @li The hour mode information of RTC is provided.
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Returns the hour mode information of RTC.
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
CSL_RtcHourMode mode;
mode = CSL_rtcGetHourModeInfo (hRtc);
@endverbatim
* ===========================================================================
*/
static inline
CSL_RtcHourMode CSL_rtcGetHourModeInfo (
CSL_RtcHandle hRtc
)
{
return (CSL_RtcHourMode) CSL_FEXT(hRtc->regs->RTC_CTRL_REG, \
RTC_RTC_CTRL_REG_MODE_12_24);
}
/** ============================================================================
* @n@b CSL_rtcGetPowerUpStatus
*
* @b Description
* @n This function query's the reset status of RTC.
*
* @b Arguments
* @verbatim
hRtc Handle to the RTC instance
@endverbatim
*
* <b> Return Value </b> Bool
*
* @li TRUE - If RTC is reset.
*
* @li FALSE - If Rtc is not reset.
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Returns the status of the Powerup bit in the RTC Status Register
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
Bool isReset;
isReset = CSL_rtcGetPowerUpStatus (hRtc);
@endverbatim
* ===========================================================================
*/
static inline
Bool CSL_rtcGetPowerUpStatus (
CSL_RtcHandle hRtc
)
{
return (Bool) CSL_FEXT(hRtc->regs->RTC_STATUS_REG, \
RTC_RTC_STATUS_REG_POWER_UP);
}
/** ============================================================================
* @n@b CSL_rtcGetAlarmStatus
*
* @b Description
* @n This function query's the generation of the alarm interrupt.
*
* @b Arguments
* @verbatim
hRtc Handle to the RTC instance
@endverbatim
*
* <b> Return Value </b> Bool
*
* @li TRUE - If Alarm Interrupt has occurred.
*
* @li FALSE - If alarm interrupt has not occurred.
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Returns the status of the Alarm bit in the RTC Status Register
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
Bool isAlarm;
isAlarm = CSL_rtcGetAlarmStatus (hRtc);
@endverbatim
* ===========================================================================
*/
static inline
Bool CSL_rtcGetAlarmStatus (
CSL_RtcHandle hRtc
)
{
return (Bool) CSL_FEXT(hRtc->regs->RTC_STATUS_REG, \
RTC_RTC_STATUS_REG_ALARM);
}
/** ============================================================================
* @n@b CSL_rtcGetEvent
*
* @b Description
* @n This function query's the occurrence of the RTC event.
*
* @b Arguments
* @verbatim
hRtc Handle to the RTC instance
@endverbatim
*
* <b> Return Value </b> CSL_RtcEvent
*
* @li Returns the RTC event status.
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Returns the status of the Event in the RTC Status Register
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
CSL_RtcEvent event;
event = CSL_rtcGetEvent (hRtc);
@endverbatim
* ===========================================================================
*/
static inline
CSL_RtcEvent CSL_rtcGetEvent (
CSL_RtcHandle hRtc
)
{
Uint8 shift = 0;
shift = 1 << CSL_FEXTR(hRtc->regs->RTC_INTERRUPTS_REG, \
CSL_RTC_INTERRUPTS_PERIOD_MSB, \
CSL_RTC_INTERRUPTS_PERIOD_LSB );
return (CSL_RtcEvent)( CSL_FEXTR(hRtc->regs->RTC_STATUS_REG, \
CSL_RTC_STATUS_EVENT_MSB, \
CSL_RTC_STATUS_EVENT_LSB ) & shift);
}
/** ============================================================================
* @n@b CSL_rtcGetRtcState
*
* @b Description
* @n This function query's the state of RTC.
*
* @b Arguments
* @verbatim
hRtc Handle to the RTC instance
@endverbatim
*
* <b> Return Value </b> CSL_RtcState
*
* @li Returns the RTC state.
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Returns the state of RTC.
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
CSL_RtcState state;
state = CSL_rtcGetRtcState (hRtc);
@endverbatim
* ===========================================================================
*/
static inline
CSL_RtcState CSL_rtcGetRtcState (
CSL_RtcHandle hRtc
)
{
return (CSL_RtcState) CSL_FEXT(hRtc->regs->RTC_STATUS_REG, \
RTC_RTC_STATUS_REG_RUN);
}
/** ============================================================================
* @n@b CSL_rtcGetBusyStat
*
* @b Description
* @n This function query's the busy bit in RTC Status Register.
*
* @b Arguments
* @verbatim
hRtc Handle to the RTC instance
@endverbatim
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -