⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csl_rtcaux.h

📁 dsp在音频处理中的运用
💻 H
📖 第 1 页 / 共 3 页
字号:
 *   <b> Return Value </b> CSL_RtcState
 *
 *   @li                   Returns the Busy status of RTC.
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  Returns the Busy bit status in RTC Status Register.
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim
        Bool busy;

        busy = CSL_rtcGetBusyStat (hRtc);
     @endverbatim
 * ===========================================================================
 */

static inline
Bool CSL_rtcGetBusyStat (
	CSL_RtcHandle hRtc
)
{
	return (Bool) CSL_FEXT(hRtc->regs->RTC_STATUS_REG, \
				                RTC_RTC_STATUS_REG_BUSY);
}

/** ============================================================================
 *   @n@b CSL_rtcGetOscPowrdnStatus
 *
 *   @b Description
 *   @n This function query's the power down status of 32-kHz Oscillator.
 *
 *   @b Arguments
 *   @verbatim

            hRtc     	    Handle to the RTC instance

     @endverbatim
 *
 *   <b> Return Value </b> CSL_RtcState
 *
 *   @li                   Returns power down status of 32-kHz Oscillator.
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  Returns power down status of 32-kHz Oscillator.
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim
        Bool pwrdn;

        pwrdn = CSL_rtcGetOscPowrdnStatus (hRtc);
     @endverbatim
 * ===========================================================================
 */

static inline
Bool CSL_rtcGetOscPowrdnStatus (
	CSL_RtcHandle hRtc
)
{
	return (Bool) CSL_FEXT(hRtc->regs->RTC_OSC_REG, \
				             RTC_RTC_OSC_REG_OSC32K_PWRDN_R);
}



/**
 *	Hardware Control Functions of RTC
 */

/** ============================================================================
 *   @n@b CSL_rtcDisable
 *
 *   @b Description
 *   @n This function disables the functioning of RTC.
 *
 *   @b Arguments
 *   @verbatim

            hRtc     	    Handle to the RTC instance

     @endverbatim
 *
 *   <b> Return Value </b> None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  RTC is Disabled.
 *
 *   @b Modifies
 *   @n  The RTC Control Register
 *
 *   @b Example
 *   @verbatim
        CSL_rtcDisable (hRtc);

     @endverbatim
 * ===========================================================================
 */

static inline
void CSL_rtcDisable (
	CSL_RtcHandle hRtc
)
{
	CSL_FINS (hRtc->regs->RTC_CTRL_REG, \
				     RTC_RTC_CTRL_REG_RTC_DISABLE, CSL_RTC_DISABLE);
}

/** ============================================================================
 *   @n@b CSL_rtcEnable
 *
 *   @b Description
 *   @n This function enables the functioning of RTC.
 *
 *   @b Arguments
 *   @verbatim

            hRtc     	    Handle to the RTC instance

     @endverbatim
 *
 *   <b> Return Value </b> None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  RTC is Enabled.
 *
 *   @b Modifies
 *   @n  The RTC Control Register
 *
 *   @b Example
 *   @verbatim
         CSL_rtcEnable (hRtc);

     @endverbatim
 * ===========================================================================
 */

static inline
void CSL_rtcEnable (
	CSL_RtcHandle hRtc
)
{
	CSL_FINS (hRtc->regs->RTC_CTRL_REG, \
				     RTC_RTC_CTRL_REG_RTC_DISABLE, CSL_RTC_ENABLE);
}

/** ============================================================================
 *   @n@b CSL_rtcSetCounterEnable
 *
 *   @b Description
 *   @n This function enables the loading of 32-kHz Counter with compensation
 *		register values.
 *
 *   @b Arguments
 *   @verbatim

            hRtc     	    Handle to the RTC instance

     @endverbatim
 *
 *   <b> Return Value </b> None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  The 32-kHz Counter is loaded with the compensation register values.
 *
 *   @b Modifies
 *   @n  The RTC Control Register
 *
 *   @b Example
 *   @verbatim
         CSL_rtcSetCounterEnable (hRtc);

     @endverbatim
 * ===========================================================================
 */

static inline
void CSL_rtcSetCounterEnable (
	CSL_RtcHandle hRtc
)
{
	CSL_FINST (hRtc->regs->RTC_CTRL_REG, \
				     RTC_RTC_CTRL_REG_SET_32_COUNTER, ENABLE);
}

/** ============================================================================
 *   @n@b CSL_rtcSetCounterDisable
 *
 *   @b Description
 *   @n This function disables the loading of 32-kHz Counter with compensation
 *		register values.
 *
 *   @b Arguments
 *   @verbatim

            hRtc     	    Handle to the RTC instance

     @endverbatim
 *
 *   <b> Return Value </b> None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  The loading of 32-kHz Counter with the compensation register values is disabled.
 *
 *   @b Modifies
 *   @n The RTC Control Register
 *
 *   @b Example
 *   @verbatim
         CSL_rtcSetCounterDisable (hRtc);

     @endverbatim
 * ===========================================================================
 */

static inline
void CSL_rtcSetCounterDisable (
	CSL_RtcHandle hRtc
)
{
	CSL_FINST (hRtc->regs->RTC_CTRL_REG, \
				     RTC_RTC_CTRL_REG_SET_32_COUNTER, DISABLE);
}

/** ============================================================================
 *   @n@b CSL_rtcHourModeConfig
 *
 *   @b Description
 *   @n This function configures the RTC to work in 24 hour mode or
 *		12 hour mode.
 *
 *   @b Arguments
 *   @verbatim

            hRtc     	    Handle to the RTC instance

            mode			Hour mode for the RTC.

     @endverbatim
 *
 *   <b> Return Value </b> None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  The RTC is configured to 24 or 12 hour mode.
 *
 *   @b Modifies
 *   @n  The RTC Control Register
 *
 *   @b Example
 *   @verbatim
        CSL_RtcHandle 	   hRtc;
        CSL_RtcHourMode	   mode = CSL_RTC_HOURMODE_12;

        CSL_rtcHourModeConfig (hRtc, mode);
    @endverbatim
 * ===========================================================================
 */

static inline
void CSL_rtcHourModeConfig (
	CSL_RtcHandle hRtc,
	CSL_RtcHourMode mode
)
{

	if ( mode == CSL_RTC_HOURMODE_24 )
        CSL_FINST (hRtc->regs->RTC_CTRL_REG, \
	   	     	    RTC_RTC_CTRL_REG_MODE_12_24, 24HR);
	else
        CSL_FINST (hRtc->regs->RTC_CTRL_REG, \
	 		        RTC_RTC_CTRL_REG_MODE_12_24, 12HR);
}

/** ============================================================================
 *   @n@b CSL_rtcRound30sEnable
 *
 *   @b Description
 *   @n This function enables rounding off to the closest minute in the next
 *		second.
 *
 *   @b Arguments
 *   @verbatim

            hRtc     	    Handle to the RTC instance

     @endverbatim
 *
 *   <b> Return Value </b> None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  The Time in RTC is rounded off to closest minute.
 *
 *   @b Modifies
 *   @n  The RTC Second Register.
 *
 *   @b Example
 *   @verbatim
         CSL_rtcRound30sEnable (hRtc);

     @endverbatim
 * ===========================================================================
 */

static inline
void CSL_rtcRound30sEnable (
	CSL_RtcHandle hRtc
)
{
	CSL_FINST (hRtc->regs->RTC_CTRL_REG, \
				     RTC_RTC_CTRL_REG_ROUND_30S, ENABLE);
}

/** ============================================================================
 *   @n@b CSL_rtcSetTime
 *
 *   @b Description
 *   @n This function loads and configures the Time and Calendar Registers
 *		of RTC.
 *
 *   @b Arguments
 *   @verbatim

            hRtc        Handle to the RTC instance

            time        Structure to load the Time and Calendar Registers.

     @endverbatim
 *
 *   <b> Return Value </b> None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n The RTC Time and Calendar Registers are configured.
 *
 *   @b Modifies
 *   @n The RTC Time and Calendar Registers
 *
 *   @b Example
 *   @verbatim
        CSL_RtcHandle   hRtc;
        CSL_RtcCalTime  time;

        CSL_rtcSetTime  (hRtc, time);

     @endverbatim
 * ===========================================================================
 */

static inline
void CSL_rtcSetTime (
	CSL_RtcHandle hRtc,
	CSL_RtcCalTime time
)
{
	hRtc->regs->SECONDS_REG 	= time.sec;
    hRtc->regs->MINUTES_REG 	= time.min;
    CSL_FINSR (hRtc->regs->HOURS_REG, CSL_RTC_HOURS_REG_MSB ,\
       			CSL_RTC_HOURS_REG_LSB, time.hour);
    CSL_FINS (hRtc->regs->HOURS_REG, RTC_HOURS_REG_PM_AM, \
    		    time.amPm);
    hRtc->regs->DAYS_REG 		= time.day;
    hRtc->regs->MONTHS_REG	 	= time.mon;
    hRtc->regs->YEARS_REG 		= time.year;
    hRtc->regs->WEEKS_REG 		= time.week;
}

/** ============================================================================
 *   @n@b CSL_rtcSetAlarmTime
 *
 *   @b Description
 *   @n This function loads and configures the Time and Calendar Alarm Registers
 *		of RTC.
 *
 *   @b Arguments
 *   @verbatim

            hRtc            Handle to the RTC instance

            alarmTime       Structure to load the Time and Calendar Alarm Registers.

     @endverbatim
 *
 *   <b> Return Value </b> None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  The RTC Time and Calendar Alarm Registers are configured.
 *
 *   @b Modifies
 *   @n  The RTC Time and Calendar Alarm Registers
 *
 *   @b Example
 *   @verbatim
        CSL_RtcHandle 	   	hRtc;
        CSL_RtcAlarmCalTime	alarmTime;

        CSL_rtcSetAlarmTime (hRtc, alarmTime);

     @endverbatim
 * ===========================================================================
 */

static inline
void CSL_rtcSetAlarmTime (
	CSL_RtcHandle 		hRtc,
	CSL_RtcAlarmCalTime alarmTime
)
{
	hRtc->regs->ALARM_SECONDS_REG 	= alarmTime.sec;
    hRtc->regs->ALARM_MINUTES_REG 	= alarmTime.min;
    CSL_FINSR ( hRtc->regs->ALARM_HOURS_REG, CSL_RTC_HOURS_REG_MSB ,\
       			CSL_RTC_HOURS_REG_LSB, alarmTime.hour );
    CSL_FINS ( hRtc->regs->ALARM_HOURS_REG, RTC_ALARM_HOURS_REG_ALARM_PM_AM, \
    		   alarmTime.amPm );
    hRtc->regs->ALARM_DAYS_REG 		= alarmTime.day;
    hRtc->regs->ALARM_MONTHS_REG	= alarmTime.mon;
    hRtc->regs->ALARM_YEARS_REG 	= alarmTime.year;
}

/** ============================================================================
 *   @n@b CSL_rtcStart
 *
 *   @b Description
 *   @n This function starts the RTC.
 *
 *   @b Arguments
 *   @verbatim

            hRtc     	    Handle to the RTC instance

⌨️ 快捷键说明

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