battdrvrutility.cpp

来自「mx27 f14v2 源代码。包括ADS板上诸多驱动的源码。」· C++ 代码 · 共 107 行

CPP
107
字号
//------------------------------------------------------------------------------
//
//  Copyright (C) 2005, Motorola Inc. All Rights Reserved
//
//------------------------------------------------------------------------------
//
//  Copyright (C) 2006, Freescale Semiconductor, Inc. All Rights Reserved.
//  THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
//  AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT 
//
//------------------------------------------------------------------------------
//
//  File:  battdrvrUtility.cpp
//
//  Provides the utility function for  battdrvr
//
//------------------------------------------------------------------------------
#include <windows.h>
#include <stdlib.h>

#include "battdrvrUtility.h"


//-----------------------------------------------------------------------------
// External Functions

//-----------------------------------------------------------------------------
// External Variables


//-----------------------------------------------------------------------------
// Defines

#define C_S_TO_MS        1000       // convert factor from sec to milli sec
#define C_A_TO_MA        1000       // convert factor from A to mA
#define C_BASE          100         // base factor to convert peukert number and charge efficiency

//-----------------------------------------------------------------------------
// Types


//-----------------------------------------------------------------------------
// Global Variables


//-----------------------------------------------------------------------------
// Local Variables



//-----------------------------------------------------------------------------
// Local Functions



//------------------------------------------------------------------------------
//
// Function: CalChargingCapacityChange
//
// This function returns the change of the batt capacity during charging based on battery charging 
// equation: delta_capacity =  current * e * t;
//
// Parameters:
//      current
//          [in] current flow inside the battery
//      e
//          [in] charge efficiency for the battery
//      t
//          [in] duration of the charging
//
// Returns:
//      DWORD
//
//------------------------------------------------------------------------------
DWORD CalChargingCapacityChange(DWORD current, DWORD e, DWORD t)
{
    return (DWORD)(current *e/C_BASE* t/C_S_TO_MS);
}


//------------------------------------------------------------------------------
//
// Function: CalDischargingCapacityChange
//
// This function returns the change of the batt capacity during discharging based on peukert's 
// equation: delta_capacity =  (current ^p) * t
//
// Parameters:
//      current
//          [in] current flow inside the battery
//      p
//          [in] peukert number for the battery
//      t
//          [in] duration of the charging
//
// Returns:
//      DWORD
//
//------------------------------------------------------------------------------
DWORD CalDischargingCapacityChange(DWORD current, DWORD p, DWORD t)
{
    return (DWORD)(pow((double)current/C_A_TO_MA, (double)p/C_BASE)*C_A_TO_MA*t/C_S_TO_MS);
}



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?