⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csl_wdthwsetup.c

📁 TI的DM6446的硬件平台搭建的相关例子
💻 C
字号:
/*  ============================================================================
 *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005                 
 *                                                                              
 *   Use of this software is controlled by the terms and conditions found in the
 *   license agreement under which this software has been supplied.             
 *   ===========================================================================
 */


/**  @file  csl_wdtHwSetup.c
 *
 *   @brief File for functional layer of CSL API @a CSL_wdtHwSetup()
 *
 *  Path: \\(CSLPATH)\\ipmodules\\wdt\\src
 *
 */

/* =============================================================================
 *  Revision History
 *  ===============
 *  01-Sep-2004 Hmm File created.
 * =============================================================================
 */
#include <csl_wdt.h>

/** ============================================================================
 *   @n@b CSL_wdtHwSetup
 *
 *   @b Description
 *   @n It configures the watchdog timer registers as per the values passed
 *      in the hardware setup structure.
 *
 *   @b Arguments
 *   @verbatim
            hWdt            Handle to the watchdog timer

            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> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  Watchdog timer registers are configured according to the hardware setup
 *       parameters
 *
 *   @b Modifies
 *   @n Watchdog timer registers
 *
 *   @b Example
 *   @verbatim

            status = CSL_wdtHwSetup(hWdt, &hwSetup);
     @endverbatim
 * ===========================================================================
 */

#pragma CODE_SECTION (CSL_wdtHwSetup, ".text:csl_section:wdt");
CSL_Status  CSL_wdtHwSetup(
    CSL_WdtHandle      hWdt,
    CSL_WdtHwSetup     *hwSetup
)
{
    if (hWdt == NULL)
        return CSL_ESYS_BADHANDLE;

    if (hwSetup == NULL)
        return CSL_ESYS_INVPARAMS;

    /* setup the Timer Period Register 12*/
    hWdt->regs->PRD12 = (Uint32)hwSetup->wdtTimerPeriod12;

    /* setup the Timer Period Register 34*/
    hWdt->regs->PRD34 = (Uint32)hwSetup->wdtTimerPeriod34;

    /* Configure the timer operating mode */
    if (hwSetup->wdtTcr12Enamode == CSL_WDT_ENAMODE_CONTINU) {
        CSL_FINST(hWdt->regs->TCR, WDT_TCR_ENAMODE12, CONTINUOUS);
    }
    else {
        return CSL_ESYS_INVPARAMS;
    }

    /* Configure the Pulse width value */
    CSL_FINS(hWdt->regs->TCR, WDT_TCR_PWID12, hwSetup->wdtTcr12PulseWidth);

    /* Configures the watchdog timer in watchdog mode */
    if(hwSetup->wdtTimerMode == CSL_WDT_TIMMODE_WDT) {
        CSL_FINS(hWdt->regs->TGCR, WDT_TGCR_TIMMODE, hwSetup->wdtTimerMode);
    }
    else {
        return CSL_ESYS_INVPARAMS;
    }

    /* set TIM34RS_ */
    CSL_FINS(hWdt->regs->TGCR, WDT_TGCR_TIM34RS, hwSetup->wdtTmr34State);

    /* set TIM34RS_ */
    CSL_FINS(hWdt->regs->TGCR, WDT_TGCR_TIM12RS, hwSetup->wdtTmr12State);

    /* load the Watchdog flag bit */
    CSL_FINS(hWdt->regs->WDTCR, WDT_WDTCR_WDFLAG, hwSetup->wdtFlagBit);
    return CSL_SOK;
}

⌨️ 快捷键说明

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