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

#include "bms_hmi.h"
#include "bms_config.h"

#include "drv_clk.h"
//跳转前要复位外设，防止应用程序未初始化进入中断
void jump_handler(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;
	
    drv_wdog_feed();
}


void bms_jump_analyse(void)
{
    flash_jump_new(APP_CFG_APP_START_ADDR, jump_handler); 
}

void bms_init_hmi(void)
{
	bms_jump_analyse();
}
