csl_gptimer.h

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

H
814
字号
/** ============================================================================
 *   @file  csl_gptimer.h
 *
 *   @path  $(CSLPATH)\arm\gptimer\src
 *
 *   @desc  API header file for general purpose timer 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
 *  ===============
 *  28-jun-2004 Ar Incoporated changes according to modified CSL architecture
 *  19-may-2004 Ar File Created.
 *
 * =============================================================================
 */

#ifndef _CSL_GPTIMER_H_
#define _CSL_GPTIMER_H_

#ifdef __cplusplus
extern "C" {
#endif

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

/**
 *  Enumeration for idle mode configuration for general-purpose timer
 */
typedef enum {
    /** Respond to idle request unconditionally */
    CSL_GPTIMER_IDLE_FORCE  = 0,
    /** Do not respond to idle request */
    CSL_GPTIMER_IDLE_NO     = 1,
    /** Respond to idle request based on internal state */
    CSL_GPTIMER_IDLE_SMART  = 2 
} CSL_GptimerIdle;

/**
 *  Enumeration for functional modes of general-purpose timer
 */
typedef enum {
    /** One shot mode */
    CSL_GPTIMER_ONESHOT       = 0,
    /** Auto reload mode */
    CSL_GPTIMER_AUTORELOAD    = 1   
} CSL_GptimerMode;

/**
 *  Enumeration for PWM signal mode
 */
typedef enum {
    /** Generate Pulse on the PWM */
    CSL_GPTIMER_PWM_PULSE  = 0,
    /** Toggle the signal on PWM */
    CSL_GPTIMER_PWM_TOGGLE = 1  
} CSL_GptimerPwmMode;

/**
 *  Enumeration for PWM signal level setting
 */
typedef enum {
    /** Set the PWM signal */
    CSL_GPTIMER_PWM_CLEAR  = 0,
    /** Clear the PWM signal */
    CSL_GPTIMER_PWM_SET    = 1  
} CSL_GptimerPwmLevel;

/**
 *  Enumeration for divisor values that can be configured in the general 
 *  purpose timer prescaler block   
 */
typedef enum {
    /** Divide functional clock by 2 */
    CSL_GPTIMER_PRESCALE_CLKBY2     = 0,
    /** Divide functional clock by 4 */
    CSL_GPTIMER_PRESCALE_CLKBY4     = 1,
    /** Divide functional clock by 8 */
    CSL_GPTIMER_PRESCALE_CLKBY8     = 2,
    /** Divide functional clock by 16 */
    CSL_GPTIMER_PRESCALE_CLKBY16    = 3,
    /** Divide functional clock by 32 */
    CSL_GPTIMER_PRESCALE_CLKBY32    = 4,    
    /** Divide functional clock by 64 */
    CSL_GPTIMER_PRESCALE_CLKBY64    = 5,    
    /** Divide functional clock by 128 */
    CSL_GPTIMER_PRESCALE_CLKBY128   = 6,    
    /** Divide functional clock by 256 */
    CSL_GPTIMER_PRESCALE_CLKBY256   = 7     
} CSL_GptimerPrescale;

/**
 * Enumeration for trigger conditions in the PWM output pins 
 */
typedef enum {
    /** No triggering on PWM output pin  */
    CSL_GPTIMER_TRIG_NO               = 0,
    /** Generate trigger on overflow */
    CSL_GPTIMER_TRIG_ON_OVF           = 1,
    /** Generate trigger on overflow or match */
    CSL_GPTIMER_TRIG_ON_OVF_OR_MATCH  = 2
} CSL_GptimerPwmTrigCond;

/**
 * Enumeration for input event to trigger capture
 */
typedef enum {
    /** No capturing enabled */
    CSL_GPTIMER_CAPT_NO               = 0,
    /** Capture low to high transition in the input pin */
    CSL_GPTIMER_CAPT_LOW_TO_HIGH      = 1,
    /** Capture high to low transition in the input pin */
    CSL_GPTIMER_CAPT_HIGH_TO_LOW      = 2,
    /** 
     * Capture both high to low transition and low to high transition in
     * the input pin
     */
    CSL_GPTIMER_CAPT_BOTH             = 3
} CSL_GptimerCaptConfig;


/**
 * Enumeration for timer event identification 
 */
typedef enum {
    /** Match event  */
    CSL_GPTIMER_EVENT_MATCH       = 1,
    /** Overflow event */
    CSL_GPTIMER_EVENT_OVERFLOW    = 2,
    /** Capture event */
    CSL_GPTIMER_EVENT_CAPTURE     = 4
} CSL_GptimerEventId;

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

/** 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_GptimerParam;

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

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

/**
 *  Enumeration for hardware control commands
 */
typedef enum {
        /**<
         * @brief   Load TCRR with the specified value
         * @param   (Uint32 *)
         */
    CSL_GPTIMER_CMD_LOAD_TCRR         = 0,
        /**<
         * @brief   Load TLDR with the specified value
         * @param   (Uint32 *)
         */
    CSL_GPTIMER_CMD_LOAD_TLDR         = 1,
        /**<
         * @brief   Trigger to load the value in TLDR into TCRR
         * @param   (None)
         */
    CSL_GPTIMER_CMD_TRIGGER           = 2,
        /**<
         * @brief   Configure the condition for interrupt generation
         * @param   (CSL_GptimerEvent * )
         */
    CSL_GPTIMER_CMD_CONFIG_INT        = 3,
        /**<
         * @brief   Configure the output generation on PWM pin
         * @param   (CSL_GptimerPwmConfig * )
         */ 
    CSL_GPTIMER_CMD_CONFIG_PWM_OUT    = 4,
        /**<
         * @brief   Select input event to be captured on the input pin
         * @param   (CSL_GptimerCaptConfig * )
         */     
    CSL_GPTIMER_CMD_CONFIG_CAPTURE    = 5,
        /**<
         * @brief   Load TMAR with value to be comapred
         * @param   (Uint32 * )
         */ 
    CSL_GPTIMER_CMD_LOAD_MATCH_VALUE  = 6,
        /**<
         * @brief   Enable/disable compare mode
         * @param   (Bool * )
         */ 
    CSL_GPTIMER_CMD_CONFIG_COMPARE    = 7,
        /**<
         * @brief   Clear the specified interrupt
         * @param   (Uint8 * )
         */ 
    CSL_GPTIMER_CMD_CLEAR_INT         = 8,
        /**<
         * @brief   Reset the functional block of the timer instance
         * @param   (None )
         */  
    CSL_GPTIMER_CMD_RESET_FUNC        = 9,
        /**<
         * @brief   Reset the timer instance
         * @param   (None )
         */     
    CSL_GPTIMER_CMD_RESET             = 10,
        /**<
         * @brief   Start the timer instance
         * @param   (None )
         */     
    CSL_GPTIMER_CMD_START             = 11,
        /**<
         * @brief   Stop the timer instance
         * @param   (None )
         */     
    CSL_GPTIMER_CMD_STOP              = 12 
}   CSL_GptimerHwControlCmd;        

/**
 *  Enumeration for hardware status query commands
 */
typedef enum {
        /**<
         * @brief   Query the hardware revision Id
         * @param   (Uint8 *)
         */
    CSL_GPTIMER_QUERY_HWREVID         = 0,
        /**<
         * @brief   Query the reset done status
         * @param   (Bool *)
         */
    CSL_GPTIMER_QUERY_RESETSTATE      = 1,
        /**<
         * @brief   Query the current count
         * @param   (Uint32 *)
         */
    CSL_GPTIMER_QUERY_COUNT           = 2,
        /**<
         * @brief   Query the captured value
         * @param   (Uint32 *)
         */
    CSL_GPTIMER_QUERY_CAPTURED_VALUE  = 3,
        /**<
         * @brief   Query to get timer event status
         * @param   (Uint8 *)
         */
    CSL_GPTIMER_QUERY_TIMER_STATUS    = 4,
        /**<
         * @brief   Query the write pending status for TMAR
         * @param   (Bool *)
         */
    CSL_GPTIMER_QUERY_W_PEND_TMAR     = 5,
        /**<
         * @brief   Query the write pending status for TTGR
         * @param   (Bool *)
         */
    CSL_GPTIMER_QUERY_W_PEND_TTGR     = 6,
        /**<
         * @brief   Query the write pending status for TLDR
         * @param   (Bool *)
         */
    CSL_GPTIMER_QUERY_W_PEND_TLDR     = 7,
        /**<
         * @brief   Query the write pending status for TCRR
         * @param   (Bool *)
         */
    CSL_GPTIMER_QUERY_W_PEND_TCRR     = 8,
        /**<
         * @brief   Query the write pending status for TCLR
         * @param   (Bool *)
         */
    CSL_GPTIMER_QUERY_W_PEND_TCLR     = 9       
}   CSL_GptimerHwStatusQuery;

/**
* This structure is used to select the response to timer events. This structure
* is used for the following 
*   
*   Configure conditions under which the timer should generate wakeup request
*
*   Configure conditions under which the timer should generate interrupt request
*/
typedef struct CSL_GptimerEvent {
    /** Respond to overflow event */
    Bool overflow;
    /** Respond to match event */
    Bool match;
    /** Respond to capture event */
    Bool capture;
} CSL_GptimerEvent;

/** 
 * This structure is used configure the output signal generation on the PWM pin
 * associated with the timer instance. Only timer instances CSL_GPTIMER_1, 
 * CSL_GPTIMER_2 and CSL_GPTIMER_3 support the output functionality.
 */
typedef struct CSL_GptimerPwmConfig {
    /** Specifies whether to generate pulse or toggle output signal */
    CSL_GptimerPwmMode                 mode;
    /** Specifies whether to generate positive or negative pulse */
    CSL_GptimerPwmLevel                level;
    /** Selects the condition for generation of output pulse */
    CSL_GptimerPwmTrigCond             trigCondition;
} CSL_GptimerPwmConfig;

/** Hardware setup structure */
typedef struct CSL_GptimerHwSetup {
    /** Auto-idle enable/disable */
    Bool                        autoIdleEnable;
    /** Configure the response to idle request from host */
    CSL_GptimerIdle             idleModeConfig;
    /** Wakeup logic enable/disable */
    Bool                        wakeupEnable;
    /** Configure the condition for generating a wakeup request */
    CSL_GptimerEvent            wakeupConfig;
    /** Configure the sensitivity to suspend signal in emulation mode */
    Bool                        emuFreeEnable;
    /** Select operation in posted/non posted modes */
    Bool                        postedModeEnable;
    /** Prescaling enable/disable */
    Bool                        prescaleEnable;
    /** Divider value for the functional clock during prescaling */
    CSL_GptimerPrescale         prescaleValue;
    /** Value to be loaded into Timer Counter Register (TCRR) */
    Uint32                      count;
    /** Value to be loaded in Timer Load Register (TLDR) */
    Uint32                      loadValue;
    /** Operate in auto reload/one shot mode */
    CSL_GptimerMode             mode;
    /** Generate a pulse /toggle the signal in the PWM output pin */
    CSL_GptimerPwmMode          pwmMode;
    /** Configure pulse polarity as positive /negative */
    CSL_GptimerPwmLevel         pwmLevel;
    /** Configures the condition for triggering output on PWM */
    CSL_GptimerPwmTrigCond      trigConfig;
    /** Compare mode enable/disable */
    Bool                        compEnable;
    /** Value to be loaded in the Timer Match register (TMAR) */
    Uint32                      matchValue;
    /** Select the transition on input pin for capture mode operation */
    CSL_GptimerCaptConfig       captConfig;
    /** Configure the condition for interrupt generation */
    CSL_GptimerEvent            intConfig;
} CSL_GptimerHwSetup;

/**
 * Configuration structure.This is used to configure general purpose timer
 * instance using CSL_HwSetupRaw function
 */
typedef struct  {
    /** Timer OCP configuration register */
    volatile Uint32 TIOCP_CFG;
    /** Timer event status register */
    volatile Uint32 TISR;
    /** Timer Interrupt enable register */
    volatile Uint32 TIER;
    /** Timer wakeup enable register */
    volatile Uint32 TWER;
    /** Timer control register */
    volatile Uint32 TCLR;
    /** Timer counter register */
    volatile Uint32 TCRR;
    /** Timer load register */
    volatile Uint32 TLDR;
    /** Timer trigger register */
    volatile Uint32 TTGR;
    /** Timer match register */
    volatile Uint32 TMAR;
    /** Timer synchronization interface control register */
    volatile Uint32 TSICR;
} CSL_GptimerConfig;

/** General purpose timer object structure */
typedef struct CSL_GptimerObj {
    /** Pointer to the register overlay structure for the peripheral */
    CSL_GptimerRegsOvly     regs;

⌨️ 快捷键说明

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