
#include "FreIn.h"
#include "FreIn_User.h"
#include "r_typedefs.h"
#include "dr7f701684.dvf.h"
#include "GPIO.h"
#include "TimerB.h"
#include "RTE_GPIO.h"
#include "Display_Info.h"
#include "TFT_LCD.h"
#include "RTE_GPIO.h"
uint8_t VEHICLE_Status = 0;
uint8_t ENGINE_Status = 0;
uint32_t Duty_VEHICLE = 0;
uint32_t Duty_ENGINE = 0;
uint32_t HZ_VEHICLE = 0;
uint32_t HZ_ENGINE = 0;
Fre_uint8_t Fre_Status_Read_0(void)
{
	Fre_uint8_t u8FrePin = 0 ;
	if(GPIO_VSpeed_PWM_IN)
	{
		u8FrePin = 1;	
	}
	return u8FrePin ;
}

Fre_uint8_t Fre_Status_Read_1(void)
{
	Fre_uint8_t u8FrePin = 0 ;
	if(GPIO_VSpeed_PWM_IN)
	{
		u8FrePin = 1;	
	}
	return u8FrePin;
}
Fre_uint8_t Fre_Status_Read_2(void)
{
	Fre_uint8_t u8FrePin = 0 ;
	/*if(GPIO_Temp_PWM_IN)
	{
		u8FrePin = 1;	
	}*/
	return u8FrePin;
}
Fre_uint8_t Fre_Status_Read_3(void)
{
	Fre_uint8_t u8FrePin = 0 ;
    /*if(GPIO_Rader_PWM_IN)
	{
		u8FrePin = 1;	
	}*/
	return u8FrePin;
}

/*在填完表格后，一定实测下所需采集信号的极大极小值，是否正确，精度是否满足需求！*/
/*在填完表格后，一定实测下所需采集信号的极大极小值，是否正确，精度是否满足需求！*/
/*在填完表格后，一定实测下所需采集信号的极大极小值，是否正确，精度是否满足需求！*/
const Fre_Attribute_st_t stFreAttribute[FRE_CHANNEL_MAX] =
{
	{  10U, 500000U, 100U,  1000U, 3000U, FRE_SAMP_CAPTURE_ROLL, Fre_Status_Read_0, 5000000UL},//车速 f= 5096*8(0~140km/h)/3600s
	{  10U, 500000U, 100U,  1000U, 3000U, FRE_SAMP_CAPTURE_ROLL, Fre_Status_Read_1, 5000000UL},//转速 f= (0~5000r/min)*4/60s
};

/************************************************/
Fre_uint8_t u8FreRamData[FRE_RAM_DATA_LEN];

void Fre_In_KL30_Wakeup_Init(void)
{
	Fre_In_Init(&u8FreRamData[0], &stFreAttribute[0], FRE_CHANNEL_MAX);
	TimerB_Input_Channel_Init(TIMERB_0_CH9, TIMERB_CLOCK_3, TIMERB_RISING_FALL);
	TimerB_Input_Channel_Start(TIMERB_0_CH9);
	
	TimerB_Input_Channel_Init(TIMERB_0_CH11, TIMERB_CLOCK_3, TIMERB_RISING_FALL);
	TimerB_Input_Channel_Start(TIMERB_0_CH11);
}



uint32_t Duty_VEHICLE_BackUp = 0;
uint32_t Duty_ENGINE_BackUp = 0;
uint32_t HZ_VEHICLE_BackUp = 0;
uint32_t HZ_ENGINE_BackUp = 0;
void Freln_Duty_HZ_Service(void)
{
    VEHICLE_Status = Fre_In_Get_Channel_Status(FRE_VEHICLE);
    // ENGINE_Status = Fre_In_Get_Channel_Status(FRE_ENGINE);

    if(Fre_In_Get_Update_Flag(FRE_VEHICLE)) 
    {
       Fre_In_Reset_Update_Flag(FRE_VEHICLE);
       Duty_VEHICLE = Fre_In_Get_Channel_Duty(FRE_VEHICLE);  
       HZ_VEHICLE = Fre_In_Get_Channel_HZ(FRE_VEHICLE);  
    }   

    // if(Fre_In_Get_Update_Flag(FRE_ENGINE)) 
    // {
    //     Fre_In_Reset_Update_Flag(FRE_ENGINE);
    //     Duty_ENGINE = Fre_In_Get_Channel_Duty(FRE_ENGINE); 
    //     HZ_ENGINE = Fre_In_Get_Channel_HZ(FRE_ENGINE);  
    // }   
	
}


