/*
 * @Description:5 * @Date: 2020-06-17 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"
volatile unsigned int adcdata1,adcdata2;
volatile u32 VBAT;
void main()
{
	// 判斷是否為上電復位或者非正常情況下的復位
	// 如果是上電復位，執行上電復位初始化，反之執行WDT溢出初始化
	if (_to == 0 || _pdf ==0)
	{
		// System
		Drv_SysClockInit();
		Drv_RamInit();
		SET_WDTTIME_125MS();
		SET_LVR_1V9();

		// 12bitADC demo
		adcdata1 = Drv_GetADC(ADC_CHANNEL_AN1);
		adcdata2 = Drv_GetADC_AVGn(ADC_CHANNEL_AN1,10);
		VBAT = adcdata2 *  3300 / 4096;  // mV 檢測電池電壓

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

	}
	//主循環
	while(1)
	{
		GCC_CLRWDT();
		/* user code */
		

	}
}