那曲檬骨新材料有限公司

電子發燒友App

硬聲App

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示
電子發燒友網>電子資料下載>類型>參考設計>AD7280A IIO鋰離子電池監控系統Linux驅動程序

AD7280A IIO鋰離子電池監控系統Linux驅動程序

2021-04-14 | pdf | 182.23KB | 次下載 | 2積分

資料介紹

This version (11 Feb 2016 20:44) was approved by Lars-Peter Clausen.The Previously approved version (16 Nov 2012 11:46) is available.Diff

AD7280A IIO Lithium Ion Battery Monitoring System Linux Driver

Supported Devices

Reference Circuits

Evaluation Boards

Description

This is a Linux industrial I/O (IIO) subsystem driver, targeting multi channel serial interface ADCs. The industrial I/O subsystem provides a unified framework for drivers for many different types of converters and sensors using a number of different physical interfaces (i2c, spi, etc). See IIO for more information.

The AD7280A contains all the functions required for general-purpose monitoring of stacked lithium ion batteries as used in hybrid electric vehicles, battery backup applications, and power tools. The part has multiplexed cell voltage and auxiliary ADC measurement channels for up to six cells of battery management. This driver supports the daisy-chain interface allowing up to eight parts to be stacked without the need for individual device isolation.

The driver automatically detects then number of devices present and creates the iio device files accordingly.

Source Code

Status

Source Mainlined?
git Yes

Files

Example platform device initialization

For compile time configuration, it’s common Linux practice to keep board- and application-specific configuration out of the main driver file, instead putting it into the board support file.

For devices on custom boards, as typical of embedded and SoC-(system-on-chip) based hardware, Linux uses platform_data to point to board-specific structures describing devices and how they are connected to the SoC. This can include available ports, chip variants, preferred modes, default initialization, additional pin roles, and so on. This shrinks the board-support packages (BSPs) and minimizes board and application specific #ifdefs in drivers.

21 Oct 2010 16:10

Some device parameter may vary between applications and use cases. The platform_data for the device's “struct device” holds this information.

#define AD7280A_ACQ_TIME_400ns			0
#define AD7280A_ACQ_TIME_800ns			1
#define AD7280A_ACQ_TIME_1200ns			2
#define AD7280A_ACQ_TIME_1600ns			3
?
#define AD7280A_CONV_AVG_DIS			0
#define AD7280A_CONV_AVG_2			1
#define AD7280A_CONV_AVG_4			2
#define AD7280A_CONV_AVG_8			3
?
#define AD7280A_ALERT_REMOVE_VIN5		(1 << 2)
#define AD7280A_ALERT_REMOVE_VIN4_VIN5		(2 << 2)
#define AD7280A_ALERT_REMOVE_AUX5		(1 << 0)
#define AD7280A_ALERT_REMOVE_AUX4_AUX5		(2 << 0)
?
struct ad7280_platform_data {
	unsigned acquisition_time;
	unsigned conversion_averaging;
	unsigned chain_last_alert_ignore;
	bool thermistor_term_en;
}

In case platform_data is not present or set to NULL, the driver will use following defaults:

static const struct ad7280_platform_data ad7280_default_pdata = {
	.acquisition_time = AD7280A_ACQ_TIME_400ns,
	.conversion_averaging = AD7280A_CONV_AVG_DIS,
	.thermistor_term_en = true,
};

Declaring SPI slave devices

Unlike PCI or USB devices, SPI devices are not enumerated at the hardware level. Instead, the software must know which devices are connected on each SPI bus segment, and what slave selects these devices are using. For this reason, the kernel code must instantiate SPI devices explicitly. The most common method is to declare the SPI devices by bus number.

This method is appropriate when the SPI bus is a system bus, as in many embedded systems, wherein each SPI bus has a number which is known in advance. It is thus possible to pre-declare the SPI devices that inhabit this bus. This is done with an array of struct spi_board_info, which is registered by calling spi_register_board_info().

For more information see: Documentation/spi/spi-summary

21 Oct 2010 16:10

Depending on the converter IC used, you may need to set the modalias accordingly, matching your part name. It may also required to adjust max_speed_hz. Please consult the datasheet, for maximum spi clock supported by the device in question.

static struct spi_board_info board_spi_board_info[] __initdata = {
#if defined(CONFIG_AD7280A) || /
 	defined(CONFIG_AD7280A_MODULE)
	{
		.modalias = "ad7280a",
		.max_speed_hz = 1000000,     /* max spi clock (SCK) speed in HZ */
		.bus_num = 0,
		.chip_select = GPIO_PF10 + MAX_CTRL_CS, /* CS, change it for your board */
		.mode = SPI_MODE_1,
		.irq = IRQ_PF6
	},
#endif
};
static int __init board_init(void)
{
	[--snip--]
?
	spi_register_board_info(board_spi_board_info, ARRAY_SIZE(board_spi_board_info));
?
	[--snip--]
?
	return 0;
}
arch_initcall(board_init);

Adding Linux driver support

Configure kernel with “make menuconfig” (alternatively use “make xconfig” or “make qconfig”)

The AD7280A Driver depends on CONFIG_SPI

Linux Kernel Configuration
	Device Drivers  --->
		[*] Staging drivers  --->
			<*>     Industrial I/O support --->
			    --- Industrial I/O support
			    -*-   Enable ring buffer support within IIO
			    -*-     Industrial I/O lock free software ring
			    -*-   Enable triggered sampling support

			          *** Analog to digital converters ***
			    [--snip--]

			    <*>   Analog Devices AD7280A Lithium Ion Battery Monitoring System

			    [--snip--]

Hardware configuration

Driver testing

Each and every IIO device, typically a hardware chip, has a device folder under /sys/bus/iio/devices/iio:deviceX. Where X is the IIO index of the device. Under every of these directory folders reside a set of files, depending on the characteristics and features of the hardware device in question. These files are consistently generalized and documented in the IIO ABI documentation. In order to determine which IIO deviceX corresponds to which hardware device, the user can read the name file /sys/bus/iio/devices/iio:deviceX/name. In case the sequence in which the iio device drivers are loaded/registered is constant, the numbering is constant and may be known in advance.

02 Mar 2011 15:16

This specifies any shell prompt running on the target

root:/> cd /sys/bus/iio/devices/
root:/sys/bus/iio/devices> ls
device0         device0:event0
root:/sys/bus/iio/devices> cd device0

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> ls -l
drwxr-xr-x    3 root     root             0 Mar 14 11:16 device0:event0
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in-in_scale
-r--r--r--    1 root     root          4096 Mar 14 11:16 in0-in12_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in0-in1_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in0-in1_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in0-in1_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in1-in2_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in1-in2_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in1-in2_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in10-in11_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in10-in11_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in10-in11_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in11-in12_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in11-in12_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in11-in12_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in2-in3_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in2-in3_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in2-in3_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in3-in4_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in3-in4_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in3-in4_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in4-in5_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in4-in5_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in4-in5_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in5-in6_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in5-in6_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in5-in6_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in6-in7_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in6-in7_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in6-in7_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in7-in8_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in7-in8_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in7-in8_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in8-in9_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in8-in9_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in8-in9_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in9-in10_balance_switch_en
-rw-r--r--    1 root     root          4096 Mar 14 11:16 in9-in10_balance_timer
-r--r--r--    1 root     root          4096 Mar 14 11:16 in9-in10_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 name
drwxr-xr-x    2 root     root             0 Mar 14 11:16 power
lrwxrwxrwx    1 root     root             0 Mar 14 11:16 subsystem -> ../../../../../bus/iio
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp0_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp10_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp11_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp1_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp2_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp3_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp4_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp5_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp6_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp7_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp8_raw
-r--r--r--    1 root     root          4096 Mar 14 11:16 temp9_raw
-rw-r--r--    1 root     root          4096 Mar 14 11:16 temp_scale
-rw-r--r--    1 root     root          4096 Mar 14 11:16 uevent
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0>

Show device name

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat name
ad7280a

Show cell channel scale

Description:
scale to be applied to inX-inY_raw in order to obtain the measured voltage in millivolts.

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in-in_scale
0.976000

Show channel 0-1 measurement

Description:
Raw unscaled voltage measurement on cell channel in0-in1_raw

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in0-in1_raw
2254

U = in0-in1_raw * in-in_scale + offset = 2254 * 0.976000 + 1000 = 3199.904 mV

Show voltage across all cells measurement

Description:
Raw unscaled voltage measurement on all cell channel in0-inX_raw

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in0-in12_raw
27048

U = in0-in1_raw * in-in_scale + (cell_num * offset) = 27048 * 0.976000 + (12 * 1000) = 38398.848 mV

Show auxiliary/temperature channel scale

Description:
scale to be applied to tempX_raw in order to obtain the measured voltage in millivolts.

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat temp_scale
1.220000

Show auxiliary/temperature channel measurement

Description:
Shows high accuracy band gap temperature sensor temperature in milli degrees Celsius.

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat temp0_raw
2096

U = temp0_raw * temp_scale = 2096 * 1.220000 = 2557.12 mV

Enable cell balance output switch on channel 4-5

The AD7280A has cell balancing interface outputs designed to control external FET transistors to allow discharging of individual cells.

Description:
Writing 1 enables the cell balance output switch corresponding
to input Y. Writing 0 disables it. If the inY-inZ_balance_timer
is set to a none zero value, the corresponding switch will
enable for the programmed amount of time, before it
automatically disables.

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> echo 1 > in4-in5_balance_switch_en
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in4-in5_balance_switch_en
1

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> echo 0 > in4-in5_balance_switch_en
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in4-in5_balance_switch_en
0
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> 

Enable cell balance timer on channel 4-5

Description:
The inY-inZ_balance_timer file allows the user to program
individual times for each cell balance output. The AD7280A
allows the user to set the timer to a value from 0 minutes to
36.9 minutes. The resolution of the timer is 71.5 sec.
The value written is the on-time in milliseconds. When the
timer value is set 0, the timer is disabled. The cell balance
outputs are controlled only by inY-inZ_balance_switch_en.

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> echo 150000 > in4-in5_balance_timer
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in4-in5_balance_timer
143000
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> 

Enabling cell and auxiliary/temperature channel threshold events

This specifies any shell prompt running on the target

root:/> cd /sys/bus/iio/devices/
root:/sys/bus/iio/devices> ls
device0         device0:event0
root:/sys/bus/iio/devices> cd device0:event0

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0> ls -l
-r--r--r--    1 root     root          4096 Mar 14 13:37 dev
-rw-r--r--    1 root     root          4096 Mar 14 13:37 in-in_thresh_high_value
-rw-r--r--    1 root     root          4096 Mar 14 13:37 in-in_thresh_low_value
drwxr-xr-x    2 root     root             0 Mar 14 13:37 power
lrwxrwxrwx    1 root     root             0 Mar 14 13:37 subsystem -> ../../../../../../bus/iio
-rw-r--r--    1 root     root          4096 Mar 14 13:37 temp_thresh_high_value
-rw-r--r--    1 root     root          4096 Mar 14 13:37 temp_thresh_low_value
-rw-r--r--    1 root     root          4096 Mar 14 13:37 uevent
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0> 

The AD7280A includes a dynamic alert function that can detect whether the cell voltages or auxiliary ADC inputs exceed an upper or lower limit defined by the user.

Description:
Specifies the value of threshold (_high|_low) that the device is comparing against.

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0> echo 2300 > in-in_thresh_low_value
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0> cat in-in_thresh_low_value
2285

root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0> echo 4000 > in-in_thresh_high_value
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0> cat in-in_thresh_high_value
3994

More Information

下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評論

查看更多

下載排行

本周

  1. 1AN-1267: 使用ADSP-CM408F ADC控制器的電機控制反饋采樣時序
  2. 1.41MB   |  3次下載  |  免費
  3. 2AN158 GD32VW553 Wi-Fi開發指南
  4. 1.51MB   |  2次下載  |  免費
  5. 3AN148 GD32VW553射頻硬件開發指南
  6. 2.07MB   |  1次下載  |  免費
  7. 4AN-1154: 采用恒定負滲漏電流優化ADF4157和ADF4158 PLL的相位噪聲和雜散性能
  8. 199.28KB   |  次下載  |  免費
  9. 5AN-960: RS-485/RS-422電路實施指南
  10. 380.8KB   |  次下載  |  免費
  11. 6EE-249:使用VisualDSP在ADSP-218x DSP上實現軟件疊加
  12. 60.02KB   |  次下載  |  免費
  13. 7AN-1111: 使用ADuCM360/ADuCM361時的降低功耗選項
  14. 306.09KB   |  次下載  |  免費
  15. 8AN-904: ADuC7028評估板參考指南
  16. 815.82KB   |  次下載  |  免費

本月

  1. 1ADI高性能電源管理解決方案
  2. 2.43 MB   |  450次下載  |  免費
  3. 2免費開源CC3D飛控資料(電路圖&PCB源文件、BOM、
  4. 5.67 MB   |  138次下載  |  1 積分
  5. 3基于STM32單片機智能手環心率計步器體溫顯示設計
  6. 0.10 MB   |  130次下載  |  免費
  7. 4使用單片機實現七人表決器的程序和仿真資料免費下載
  8. 2.96 MB   |  44次下載  |  免費
  9. 5美的電磁爐維修手冊大全
  10. 1.56 MB   |  24次下載  |  5 積分
  11. 6如何正確測試電源的紋波
  12. 0.36 MB   |  18次下載  |  免費
  13. 7感應筆電路圖
  14. 0.06 MB   |  10次下載  |  免費
  15. 8萬用表UT58A原理圖
  16. 0.09 MB   |  9次下載  |  5 積分

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935121次下載  |  10 積分
  3. 2開源硬件-PMP21529.1-4 開關降壓/升壓雙向直流/直流轉換器 PCB layout 設計
  4. 1.48MB  |  420062次下載  |  10 積分
  5. 3Altium DXP2002下載入口
  6. 未知  |  233088次下載  |  10 積分
  7. 4電路仿真軟件multisim 10.0免費下載
  8. 340992  |  191367次下載  |  10 積分
  9. 5十天學會AVR單片機與C語言視頻教程 下載
  10. 158M  |  183335次下載  |  10 積分
  11. 6labview8.5下載
  12. 未知  |  81581次下載  |  10 積分
  13. 7Keil工具MDK-Arm免費下載
  14. 0.02 MB  |  73810次下載  |  10 積分
  15. 8LabVIEW 8.6下載
  16. 未知  |  65988次下載  |  10 積分
澳门葡京赌场官网| 南江县| 百家乐官网现金网平台| 百家乐官网太阳城 | 百家乐官网在线手机玩| 反赌百家乐官网的玩法技巧和规则 | 网上百家乐庄家有赌场优势吗| 百家乐制胜方法| 万龙百家乐的玩法技巧和规则| 皇冠娱乐| 百家乐官网电投网址| 百家乐游戏真人游戏| 大发888手机版官网| 百家乐官网必胜软件下载| 免费百家乐官网计划| 最新百家乐网评测排名| 鸿博开户| 龍城百家乐官网的玩法技巧和规则 | 百家乐赌缆十三式| 大发888bet下载| 百家乐官网筹码500| 百家乐赢谷输缩| 庄浪县| 百家乐官网最佳打| 天天百家乐的玩法技巧和规则 | 大发888游戏平台888| 澳门百家乐官网怎么赢钱| 百家乐号论坛博彩正网| 澳门博彩官网| 百家乐官网7人桌布| 路劲太阳城样板间| 宝马会百家乐官网现金网| 博E百百家乐娱乐城| 永利国际| 百家乐软件代打| 金皇冠娱乐城| 24山 分金 水口 论 吉凶| 大发888娱乐游戏外挂| 百家乐官网最新的投注方法 | 棋牌娱乐网,| 百家乐路单用处|