#include "drv_wdog.h"
#include "drv_flash.h"

#include "app_hmi.h"
#include "app_config.h"

#include "drv_rcc.h"
#include "drv_clk.h"

//跳转前要复位外设，防止应用程序未初始化进入中断
void jumpHandler(void)
{
    RCC->APB2RSTR |= RCC_APB2Periph_USART1;
	RCC->APB2RSTR &= ~RCC_APB2Periph_USART1;
	RCC->APB2ENR &= ~RCC_APB2Periph_USART1;
    
	RCC->APB1RSTR |= RCC_APB1Periph_USART2;
	RCC->APB1RSTR &= ~RCC_APB1Periph_USART2;
	RCC->APB1ENR &= ~RCC_APB1Periph_USART2;
    
    RCC->APB1RSTR |= RCC_APB1Periph_USART3;
	RCC->APB1RSTR &= ~RCC_APB1Periph_USART3;
	RCC->APB1ENR &= ~RCC_APB1Periph_USART3;
    
    RCC->APB1RSTR |= RCC_APB1Periph_UART4;
	RCC->APB1RSTR &= ~RCC_APB1Periph_UART4;
	RCC->APB1ENR &= ~RCC_APB1Periph_UART4;
    
    RCC->APB1RSTR |= RCC_APB1Periph_UART5;
	RCC->APB1RSTR &= ~RCC_APB1Periph_UART5;
	RCC->APB1ENR &= ~RCC_APB1Periph_UART5;
	
	RCC->APB1RSTR |= RCC_APB1Periph_USART3;
	RCC->APB1RSTR &= ~RCC_APB1Periph_USART3;
	RCC->APB1ENR &= ~RCC_APB1Periph_USART3;
	
	RCC->APB2RSTR |= RCC_APB2Periph_USART1;
	RCC->APB2RSTR &= ~RCC_APB2Periph_USART1;
	RCC->APB2ENR &= ~RCC_APB2Periph_USART1;
	
    drvFeedWdog();
}


void appJumpAnalyse(void)
{
    flashJumpNew(APP_CFG_APP_START_ADDR, jumpHandler); 
}

void appInitHmi(void)
{
	appJumpAnalyse();
}
