
#include "main.h"
#include "user_init.h"
#include "common_cfg.h"
#include "key_encoder_driver.h"
#include "app_encoder.h"
#include "led_app.h"
#include "CanNm.h"
#include "Can_BusOff.h"
#include "low_power_app.h"
#include "system_voltage_app.h"
#include "can_app.h"
#include "demm_app.h"
#include "SimpleOs.h"
#include "SimpleOs_Cfg.h"
#include "SimpleOs_Time.h"
#include "Cpu.h"
#include "pwm_manage.h"
#include "wheelHeat.h"




int main(void)
{
	
	System_DisableIrqGlobal();
	
	(void)wdog_init();

	(void)rmu_init();
	(void)nvic_init();
	(void)clk_init();
	(void)svd_init();
	(void)gpio_init();
	(void)adc_init();
	(void)tim_init();
	(void)system_voltage_manage_init();
	(void)app_encoder_init();
	(void)stack_check_init();
	(void)CanTrcv_Init();
	(void)Can_Init();
	(void)CanIf_Init();
	(void)CanIf_SetControllerMode(0,CANIF_CS_STARTED);
	(void)Com_Init();
	(void)CanNm_Init(NULL_PTR);
	(void)Com_TxStart();
	(void)Com_RxStart();
	(void)CanTp_Init(((void *) 0));
	(void)CAN_BusOff_Init();
	(void)Dcm_Init(((void *) 0));
	(void)key_app_init();
	(void)key_encoder_driver_init();
	(void)cal_did_init();
	(void)boot_app_init();
	(void)random_init();
	(void)service_27_init();
	(void)nvm_init();
	(void)dem_task_init();
	(void)can_app_init();
	(void)led_app_init();
	(void)WheelHeat_Init();
	NVIC_DisableIRQ(CAN_IRQn);
	NVIC_SetPriority(CAN_IRQn, 0);/* 中断优先级配置 */
	NVIC_EnableIRQ(CAN_IRQn);
	
	System_EnableIrqGlobal();
	
    
	SimpleOs_Start();
}





TASK(OS_Task1ms)
{
	
	(void)wdog_task();
	(void)wdt_feed_windows();
	(void)adc_task();
	(void)key_encoder_driver_task();
    (void)eeprom_task();

}

TASK(OS_Task2ms)
{
	
	(void)system_voltage_manage_task();
	(void)system_voltage_app_task();

}
TASK(OS_Task5msA)
{

	(void)Com_MainFunctionRx();
	(void)Com_MainFunctionTx();	
	(void)Dcm_MainFunction();
	(void)CanTp_MainFunction();
	(void)CanNm_MainFunction();
	(void)CanBusOffMainFunction();

}
TASK(OS_Task5msB)
{

	(void)dem_task();

}
TASK(OS_Task5msC)
{

	(void)led_app_task();

}
TASK(OS_Task10msA)
{

	key_digital_driver_normal_task();
	key_adc_mid_task();
    key_app_task();

}
TASK(OS_Task10msB)
{
	(void)low_power_app_task();


}
TASK(OS_Task10msC)
{

	(void)demm_app_task();
}


TASK(OS_Task10msD)
{

	(void)app_encoder_task();

}
TASK(OS_Task10msE)
{

	WheelHeat_MainFunction();

}


