# TIMER Functions
[TIMER]

## Functions
CSL_Status | CSL_tmrInit (CSL_TmrContext *pContext)
CSL_TmrHandle | CSL_tmrOpen (CSL_TmrObj *tmrObj, CSL_InstNum tmrNum, CSL_TmrParam *pTmrParam, CSL_Status *status)
CSL_Status | CSL_tmrGetBaseAddress (CSL_InstNum tmrNum, CSL_TmrParam *pTmrParam, CSL_TmrBaseAddress *pBaseAddress)
CSL_Status | CSL_tmrClose (CSL_TmrHandle hTmr)
CSL_Status | CSL_tmrHwSetup (CSL_TmrHandle hTmr, CSL_TmrHwSetup *hwSetup)
CSL_Status | CSL_tmrHwControl (CSL_TmrHandle hTmr, CSL_TmrHwControlCmd cmd, void *cmdArg)
CSL_Status | CSL_tmrGetHwStatus (CSL_TmrHandle hTmr, CSL_TmrHwStatusQuery query, void *response)
CSL_Status | CSL_tmrHwSetupRaw (CSL_TmrHandle hTmr, CSL_TmrConfig *config)
CSL_Status | CSL_tmrGetHwSetup (CSL_TmrHandle hTmr, CSL_TmrHwSetup *hwSetup)
CSL_IDEF_INLINE void | CSL_tmrGetTimHiCount (CSL_TmrHandle hTmr, Uint32 *countHi)
CSL_IDEF_INLINE void | CSL_tmrGetTimLoCount (CSL_TmrHandle hTmr, Uint32 *countLo)
CSL_IDEF_INLINE CSL_TmrTstat | CSL_tmrGetTstatLoStatus (CSL_TmrHandle hTmr)
CSL_IDEF_INLINE CSL_TmrTstat | CSL_tmrGetTstatHiStatus (CSL_TmrHandle hTmr)
CSL_IDEF_INLINE CSL_TmrWdflagBitStatus | CSL_tmrGetWdflagStatus (CSL_TmrHandle hTmr)
CSL_IDEF_INLINE void | CSL_TmrLoadPrdLo (CSL_TmrHandle hTmr, Uint32 *loadVal)
CSL_IDEF_INLINE void | CSL_TmrLoadPrdHi (CSL_TmrHandle hTmr, Uint32 *loadVal)
CSL_IDEF_INLINE void | CSL_TmrLoadPrescalarHi (CSL_TmrHandle hTmr, Uint8 *loadVal)
CSL_IDEF_INLINE void | CSL_TmrStartHi (CSL_TmrHandle hTmr, CSL_TmrEnamode countMode)
CSL_IDEF_INLINE void | CSL_TmrStartLo (CSL_TmrHandle hTmr, CSL_TmrEnamode countMode)
CSL_IDEF_INLINE void | CSL_TmrStart64 (CSL_TmrHandle hTmr, CSL_TmrEnamode countMode)
CSL_IDEF_INLINE void | CSL_TmrStopLo (CSL_TmrHandle hTmr)
CSL_IDEF_INLINE void | CSL_TmrStopHi (CSL_TmrHandle hTmr)
CSL_IDEF_INLINE void | CSL_TmrStop64 (CSL_TmrHandle hTmr)
CSL_IDEF_INLINE void | CSL_TmrResetHi (CSL_TmrHandle hTmr)
CSL_IDEF_INLINE void | CSL_TmrResetLo (CSL_TmrHandle hTmr)
CSL_IDEF_INLINE void | CSL_TmrReset64 (CSL_TmrHandle hTmr)
CSL_IDEF_INLINE void | CSL_TmrStartWdt (CSL_TmrHandle hTmr, CSL_TmrEnamode countMode)
CSL_IDEF_INLINE void | CSL_TmrLoadWdkey (CSL_TmrHandle hTmr, Uint16 cmd)
CSL_IDEF_INLINE void | CSL_TmrDisableWdt (CSL_TmrHandle hTmr)

## Function Documentation

CSL_Status CSL_tmrClose | ( | CSL_TmrHandle | hTmr | ) |

============================================================================
CSL_tmrClose

Description
This function marks that CSL for the GP timer instance is closed. CSL for the GP timer instance need to be reopened before using any GP timer CSL API.

Arguments

                hTmr         Timer handle to be closed.

Return Value
Success - CSL_SOK
Error - CSL_ESYS_BADHANDLE (The handle passed is invalid)

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
1. The GP timer CSL APIs can not be called until the GP timer CSL is reopened again using CSL_tmrOpen()

Writes
None

Example

                CSL_status      status;
                CSL_TmrObj      tmrObj;
                CSL_TmrHandle   hTmr;
                CSL_TmrContext  context;

                // Initialize the Timer Module.
                CSL_tmrInit(&context);
                ...
                // Open TIMER 0
                hTmr = CSL_tmrOpen(&tmrObj, 0, NULL, &status);
                ...
                // Close the timer.
                CSL_tmrClose(hTmr);

===========================================================================

CSL_IDEF_INLINE void CSL_TmrDisableWdt | ( | CSL_TmrHandle | hTmr | ) |

===========================================================================
CSL_TmrDisableWdt

Description The function disables the Watch Dog Timer.

Arguments

            hTmr         Handle to the Timer instance

Return Value None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
The Watch Dog timer is disabled.

Writes
TMR_WDTCR_WDEN=0

Example

            CSL_TmrHandle hWdt;
            ...
            CSL_TmrDisableWdt(hWdt);
            ...

===========================================================================

CSL_Status CSL_tmrGetBaseAddress | ( | CSL_InstNum | tmrNum,
|  | CSL_TmrParam * | pTmrParam,
|  | CSL_TmrBaseAddress * | pBaseAddress |
| ) |  |  |

============================================================================
CSL_tmrGetBaseAddress

Description
This function gets the base address of the given GPTIMER instance.

Arguments

                tmrNum        Specifies the instance of the gptimer to be opened
                pTmrParam     TIMER module specific parameters
                pBaseAddress  Pointer to base address structure containing base
                              address details

Return Value
Success - CSL_SOK
Error - CSL_ESYS_FAIL (Timer Instance is invalid)
Error - CSL_ESYS_INVPARAMS (The parameter passed is invalid)

Pre Condition
None

Post Condition
None

Affects
None

Example

            CSL_Status            status;
            CSL_TmrBaseAddress    baseAddress;
            CSL_TmrContext  context;

            // Initialize the Timer Module.
            CSL_tmrInit(&context);
            ...
            // Get the base address for TIMER Instance 0.
            status = CSL_tmrGetBaseAddress(0, NULL, &baseAddress);
            ...

===========================================================================

CSL_Status CSL_tmrGetHwSetup | ( | CSL_TmrHandle | hTmr,
|  | CSL_TmrHwSetup * | hwSetup |
| ) |  |  |

============================================================================
CSL_tmrGetHwSetup

Description
It retrives the hardware setup parameters

Arguments

                hTmr            Handle to the timer instance
                hwSetup         Pointer to hardware setup structure populated by this API

Return Value
Success - CSL_SOK
Error - CSL_ESYS_BADHANDLE (The handle passed is invalid)

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
The hardware set up structure will be populated with values from the registers

Reads
TMR_PRDLO_PRDLO,TMR_PRDHI_PRDHI,TMR_CNTLO_CNT,TMR_CNT_CNTHI,TMR_TCR_TIEN_HI,TMR_TCR_CLKSRC_HI, TMR_TCR_PWID_HI,TMR_TCR_CP_HI,TMR_TCR_INVINP_HI,TMR_TCR_INVOUTP_HI,TMR_TCR_TIEN_LO,TMR_TCR_CLKSRC_LO, TMR_TCR_PWID_LO,TMR_TCR_CP_LO,TMR_TCR_INVINP_LO,TMR_TCR_INVOUTP_LO,TMR_TGCR_PSCHI,TMR_TGCR_TIMMODE,

Example

                CSL_status      status;
                CSL_TmrObj      tmrObj;
                CSL_TmrHandle   hTmr;
                CSL_TmrContext  context;
                CSL_TmrConfig   config;

                // Initialize the Timer Module.
                CSL_tmrInit(&context);
                ...
                // Open TIMER 0
                hTmr = CSL_tmrOpen(&tmrObj, 0, NULL, &status);
                ...
                // Get the current timer configuration the timer with the 'defaults'
                CSL_tmrGetHwsetup (hTmr, &config);
                ...

===========================================================================

CSL_Status CSL_tmrGetHwStatus | ( | CSL_TmrHandle | hTmr,
|  | CSL_TmrHwStatusQuery | query,
|  | void * | response |
| ) |  |  |

===========================================================================
CSL_tmrGetHwStatus

Description
This function is used to get the value of various parameters of the timer instance. The value returned depends on the query passed.

Arguments

                hTmr            Handle to the timer instance
                query           Query to be performed
                response        Pointer to buffer to return the data requested by
                                the query passed

Return Value CSL_Status
Success - CSL_SOK
Error - CSL_ESYS_BADHANDLE (The handle passed is invalid)
Error - CSL_ESYS_INVQUERY (The query passed is invalid)
Error - CSL_ESYS_INVPARAMS (The parameter passed is invalid)

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition Data requested by the query is returned through the variable "response"

Reads
TMR_CNTLO_CNT;TMR_CNTHI_CNT;TMR_TCR_TSTAT_LO;TMR_TCR_TSTAT_HI;TMR_WDTCR_WDFLAG

Example

                CSL_status      status;
                CSL_TmrObj      tmrObj;
                CSL_TmrHandle   hTmr;
                CSL_TmrContext  context;
                Uint32          response;

                // Initialize the Timer Module.
                CSL_tmrInit(&context);
                ...
                // Open TIMER 0
                hTmr = CSL_tmrOpen(&tmrObj, 0, NULL, &status);
                ...
                // Get the value of LOW Count for Timer 0.
                CSL_tmrGetHwStatus(hTmr, CSL_TMR_QUERY_COUNT_LO, &response);

===========================================================================

CSL_IDEF_INLINE void CSL_tmrGetTimHiCount | ( | CSL_TmrHandle | hTmr,
|  | Uint32 * | countHi |
| ) |  |  |

============================================================================
CSL_tmrGetTimHiCount

Description
This function gets the value of the CNTHI counter

Arguments

             hTmr        Pointer to the object that holds reference to the
                         instance of TIMER requested after the call
             countHi     Output parameter to get the CNTHI value

Return Value
The argument countHi is populated with the contents of the CNTHI register

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
None

Reads
TMR_CNTHI_CNT

Example

            CSL_TmrHandle   hTmr;
            Unit32*         countHi;
            ...
            CSL_tmrGetTimHiCount(hTmr, &countHi);
            ...

============================================================================

CSL_IDEF_INLINE void CSL_tmrGetTimLoCount | ( | CSL_TmrHandle | hTmr,
|  | Uint32 * | countLo |
| ) |  |  |

===========================================================================
CSL_tmrGetTimLoCount

Description
This function gets the value of the CNTLO counter

Arguments

             hTmr       Pointer to the object that holds reference to the
                        instance of TIMER requested after the call
             countLo    Output parameter to get the CNTLO value

Return Value None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
The argument countLo is populated with the contents of the CNTLO register

Reads
TMR_CNTLO_CNT

Example

            CSL_TmrHandle hTmr;
            Unit32        *countLo;
            ...
            CSL_tmrGetTimLoCount(hTmr, &countLo);
            ...

============================================================================

CSL_IDEF_INLINE CSL_TmrTstat CSL_tmrGetTstatHiStatus | ( | CSL_TmrHandle | hTmr | ) |

===========================================================================
CSL_tmrGetTstatHiStatus

Description
This function gets the status of the TINTHI

Arguments

             hTmr   Pointer to the object that holds reference to the
                    instance of TIMER requested after the call

Return Value
CSL_TmrTstatHi - TINTHI status value

- CSL_TMR_TSTATHI_LOW - Data low
- CSL_TMR_TSTATHI_HIGH - Data High

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
None

Reads
TMR_TCR_TSTAT_HI

Example

            CSL_TmrHandle  hTmr;
            CSL_TmrTstatHi statusHi;
            ...
            statusHi = CSL_tmrGetTstatHiStatus(hTmr);
            ...

============================================================================

CSL_IDEF_INLINE CSL_TmrTstat CSL_tmrGetTstatLoStatus | ( | CSL_TmrHandle | hTmr | ) |

===========================================================================
CSL_tmrGetTstatLoStatus

Description
This function gets the status of the TINTLO

Arguments

             hTmr   Pointer to the object that holds reference to the
                    instance of TIMER requested after the call

Return Value
CSL_TmrTstatLo - TINTLO status value

- CSL_TMR_TSTAT_LO_LOW - Data low
- CSL_TMR_TSTAT_LO_HIGH - Data High

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
None

Reads
TMR_TCR_TSTAT_LO

Example

            CSL_TmrHandle  hTmr;
            CSL_TmrTstatLo statusLo;
            ...
            statusLo = CSL_tmrGetTstatLoStatus(hTmr);
            ...

===========================================================================

CSL_IDEF_INLINE CSL_TmrWdflagBitStatus CSL_tmrGetWdflagStatus | ( | CSL_TmrHandle | hTmr | ) |

===========================================================================
CSL_tmrGetWdflagStatus

Description
This function gets the status of the WDFLAG

Arguments

             hTmr   Pointer to the object that holds reference to the
                    instance of TIMER requested after the call

Return Value
CSL_TmrFlagBitStatus - WDFLAG status value

- CSL_TMR_WDFLAG_NOTIMEOUT - no watchdog timeout occurred
- CSL_TMR_WDFLAG_TIMEOUT - watchdog timeout occurred

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called and the Timer should be set in WATCHDOG mode

Post Condition
None

Reads
TMR_WDTCR_WDFLAG

Example

            CSL_TmrHandle          hTmr;
            CSL_TmrWdflagBitStatus status;
            ...
            status = CSL_tmrGetWdflagStatus(hTmr);
            ...

===========================================================================

CSL_Status CSL_tmrHwControl | ( | CSL_TmrHandle | hTmr,
|  | CSL_TmrHwControlCmd | cmd,
|  | void * | arg |
| ) |  |  |

============================================================================
CSL_tmrHwControl

Description
This function performs various control operations on the timer instance, based on the command passed.

Arguments

                hTmr         Handle to the timer instance
                cmd          Operation to be performed on the timer
                cmdArg       Argument specific to the command

Return Value
Success - CSL_SOK
Error - CSL_ESYS_BADHANDLE (The handle passed is invalid)
Error - CSL_ESYS_INVPARAMS (The parameter passed is invalid)
Error - CSL_ESYS_INVCMD (The command passed is invalid)

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
Registers of the timer instance are configured according to the command and the command arguments. The command determines which registers are modified.

Writes
TMR_PRDLO_PRDLO; TMR_PRDHI_PRDHI; TMR_TGCR_PSCHI; TMR_TGCR_TIMLORS=1,TMR_TCR_ENAMODE_LO; TMR_TGCR_TIMHIRS=1,TMR_TCR_ENAMODE_HI; TMR_TCR_ENAMODE_LO=0; TMR_TCR_ENAMODE_HI=0; TMR_TGCR_TIMLORS=0; TMR_TGCR_TIMHIRS=0; TMR_TGCR_TIMLORS=1,TMR_TGCR_TIMHIRS=1, TMR_TCR_ENAMODE_LO,TMR_TCR_ENAMODE_HI; TMR_TCR_ENAMODE_LO=0,TMR_TCR_ENAMODE_HI=0; TMR_TGCR_TIMLORS=0,TMR_TGCR_TIMHIRS=0; TMR_TGCR_TIMLORS=1,TMR_TGCR_TIMHIRS=1,TMR_WDTCR_WDEN=1,TMR_TCR_ENAMODE_LO,TMR_TCR_ENAMODE_HI; TMR_WDTCR_WDKEY

Example

                CSL_status      status;
                CSL_TmrObj      tmrObj;
                CSL_TmrHandle   hTmr;
                CSL_TmrContext  context;

                // Initialize the Timer Module.
                CSL_tmrInit(&context);
                ...
                // Open TIMER 0
                hTmr = CSL_tmrOpen(&tmrObj, 0, NULL, &status);
                ...
                // Start the LO Timer.
                CSL_tmrHwControl(hTmr, CSL_TMR_CMD_START_TIMLO, NULL);
                ...

============================================================================

CSL_Status CSL_tmrHwSetup | ( | CSL_TmrHandle | hTmr,
|  | CSL_TmrHwSetup * | hwSetup |
| ) |  |  |

============================================================================
CSL_tmrHwSetup

Description
It configures the timer instance registers as per the values passed in the hardware setup structure.

Arguments

                htmr        Handle to the timer instance
                setup       Pointer to hardware setup structure populated by
                            this API

Return Value
Success - CSL_SOK
Error - CSL_ESYS_BADHANDLE (The handle passed is invalid)
Error - CSL_ESYS_INVPARAMS (The parameter passed is invalid)

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
The specified instance will be setup according to value passed

Writes
TMR_PRDLO_PRDLO,TMR_PRDHI_PRDHI,TMR_CNTLO_CNT,TMR_CNTHI_CNT, TMR_TCR_TIEN_HI,TMR_TCR_CLKSRC_HI,TMR_TCR_PWID_HI,TMR_TCR_CP_HI,TMR_TCR_INVINP_HI, TMR_TCR_INVOUTP_HI,TMR_TCR_TIEN_LO,TMR_TCR_CLKSRC_LO,TMR_TCR_PWID_LO,TMR_TCR_CP_LO, TMR_TCR_INVINP_LO, TMR_TCR_INVOUTP_LO,TMR_TGCR_PSCHI,TMR_TGCR_TIMMODE,

Example

                CSL_status      status;
                CSL_TmrObj      tmrObj;
                CSL_TmrHandle   hTmr;
                CSL_TmrContext  context;
                CSL_tmrHwSetup  hwSetup;

                // Initialize the Timer Module.
                CSL_tmrInit(&context);
                ...
                // Open TIMER 0
                hTmr = CSL_tmrOpen(&tmrObj, 0, NULL, &status);
                ...
                // Get the Hardware Setup for Timer 0.
                CSL_tmrHwSetup(htmr, &hwSetup);
                ...

===========================================================================

CSL_Status CSL_tmrHwSetupRaw | ( | CSL_TmrHandle | hTmr,
|  | CSL_TmrConfig * | config |
| ) |  |  |

============================================================================
CSL_tmrHwSetupRaw

Description
This function initializes the device registers with the register-values provided through the config data structure.

Arguments

                hTmr            Pointer to the object that holds reference to the
                                instance of TIMER requested after the call
                config          Pointer to the config structure containing the
                                device register values

Return Value
Success - CSL_SOK
Error - CSL_ESYS_BADHANDLE (The handle passed is invalid)
Error - CSL_ESYS_INVPARAMS (The parameter passed is invalid)

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
The registers of the specified General purpose timer instance will be setup according to the values passed through the config structure

Writes
TMR_CNTLO_CNT,TMR_CNTHI_CNT,TMR_PRDLO_PRDLO,TMR_PRDHI_PRDHI,TMR_TCR_TCR,TMR_TGCR_TGCR, TMR_WDTCR_WDTCR

Example

                CSL_status      status;
                CSL_TmrObj      tmrObj;
                CSL_TmrHandle   hTmr;
                CSL_TmrContext  context;
                CSL_TmrConfig   config = CSL_TMR_CONFIG_DEFAULTS;

                // Initialize the Timer Module.
                CSL_tmrInit(&context);
                ...
                // Open TIMER 0
                hTmr = CSL_tmrOpen(&tmrObj, 0, NULL, &status);
                ...
                // Configure the timer with the 'defaults'
                CSL_tmrHwSetupRaw (hTmr, &config);
                ...

===========================================================================

CSL_Status CSL_tmrInit | ( | CSL_TmrContext * | pContext | ) |

============================================================================
CSL_tmrInit

Description
This is the initialization function for the General purpose timer CSL. The function must be called before calling any other API from this CSL. This function is idem-potent. Currently, the function just return status CSL_SOK, without doing anything.

Arguments

            pContext    Pointer to module-context. As General purpose timer doesn't
                        have any context based information user is expected to pass
                        NULL.

Return Value
Always returns Success - CSL_SOK

Pre Condition
None

Post Condition
The CSL for gptimer is initialized

Writes
None

Example

                CSL_TmrContext  context;

                // Initialize the Timer Module.
                CSL_tmrInit(&context);
                ...

=============================================================================

CSL_IDEF_INLINE void CSL_TmrLoadPrdHi | ( | CSL_TmrHandle | hTmr,
|  | Uint32 * | loadVal |
| ) |  |  |

============================================================================
CSL_TmrLoadPrdHi

Description Loads the General purpose timer HIGH period register

Arguments

             hTmr        Handle to the GPtimer instance
             loadVal     Value to be loaded to the Gptimer period register High

Return Value None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
Period register is loaded with the given value.

Writes
TMR_PRDHI_PRDHI

Example

            CSL_TmrHandle   hTmr;
            Uint32          loadVal;
            ...
            loadVal = 10;
            CSL_TmrLoadPrdHi(hWdt, &loadVal);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrLoadPrdLo | ( | CSL_TmrHandle | hTmr,
|  | Uint32 * | loadVal |
| ) |  |  |

============================================================================
CSL_TmrLoadPrdLo

Description Loads the General purpose timer LOW period register.

Arguments

             hTmr        Handle to the Gptimer instance
             loadVal     Value to be loaded to the Gptimer period register Low

Return Value
None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
Period register is loaded with the given value.

Writes
TMR_PRDLO_PRDLO

Example

            CSL_TmrHandle hTmr;
            Uint32       loadVal;

            loadVal = 10;
            CSL_TmrLoadPrdLo(hWdt, &loadVal);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrLoadPrescalarHi | ( | CSL_TmrHandle | hTmr,
|  | Uint8 * | loadVal |
| ) |  |  |

============================================================================
CSL_TmrLoadPrescalarHi

Description Configures the prescalar values for the HIGH Timer.

Arguments

             hTmr        Handle to the Timer Instance
             loadVal     Value to be loaded to the PRESCALAR bits in the TGCR register

Return Value
None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
Gptimer pre scalar register is loaded with the given value.

Writes
TMR_TGCR_PSCHI

Example

            CSL_TmrHandle hTmr;
            Uint8         *loadVal;
            ...
            CSL_TmrLoadPrescalarHi(hWdt, &loadVal);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrLoadWdkey | ( | CSL_TmrHandle | hTmr,
|  | Uint16 | cmd |
| ) |  |  |

===========================================================================
CSL_TmrLoadtWdkey

Description The function loads the watch dog timer with the appropriate key.

Arguments

             hTmr        Handle to the Gptimer instance
             cmd         Specifies the WATCHDOG Key. This can only be either of
                         the following:-
                            - CSL_TMR_WDTCR_WDKEY_CMD1
                            - CSL_TMR_WDTCR_WDKEY_CMD2

Return Value None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
Loads the WDKEY in WDTCR register.

Writes
TMR_WDTCR_WDKEY

Example

            CSL_TmrHandle hWdt;
            ...
            CSL_TmrLoadWdkey(hWdt, CSL_TMR_WDTCR_WDKEY_CMD1);
            ...

===========================================================================

CSL_TmrHandle CSL_tmrOpen | ( | CSL_TmrObj * | pTmrObj,
|  | CSL_InstNum | tmrNum,
|  | CSL_TmrParam * | pTmrParam,
|  | CSL_Status * | pStatus |
| ) |  |  |

============================================================================
CSL_tmrOpen

Description
This function populates the peripheral data object for the TIMER instance and returns a handle to the instance. The open call sets up the data structures for the particular instance of TIMER 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.

Arguments

                tmrObj          Pointer to GPTIMER object.
                tmrNum          Instance of GPTIMER CSL to be opened.
                pTmrParam       Module specific parameters.
                status          Status of the function call

Return Value
Success - Valid Timer Handle
Error - CSL_ESYS_FAIL (The Timer Instance is invalid)
Error - CSL_ESYS_INVPARAMS (The parameter passed is invalid)

Pre Condition
CSL_tmrInit() must be called.

Post Condition
None

Writes
None

Example

                CSL_status      status;
                CSL_TmrObj      tmrObj;
                CSL_TmrHandle   hTmr;
                CSL_TmrContext  context;

                // Initialize the Timer Module.
                CSL_tmrInit(&context);
                ...
                // Open TIMER 0
                hTmr = CSL_tmrOpen(&tmrObj, 0, NULL, &status);
                ...

=============================================================================

CSL_IDEF_INLINE void CSL_TmrReset64 | ( | CSL_TmrHandle | hTmr | ) |

===========================================================================
CSL_TmrReset64

Description The function resets the 64bit timer.

Arguments

             hTmr        Handle to the Timer instance

Return Value
None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
64bit Timer is reset.

Writes
TMR_TGCR_TIMLORS=0,TMR_TGCR_TIMHIRS=0

Example

            CSL_TmrHandle hTmr;
            ...
            CSL_TmrReset64(hTmr);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrResetHi | ( | CSL_TmrHandle | hTmr | ) |

===========================================================================
CSL_TmrResetHi

Description The HIGH timer is moved to RESET state.

Arguments

             hTmr        Handle to the HIGH timer instance

Return Value
None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
High timer is reset.

Writes
TMR_TGCR_TIMHIRS=0

Example

            CSL_TmrHandle hTmr;
            ...
            CSL_TmrResetHi(hTmr);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrResetLo | ( | CSL_TmrHandle | hTmr | ) |

===========================================================================
CSL_TmrResetLo

Description The LOW timer is moved to RESET state.

Arguments

             hTmr        Handle to the Gptimer instance

Return Value
None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
Low Timer is Reset

Writes
TMR_TGCR_TIMLORS=0

Example

            CSL_TmrHandle hTmr;
            ...
            CSL_TmrResetLo(hWdt);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrStart64 | ( | CSL_TmrHandle | hTmr,
|  | CSL_TmrEnamode | countMode |
| ) |  |  |

===========================================================================
CSL_TmrStart64

Description The function starts the 64bit Timer by bringing both the LOW and HIGH timer out of reset.

Arguments

             hTmr        Handle to the Gptimer instance
             countMode   Specifies the timer counting mode (OFF/CONTINIOUS/SINGLE Shot)

Return Value None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
Set the GP OR chained timer counting mode and timer Low and High reset register.

Writes
TMR_TGCR_TIMLORS=1,TMR_TGCR_TIMHIRS=1,
TMR_TCR_ENAMODE_LO,TMR_TCR_ENAMODE_HI

Example

            CSL_TmrHandle  hTmr;
            ...
            CSL_TmrStart64(hTmr, CSL_TMR_ENAMODE_ENABLE);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrStartHi | ( | CSL_TmrHandle | hTmr,
|  | CSL_TmrEnamode | countMode |
| ) |  |  |

============================================================================
CSL_TmrStartHi

Description The functions starts the HIGH timer.

Arguments

             hTmr        Handle to the Timer instance
             countMode   Specifies the timer counting mode (OFF/CONTINIOUS/SINGLE Shot)

Return Value None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
The HIGH timer is brought out of reset and is activated in the provided counting mode.

Writes
TMR_TGCR_TIMHIRS=1,TMR_TCR_ENAMODE_HI

Example

            CSL_TmrHandle  hTmr;
            ...
            CSL_TmrStartHi(hTmr, CSL_TMR_ENAMODE_ENABLE);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrStartLo | ( | CSL_TmrHandle | hTmr,
|  | CSL_TmrEnamode | countMode |
| ) |  |  |

============================================================================
CSL_TmrStartLo

Description The function starts the LOW Timer.

Arguments

             hTmr        Handle to the Gptimer instance
             countMode   Specifies the timer counting mode (OFF/CONTINIOUS/SINGLE Shot)

Return Value None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
The LOW timer is brought out of reset and is activated in the provided counting mode.

Writes
TMR_TGCR_TIMLORS=1,TMR_TCR_ENAMODE_LO

Example

            CSL_TmrHandle  hTmr;
            ...
            CSL_TmrStartLo(hTmr, CSL_TMR_ENAMODE_ENABLE);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrStartWdt | ( | CSL_TmrHandle | hTmr,
|  | CSL_TmrEnamode | countMode |
| ) |  |  |

===========================================================================
CSL_TmrStartWdt

Description The function starts the timer in Watch Dog Mode.

Arguments

             hTmr        Handle to the Timer instance
             countMode   Specifies the timer counting mode (OFF/CONTINIOUS/SINGLE Shot)

Return Value None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
Timer has been started in WATCH Dog Mode.

Writes
TMR_TGCR_TIMLORS=1,TMR_TGCR_TIMHIRS=1,TMR_WDTCR_WDEN=1,TMR_TCR_ENAMODE_LO,TMR_TCR_ENAMODE_HI;

Example

            CSL_TmrHandle  hWdt;
            ...
            CSL_TmrStartWdt(hWdt, CSL_TMR_ENAMODE_CONT);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrStop64 | ( | CSL_TmrHandle | hTmr | ) |

===========================================================================
CSL_TmrStop64

Description The function stops the 64bit timer.

Arguments

             hTmr        Handle to the Timer instance

Return Value
None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
The 64bit timer is stopped

Writes
TMR_TCR_ENAMODE_LO=0,TMR_TCR_ENAMODE_HI=0

Example

            CSL_TmrHandle hTmr;
            ...
            CSL_TmrStop64(hWdt);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrStopHi | ( | CSL_TmrHandle | hTmr | ) |

===========================================================================
CSL_TmrStopHi

Description The function stops the HIGH Timer

Arguments

             hTmr        Handle to the Timer instance

Return Value
None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
High Timer is disabled.

Writes
TMR_TCR_ENAMODE_HI=0

Example

            CSL_TmrHandle hTmr;
            ...
            CSL_TmrStopHi(hTmr);
            ...

===========================================================================

CSL_IDEF_INLINE void CSL_TmrStopLo | ( | CSL_TmrHandle | hTmr | ) |

===========================================================================
CSL_TmrStopLo

Description The function stops the LOW Timer

Arguments

             hTmr        Handle to the Timer instance

Return Value
None

Pre Condition
Both CSL_tmrInit() and CSL_tmrOpen() must be called.

Post Condition
Low Timer is disabled.

Writes
TMR_TCR_ENAMODE_LO=0

Example

            CSL_TmrHandle hTmr;
            ...
            CSL_TmrStopLo(hTmr);
            ...

===========================================================================

Copyright 2012, Texas Instruments Incorporated