csl_rtc.h

来自「dsp在音频处理中的运用」· C头文件 代码 · 共 877 行 · 第 1/2 页

H
877
字号
/** ============================================================================
 *   @file  csl_rtc.h
 *
 *   @path  $(CSLPATH)\arm\rtc\src
 *
 *   @desc  API 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-06-02) */
 
/* =============================================================================
 *  Revision History
 *  ===============
 *  07-Jun-2004 Ru File Created.
 *
 * =============================================================================
 */
 
#ifndef _CSL_RTC_H_
#define _CSL_RTC_H_

#ifdef __cplusplus
extern "C" {
#endif


#include <csl_types.h>
#include <csl_error.h>
#include <cslr_rtc.h>

/**************************************************************************\
* RTC global typedef declarations
\**************************************************************************/

/** Split Power setting */
typedef enum {
	/** The Split Power mode is disabled for RTC */
    CSL_RTC_SPLITPOWER_DISABLE   = CSL_RTC_RTC_CTRL_REG_SPLIT_POWER_DISABLE,
    /** The RTC is configured to work in Split Power mode */
    CSL_RTC_SPLITPOWER_ENABLE    = CSL_RTC_RTC_CTRL_REG_SPLIT_POWER_ENABLE
} CSL_RtcSplitPower;

/** Enumeration to Set the 32-kHz Oscillator */
typedef enum {
	/** The 32-kHz counter functions normally */
	CSL_RTC_SETCOUNTER_DISABLE = CSL_RTC_RTC_CTRL_REG_SET_32_COUNTER_DISABLE,
	/** The 32-kHz counter is loaded with the Compensation Registers */
	CSL_RTC_SETCOUNTER_ENABLE  = CSL_RTC_RTC_CTRL_REG_SET_32_COUNTER_ENABLE
} CSL_RtcSetCounter;

/** Enumeration for the Test Mode of RTC */
typedef enum {
	/** The RTC is configured to work in functional mode */
	CSL_RTC_TESTMODE_FUNCTIONAL = CSL_RTC_RTC_CTRL_REG_TEST_MODE_FUNC,
	/** The RTC is configured to work in Test mode */
	CSL_RTC_TESTMODE_TEST		= CSL_RTC_RTC_CTRL_REG_TEST_MODE_TEST
} CSL_RtcTestMode;

/** Enumeration for the Hour Mode of RTC */
typedef enum {
	/** The RTC is configured to work in 24 hour mode */
	CSL_RTC_HOURMODE_24 = CSL_RTC_RTC_CTRL_REG_MODE_12_24_24HR,
	/** The RTC is configured to work in 12 hour mode */
	CSL_RTC_HOURMODE_12 = CSL_RTC_RTC_CTRL_REG_MODE_12_24_12HR
} CSL_RtcHourMode;

/** Enumeration for the Autocompensation of RTC */
typedef enum {
	/** The Autocompensation of 32-kHz counter is disabled */
	CSL_RTC_AUTOCOMP_DISABLE = CSL_RTC_RTC_CTRL_REG_AUTO_COMP_DISABLE,
	/** The 32-kHz counter is automatically compensated with COMP_REG values */
	CSL_RTC_AUTOCOMP_ENABLE  = CSL_RTC_RTC_CTRL_REG_AUTO_COMP_ENABLE
} CSL_RtcAutoComp;

/** Enumeration for the state of RTC */
typedef enum {
	/** The RTC is frozen */
	CSL_RTC_STATE_FROZEN  = CSL_RTC_RTC_STATUS_REG_RUN_FROZEN,
	/** The RTC is running */
	CSL_RTC_STATE_RUNNING = CSL_RTC_RTC_STATUS_REG_RUN_RUNNING
} CSL_RtcState;

/** Enable or Disable Alarm Interrupt */
typedef enum {
	/** The Alarm interrupt is disabled for RTC */
	CSL_RTC_INT_ALARM_DISABLE = CSL_RTC_RTC_INTERRUPTS_REG_IT_ALARM_DISABLE,
	/** The Alarm interrupt is enabled for RTC */
	CSL_RTC_INT_ALARM_ENABLE  = CSL_RTC_RTC_INTERRUPTS_REG_IT_ALARM_ENABLE
} CSL_RtcIntAlarm;

/** Enable or Disable Timer Interrrupt */
typedef enum {
	/** The Timer interrupt is disabled for RTC */
	CSL_RTC_INT_TIMER_DISABLE = CSL_RTC_RTC_INTERRUPTS_REG_IT_TIMER_DISABLE,
	/** The Timer interrupt is enabled for RTC */
	CSL_RTC_INT_TIMER_ENABLE  = CSL_RTC_RTC_INTERRUPTS_REG_IT_TIMER_ENABLE
} CSL_RtcIntTimer;

/** Specifies the Event occurred  */
typedef enum {
	/** Specifies the occurrence of one second */
	CSL_RTC_EVENT_SEC   = 0x1,
	/** Specifies the occurrence of one minute */
	CSL_RTC_EVENT_MIN   = 0x2,
	/** Specifies the occurrence of one hour */
	CSL_RTC_EVENT_HOUR  = 0x4,
	/** Specifies the occurrence of one day */
	CSL_RTC_EVENT_DAY   = 0x8
} CSL_RtcEvent;

/** Interrupt time period setting */
typedef enum {
	/** Configure the Interrupt period of RTC for every second */
	CSL_RTC_INT_PERIOD_SECOND = CSL_RTC_RTC_INTERRUPTS_REG_EVERY_SEC,
	/** Configure the Interrupt period of RTC for every minute */
	CSL_RTC_INT_PERIOD_MINUTE = CSL_RTC_RTC_INTERRUPTS_REG_EVERY_MIN,
	/** Configure the Interrupt period of RTC for every hour */
	CSL_RTC_INT_PERIOD_HOUR   = CSL_RTC_RTC_INTERRUPTS_REG_EVERY_HR,
	/** Configure the Interrupt period of RTC for every day */
	CSL_RTC_INT_PERIOD_DAY    = CSL_RTC_RTC_INTERRUPTS_REG_EVERY_DAY
} CSL_RtcIntPeriod;

/** Enumeration for AM or PM in 12 hour clock System */
typedef enum {
	/** Denotes AM in 12 hour clock system */
	CSL_RTC_12HOURMODE_AM = 0,
	/** Denotes PM in 12 hour clock system */
	CSL_RTC_12HOURMODE_PM = 1
} CSL_Rtc12HourMode;

/**
 * The config-structure
 *
 * Used to configure the RTC using CSL_rtcHwSetupRaw(..)
 */

typedef struct {
	/** RTC seconds register */	
     Uint8 SECONDS_REG;
    
    /** RTC minutes register */	
     Uint8 MINUTES_REG;
    
    /** RTC hours register */	
     Uint8 HOURS_REG;
    
    /** RTC days register */	
     Uint8 DAYS_REG;
    
    /** RTC months register */	
     Uint8 MONTHS_REG;
    
    /** RTC years register */	
     Uint8 YEARS_REG;
    
    /** RTC weeks register */	
     Uint8 WEEKS_REG;
    
    /** RTC Alarm seconds register */	
     Uint8 ALARM_SECONDS_REG;
    
    /** RTC Alarm minutes register */
     Uint8 ALARM_MINUTES_REG;
    
    /** RTC Alarm hours register */
     Uint8 ALARM_HOURS_REG;
    
    /** RTC Alarm days register */
     Uint8 ALARM_DAYS_REG;
    
    /** RTC Alarm months register */
     Uint8 ALARM_MONTHS_REG;
    
    /** RTC Alarm years register */
     Uint8 ALARM_YEARS_REG;
    
    /** RTC control register */
     Uint8 RTC_CTRL_REG;
    
    /** RTC status register */
     Uint8 RTC_STATUS_REG;
    
    /** RTC interrupts register */
     Uint8 RTC_INTERRUPTS_REG;
    
    /** RTC Compensation LSB register */
     Uint8 RTC_COMP_LSB_REG;
    
    /** RTC Compensation MSB register */
     Uint8 RTC_COMP_MSB_REG;
    
    /** RTC Oscillator register */
     Uint8 RTC_OSC_REG;
} CSL_RtcConfig;

/** This will have the base-address information for the peripheral
 *  instance
 */
typedef struct {
	/** Base-address of the Configuration registers of the peripheral
	 */
	CSL_RtcRegsOvly	regs;
} CSL_RtcBaseAddress;

/** Module specific parameters. Present implementation doesn't have
 *  any module specific parameters.
 */
typedef struct {
	/** Bit mask to be used for module specific parameters.
     *  The below declaration is just a place-holder for future
 	 *  implementation.
	 */
	CSL_BitMask16   flags;
} CSL_RtcParam;

/** Module specific context information. Present implementation doesn't
 *  have any Context information.
 */

typedef struct {
	/** Context information of RTC.
     *  The below declaration is just a place-holder for future
 	 *  implementation.
 	 */
    Uint16	contextInfo;
} CSL_RtcContext;

/** This enum describes the commands used to control the 
 *  RTC through CSL_rtcHwControl(). 
 */
typedef enum {
	/** @brief Enables RTC
	 *  @param (None) 
	 */
	CSL_RTC_CMD_ENABLE,
	/** @brief Disables RTC
	 *  @param (None)
	 */
	CSL_RTC_CMD_DISABLE,
	/** @brief Enable loading of 32-kHz counter with COMP_REG Values
	 *  @param (None) 
	 */
	CSL_RTC_CMD_SETCOUNTER_ENABLE,
	/** @brief Disable the loading of 32-kHz counter with COMP_REG Values
	 *  @param (None) 
	 */
	CSL_RTC_CMD_SETCOUNTER_DISABLE,
	/** @brief Configure the Hour Mode of RTC.
	 *  @param (CSL_RtcHourMode) 
	 */
	CSL_RTC_CMD_HOURMODE_CONFIG,
	/** @brief Round off to closest minute in the next second.
	 *  @param (None) 
	 */
	CSL_RTC_CMD_ROUND30S_ENABLE,
	/** @brief Load the RTC Time and Calendar Registers with structure provided.
	 *  @param (CSL_RtcCalTime) 
	 */
	CSL_RTC_CMD_SET_TIME,
	/** @brief Load the RTC Time and Calendar Alarm Registers with structure provided.
	 *  @param (CSL_RtcAlarmCalTime) 
	 */
	CSL_RTC_CMD_SET_ALARMTIME,
	/** @brief Starts the RTC 
	 *  @param (None)
	 */
	CSL_RTC_CMD_START,
	/** @brief Freezes the RTC
	 *  @param (None) 
	 */
	CSL_RTC_CMD_FREEZE,
	/** @brief Clears the Power up bit in RTC Status Register.
	 *  @param (None) 
	 */
	CSL_RTC_CMD_CLEAR_POWERUP,
	/** @brief Clears the Alarm bit in RTC Status Register.
	 *  @param (None) 
	 */
	CSL_RTC_CMD_CLEAR_ALARM,
	/** @brief Enable the Alarm Interrupt
	 *  @param (None) 
	 */
	CSL_RTC_CMD_ALARMINT_ENABLE,
	/** @brief Disable the Alarm Interrupt
	 *  @param (None) 
	 */
	CSL_RTC_CMD_ALARMINT_DISABLE,
	/** @brief Enable the Timer Interrupt
	 *  @param (None) 
	 */
	CSL_RTC_CMD_TIMERINT_ENABLE,
	/** @brief Disable the Timer Interrupt
	 *  @param (None) 
	 */
	CSL_RTC_CMD_TIMERINT_DISABLE,
	/** @brief Configure the Interrupt period of the Timer.
	 *  @param (CSL_RtcIntPeriod) 
	 */
	CSL_RTC_CMD_INTPERIOD_CONFIG,
	/** @brief Load the Compensation Registers.
	 *  @param (CSL_RtcComp) 
	 */
	CSL_RTC_CMD_LOAD_COMP_REG,
	/** @brief Power Down the 32-kHz Oscillator.
	 *  @param (None) 
	 */
	CSL_RTC_CMD_SET_OSC_PWRDN
} CSL_RtcHwControlCmd;

/**
 * This enum describes the commands used to get status of various 
 * parameters of the RTC. These values are used in CSL_rtcGetHwStatus ()
 */
typedef enum {
	/** @brief Query to check if RTC is currently disabled.
	 *  @param (Bool *) 
	 */
	CSL_RTC_QUERY_IS_RTC_DISABLED,
	/** @brief Query to get the current date and time.
	 *  @param (CSL_RtcCalTime *) 
	 */
	CSL_RTC_QUERY_GET_TIME,
	/** @brief Query to get the date and time of alarm.
	 *  @param (CSL_RtcAlarmCalTime *) 
	 */
	CSL_RTC_QUERY_GET_ALARMTIME,
	/** @brief Query to get the hour mode information.
	 *  @param (CSL_RtcHourMode *) 
	 */
	CSL_RTC_QUERY_HOURMODE_INFO,
	/** @brief Query the reset state of the real time clock.
	 *  @param (Bool *) 
	 */
	CSL_RTC_QUERY_POWERUP_STAT,
	/** @brief Query to get the alarm event generated.
	 *  @param (Bool *) 
	 */
	CSL_RTC_QUERY_ALARM_STAT,
	/** @brief Query to get the occurrence of the event.
	 *  @param (CSL_RtcEvent *) 
	 */
	CSL_RTC_QUERY_EVENT,
	/** @brief Query to get the running state of RTC
	 *  @param (CSL_RtcState *) 
	 */
	CSL_RTC_QUERY_RTC_STATE,
	/** @brief Query to check if RTC is busy.
	 *  @param (Bool *) 
	 */
	CSL_RTC_QUERY_BUSY_STAT,
	/** @brief Query the power down state of 32-kHz oscillator.
	 *  @param (Bool *) 
	 */
	CSL_RTC_QUERY_OSC_PWRDN
} CSL_RtcHwStatusQuery;

/** Structure used to store the time and calendar register values */
typedef struct {
	/** RTC time register storing seconds.
	 *  This register value is in BCD code.
	 */
	Uint8				sec;
	/** RTC time register storing minutes.
	 *  This register value is in BCD code.
	 */
	Uint8				min;
	/** RTC time register storing hours.
	 *  This register value is in BCD code.
	 */
	Uint8				hour;
	/** AM or PM in 12 hour clock system. */
	CSL_Rtc12HourMode	amPm;
	/** RTC calendar register storing day.
	 *  This register value is in BCD code.
	 */
	Uint8				day;
	/** RTC calendar register storing month.
	 *  This register value is in BCD code.
	 */
	Uint8				mon;
	/**RTC calendar register storing year.
	 *  This register value is in BCD code.
	 */
	Uint8				year;
	/** RTC calendar register storing day of the week.
	 *  This register value is in BCD code.
	 */
	Uint8				week;
} CSL_RtcCalTime;

/** Structure used to store the time and calendar alarm register values */
typedef struct {
	/** RTC Alarm register storing seconds. 
	 *  This register value is in BCD code.
	 */
	Uint8				sec;
	/** RTC Alarm register storing minutes.
	 *  This register value is in BCD code.
	 */
	Uint8				min;
	/** RTC Alarm register storing hours.
	 *  This register value is in BCD code.
	 */
	Uint8				hour;
	/** AM or PM in 12 hour clock system */
	CSL_Rtc12HourMode	amPm;
	/** RTC Alarm register storing day. 
	 *  This register value is in BCD code.
	 */
	Uint8				day;
	/** RTC Alarm register storing month.
	 *  This register value is in BCD code.
	 */
	Uint8				mon;
	/** RTC Alarm register storing year. 
	 *  This register value is in BCD code.
	 */
	Uint8				year;
} CSL_RtcAlarmCalTime;

/** 
 * Structure used to store the values of LSB and MSB of the RTC compensation 
 * register 
 */
typedef struct {
	/** RTC LSB Compensation Register */
	Uint8 lsb;
	/** RTC MSB Compensation Register */
	Uint8 msb;
} CSL_RtcComp;

⌨️ 快捷键说明

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