当前位置:网站首页>2022 - 06 - 09 rk817 PMU Battery Temperature Detection
2022 - 06 - 09 rk817 PMU Battery Temperature Detection
2022-06-10 21:52:00 【Xichen, lune de mer】
Un.、Connexions matérielles,TS/GPIO,Thermistor connecté à la batterie thermistor


2.、Thermistor(the resistance of the thermistor)Il existe deux catégories générales::
1、La résistance augmente avec la température,Appelé facteur de température positif(PTC,Positive Temperature Coefficient)Thermistor.
2、La résistance diminue avec la température,Appelé coefficient de température négatif(NTC,Negative Temperature Coefficient)Thermistor.
Trois、Schéma interne de la batterie


Quatre、 Type thermométriqueNTC Tableau des caractéristiques de température de résistance des Thermistors

Cinq、 Registre impliqué dans l'obtention de la valeur du Thermistor
1、gas_gauge_ADC_CONFIG0
Address: Operational Base + offset (0x0050),TS_ADC_EN BIT à configurer comme 1

2、gas_gauge_ADC_CONFIG1 Address: Operational Base + offset (0x0055) VOL_ADC_TSCUR_SEL ..Assurez - vous que celui - ci décrit le passage de TS La taille du courant de sortie du pied .

3、CODEC_AREF_RTCFG1
Address: Operational Base + offset (0x0017) REF_ADC_SEL ParamètresADC Tension de référence.
4、gas_gauge_BAT_TS_H Etgas_gauge_BAT_TS_L AccèsADC Valeur

Six、Code modifié,Et tester
1、Code modifié
commit b353b70850442863c4b051beb258681c6cd71cdf
Author: xxx.wei <[email protected]>
Date: Thu Jun 9 14:09:22 2022 +0800
get battery temperature
diff --git a/drivers/power/supply/rk817_battery.c b/drivers/power/supply/rk817_battery.c
index 32e2d65..4c49a27 100755
--- a/drivers/power/supply/rk817_battery.c
+++ b/drivers/power/supply/rk817_battery.c
@@ -632,6 +632,11 @@ struct rk817_battery_device {
bool change; /* Battery status change, report information */
};
+struct battery_res_temp_data {
+ unsigned long res;
+ int temp;
+};
+
static void rk817_bat_resume_work(struct work_struct *work);
static u64 get_boot_sec(void)
@@ -2095,6 +2100,40 @@ static int rk817_battery_time_to_full(struct rk817_battery_device *battery)
return time_sec;
}
+static const struct battery_res_temp_data bat_temp_table[] = {
+ {324 ,125},{ 371,120},{ 427,115},{ 491,110},{ 567,105},
+ {657 ,100},{ 763, 95},{ 890, 90},{ 1044, 85},{ 1228, 80},
+ {1452 , 75},{ 1725, 70},{ 2058, 65},{ 2466, 60},{ 2968, 55},
+ {3588 , 50},{ 4357, 45},{ 5318, 40},{ 6523, 35},{ 8047, 30},
+ {10000, 25},{12461, 20},{15652, 15},{19783, 10},{25152, 5},
+ {32116, 0},{41306, -5},{53280,-10},{68982,-15},{89682,-20}
+};
+
+#define BAT_TEMP_TEBLE_NUM (sizeof(bat_temp_table) / sizeof(bat_temp_table[0]))
+
+static int rk817_battery_get_temperature(struct rk817_battery_device *battery)
+{
+ int i ,ret = 25 ;
+ unsigned long val = 0 ,res = 0;
+ val = rk817_bat_field_read(battery, BAT_TS_H) << 8;
+ val |= rk817_bat_field_read(battery, BAT_TS_L);
+ res=(val * 12 *10000)/(0XFFFF+1);//res=(val * 12 *1000000)/((0XFFFF+1)*10*10);
+ for( i = 0; i < BAT_TEMP_TEBLE_NUM ;i++)
+ {
+ if ( res <= bat_temp_table[i].res)
+ {
+ if( i > 0)
+ ret = bat_temp_table[i].temp + ((bat_temp_table[i].res - res)*5/(bat_temp_table[i].res-bat_temp_table[i-1].res));
+ else
+ ret = bat_temp_table[i].temp;
+
+ break;
+ }
+ }
+ printk("Negative Temperature Coefficient,val = %lu ,res = %lu ret = %d \r\n",val,res,ret);
+ return ret;
+}
+
static int rk817_battery_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
@@ -2141,6 +2180,7 @@ static int rk817_battery_get_property(struct power_supply *psy,
break;
case POWER_SUPPLY_PROP_TEMP:
val->intval = battery->temperature;
+ val->intval = rk817_battery_get_temperature(battery);
if (battery->pdata->bat_mode == MODE_VIRTUAL)
val->intval = VIRTUAL_TEMPERATURE;
break;
2、cat /sys/class/power_supply/battery/temp Obtenir la valeur de température

Sept、Article de référence
边栏推荐
- 详解MATLAB中与矩阵运算有关的算术运算符(加、减、乘、除、点乘、点除、乘方)
- Attack and defense drill | network security "whistleblower": security monitoring
- Brute force method /k integers out of 1~n integers
- 记录一下今天的MySQL故障
- [nk] Niuke monthly competition 51 f-average question
- 蛮力法/任务分配
- Understanding deep learning attention
- 2022-06-09 RK817 PMU 电池温度检测
- C language -- 10 first knowledge of structure
- LeetCode 进阶之路 - 加一
猜你喜欢

Explain in detail the arithmetic operators related to matrix operation in MATLAB (addition, subtraction, multiplication, division, point multiplication, point division, power)

C language -- 4 first-time constant

Will your company choose to develop data center?

在模仿学习中进步的智能机器人
An analysis of SQL query optimization principle (900w+ data from 17s to 300ms)

Practical | how to use burp suite for password blasting!
一次SQL查询优化原理分析(900W+数据从17s到300ms)

Attack and defense drill | network security "whistleblower": security monitoring

关于type-c

实用 | 如何利用 Burp Suite 进行密码爆破!
随机推荐
shell实现ssh登录并执行命令
SQL Server2019安装的详细步骤实战记录(亲测可用)
北大青鸟昌平校区:高中学历可以学UI吗?
Realize OSD reverse color on YUV image according to background color
app測試用例
Practical | how to use burp suite for password blasting!
Fast Planner - detailed explanation of kinetic astar
Self made table
Cas de test app
Tableau auto - fabriqué
^30H5 Web Worker多线程
Rotate navigation bar
Redis缓存穿透
LeetCode 进阶之路 - 69.X的平方根
LeetCode 进阶之路 - 167.两数之和 II - 输入有序数组
[nk] 牛客月赛51 F-平均题
Video monitoring system storage control, bandwidth calculation method
蛮力法/1~n个整数中取k个整数
Anti shake and throttling
Redis cache breakdown