📄 csl_tmr.h
字号:
Uint32 WDTCR;} CSL_TmrConfig;/** * @brief Module specific context information. Present implementation of GP * timer CSL doesn't have any context information. */typedef struct { /** Context information of GP timer CSL. * The below declaration is just a place-holder for future implementation. */ Uint16 contextInfo;} CSL_TmrContext;/** @brief Module specific parameters. Present implementation of GP timer CSL * 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_TmrParam;/** @brief This structure contains the base-address information for the * peripheral instance */typedef struct { /** Base-address of the configuration registers of the peripheral */ CSL_TmrRegsOvly regs;} CSL_TmrBaseAddress;/** * @brief Watchdog timer object structure. */typedef struct CSL_TmrObj { /** Pointer to the register overlay structure of the GP timer */ CSL_TmrRegsOvly regs; /** Instance of GP timer being referred by this object */ CSL_InstNum perNum;} CSL_TmrObj;/** Default values for config structure */#define CSL_TMR_CONFIG_DEFAULTS { \ CSL_TMR_EMUMGT_CLKSPD_RESETVAL, \ CSL_TMR_GPINT_GPEN_RESETVAL, \ CSL_TMR_GPTDAT_GPDIR_RESETVAL, \ CSL_TMR_TIM12_RESETVAL, \ CSL_TMR_TIM34_RESETVAL, \ CSL_TMR_PRD12_RESETVAL, \ CSL_TMR_PRD34_RESETVAL, \ CSL_TMR_TCR_RESETVAL, \ CSL_TMR_TGCR_RESETVAL, \ CSL_TMR_WDTCR_RESETVAL \}/** Default hardware setup parameters */#define CSL_TMR_HWSETUP_DEFAULTS { \ CSL_TMR_GPINT_GPEN_GPINT34_ENI_RESETVAL, \ CSL_TMR_GPINT_GPEN_GPINT34_ENO_RESETVAL, \ CSL_TMR_GPINT_GPEN_GPINT34_INVI_RESETVAL, \ CSL_TMR_GPINT_GPEN_GPINT34_INVO_RESETVAL, \ CSL_TMR_GPINT_GPEN_GPINT12_ENI_RESETVAL, \ CSL_TMR_GPINT_GPEN_GPINT12_ENO_RESETVAL, \ CSL_TMR_GPINT_GPEN_GPINT12_INVI_RESETVAL, \ CSL_TMR_GPINT_GPEN_GPINT12_INVO_RESETVAL, \ CSL_TMR_GPINT_GPEN_GPIO_ENI34_RESETVAL, \ CSL_TMR_GPINT_GPEN_GPIO_ENO34_RESETVAL, \ CSL_TMR_GPINT_GPEN_GPIO_ENI12_RESETVAL, \ CSL_TMR_GPINT_GPEN_GPIO_ENO12_RESETVAL, \ CSL_TMR_GPTDAT_GPDIR_GPIO_DIRO34_RESETVAL, \ CSL_TMR_GPTDAT_GPDIR_GPIO_DIRI34_RESETVAL, \ CSL_TMR_GPTDAT_GPDIR_GPIO_DIRO12_RESETVAL, \ CSL_TMR_GPTDAT_GPDIR_GPIO_DIRI12_RESETVAL, \ CSL_TMR_PRD12_RESETVAL, \ CSL_TMR_PRD34_RESETVAL, \ CSL_TMR_TIM12_RESETVAL, \ CSL_TMR_TIM34_RESETVAL, \ (CSL_TmrIpGate)CSL_TMR_TCR_TIEN34_RESETVAL, \ (CSL_TmrClksrc)CSL_TMR_TCR_CLKSRC34_RESETVAL, \ (CSL_TmrPulseWidth)CSL_TMR_TCR_PWID34_RESETVAL, \ (CSL_TmrClockPulse)CSL_TMR_TCR_CP34_RESETVAL, \ (CSL_TmrInvInp)CSL_TMR_TCR_INVINP34_RESETVAL, \ (CSL_TmrInvOutp)CSL_TMR_TCR_INVOUTP34_RESETVAL, \ (CSL_TmrIpGate)CSL_TMR_TCR_TIEN12_RESETVAL, \ (CSL_TmrClksrc)CSL_TMR_TCR_CLKSRC12_RESETVAL, \ (CSL_TmrPulseWidth)CSL_TMR_TCR_PWID12_RESETVAL, \ (CSL_TmrClockPulse)CSL_TMR_TCR_CP12_RESETVAL, \ (CSL_TmrInvInp)CSL_TMR_TCR_INVINP12_RESETVAL, \ (CSL_TmrInvOutp)CSL_TMR_TCR_INVOUTP12_RESETVAL, \ CSL_TMR_TGCR_PSC34_RESETVAL, \ (CSL_TmrMode)CSL_TMR_TGCR_TIMMODE_RESETVAL \}/** * @brief This data type is used to return the handle to the CSL of the GP * timer */typedef struct CSL_TmrObj *CSL_TmrHandle;/******************************************************************************* * Watchdog global function declarations ******************************************************************************//** ============================================================================ * @n@b CSL_tmrInit * * @b Description * @n This is the initialization function for the TIMER. This function is * idempotent in that calling it many times is same as calling it once. * This function initializes the CSL data structures, and doesn't affect * the H/W. * * @b Arguments @verbatim pContext Context information for the instance. Should be NULL @endverbatim * * <b> Return Value </b> CSL_Status * @li CSL_SOK - Always returns * * <b> Pre Condition </b> * @n None * * <b> Post Condition </b> * @n None * * @b Modifies * @n None * * @b Example * @verbatim * ... * if (CSL_sysInit() == CSL_SOK) { * CSL_tmrInit(); * } * @endverbatim * ============================================================================ */CSL_Status CSL_tmrInit ( CSL_TmrContext *pContext);/** ============================================================================ * @n@b CSL_tmrOpen * * @b Description * @n This function populates the peripheral data object for the TMR instance * and returns a handle to the instance. * The open call sets up the data structures for the particular instance * of TMR device. The device can be re-opened anytime after it has been * normally closed if so required. The handle returned by this call is * input as an essential argument for rest of the APIs described * for this module. * * @b Arguments * @verbatim pTmrObj Pointer to the TMR instance object tmrNum Instance of the TMR to be opened pTmrParam Pointer to module specific parameters pStatus pointer for returning status of the function call @endverbatim * * <b> Return Value </b> CSL_TmrHandle * @n Valid TMR instance handle will be returned if status value is equal to CSL_SOK. * * <b> Pre Condition </b> * @n None * * <b> Post Condition </b> * @n 1. The status is returned in the status variable. If status * returned is * @li CSL_SOK Valid tmr handle is returned * @li CSL_ESYS_FAIL The tmr instance is invalid * @li CSL_ESYS_INVPARAMS Invalid parameter * * 2. TMR object structure is populated * * @b Modifies * @n 1. The status variable * * 2. TMR object structure * * @b Example * @verbatim CSL_status status; CSL_TmrObj tmrObj; CSL_TmrHandle hTmr; ... hTmr = CSL_tmrOpen (&tmrObj, CSL_TMR_PER_CNT, NULL, &status); @endverbatim * ============================================================================ */CSL_TmrHandle CSL_tmrOpen ( CSL_TmrObj *tmrObj, CSL_InstNum tmrNum, CSL_TmrParam *pTmrParam, CSL_Status *status);/* ============================================================================ * @n@b CSL_tmrGetBaseAddress * * @b Description * @n This function gets the base address of the given GP timer * instance. * * @b Arguments * @verbatim hTmr Pointer to the peripheral data object of the GP timer instance tmrNum Specifies the instance of the GP timer for which the base address is requested pTmrParam Module specific parameters. pBaseAddress Pointer to the base address structure to return the base address details. @endverbatim * * <b> Return Value </b> CSL_Status * @li CSL_OK Open call is successful * @li CSL_ESYS_FAIL The GP timer instance is not * available. * * <b> Pre Condition </b> * @n None * * <b> Post Condition </b> * @n Base address structure is populated * * @b Modifies * @n 1. The status variable * * 2. Base address structure. * * @b Example * @verbatim CSL_Status status; CSL_TmrBaseAddress baseAddress; ... status = CSL_tmrGetBaseAddress(CSL_WDT, NULL, &baseAddress); @endverbatim * =========================================================================== */CSL_Status CSL_tmrGetBaseAddress ( CSL_InstNum tmrNum, CSL_TmrParam *pTmrParam, CSL_TmrBaseAddress *pBaseAddress);/** ============================================================================ * @n@b CSL_tmrClose * * @b Description * @n This function closes the specified instance of TMR. * * @b Arguments * @verbatim hTmr Handle to the TMR instance @endverbatim * * <b> Return Value </b> CSL_Status * @li CSL_SOK - Close successful * @li CSL_ESYS_BADHANDLE - Invalid handle * * @b Example * @verbatim CSL_TmrHandle hTmr; CSL_status status; ... status = CSL_tmrClose(hTmr); @endverbatim * ============================================================================ */CSL_Status CSL_tmrClose ( CSL_TmrHandle hTmr);/** ============================================================================ * @n@b CSL_tmrHwSetup * * @b Description * @n It configures the tmr registers as per the values passed * in the hardware setup structure. * * @b Arguments * @verbatim hTmr Handle to the TMR instance hwSetup Pointer to harware setup structure @endverbatim * * <b> Return Value </b> CSL_Status * @li CSL_SOK - Hardware setup successful. * @li CSL_ESYS_BADHANDLE - Invalid handle * @li CSL_ESYS_INVPARAMS - Hardware structure is not properly initialized * * @b Modifies * @n The hardware registers of TMR. * * @b Example * @verbatim CSL_TmrHandle hTmr; CSL_TmrObj tmrObj; CSL_TmrHwSetup hwSetup; CSL_status status; ... hTmr = CSL_tmrOpen (&tmrObj, CSL_TMR_PRIMARY, NULL, &status); status = CSL_tmrHwSetup(hTmr, &hwSetup); * @endverbatim * ============================================================================ */CSL_Status CSL_tmrHwSetup ( CSL_TmrHandle hTmr, CSL_TmrHwSetup *hwSetup);/** ============================================================================ * @n@b CSL_tmrHwControl * * @b Description * @n Takes a command of TMR with an optional argument & implements it. * * @b Arguments * @verbatim hTmr Handle to the TMR instance cmd The command to this API indicates the action to be taken on TMR. arg An optional argument. @endverbatim * * <b> Return Value </b> CSL_Status * @li CSL_SOK - Status info return successful. * @li CSL_ESYS_BADHANDLE - Invalid handle * @li CSL_ESYS_INVCMD - Invalid command * @li CSL_ESYS_FAIL - Invalid instance number * * <b> Pre Condition </b> * @n None * * <b> Post Condition </b> * @n None * * @b Modifies * @n The hardware registers of TMR. * * @b Example * @verbatim CSL_TmrCount tmrCount = 0xABCD; status = CSL_tmrHwControl(hTmr, CSL_TIMER_CMD_LOAD, &tmrCount); @endverbatim * ============================================================================ */CSL_Status CSL_tmrHwControl ( CSL_TmrHandle hTmr, CSL_TmrHwControlCmd cmd, void *cmdArg);/** ============================================================================ * @n@b CSL_tmrGetHwStatus * * @b Description * @n Gets the status of the different operations of TMR. * * @b Arguments * @verbatim hTmr Handle to the TMR instance query The query to this API of TMR which indicates the status to be returned. response Placeholder to return the status. @endverbatim * * <b> Return Value </b> CSL_Status * @li CSL_SOK - Status info return successful. * @li CSL_ESYS_BADHANDLE - Invalid handle * @li CSL_ESYS_INVPARAMS - Invalid parameter * * <b> Pre Condition </b> * @n None * * <b> Post Condition </b> * @n None * * @b Modifies * @n None * * @b Example * @verbatim Uint16 count = 0; CSL_Status status; status = CSL_tmrGetHwStatus(hTmr, CSL_TMR_QUERY_COUNT, &count); @endverbatim * ============================================================================ */CSL_Status CSL_tmrGetHwStatus ( CSL_TmrHandle hTmr, CSL_TmrHwStatusQuery query, void *response);/** ============================================================================ * @n@b CSL_tmrHwSetupRaw * * @b Description * @n This function initializes the device registers with the register-values * provided through the Config Data structure. * * @b Arguments * @verbatim hTmr Handle to the TMR instance config Pointer to config structure @endverbatim * * <b> Return Value </b> CSL_Status * @li CSL_SOK - Configuration successful * @li CSL_ESYS_BADHANDLE - Invalid handle * @li CSL_ESYS_INVPARAMS - Configuration is not properly initialized * <b> Pre Condition </b> * @n None * * <b> Post Condition </b> * @n The registers of the specified TMR instance will be setup * according to input configuration structure values. * * @b Modifies * @n Hardware registers of the specified TMR instance. * * @b Example * @verbatim CSL_TmrHandle hTmr; CSL_TmrConfig config = CSL_TMR_CONFIG_DEFAULTS; CSL_Status status; status = CSL_tmrHwSetupRaw (hTmr, &config); @endverbatim * ============================================================================ */CSL_Status CSL_tmrHwSetupRaw ( CSL_TmrHandle hTmr, CSL_TmrConfig *config);/** ============================================================================ * @n@b CSL_tmrGetHwSetup * * @b Description * @n Gets the current setup of TMR. * * @b Arguments * @verbatim hTmr Handle to the TMR instance setup Pointer to setup structure which contains the setup information of TMR. @endverbatim * * <b> Return Value </b> CSL_Status * @li CSL_SOK - Setup info load successful. * @li CSL_ESYS_BADHANDLE - Invalid handle * @li CSL_ESYS_INVPARAMS - Invalid parameter * * <b> Pre Condition </b> * @n None * * <b> Post Condition </b> * @n The registers of the specified TMR instance will be setup. * * @b Modifies * @n Hardware registers of the specified TMR instance. * * @b Example * @verbatim CSL_TmrHandle hTmr; CSL_TmrHwSetup setup; CSL_Status status; status = CSL_tmrGetHwSetup (hTmr, &setup); @endverbatim * ============================================================================ */CSL_Status CSL_tmrGetHwSetup ( CSL_TmrHandle hTmr, CSL_TmrHwSetup *hwSetup);#ifdef __cplusplus}#endif#endif /* _CSL_TMR_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -