landzo

来自「【开源】线性CCD自适应性算法攻略」· 代码 · 共 60 行

TXT
60
字号
/*
 * File:        wdog.c
 * Purpose:     Provide common watchdog module routines
 *
 * Notes:		Need to add more functionality. Right now it
 * 				is just a disable routine since we know almost
 * 				all projects will need that.
 *
 */

#include "common.h"
#include "wdog.h"

/********************************************************************/
/*
 * Watchdog timer disable routine
 *
 * Parameters:
 * none
 */
void wdog_disable(void)
{
    /* First unlock the watchdog so that we can write to registers */
    wdog_unlock();

    /* Clear the WDOGEN bit to disable the watchdog */
    WDOG_STCTRLH &= ~WDOG_STCTRLH_WDOGEN_MASK;
}
/********************************************************************/
/*
 * Watchdog timer unlock routine. Writing 0xC520 followed by 0xD928
 * will unlock the write once registers in the WDOG so they are writable
 * within the WCT period.
 *
 * Parameters:
 * none
 */
void wdog_unlock(void)
{
    /* NOTE: DO NOT SINGLE STEP THROUGH THIS FUNCTION!!! */
    /* There are timing requirements for the execution of the unlock. If
     * you single step through the code you will cause the CPU to reset.
     */

    /* This sequence must execute within 20 clock cycles, so disable
         * interrupts will keep the code atomic and ensure the timing.
         */
    DisableInterrupts;

    /* Write 0xC520 to the unlock register */
    WDOG_UNLOCK = 0xC520;

    /* Followed by 0xD928 to complete the unlock */
    WDOG_UNLOCK = 0xD928;

    /* Re-enable interrupts now that we are done */
    EnableInterrupts;
}
/********************************************************************/

⌨️ 快捷键说明

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