?? wdt.c
字號:
/*-------------------------------------*
* 頭文件 *
*---------------------------------------------------------------------------*/
#include "ioCC1110.h"
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "Hal.h"
/*-------------------------------------*
* 宏定義 *
*---------------------------------------------------------------------------*/
#define LED_OFF 0
#define LED_ON 1
#define GLED P1_0
#define RLED P1_3
#define INIT_LED() RLED=1;GLED=1; \
P1DIR |= 0x09; \
P1SEL &=~0x09; \
#define SET_GLED() (GLED = LED_ON )
#define CLR_GLED() (GLED = LED_OFF)
#define SET_RLED() (RLED = LED_ON )
#define CLR_RLED() (RLED = LED_OFF)
// Where _timeout_ is one of
#define SEC_1 0x00 // after 1 second
#define M_SEC_250 0x01 // after 250 ms
#define M_SEC_15 0x02 // after 15 ms
#define M_SEC_2 0x03 // after 2 ms
// Macro for setting the WDT timeout interval.
#define WDT_SET_TIMEOUT_PERIOD(timeout) \
do { WDCTL &= ~0x03; WDCTL |= timeout; } while (0)
// Macro for resetting the WDT. If this is not done before the WDT times out,
// the system is reset.
#define WDT_RESET() do { \
WDCTL = (WDCTL & ~0xF0) | 0xA0; \
WDCTL = (WDCTL & ~0xF0) | 0x50; \
} while (0)
// Macro for turning on the WDT
#define WDT_ENABLE() WDCTL |= 0x08
#define WDT_DISABLE() WDCTL &= ~0x08
/*-------------------------------------*
* 函數定義 *
*---------------------------------------------------------------------------*/
void Reset(void)
{
// do reset by setting the WDT and waiting for it to timeout
DISABLE_ALL_INTERRUPTS(); // prevent petting the dog...
WDT_SET_TIMEOUT_PERIOD(SEC_1);
WDT_ENABLE();
// enable watchdog and wait for timeout...
while (1) {
asm("NOP");
}
}
void main(void)
{
unsigned int i,j;
SET_MAIN_CLOCK_SOURCE(CRYSTAL);
INIT_LED();
for (i=5; i!=0; i--)
{
GLED ^= 1;
RLED ^= 1;
for (j=50000; j!=0; j--);
}
INIT_LED();
Reset();
while(1)
{
;
}
}
/*------------------------------------------------------------------------------
0ooo
ooo0 ( )
( ) ) /
\ ( (_/
\_) By:cuiqingwei [gary]
------------------------------------------------------------------------------*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -