发烧挂什么科| 黔鱼是什么鱼| 前列腺炎需要做什么检查| 打歌是什么意思| 盐酸二甲双胍缓释片什么时候吃| 菠萝蜜的核有什么功效| 包皮是什么样子的| 杨过是什么生肖| 声带白斑是什么病| 总胆红素偏高是什么意思| 奶粉罐可以做什么手工| 检查鼻炎要做什么检查| 嫩模是什么意思| 皈依有什么好处| 儿保做些什么检查项目| mk包包属于什么档次| 1.23是什么星座| 4月出生是什么星座| 什么食物| 县尉相当于现在什么官| 分泌物豆腐渣状是什么原因| 舌苔白厚腻吃什么药| 维生素b吃多了有什么副作用| 怡字五行属什么的| 白带像豆腐渣用什么药| 花开半夏什么意思| 宗气是什么意思| 京东什么时候有活动| 无私的动物是什么生肖| 肝不好吃什么药最好| 咽炎雾化用什么药最好| 黄山毛峰属于什么茶| 益生菌是什么东西| 生长因子是什么| 白头发多吃什么食物能变黑| 宫颈机能不全是什么原因造成的| csf是什么意思| 青岛市市长什么级别| 拍胸片能检查出什么| 夏天哈尔滨有什么好玩的地方| 退行性变是什么意思| 金钱草有什么功效| 鸽子单眼伤风用什么药| 走路脚心疼是什么原因| 过敏性鼻炎吃什么药| 鳞状上皮内低度病变是什么意思| 什么水晶招财| 胃溃疡适合吃什么水果| 什么水花| 办理公证需要什么材料| 小麦肤色是什么颜色| 神经内科和神经外科有什么区别| 吴佳尼为什么嫁马景涛| 欠是什么意思| 阴茎不硬吃什么药| 杀破狼是什么意思| 发烧适合吃什么水果| 5月26号什么星座| 膀胱过度活动症是什么原因引起的| 孩子鼻子流鼻血是什么原因| 泡奶粉用什么水最好| 尿有泡泡是什么病| 2月18号是什么星座| 什么桥下没有水脑筋急转弯| 冠冕是什么意思| 二十年是什么婚| 三个句号代表什么意思| 鸡蛋和面粉可以做什么好吃的| hello什么意思| 项羽字什么| 章鱼吃什么食物| ch4是什么气体| 腹腔淋巴结是什么意思| 乳头瘤有什么症状| 有什么树| 义务兵是什么意思| 尿骚味重是什么原因| 为什么不能抠肚脐眼| 劼字取名的寓意是什么| 突然膝盖疼是什么原因| 人为什么会长痔疮| 什么是孝顺| 神什么气什么| 津液不足吃什么中成药| 什么是桥本病| 急性肠胃炎吃什么药好| 不感冒是什么意思| 吃什么水果对肺好| 一什么心| 胃一阵一阵绞痛是什么原因| 梦见摘菜是什么意思| 为什么大便是绿色的| 白球比低是什么原因| 慢脚是什么| 什么叫比例| 看结石挂什么科室| 结晶是什么意思| 你正在干什么用英语怎么说| 淋巴结节吃什么药| 心电轴右偏是什么意思| 鸡蛋有什么营养| 为什么一喝酒就拉肚子| 突厥是现在的什么地方| zoe什么意思| 反胃吃什么药| 蔗去掉草字头读什么| 牛肉饺子馅配什么蔬菜好吃| 骨质密度增高是什么意思| 皮肤湿疹用什么药膏| 脾胃不好能吃什么水果| 心什么神什么| 安代表什么生肖| 呈味核苷酸二钠是什么| 拉肚子吃什么最好| 吃胡萝卜有什么好处| 孕妇吃鹅蛋有什么好处| 吐黑水是什么原因| 子宫内膜厚是什么原因造成的| 三个大是什么字| 口差念什么| 查钙含量做什么检查| 北极有什么动物| 什么原因会导致月经推迟| 腹泻吃什么水果| 吃什么水果减肥最快| 颈椎病用什么药最好| 正主是什么意思| 大便的颜色代表什么| 教导是什么意思| 小猫的尾巴有什么作用| a9什么意思| 冰山一角是什么生肖| 中将相当于什么级别| 新生儿贫血是什么原因造成的| 喝水经常呛到是什么原因| 86年属什么的生肖| 眼睛发痒是什么原因| 窥视是什么意思| 计生用品是什么| 人民检察院是国家的什么机关| 3.25是什么星座| 什么是二级医院| 皮肤黄的人适合穿什么颜色的衣服| 李世民是什么民族| eoa是什么意思| 牛肉不能和什么水果一起吃| 中性粒细胞偏高是什么意思| 寸关尺代表什么器官| 共青团书记是什么级别| 牛鞭是什么东西| 甘油三脂高是什么意思| 吃猪肺有什么好处和坏处| 宝宝拉肚子挂什么科| 胸部ct可以检查出什么| 百事可乐和可口可乐有什么区别| 肉偿是什么意思| 侧切是什么意思| 来月经可以吃什么水果好| 1988属什么| 感冒应该挂什么科| 牛肉和什么炒最好吃| 肛门被捅后有什么影响| 罢免是什么意思| 办理港澳通行证需要带什么证件| 阿佛洛狄忒是什么神| 鼻炎咳嗽吃什么药| 吃无花果干有什么好处| 伤口消毒用什么| 什么什么发抖| 猥琐是什么意思| 楞严神咒是什么意思| syp是什么意思| 为什么一直打哈欠| 孕妇能吃什么| 114是什么意思| 什么叫肠化生| 海蛎子是什么| 摆地摊卖什么最赚钱而且很受欢迎| 史迪奇是什么动物| 鼻子旁边的痣代表什么| 蜂蜡有什么用| gdp是什么意思啊| 痰湿是什么意思| 芬必得是什么药| 孕酮低什么原因| 赛博朋克是什么意思| 超脱是什么意思| 57是什么意思| 巨蟹男和什么座最配对| 家用制氧机什么牌子好| 胆囊炎吃什么食物好| 吃什么长内膜最快最有效| 玫瑰花和什么一起泡水喝好| 吃什么对脾胃好| 甲胎蛋白偏高是什么原因| 阴囊湿疹用什么药效果最好| 926是什么星座| 什么时候做四维| 来姨妈头疼是什么原因| 熬夜吃什么补回来| 阴道出血是什么样的| 有什么植物| 唯我独尊是什么意思| 创字五行属什么| 四月份是什么季节| 开塞露加什么能去皱纹| 土中金是什么生肖| 低血糖挂什么科| 孕妇梦见掉牙齿是什么意思| 256排ct能检查什么病| 紧张的反义词是什么| 八月二十是什么星座| 上眼皮痒是什么原因| 飞的第一笔是什么| 胃不好吃什么水果| 山什么水什么| 上午九点多是什么时辰| 子宫下垂吃什么药| 卒中是什么意思| lgg是什么意思| 男人吃什么容易生儿子| 轻度郁症有什么表现| 翡翠是什么意思| 卵巢多囊是什么原因造成的| 禅位是什么意思| 济南是什么城| 小孩拉肚子吃什么食物好| 5d电影是什么| 流鼻血去药店买什么药| 殊胜的意思是什么| 硒对身体有什么好处| 绿色食品指什么食品| 补气血吃什么食物| 深紫色配什么颜色好看| 肺结节吃什么| 为什么会拉水| 头抖是什么原因| 桑葚什么时候成熟| 秋刀鱼是什么鱼| 盐酸对人体有什么危害| 手忙脚乱是什么意思| 乌冬面是什么面| 亨特综合症是什么病| 什么是超标电动车| 恶心想吐是什么原因| 并驾齐驱什么意思| 半套什么意思| 火舌是什么意思| 十二生肖排第七是什么生肖| 咸鱼什么意思| 单抗主要治疗什么| 毛毛虫吃什么| 结扎挂什么科| 卑微是什么意思| 为什么会感染hpv| 色觉异常是什么意思| 紫烟是什么意思| 婴儿什么时候开始认人| 蕾丝边是什么意思| 牙疼不能吃什么东西| 孕妇梦到被蛇咬是什么意思| 姜薯是什么| 白鳍豚用什么呼吸| 什么才是真正的情人| 百度

CBA集锦-易建联砍大两双伤退 吉林113-119广东;

This version (31 Oct 2024 20:25) is a draft.
Approvals: 0/1
The Previously approved version (11 Sep 2021 18:17) is available.Diff

AD7476A IIO Single Channel Serial ADC Linux Driver

Supported Devices

Reference Circuits

Evaluation Boards

Description

百度 它当然不是高清画质,但效果也可以。

This is a Linux industrial I/O (IIO) subsystem driver, targeting single 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.

Source Code

Status

Source Mainlined?
git Yes

Files

Function File
driver drivers/iio/adc/ad7476.c

Example platform device initialization

Specifying reference voltage via the regulator framework

Below example specifies a 3.3 Volt reference for the SPI device 3 on SPI-Bus 0. (spi0.3)

#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE)
static struct regulator_consumer_supply ad7476_consumer_supplies[] = {
	REGULATOR_SUPPLY("vcc", "spi0.3"),
};
 
static struct regulator_init_data stamp_avdd_reg_init_data = {
	.constraints	= {
		.name	= "3V3",
		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
	},
	.consumer_supplies = ad7476_consumer_supplies,
	.num_consumer_supplies = ARRAY_SIZE(ad7476_consumer_supplies),
};
 
static struct fixed_voltage_config stamp_vdd_pdata = {
	.supply_name	= "board-3V3",
	.microvolts	= 3300000,
	.gpio		= -EINVAL,
	.enabled_at_boot = 0,
	.init_data	= &stamp_avdd_reg_init_data,
};
static struct platform_device brd_voltage_regulator = {
	.name		= "reg-fixed-voltage",
	.id		= -1,
	.num_resources	= 0,
	.dev		= {
		.platform_data	= &stamp_vdd_pdata,
	},
};
#endif
static struct platform_device *board_devices[] __initdata = {
#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE)
	&brd_voltage_regulator
#endif
};
static int __init board_init(void)
{
	[--snip--]
 
	platform_add_devices(board_devices, ARRAY_SIZE(board_devices));
 
	[--snip--]
 
	return 0;
}
arch_initcall(board_init);

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.rst

21 Oct 2010 14: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_AD7476) || \
 	defined(CONFIG_AD7476_MODULE)
	{
		/* the modalias must be the same as spi device driver name */
		.modalias = "ad7476", /* Name of spi_driver for this device */
		.max_speed_hz = 1000000,     /* max spi clock (SCK) speed in HZ */
		.bus_num = 0, /* Framework bus number */
		.chip_select = 3, /* Framework chip select */
		.mode = SPI_MODE_3,
	},
#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);

Devicetree

Required devicetree properties:

  • compatible: Needs to be “adi,” followed by the name of the device. E.g. “adi,ad7476a”
  • reg: The chipselect number used for the device
  • spi-max-frequency: Maximum SPI clock frequency.
  • spi-cpha: Needs to be set for the correct SPI mode
  • spi-cpol: Needs to be set for the correct SPI mode
  • vcc-supply: Phandle to the supply regulator
       adc_supply: fixedregulator {
               compatible = "regulator-fixed";
               regulator-name = "fixed-supply";
               regulator-min-microvolt = <3300000>;
               regulator-max-microvolt = <3300000>;
       };

       spi: spi@e0007000 {
               #address-cells = <1>;
               #size-cells = <0>;
               compatible = "xlnx,ps7-spi-1.00.a";
               ...

               ad7476@0 {
                       compatible = "adi,ad7476a";
                       reg = <0>;
                       spi-max-frequency = <1000000>;
                       spi-cpha;
                       spi-cpol;
                       vcc-supply = <&adc_supply>;
               };
        };

Adding Linux driver support

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

The AD7476 Driver depends on CONFIG_SPI

Linux Kernel Configuration
    Device Drivers  --->
        ...
        <*>     Industrial I/O support --->
            --- Industrial I/O support
            ...
            Analog to digital converters  ---> 
                ...
                <*>  Analog Devices AD7476 and similar 1-channel ADCs driver
                ...
            ...
        ...

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 14:16

This specifies any shell prompt running on the target

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

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

root:/sys/devices/platform/bfin-spi.0/spi0.3/device0> ls -l
drwxr-xr-x    5 root     root             0 Jan  1 00:00 buffer
-r--r--r--    1 root     root          4096 Jan  1 00:00 in_voltage0_raw
-r--r--r--    1 root     root          4096 Jan  1 00:00 in_voltage_scale
-r--r--r--    1 root     root          4096 Jan  1 00:00 name
lrwxrwxrwx    1 root     root             0 Jan  1 00:00 subsystem -> ../../../../../bus/iio
drwxr-xr-x    2 root     root             0 Jan  1 00:00 trigger
-rw-r--r--    1 root     root          4096 Jan  1 00:00 uevent

Show device name

This specifies any shell prompt running on the target

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

Show scale

Description:
scale to be applied to in_voltage0_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.3/device0> cat in_voltage_scale
0.805

Show channel 0 measurement

Description:
Raw unscaled voltage measurement on channel 0

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.3/device0> cat in_voltage0_raw
2001

U = in_voltage0_raw * in_voltage_scale = 2001 * 0.805 = 1610,805 mV

Trigger management

If deviceX supports triggered sampling, it’s a so called trigger consumer and there will be an additional folder /sys/bus/iio/device/iio:deviceX/trigger. In this folder there is a file called current_trigger, allowing controlling and viewing the current trigger source connected to deviceX. Available trigger sources can be identified by reading the name file /sys/bus/iio/devices/triggerY/name. The same trigger source can connect to multiple devices, so a single trigger may initialize data capture or reading from a number of sensors, converters, etc.

Trigger Consumers:
Currently triggers are only used for the filling of software ring buffers and as such any device supporting INDIO_RING_TRIGGERED has the consumer interface automatically created.

Description: Read name of triggerY

This specifies any shell prompt running on the target

root:/sys/bus/iio/devices/triggerY/> cat name
irqtrig56

Description: Make irqtrig56 (trigger using system IRQ56, likely a GPIO IRQ), to current trigger of deviceX

This specifies any shell prompt running on the target

root:/sys/bus/iio/devices/iio:deviceX/trigger> echo irqtrig56 > current_trigger

Description: Read current trigger source of deviceX

This specifies any shell prompt running on the target

root:/sys/bus/iio/devices/iio:deviceX/trigger> cat current_trigger
irqtrig56

02 Mar 2011 14:16

Available standalone trigger drivers

name description
iio-trig-gpio Provides support for using GPIO pins as IIO triggers.
iio-trig-rtc Provides support for using periodic capable real time clocks as IIO triggers.
iio-trig-sysfs Provides support for using SYSFS entry as IIO triggers.
iio-trig-bfin-timer Provides support for using a Blackfin timer as IIO triggers.
02 Mar 2011 14:16

Buffer management

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.3/device0/device0:buffer0> ls
bytes_per_datum          enable                   subsystem
device0:buffer0:access0  length                   uevent
device0:buffer0:event0   scan_elements
root:/sys/devices/platform/bfin-spi.0/spi0.3/device0/device0:buffer0>

The Industrial I/O subsystem provides support for various ring buffer based data acquisition methods. Apart from device specific hardware buffer support, the user can chose between two different software ring buffer implementations. One is the IIO lock free software ring, and the other is based on Linux kfifo. Devices with buffer support feature an additional sub-folder in the /sys/bus/iio/devices/deviceX/ folder hierarchy. Called deviceX:bufferY, where Y defaults to 0, for devices with a single buffer.

Every buffer implementation features a set of files:

length
Get/set the number of sample sets that may be held by the buffer.

enable
Enables/disables the buffer. This file should be written last, after length and selection of scan elements.

watermark
A single positive integer specifying the maximum number of scan elements to wait for. Poll will block until the watermark is reached. Blocking read will wait until the minimum between the requested read amount or the low water mark is available. Non-blocking read will retrieve the available samples from the buffer even if there are less samples then watermark level. This allows the application to block on poll with a timeout and read the available samples after the timeout expires and thus have a maximum delay guarantee.

data_available
A read-only value indicating the bytes of data available in the buffer. In the case of an output buffer, this indicates the amount of empty space available to write data to. In the case of an input buffer, this indicates the amount of data available for reading.

length_align_bytes
Using the high-speed interface. DMA buffers may have an alignment requirement for the buffer length. Newer versions of the kernel will report the alignment requirements associated with a device through the `length_align_bytes` property.

scan_elements
The scan_elements directory contains interfaces for elements that will be captured for a single triggered sample set in the buffer.

02 Mar 2011 14:16

This specifies any shell prompt running on the target

root:/sys/devices/platform/bfin-spi.0/spi0.3/device0/device0:buffer0/scan_elements> ls
in0_en           in_type          timestamp_index
in0_index        timestamp_en     timestamp_type
root:/sys/devices/platform/bfin-spi.0/spi0.3/device0/device0:buffer0/scan_elements>

in_voltageX_en / in_voltageX-voltageY_en / timestamp_en:
Scan element control for triggered data capture. Writing 1 will enable the scan element, writing 0 will disable it

in_voltageX_type / in_voltageX-voltageY_type / timestamp_type:
Description of the scan element data storage within the buffer and therefore in the form in which it is read from user-space. Form is [s|u]bits/storage-bits. s or u specifies if signed (2's complement) or unsigned. bits is the number of bits of data and storage-bits is the space (after padding) that it occupies in the buffer. Note that some devices will have additional information in the unused bits so to get a clean value, the bits value must be used to mask the buffer output value appropriately. The storage-bits value also specifies the data alignment. So u12/16 will be a unsigned 12 bit integer stored in a 16 bit location aligned to a 16 bit boundary. For other storage combinations this attribute will be extended appropriately.

in_voltageX_index / in_voltageX-voltageY_index / timestamp_index:
A single positive integer specifying the position of this scan element in the buffer. Note these are not dependent on what is enabled and may not be contiguous. Thus for user-space to establish the full layout these must be used in conjunction with all _en attributes to establish which channels are present, and the relevant _type attributes to establish the data storage format.

02 Mar 2011 14:16

More Information

resources/tools-software/linux-drivers/iio-adc/ad7476a.txt · Last modified: 31 Oct 2024 20:25 by David Lechner

? 
酒是什么时候发明的 骟是什么意思 狗牯脑茶属于什么茶 支气管炎吃什么药好得快 跖围是什么意思
鹿角粉有什么功效和作用 头皮痒用什么止痒最好 牙龈肿痛用什么药 什么药和酒一起吃必死 这什么情况
孩子磨牙是什么原因 醒酒喝什么饮料 饕餮是什么意思 检察长是什么级别 身上长小红点是什么原因
口舌麻木吃什么药 左胸上方隐痛什么原因 蜜饯是什么意思 gtp什么意思 嘴唇痒边缘痒用什么药
吃羊肉不能吃什么东西hkuteam.com 大便恶臭是什么原因jasonfriends.com 冬至为什么吃水饺hcv8jop5ns8r.cn 怀孕为什么会流褐色分泌物hcv8jop0ns5r.cn 做梦梦见拉屎是什么意思hcv9jop5ns4r.cn
阴唇内侧长疙瘩是什么原因hcv8jop7ns5r.cn 生眼屎是什么原因引起的qingzhougame.com fila是什么品牌hcv9jop3ns5r.cn 联通查流量发什么短信hcv9jop5ns8r.cn 易激惹是什么意思96micro.com
摩羯座跟什么星座最配hcv9jop6ns8r.cn 染指是什么意思hcv9jop2ns8r.cn 热火朝天是什么意思hcv9jop4ns2r.cn 尿道炎吃什么药比较好的快hcv8jop5ns8r.cn 12月28日什么星座bfb118.com
脱落细胞学检查是什么hcv9jop2ns7r.cn 新生儿甲状腺偏高有什么影响hcv8jop6ns2r.cn 四月十一日是什么星座hcv9jop0ns5r.cn 尿结石什么症状hcv9jop1ns7r.cn 减脂喝什么茶最有效youbangsi.com
百度