

/*
********************************************************************************
*
*                                 APP_Main.c
*
* File          : APP_Main.c
* Version       : V1.2
* Author        : yujiadong
* Mode          : xx
* Toolchain     : xx
* Description   : 
*                
* History       : xx
* Date          : 2020/01/01
*******************************************************************************/
#include "Allinclusions.h"
extern UINT16 g_ucUpdateParam[3];

tSysCtrl SysInfo;

/*******************************************************************************
* Function Name : void System_IntrruptCtrl(void)
* Description   : 娑擃厽鏌囬幒褍鍩楅崙鑺ユ殶
* Author        : yujiadong
* Input         : NULL
* Output        : NULL
* Other         : NULL
* Date          : 2020/01/01
*******************************************************************************/
void System_IntrruptCtrl()
{
//    // enable the ADC interrupts
////    HAL_enableAdcInts(halHandle);
//
//    // enable scia interrupts
//    PIE_enable(halHandle->pieHandle);
//    halHandle->pieHandle->PIEIER_PIEIFR[8].IER |= (1 << 0);
//    halHandle->pieHandle->PIEIER_PIEIFR[8].IER |= (1 << 1);
////    CPU_enableInt(halHandle->cpuHandle,CPU_IntNumber_9);
//
//    // enable scib interrupts
//    PIE_enable(halHandle->pieHandle);
//    halHandle->pieHandle->PIEIER_PIEIFR[8].IER |= (1 << 2);
//    halHandle->pieHandle->PIEIER_PIEIFR[8].IER |= (1 << 3);
////    CPU_enableInt(halHandle->cpuHandle,CPU_IntNumber_9);
//
//    // enable timer 2
////    CPU_enableInt(halHandle->cpuHandle,CPU_IntNumber_14);
//
//    // enable global interrupts
//    HAL_enableGlobalInts(halHandle);
//
//    // enable debug interrupts
//    HAL_enableDebugInt(halHandle);
//
//    EINT;   // Enable Global interrupt INTM
//    ERTM;   // Enable Global realtime interrupt DBGM

}




UINT64 GetSysTime()
{
    return  SysInfo.SysTime.ulSysTime;
}

void SystemRunTime(tSysTime *Systime)
{
    tSysTime *Sys = Systime;

    Sys->ulSysTime++;
}


void Delay_ms(UINT64 (*ReturnTime)(void),UINT32 ucSysTime)
{

    UINT32 ucDelayTime  = 0;

    ucDelayTime = ucSysTime + ReturnTime();


    while(ReturnTime() <= ucDelayTime)
    {

    }

}


/*******************************************************************************
* Function Name : int System_Init(void)
* Description   : 系统初始化函数
* Author        : yujiadong
* Input         : NULL
* Output        : NULL
* Other         : NULL
* Date          : 2020/01/01
*******************************************************************************/
void System_Init(void)
{
//  if(readUpateParamFromFlash() == 1)
//  {
//     if(g_ucUpdateParam[2] != 0xF5)  //电机错误标志
//     {
//         memset(&SysInfo,0,sizeof(SysInfo));
//         Driver_MotorInit();
//         IntrruptInit();
//         BSP_Timer2Init();
//         BSP_SciaInit();
//         BSP_ScibInit();
//         System_IntrruptCtrl();
//         Driver_SpinTacInit();
//         Driver_FanCtrlInit();
//         IIC_Init();
//
//#ifdef WATCHDOG_NO
//WatchDogInit();
//#endif
//
//         SysInfo.Sleep.ucUpMonSleepFla = Run;
//         SysInfo.Sleep.ucSysSleepFla   = Run;
////         gMotorVars[0].Flag_Run_Identify    = VALID;
////         gMotorVars[1].Flag_Run_Identify    = VALID;
//     }
//     else
//     {
//         while(1);
//     }
//  }
}
