#include "CommandsDefine.h"
#include "delay.h"
//#include "AnalogChannelCtrl.h"
#include "usart.h"
#include "timer.h"
#include "iwdg.h"
#include "iap.h"
#include "stmflash.h"

#define RUNNING_WHERE_AT_BOOT 1
//#include "Probe.h"

const VersionInfo OurVersionInfo /*__attribute__((at(BOOT_VERSION_FLASH_ADDR_BASE)))*/=
{
	0,//Version_MainNo
	2,//Version_SubNo
	3,//Version_ModifyNo
	0,//Version_Revision_Number
	"20230823094500",//Version_Date
	"ljw",//Version_ModifierName
	"Boot",//Version_ModelName
	"At Boot"//Version_Comment
};

/*
#include "stm32f4xx.h"                  // Device header
S16(*VersionInfo) OurVersionInfo=
{
	0,//Version_MainNo
	2,//Version_SubNo
	3,//Version_ModifyNo
	0,//Version_Revision_Number
	"20230823094500",//Version_Date
	"ljw",//Version_ModifierName
	"Boot",//Version_ModelName
	"At Boot"//Version_Comment
}VERSION_FLASH_ADDR_BASE;
*/
VersionInfo* GetVersion()
{
	return (VersionInfo*)(&OurVersionInfo);
}
void MainInit()
{
    	Queue_Init(&BufferQueue, BufferCMD, Q_BUFFER_SIZE);
	
			NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
			delay_init(168);  //初始化延时函数
			uart_init(115200);		//初始化串口6波特率为115200
			sysIsReady =1;
			//u32 tt = USART_REC_LEN;
			//tt = tt + 1;
			//启动检测
			if(iap_check_appstate()==1)
			{
				//跳转APP1
				if(((*(vu32*)(FLASH_APP1_ADDR+4))&0xFF000000)==0x08000000)// 0X08XXXXXX.
				//if(((*(vu32*)(FLASH_APP1_ADDR))&0x2FFE0000)==0x200A0000)//判断
				{	 
						//USART_Cmd(USART6, DISABLE);
						//iap_set_run_count();
						iap_load_app(FLASH_APP1_ADDR);//执行FLASH APP代码
				}
				else 
				{
				}									 
			}
}
