Speed_PPK_Out.c 1.33 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5 6 7 8 9 10 11 12
#include "Speed_PPK_Out.h"
#include "RTE_PWM_OUT.h"
#include "Common_Interface.h"
#include "Data_VehicleSpeed.h"
#include "GaugesInterface.h"

#define Speed_Clock 64453u  /*PWM时钟512分频之后*/

uint16_t Speed_PPK_Calc(uint16_t V_Speed, uint16_t m_PPK)
{
    uint32_t Frequency;
    Frequency = (uint32_t)V_Speed / 10u;
hu's avatar
hu committed
13
    Frequency = (uint32_t)(Frequency * m_PPK);
hu's avatar
hu committed
14 15 16 17 18 19 20 21 22 23 24 25
    Frequency = Frequency / 3600u;
    return (uint16_t)Frequency;
}

void Speed_PPK_Processing(void)
{
    uint16_t Frequency;
    //uint16_t m_Clock;
    //uint16_t m_Duty;
    uint32_t PPK ;

    PPK = Get_Speed_PPK();
26
    if (Common_Get_IG_Sts() == COMMON_POWER_ON)
hu's avatar
hu committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    {
        if (Common_Get_Act_V_Speed_Valid() == 1u)
        {
            //Frequency = Speed_PPK_Calc(Common_Get_Act_V_Speed(), PPK);
            Frequency = Cal_Veh_Frequency();
        }
        else
        {
            Frequency = 0u;
        }
    }
    else
    {
        Frequency = 0u;
    }
/*    
    if (Frequency == 0u)
    {
        Frequency = 0u;
    }
    else if (Frequency >= 1u)
    {
        Frequency = Frequency;
    }
    else
    {
        Frequency = 1u;
    }
    if (Frequency != 0u)
    {
        m_Clock = Speed_Clock / Frequency;
        m_Duty = m_Clock / 2u;
    }
    else
    {
        m_Clock = 0u;
        m_Duty = 0u;
    }
*/

    RTE_PWM_Set_Speed_Out(Frequency, 500);
}