csl_ostimer.h

来自「dsp在音频处理中的运用」· C头文件 代码 · 共 452 行

H
452
字号
/** =========================================================
 *   @file  csl_ostimer.h
 *
 *   @path  $(CSLPATH)\arm\ostimer\src
 *
 *   @desc  Register header file for ostimer 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-01) */

/* =============================================================================
 *  Revision History
 *  ===============
 *  07-Jun-2004 PR File Created.
 *
 * =============================================================================
 */
#ifndef _CSL_OSTIMER_H_
#define _CSL_OSTIMER_H_

#ifdef __cplusplus
extern "C" {
#endif
#include <csl.h>
#include <cslr_ostimer.h>

/**
 *  This enum describes the load modes of the ostimer. The ostimer
 *  can be programmed in auto-reload mode or in one shot mode   
 */
typedef enum {
  /**ostimer in one-shot mode */
    CSL_OSTIMER_MODE_ONESHOT,        
  /**ostimer in auto-reload mode */
    CSL_OSTIMER_MODE_AUTORELOAD     
} CSL_OstimerLoadMode;

/**
 * Enumeration of the control commands
 *
 * These are the control commands that could be used with
 * CSL_ostimerHwControl(..). Some of the commands expect an
 * argument as documented along-side the description of
 * the command.
 *
 */
typedef enum {
     /**
       * @brief   Write value in TICK_VALUE_REG
       * @param   None
       */
    CSL_OSTIMER_CMD_LOAD,            
     /**
       * @brief   Load the counter with the value from TICK_VALUE_REG
       * @param   None
       */          
    CSL_OSTIMER_CMD_RELOAD,   
    /**
      * @brief   Start the timer
      * @param   None
      */
    CSL_OSTIMER_CMD_START,             
    /**
      * @brief   Stop the timer
      * @param   None
      */
    CSL_OSTIMER_CMD_STOP
} CSL_OstimerHwControlCmd;

/** 
  * This enum describes the commands used to get status of various
  * parameters of the
  *  ostimer. These values are used in CSL_ostimerGetHwStatus()
  */
typedef enum {
   /**
     * @brief Gets the current value of the ostimer read register 
     * @param   None
     */
    CSL_OSTIMER_QUERY_COUNT,
   /**
     * @brief   Gets the current status of TRB bit 
     * @param   None 
     */
    CSL_OSTIMER_QUERY_TRB_STATUS    
} CSL_OstimerHwStatusQuery;

/** Hardware setup structure */
typedef struct CSL_OstimerHwSetup {
   /** 32 bit init value to be loaded to (TICK_VALUE_REG) register */ 
    Uint32                initVal;
   /** Configure the ostimer in one-shot mode or auto reload mode */
    CSL_OstimerLoadMode   mode;
   /** Configure the ostimer interrupt mode either TRUE or FALSE */
    Bool                  intEnable;
} CSL_OstimerHwSetup;

/** Module specific parameters. Present implementation doesn't have
 *  any module specific parameters.
 */
typedef struct{
	/** Bit mask to be used for module specific parameters */
	CSL_BitMask16   flags;
} CSL_OstimerParam;

/** Module specific context information. Present implementation doesn't have
 *  any Context information.
 */
typedef struct {
	/** Context information of OSTIMER. The below declaration
	 *  is just a place-holder for future implementation.
	 */
    Uint16	contextInfo;
} CSL_OstimerContext;


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

/** ostimer object structure */
typedef struct CSL_OstimerObj {
    /** Pointer to the register overlay structure of the ostimer */
    CSL_OstimerRegsOvly     regs;
    /** Specifies a particular instance of the ostimer.*/
    CSL_InstNum           ostimerNum;
} CSL_OstimerObj;

/** 
 * The config-structure Used to configure the ostimer using 
 * CSL_ostimerHwSetupRaw(..)
 */
typedef struct {
  /** TIMER_CTRL_REG register */
    Uint32  TIMER_CTRL_REG;   
  /** TICK_VALUE_REG */
    Uint32  TICK_VALUE_REG;   
} CSL_OstimerConfig;

/** Default hardware setup parameters */
#define CSL_OSTIMER_HWSETUP_DEFAULTS{\
        0xFFFFFFFF,\
        CSL_OSTIMER_MODE_ONESHOT,\
        FALSE\
        }

/** 
 * This data type is used to return the handle to the CSL of the
 * ostimer
 */
typedef struct CSL_OstimerObj  *CSL_OstimerHandle;

/************************************* ******************************************
 * Ostimer global function declarations
 ******************************************************************************/

/** ============================================================================
 *   @func CSL_ostimerInit
 *
 *   @desc
 *      This is the initialization function for the ostimer CSL. This
 *      function needs to be called before any other ostimer CSL
 *      functions are to be called. This function is idem-potent.
 *
 *   @arg    pContext TIMER specific context information
 *
 *   @ret    returns the status of the operation
 *
 *   @eg
  * @b Example:
 *  @verbatim

    ...
    if (CSL_SOK != CSL_ostimerInit(NULL)) {
       return;
    }
    @endverbatim
 * ===========================================================================
 */
CSL_Status  CSL_ostimerInit(
    CSL_OstimerContext *pContext
);

/** ===========================================================================
 *
 *   @func   CSL_ostimerOpen
 *
 *   @desc
 *           Function opens the ostimer Obj, for the specified ostimer number
 *
 *   @arg  hOstimerObj
 *           Handle to the ostimer Obj
 *
 *   @arg  ostimerNum
 *           specifies the ostimer to be open
 *
 *   @arg  pOstimerParam
 *         Module specific parameters; Currently there are none; the user 
 *         should pass 'NULL'
 *
 *   @arg  pStatus
 *           Return Status
 *
 *   @ret  CSL_OstimerHandle
 *           Valid ostimer handle will be returned if  status value is
 *           equal to CSL_SOK.
 *
 *   @eg
 *   @verbatim
 *  @verbatim
		  CSL_OstimerObj     ostimerObj;
		  CSL_Status         Status;
 		  ...
	      hOstimer = CSL_ostimerOpen(&ostimerObj,
                                 CSL_OSTIMER,
                                 NULL,
                                 &Status);
   @endverbatim
* ============================================================================
*/
CSL_OstimerHandle  CSL_ostimerOpen(
    CSL_OstimerObj     *pOstimerObj,  
    CSL_InstNum         ostimerNum,
    CSL_OstimerParam   *pOstimerParam,
    CSL_Status         *pStatus
);

/** ============================================================================
 *   @func CSL_ostimerClose
 *
 *   @desc
 *       This function marks that ostimer is available for reopen.      
 *      
 *   @arg    hOstimer
 *           Handle to the ostimer instance 
 *
 *   @ret    CSL_Status
 *           CSL_SOK            - ostimer is closed successfully
 *           CSL_ESYS_BADHANDLE - The handle passed is invalid
 *
 *   @eg
 *       CSL_ostimerClose (hOstimer);
 * ===========================================================================
 */
CSL_Status  CSL_ostimerClose(
    CSL_OstimerHandle        hOstimer
);

/** ============================================================================
 *   @func CSL_ostimerHwSetup
 *
 *   @desc
 *       It configures the ostimer registers as per the values passed
 *       in the hardware setup structure.
 *
 *   @arg    hOstimer
 *           Handle to the ostimer
 *            
 *   @arg    hwSetup         
 *           Pointer to harware setup structure
 *
 *   @ret    CSL_Status
 *           CSL_SOK             - Hardware setup successful
 *           CSL_ESYS_BADHANDLE  - Invalid handle
 *
 *   @eg
 *       CSL_OstimerHandle   hOstimer;
 *       CSL_OstimerObj      ostimerObj;
 *       CSL_OstimerHwSetup  hwSetup;
 *       CSL_status          status;
 *
 *       hOstimer = CSL_ostimerOpen(&ostimerObj, CSL_OSTIMER, 
 *                                  NULL, &status); 
 *           
 *       status = CSL_ostimerHwSetup(hOstimer, &hwSetup);
 * ===========================================================================
 */
CSL_Status  CSL_ostimerHwSetup(
    CSL_OstimerHandle           hOstimer,
    CSL_OstimerHwSetup          *hwSetup
);

/*
 * ============================================================================
 *   @func CSL_ostimerGetHwSetup
 *
 *   @desc
 *        It retrieves the hardware setup parameters 
 *
 *   @arg hOstimer
 *        Handle to the ostimer instance
 *
 *   @arg hwSetup
 *        Pointer to hardware setup structure
 *
 *   @ret CSL_Status
 *        CSL_SOK             - Get hardware setup successful
 *        CSL_ESYS_BADHANDLE  - Invalid handle
 *
 *   @eg
 *        CSL_status            status;
 *        CSL_OstimerHwSetup    hwSetup;
 *        
 *        status = CSL_ostimerGetHwSetup (hCfc, &hwSetup);
 *
 * ===========================================================================
 */

extern CSL_Status CSL_ostimerGetHwSetup (
    CSL_OstimerHandle       hOstimer,
    CSL_OstimerHwSetup *    hwSetup
);

/** ============================================================================
 *   @func CSL_ostimerHwControl
 *
 *   @desc
 *       This function performs various control operations on the ostimer,
 *       based on the command passed.
 *
 *   @arg    hOstimer
 *           Handle to the ostimer
 *
 *   @arg    cmd
 *           Operation to be performed on the ostimer
 *
 *   @arg    cmdArg
 *           Arguement specific to the command 
 *            
 *   @eg
 *     status = CSL_ostimerHwControl(hOstimer, CSL_OSTIMER_CMD_START, NULL);
 * =============================================================================
 */
CSL_Status  CSL_ostimerHwControl(
    CSL_OstimerHandle             hOstimer,
    CSL_OstimerHwControlCmd       cmd,
    void                          *cmdArg
);

/*
 * ======================================================
 *   @func   CSL_ostimerGetHwStatus
 *   @desc
 *       This function is used to get the value of various parameters of the
 *       ostimer. The value returned depends on the query passed.
 *
 *   @arg  hOstimer
 *         Handle to the ostimer
 *
 *   @arg  myQuery
 *         Query to be performed
 *
 *   @arg  *response
 *         Pointer to buffer to return the data requested by the query passed.
 *
 *   @ret  CSL_Status
 *           CSL_SOK            - Successful completion of the query
 *           CSL_ESYS_BADHANDLE - Invalid handle
 *           CSL_ESYS_INVQUERY  - Query command not supported
 *
 *   @eg
 *     status = CSL_ostimerGetHwStatus(hOstimer, CSL_OSTIMER_QUERY_COUNT, 
 *                                       &response);
 * ======================================================
 */
CSL_Status  CSL_ostimerGetHwStatus(
    CSL_OstimerHandle           hOstimer,
    CSL_OstimerHwStatusQuery    myQuery,
    void                        *response
);


/*
 * ======================================================
 *   @func   CSL_ostimerGetBaseAddress
 *   @desc
 *      This function is open for re-implementing if the user wants to modify
 *      the base address of the peripheral object to point to a different location
 *      and there by allow CSL initiated write/reads into peripheral MMR's go to an 
 *      alternate location
 *
 *   @arg   ostimerNum  
 *          Peripheral instance number.
 *
 *   @arg  pOstimerParam
 *         Module specific parameters
 *
 *   @arg  pBaseAddress
 *         Base address details. 
 *
 *   @ret  CSL_Status
 *           CSL_SOK            - Successful completion of the query
 *           CSL_ESYS_BADHANDLE - Invalid handle
 *           CSL_ESYS_INVQUERY  - Invalid parameter
 *
 *   @eg
 *        status = csl_ostimerGetBaseAddress(ostimerNum,pOstimerParam, pBaseAddress);
 * ======================================================
 */
CSL_Status
    CSL_ostimerGetBaseAddress (
	CSL_InstNum 	            ostimerNum,
	CSL_OstimerParam           *pOstimerParam,
	CSL_OstimerBaseAddress     *pBaseAddress 
);

/*
 * ======================================================
 *   @func   CSL_ostimerHwSetupRaw
 *
 *   @desc
 *     This function initializes the device registers with the 
       register-values provided through the Config Data structure
       For information passed through the Config Data structure 
       refer to @a CSL_OstimerConfig.
 *
 *   @arg  hOstimer
 *         Handle to the ostimer.  
 *
 *   @arg  setup
 *         Instance of the ostimer h/w set up
 *
 *   @eg
 *     	CSL_OstimerHandle hOstimer;
     	CSL_OstimerConfig config;
     	config.CNTL = 0x1000;
     	config.LOAD = 0xFFFF;
     	config.READ = 0x0000;
     CSL_ostimerHwSetupRaw(hOstimer, &config);
 * ======================================================
 */

CSL_Status  CSL_ostimerHwSetupRaw(
    CSL_OstimerHandle       hOstimer,
    CSL_OstimerConfig       *config
);

#ifdef __cplusplus
}
#endif
#endif

⌨️ 快捷键说明

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