/*
 * @Description:5 * @Date: 2019-07-03 09:32:04
 * @Author: 吳星萍 iris@e-besthealth.com
 * @LastEditors: 吳星萍 iris@e-besthealth.com
 * @LastEditTime: 2020-06-17 11:16:29
 * @copyright: BEST HEALTH ELECTRONIC INC (c) 2019
 */
#include "common.h"


void main()
{
	// 判斷是否為上電復位或者非正常情況下的復位
	// 如果是上電復位，執行上電復位初始化，反之執行WDT溢出初始化
	if (_to == 0 || _pdf ==0)
	{
		// System
		Drv_GPIOPowerOnInit();
		Drv_SysClockInit();
		Drv_RamInit();
		SET_WDTTIME_125MS();
		SET_LVR_1V9();

		Drv_GPIOPowerDownInit();
		
		_pbc6 = 0;
		_pbc7 = 0;
		SET_PA7_GPIO();     //設置按鍵喚醒
		_pac7 =1;
		_pawu7 = 1;
		_papu7 = 1;

	}
	else
	{
		// WDT溢出復位初始化
		GCC_CLRWDT();

	}
	//主循環
	while(1)
	{
		GCC_CLRWDT();
		//IO翻轉
		_pb7 = 0;
		GCC_DELAY(1000);
		_pb7 = 1;
		GCC_DELAY(5000);
		_pb7 = 0;
		GCC_DELAY(1000);
		_fhiden = 0;        //HALT模式
		_fsiden = 0;
		GCC_HALT();
		_pb6 = 0;
		GCC_DELAY(1000);
		_pb6 = 1;
		GCC_DELAY(5000);
		_pb6 = 0;
		GCC_DELAY(1000);

	}
}
