⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcc.h

📁 是一个手机功能的模拟程序
💻 H
📖 第 1 页 / 共 2 页
字号:
    uint8    flag_chg_plugged;       // Charger has been plugged (1) or not (0) flag
    uint8    flag_chg_prev_plugged;  // The previous charger poll said plugged (1) or not plugged (0) flag
    uint8    flag_chg_cfg_read;      // Charger configuration has been read (1) or not (0) flag
    uint8    flag_cal_cfg_read;      // Calibration files has been read (1) or not (0) flag
    uint8    flag_bat_unknown;       // Battery was unknown (1) - or not (0) - the MMI must be told
    uint8    flag_chg_unknown;       // Charger plugged  was unknown (1) - or not (0) - the MMI must be told
    uint8    flag_mmi_registered;    // MMI has registered (1) or not (0)
    uint8    flag_prechg_started;    // Stay in precharge state PRE - Apply fast charging no matter what charger type
    uint8    flag_chg_int_disabled;  // Charger interrupts are disabled (1) or enabled (0)
    uint8    flag_ini_virgo;         // Entering INI state for the very first time - in order to control some very basic initialization
    uint8    cfg_id;                 // Applied battery configuration id
    uint8    chg_cfg_id;             // Applied charger configuration id
    uint8    count_bat_type;         // The number of battery identification measurements reported in state INI
    uint8    count_chg_type;         // The number of charger identification measurements made in state SUP
    uint8    chg_unplug_vec[CONSECUTIVE_CHG_UNPLUGS];    // The charger unplug vector keeps the latest polled values of charger unplug
    uint8    index;                  // The current index of the charger unplug vector
    uint16   capacity;               // The current capacity : 0..100%

    // Timers
    UINT32   time_begin_T0;          // T0: Sampling timer  (constant but modulo ADC updates)
    UINT32   time_elapsed_T0;
    UINT32   time_begin_T1;          // T1: The total charging time timer (constant)
    UINT32   time_elapsed_T1;
    UINT32   time_begin_T2;          // T2: The total CV charging time timer (constant)
    UINT32   time_elapsed_T2;
    UINT32   time_begin_T3;          // T3: The charge-again-without start-stop of charging (constant)
    UINT32   time_elapsed_T3;
    UINT32   time_begin_T4;          // T4: The duty cycle timer
    UINT32   time_elapsed_T4;
    UINT32   time_begin_mod_cycle;   // The modulation cycle timer
    UINT32   time_elapsed_mod_cycle;
    UINT32   time_begin_mmi_rep;     // MMI repetition
    UINT32   time_elapsed_mmi_rep;

    UINT32   tmask;                  // The trace mask used for the PWR process - activated by test mode

    T_RVF_ADDR_ID addr_id;           // Task address id assigned by Riviera framework
    T_RVF_MB_ID   prim_id;           // Memory bank id assigned by Riviera framework

    T_RV_RETURN rpath;               // Return path of the MMI - initialized in pwr_register
    struct mmi_info_ind_s *mmi_ptr;  // Pointer to mmi event memory assigned by the MMI
} T_PWR_CTRL_BLOCK;

// The PWR configuration block - common, charger and battery
typedef struct
{
    T_PWR_CAL_BLOCK cal;             // Calibration matrix
    T_PWR_COMMON_CFG_BLOCK common;   // Common configuration
    T_PWR_BAT_CFG_BLOCK bat;         // Battery configuration
    T_PWR_BAT_TEMP_CFG_BLOCK temp;   // Battery temperature configuration
    T_PWR_CHG_CFG_BLOCK chg;         // Charger configuration
    T_PWR_MMI_CFG_BLOCK mmi;         // MMI configuration
    T_PWR_DATA_BLOCK data;           // Data (dynamic) related to configuration
} T_PWR_CFG_BLOCK;

// Use these values if no FFS files are found
// Units: [ms], [mV] and [mA]
#ifndef PWR_FFS_CFG
    #define PWR_T0_THR            10000
    #define PWR_T1_THR            1800000 // 1/2 hour
    #define PWR_T2_THR            25000
    #define PWR_T3_THR            10000
    #define PWR_MOD_CYCLE_THR    10000
    #define PWR_MMI_REP_THR       60000
    #define PWR_ICHG_MAX          400
    #define EXP_MOVING_AVG_FILTER1 5
    #define EXP_MOVING_AVG_FILTER2 10
    #define EXP_MOVING_AVG_FILTER3 10
    #define PWR_TEMPERATURE_LOW   -20
    #define PWR_TEMPERATURE_HIGH   45
    #define PWR_CV_START_THR      4050
    #define PWR_CHG_STOP_THR      4100
    #define PWR_RISE_THR          4
    #define PWR_MIN_K             20
    #define PWR_MAX_K             350
#endif

#define TYPEN 0x0080               /* Enables the 10uA bias current for the main battery type reading */
#define THERMAL_SENSOR_10uA 0x0041 /* THSENS0 , THSENS1, THSENS2 = 0, 0, 0  MESBAT = 1 */
#define THERMAL_SENSOR_30uA 0x0051 /* THSENS0 , THSENS1, THSENS2 = 0, 1, 0  MESBAT = 1 */
#define THERMAL_SENSOR_50uA 0x0061 /* THSENS0 , THSENS1, THSENS2 = 0, 0, 1  MESBAT = 1 */
#define THERMAL_SENSOR_80uA 0x0079 /* THSENS0 , THSENS1, THSENS2 = 1, 1, 1  MESBAT = 1 */
#define MESBAT              0x0001 /* Resistive divider connected to main battery */
#define CHARGER_IT_MSK      0x0008 /* Mask the charger plug/unplug interrupts */
#define ALL_IT_UMSK         0x0000 /* Unmask all interrupt 2 register related interrupts */

// Convert functions
#define ADC_to_mV(ADC) ((pwr_cfg->cal.vbat.alfa_num*(ADC))/(pwr_cfg->cal.vbat.alfa_denom) + pwr_cfg->cal.vbat.beta)
#define ADC_to_mA(ADC) ((pwr_cfg->cal.i2v.alfa_num*(ADC))/(pwr_cfg->cal.i2v.alfa_denom) + pwr_cfg->cal.i2v.beta)

// Inverse convert functions
#define mV_to_ADC(V) (pwr_cfg->cal.vbat.alfa_num*((V)/pwr_cfg->cal.vbat.alfa_denom) - pwr_cfg->cal.vbat.beta)
#define mA_to_ADC(I) (pwr_cfg->cal.i2v.alfa_num*((I)/pwr_cfg->cal.i2v.alfa_denom) - pwr_cfg->cal.i2v.beta)

/******************************************************************************
 * Errors
 ******************************************************************************/

enum PWR_ERRORS {
    EPWR_OK          =  0  /* ok */
};

/******************************************************************************
 * Enumerations
 ******************************************************************************/

// Message IDs for all PWR module messages
typedef enum PWR_MESSAGES {
    NOP = 0,

    /* Requests */
        /* ABB */
        /* MMI */
    MMI_REGISTER_REQ         = 20,

    /* Timers*/
    TIMER_T1_EXPIRED         = 30,
    TIMER_T2_EXPIRED,
    TIMER_T3_EXPIRED,
    TIMER_T4_EXPIRED,
    TIMER_MOD_CYCLE_EXPIRED,
    TIMER_MMI_INFO_EXPIRED,

    /* Indications */
    /* PWR */
    PWR_CHARGER_PLUGGED_IND  = 40,
    PWR_CHARGER_UNPLUGGED_IND,

    /* Confirmations */

    /* Test mode */
    /* Request */
    PWR_TM_READ_REQ = 70,
    PWR_TM_WRITE_REQ,

    /* Indications */
    PWR_TM_READ_IND = 80,
    PWR_TM_WRITE_IND,

    PWR_ADC_IND = 90

} pwr_msg_e;

// See LCC Detailed Design Specification
typedef enum PWR_STATES {
    CAL = 0, // Reading calibration file(s)
    PRE = 1, // Pre-charging no matter which charger type
    INI = 2, // Reading configuration files
    SUP = 3, // No charging - supervision only
    CCI = 4, // Charging using CI/CV charger
    LCI = 5, // Charging using linear charger
    CCV = 6, // Charging using CI/CV charger
    LCV = 7  // Charging using linear charger
} pwr_states_e;

// See RD818
typedef enum CHG_TYPES {
    CI = 1,
    CV = 2,
    UNREGULATED = 3
} chg_types_e;

// See RD818
typedef enum BAT_TYPES {
    LITHIUM = 1,
    NICKEL = 2
} bat_types_e;

// See RIV261
typedef enum CAUSE_TYPES {
    BATTERY_TEMPERATURE_OK   = 0,
    BATTERY_TEMPERATURE_LOW  = 1,
    BATTERY_TEMPERATURE_HIGH = 2
} cause_types_e;

enum PWR_Errors {
    // PWR Common Target Errors
    PWR_OK          =    0,  // Ok
    PWR_INDEX       =  -1,   // Unknown index
    PWR_OK_MORE     = -63,   // Ok, more data coming
    PWR_PACKET      = -62,   // Packet error (checksum or other)
    PWR_FATAL       = -61,   // System fatal error
    PWR_NOSYS       = -60,   // Module or function not present
    PWR_INVAL       = -59,   // Invalid parameter/argument
    PWR_BADOP       = -58,   // Operation not possible in current context
    PWR_AGAIN       = -57,   // Not ready, try again later
    PWR_NOMEM       = -56,   // Out of memory
    PWR_MESSAGE     = -55,   // Received unknown message

    // Errors that are related to the Riv env.
    PWR_RV_NOT_SUPPORTED = -51, //
    PWR_RV_MEMORY_ERR    = -50, //
    PWR_RV_INTERNAL_ERR  = -49, //
    PWR_RV_FATAL         = -48 //

};

#endif //_PWR_H_

⌨️ 快捷键说明

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