csl_gptimeraux.h

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

H
1,099
字号
 *   @b Description
 *   @n This function writes the specified value into the TLDR register
 *
 *   @b Arguments
 *   @verbatim

            hGptimer            Handle to the general purpose timer instance

            count               Value to be loaded into TLDR register
 
     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n TLDR register will be loaded with the specified value
 *
 *   @b  Modifies
 *   @n  TLDR register
 *
 *   @b Example
 *   @verbatim
        Uint32  count;
        
        count = 0xFF000000;
        CSL_gptimerLoadTldr (hGptimer, count);
        
     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_gptimerLoadTldr (
    CSL_GptimerHandle    hGptimer,
    Uint32               count
)

{
    hGptimer->regs->TLDR= count;
}

/** ============================================================================
 *   @n@b CSL_gptimerLoadTtgr
 *
 *   @b Description
 *   @n This function writes the specified value into the TTGR register
 *
 *   @b Arguments
 *   @verbatim

            hGptimer            Handle to the general purpose timer instance
 
     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n TCRR register will be loaded with the value in TLDR register
 *
 *   @b  Modifies
 *   @n  TCRR register
 *
 *   @b Example
 *   @verbatim
  
        CSL_gptimerLoadTtgr (hGptimer);
        
     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_gptimerLoadTtgr (
    CSL_GptimerHandle    hGptimer
)

{
    hGptimer->regs->TTGR = CSL_GPTIMER_TRIG_VAL;
}

/** ============================================================================
 *   @n@b CSL_gptimerConfigInt
 *
 *   @b Description
 *   @n This function selects the events for interrupt generation
 *
 *   @b Arguments
 *   @verbatim

            hGptimer        Handle to the general purpose timer instance

            pEvent          Pointer to interrupt configuration structure        
 
     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n Interrupt generation is configured
 *
 *   @b  Modifies
 *   @n  TIER register
 *
 *   @b Example
 *   @verbatim
        CSL_GptimerEvent     event;  

        event.overflow = TRUE;
        event.match = FALSE;
        event.capture = FALSE;
        CSL_gptimerConfigInt (hGptimer, &event);
        
     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_gptimerConfigInt (
    CSL_GptimerHandle    hGptimer,
    CSL_GptimerEvent     *pEvent
)
{
    if (pEvent->overflow == TRUE)
        CSL_FINST(hGptimer->regs->TIER, GPTIMER_TIER_OVF_IT_ENA, ENABLE);
    else
        CSL_FINST(hGptimer->regs->TIER, GPTIMER_TIER_OVF_IT_ENA, DISABLE);

    if (pEvent->match == TRUE)
        CSL_FINST(hGptimer->regs->TIER, GPTIMER_TIER_MAT_IT_ENA, ENABLE);
    else
        CSL_FINST(hGptimer->regs->TIER, GPTIMER_TIER_MAT_IT_ENA, DISABLE);

    if (pEvent->capture == TRUE)
        CSL_FINST(hGptimer->regs->TIER, GPTIMER_TIER_TCAR_IT_ENA, ENABLE);
    else
        CSL_FINST(hGptimer->regs->TIER, GPTIMER_TIER_TCAR_IT_ENA, DISABLE);
}

/** ============================================================================
 *   @n@b CCSL_gptimerPwmConfig 
 *
 *   @b Description
 *   @n This function configures the output generation on PWM pin
 *
 *   @b Arguments
 *   @verbatim

            hGptimer        Handle to the general purpose timer instance

            pwmconfig       Pointer to PWM output configuration structure        
 
     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n Interrupt generartion is configured
 *
 *   @b  Modifies
 *   @n  TIER register
 *
 *   @b Example
 *   @verbatim
        CSL_GptimerPwmConfig pwmConfig  

        pwmConfig.mode = CSL_GPTIMER_PWM_TOGGLE;
        pwmConfig.level = CSL_GPTIMER_PWM_SET;
        pwmConfig.trigCondition = CSL_GPTIMER_TRIG_ON_OVF;

        CSL_gptimerConfigPwmOut (hGptimer, &pwmConfig);
        
     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_gptimerConfigPwmOut (
    CSL_GptimerHandle    hGptimer,
    CSL_GptimerPwmConfig *pwmConfig
)
{
    CSL_FINS(hGptimer->regs->TCLR, GPTIMER_TCLR_PT, pwmConfig->mode);

    CSL_FINS(hGptimer->regs->TCLR, GPTIMER_TCLR_SCPWM, pwmConfig->level);

    /* Select the condition for output generartion */
    CSL_FINS(hGptimer->regs->TCLR, GPTIMER_TCLR_TRG, pwmConfig->trigCondition);
}


/** ============================================================================
 *   @n@b CSL_gptimerConfigCapture 
 *
 *   @b Description
 *   @n This function configures the event capture on the timer input pin 
 *
 *   @b Arguments
 *   @verbatim

            hGptimer        Handle to the general purpose timer instance

            captEvent       Event that should be captured        
 
     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n Event capturing on input pin is configured
 *
 *   @b  Modifies
 *   @n  TCLR register
 *
 *   @b Example
 *   @verbatim
  
        CSL_gptimerConfigCapture (hGptimer, CSL_GPTIMER_CAPT_HIGH_TO_LOW);
        
     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_gptimerConfigCapture (
    CSL_GptimerHandle       hGptimer,
    CSL_GptimerCaptConfig   captEvent
)
{
    CSL_FINS(hGptimer->regs->TCLR, GPTIMER_TCLR_TCM, captEvent);
}

/** ============================================================================
 *   @n@b CSL_gptimerLoadMatchValue
 *
 *   @b Description
 *   @n This function writes the specified value into the TLDR register
 *
 *   @b Arguments
 *   @verbatim

            hGptimer            Handle to the general purpose timer instance

            count               Value to be loaded into TLDR register
 
     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n TMAR register will be loaded with the specified value
 *
 *   @b  Modifies
 *   @n  TMAR register
 *
 *   @b Example
 *   @verbatim
        Uint32  matchValue;
        
        count = 0xFF000000;
        CSL_gptimerLoadMatchValue (hGptimer, matchValue);
        
     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_gptimerLoadMatchValue (
    CSL_GptimerHandle       hGptimer,
    Uint32                  matchValue
)
{
    hGptimer->regs->TMAR = matchValue;
}

/** ============================================================================
 *   @n@b CSL_gptimerCompModeConfig
 *
 *   @b Description
 *   @n This function enables the compare mode operation
 *
 *   @b Arguments
 *   @verbatim

            hGptimer            Handle to the general purpose timer instance

            enable              TRUE - enable 

                                FALSE - Disable compare mode config
 
     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n Compare mode operation will be enabled/disabled
 *
 *   @b  Modifies
 *   @n  TCLR register
 *
 *   @b Example
 *   @verbatim
 
        CSL_gptimerCompModeConfig (hGptimer, TRUE);
        
     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_gptimerCompModeConfig (
    CSL_GptimerHandle       hGptimer,
    Bool                    enable
)
{
    CSL_FINS(hGptimer->regs->TCLR, GPTIMER_TCLR_CE, enable);  
}

/** ============================================================================
 *   @n@b CSL_gptimerClearInt
 *
 *   @b Description
 *   @n This function clears the specified interrupt.The best way of using this
 *      function is for writing back the interrupt status read using the 
 *      corresponding status query command
 *
 *   @b Arguments
 *   @verbatim

            hGptimer            Handle to the general purpose timer instance

            intFlag             Interrupt to be cleared

                                
     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n Pending interrupt will be cleared
 *
 *   @b  Modifies
 *   @n  TISR register
 *
 *   @b Example
 *   @verbatim
        Uint8  intFlag;
        intFlag = 0x7;

        CSL_gptimerClearInt (hGptimer, intFlag);
        
     @endverbatim
 * ===========================================================================
 */
static inline 
void CSL_gptimerClearInt (
    CSL_GptimerHandle       hGptimer,
    Uint8                   intFlag
)
{
    hGptimer->regs->TISR = intFlag;
}

/** ============================================================================
 *   @n@b CSL_gptimerResetFuncBlock
 *
 *   @b Description
 *   @n This function resets the functional block of the timer instance
 *
 *   @b Arguments
 *   @verbatim

            hGptimer            Handle to the general purpose timer instance

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n Functional block is reset
 *
 *   @b  Modifies
 *   @n  Registers of the timer instance
 *
 *   @b Example
 *   @verbatim
 
        CSL_gptimerResetFuncBlock (hGptimer);
        
     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_gptimerResetFuncBlock (
    CSL_GptimerHandle       hGptimer
    
)
{
    CSL_FINST(hGptimer->regs->TSICR, GPTIMER_TSICR_SFT, ENABLE);
    
}

/** ============================================================================
 *   @n@b CSL_gptimerReset
 *
 *   @b Description
 *   @n This function resets the timer instance
 *
 *   @b Arguments
 *   @verbatim

            hGptimer            Handle to the general purpose timer instance

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n Timer instance is reset
 *
 *   @b  Modifies
 *   @n  Registers of the timer instance
 *
 *   @b Example
 *   @verbatim
 
        CSL_gptimerReset (hGptimer);
        
     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_gptimerReset (
    CSL_GptimerHandle       hGptimer
    
)
{
    CSL_FINST(hGptimer->regs->TIOCP_CFG, GPTIMER_TIOCP_CFG_SOFTRESET, RESET);   
}

/** ============================================================================
 *   @n@b CSL_gptimerStart
 *
 *   @b Description
 *   @n This function starts the timer instance
 *
 *   @b Arguments
 *   @verbatim

            hGptimer            Handle to the general purpose timer instance

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n Timer instance is started
 *
 *   @b  Modifies
 *   @n  Registers of the timer instance
 *
 *   @b Example
 *   @verbatim
 
        CSL_gptimerStart (hGptimer);
        
     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_gptimerStart (
    CSL_GptimerHandle       hGptimer
    
)
{
    CSL_FINST(hGptimer->regs->TCLR, GPTIMER_TCLR_ST, START);   
}

/** ============================================================================
 *   @n@b CSL_gptimerStop
 *
 *   @b Description
 *   @n This function stops the timer instance
 *
 *   @b Arguments
 *   @verbatim

            hGptimer    Handle to the general purpose timer instance

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n Timer instance is stopped
 *
 *   @b  Modifies
 *   @n  Registers of the timer instance
 *
 *   @b Example
 *   @verbatim
 
        CSL_gptimerStop (hGptimer);
        
     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_gptimerStop (
    CSL_GptimerHandle       hGptimer
    
)
{
    CSL_FINST(hGptimer->regs->TCLR, GPTIMER_TCLR_ST, STOP);   
}
#ifdef __cplusplus
extern "C" {
#endif

#endif /* CSL_GPTIMERAUX_H_ */

⌨️ 快捷键说明

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