資源簡介
對max17055的寄存器配置,進行詳細配置,包括校準,bsp的驅動匹配文件都有,電量檢測很準。
代碼片段和文件信息
/*
?*?Maxim?MAX17055?IC?Fuel?Gauge?driver
?*
?*?Author:?Kerem?Sahin?
?*?Copyright?(C)?2016?Maxim?Integrated
?*
?*?This?program?is?free?software;?you?can?redistribute??it?and/or?modify?it
?*?under??the?terms?of??the?GNU?General??Public?License?as?published?by?the
?*?Free?Software?Foundation;??either?version?2?of?the??License?or?(at?your
?*?option)?any?later?version.
?*/
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#define?DRV_NAME?“max17055“
/*?CONFIG?register?bits?*/
#define?MAX17055_CONFIG_ALRT_EN?????????(1?<2)
#define?MAX17055_CONFIG2_LDMDL??????????(1?<5)
/*?STATUS?register?bits?*/
#define?MAX17055_STATUS_BST?????????????(1?<3)
#define?MAX17055_STATUS_POR?????????????(1?<1)
/*?MODELCFG?register?bits?*/
#define?MAX17055_MODELCFG_REFRESH???????(1?<15)
/*?TALRTTH?register?bits?*/
#define?MIN_TEMP_ALERT??????????????????0
#define?MAX_TEMP_ALERT??????????????????8
/*?FSTAT?register?bits?*/
#define?MAX17055_FSTAT_DNR??????????????(1)
/*?STATUS?interrupt?status?bits?*/
#define?MAX17055_STATUS_ALRT_CLR_MASK???(0x88BB)
#define?MAX17055_STATUS_SOC_MAX_ALRT????(1?<14)
#define?MAX17055_STATUS_TEMP_MAX_ALRT???(1?<13)
#define?MAX17055_STATUS_VOLT_MAX_ALRT???(1?<12)
#define?MAX17055_STATUS_SOC_MIN_ALRT????(1?<10)
#define?MAX17055_STATUS_TEMP_MIN_ALRT???(1?<9)
#define?MAX17055_STATUS_VOLT_MIN_ALRT???(1?<8)
#define?MAX17055_STATUS_CURR_MAX_ALRT???(1?<6)
#define?MAX17055_STATUS_CURR_MIN_ALRT???(1?<2)
#define?MAX17055_VMAX_TOLERANCE?????50?/*?50?mV?*/
enum?chip_id?{
????ID_MAX17055
};
struct?max17055_priv?{
????struct?i2c_client???????*client;
????struct?device???????????*dev;
????struct?regmap???????????*regmap;
????struct?power_supply?????battery;
????struct?max17055_platform_data???*pdata;
????struct?work_struct??????init_worker;
????struct?attribute_group??*attr_grp;
};
static?inline?int?max17055_lsb_to_uvolts(struct?max17055_priv?*priv?int?lsb)
{
????return?lsb?*?625?/?8;?/*?78.125uV?per?bit?*/
}
static?int?max17055_raw_current_to_uamps(struct?max17055_priv?*priv?u32?curr)
{
????int?res?=?curr;
????/*?Negative?*/
????if?(res?&?0x8000)
????????res?|=?0xFFFF0000;
????res?*=?1562500?/?(priv->pdata->rsense?*?1000);
????return?res;
}
static?enum?power_supply_property?max17055_battery_props[]?=?{
????POWER_SUPPLY_PROP_PRESENT
????POWER_SUPPLY_PROP_CYCLE_COUNT
????POWER_SUPPLY_PROP_VOLTAGE_MAX
????POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN
????POWER_SUPPLY_PROP_VOLTAGE_NOW
????POWER_SUPPLY_PROP_VOLTAGE_AVG
????POWER_SUPPLY_PROP_VOLTAGE_OCV
????POWER_SUPPLY_PROP_CAPACITY
????POWER_SUPPLY_PROP_CHARGE_FULL
????POWER_SUPPLY_P
- 上一篇:五子棋局域網聯機版
- 下一篇:圣天諾系列加密狗驅動完全卸載工具
評論
共有 條評論