コード例 #1
0
ファイル: watchdog.c プロジェクト: CNCBASHER/TinyG
void WDT_EnableAndSetTimeout( void )
{
        uint8_t temp = WDT_ENABLE_bm | WDT_CEN_bm | WATCHDOG_TIMEOUT;
        CCP = CCP_IOREG_gc;
        WDT.CTRL = temp;
        
        /* Wait for WD to synchronize with new settings. */
        while(WDT_IsSyncBusy());
}
コード例 #2
0
ファイル: wdt_driver.c プロジェクト: nandojve/embedded
/*! \brief Enable Watchdog without changing prescaler settings.
 *
 *  This function enables the Watchdog without changing prescaler settings.
 *  The Watchdog will be reset automatically.
 *
 *  The function writes the correct signature to the Configuration
 *  Change Protection register before writing the CTRL register. Interrupts are
 *  automatically ignored during the change enable period. The function will
 *  wait for the watchdog to be synchronized to the other clock domains. before
 *  proceeding
 */
void WDT_Enable( void )
{
	uint8_t temp = WDT.CTRL | WDT_ENABLE_bm | WDT_CEN_bm;
	CCP = CCP_IOREG_gc;
	WDT.CTRL = temp;

	/* Wait for WD to synchronize with new settings. */
	while(WDT_IsSyncBusy()){

	}
}
コード例 #3
0
ファイル: wdt_driver.c プロジェクト: nandojve/embedded
/*! \brief Enable Watchdog and set prescaler.
 *
 *  This function enables the Watchdog and applies prescaler settings.
 *  The Watchdog will be reset automatically.
 *
 *  The function writes the correct signature to the Configuration
 *  Change Protection register before writing the CTRL register. Interrupts are
 *  automatically ignored during the change enable period. TThe function will
 *  wait for the watchdog to be synchronized to the other clock domains. before
 *  proceeding
 *
 *  \param  period  Watchdog Timer timeout period
 */
void WDT_EnableAndSetTimeout( WDT_PER_t period )
{
	uint8_t temp = WDT_ENABLE_bm | WDT_CEN_bm | period;
	CCP = CCP_IOREG_gc;
	WDT.CTRL = temp;

	/* Wait for WD to synchronize with new settings. */
	while(WDT_IsSyncBusy()){

	}
}
コード例 #4
0
ファイル: wdt_driver.c プロジェクト: nandojve/embedded
/*! \brief Enable window mode and set prescaler.
 *
 *  This function enables window mode and applies prescaler settings.
 *  The WD must be enabled before enabling window mode and a true value is
 *  returned if this condition is met.
 *
 *  The function writes the correct signature to the Configuration
 *  Change Protection register before writing the WINCTRL register. Interrupts are
 *  automatically ignored during the change enable period. The function will
 *  wait for the watchdog to be synchronized to the other clock domains. before
 *  proceeding
 *
 *  \param  period  Window mode "closed" timeout period
 *
 *  \retval  true   The WD is enabled before enabling window mode
 *  \retval  false  The WD is not enabled before enabling window mode.
 */
bool WDT_EnableWindowModeAndSetTimeout( WDT_WPER_t period )
{
	uint8_t wd_enable = WDT.CTRL & WDT_ENABLE_bm;
	uint8_t temp = WDT_WEN_bm | WDT_WCEN_bm | period;
	CCP = CCP_IOREG_gc;
	WDT.WINCTRL = temp;
        
	/* Wait for WD to synchronize with new settings. */
	while(WDT_IsSyncBusy()){

	}
        
	return wd_enable;
}