匿名
未登录
登录
百问网嵌入式Linux wiki
搜索
查看“ADC Linux driver”的源代码
来自百问网嵌入式Linux wiki
名字空间
页面
讨论
更多
更多
页面选项
Read
查看源代码
历史
←
ADC Linux driver
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
该页面已被保护以防止编辑和其他操作。
您可以查看与复制此页面的源代码。
== Article purpose == This article introduces the Linux<sup>®</sup> driver for the ADC<ref name="ADC internal peripheral">[[ADC internal peripheral]]</ref> internal peripheral: * Which ADC features are supported by the driver * How to configure, use and debug the driver * What is the driver structure, and where the source code can be found. == Short description == The ADC Linux<sup>®</sup> driver (kernel space) is based on the [[IIO overview|IIO]] framework. It supports two modes: # '''IIO direct mode''': single capture on a channel (using interrupts) # '''IIO triggered buffer mode''': capture on one or more channels (preferably using DMA).<br/>It uses the hardware triggers available in IIO. See [[TIM Linux driver]] and [[LPTIM Linux driver]]. == Configuration == === Kernel configuration === Activate the ADC<ref name="ADC internal peripheral"/> Linux<sup>®</sup> driver in the kernel configuration using the Linux Menuconfig tool: [[Menuconfig or how to configure kernel]] (enable both CONFIG_STM32_ADC_CORE and CONFIG_STM32_ADC). <pre> Device Drivers ---> <*> Industrial I/O support ---> Analog to digital converters ---> <*> STMicroelectronics STM32 adc core <*> STMicroelectronics STM32 adc </pre> === Device tree === Refer to the [[ADC device tree configuration]] article when configuring the ADC Linux kernel driver. == How to use == In "'''IIO direct mode'''", the conversion result can be read directly from '''sysfs''' (refer to [[How to use the IIO user space interface#How to do a simple ADC conversion using the sysfs interface|How to do a simple ADC conversion using the sysfs interface]]). In "'''IIO triggered buffer mode'''", the configuration must be performed using '''sysfs''' first. Then, '''character device''' (/dev/iio:deviceX) is used to read data (refer to [[How to use the IIO user space interface#Convert one or more channels using triggered buffer mode|Convert one or more channels using triggered buffer mode]]). == How to trace and debug == Refer to [[IIO_overview#How_to_trace_with_dynamic_debug|How to trace with dynamic debug]] for how to '''enable the debug logs''' in the driver and in the framework. Refer to [[IIO_overview#How_to_debug_with_debugfs|How to debug with debugfs]] for how to '''access the ADC registers'''. The ADC has system wide dependencies towards other key resources: * '''runtime power management''' can be disabled, for example it may be forced '''on''' via ''power/control'' sysfs entry: {{Board$}} cd /sys/devices/platform/soc/48003000.adc/48003000.adc:adc@0 {{Board$}} cat power/autosuspend_delay_ms 2000 {{Board$}} cat power/control auto # kernel is allowed to automatically suspend the ADC device after autosuspend_delay_ms {{Board$}} {{highlight|echo on > power/control}} # force the kernel to resume the ADC device (e.g. keep clocks and regulators enabled) {{Info| It might be useful to disable runtime power management, in order to dump registers by any means or to check clock and regulator usage (see example below).}} * '''clock'''<ref name="Clock overview">[[Clock overview]]</ref> usage can be verified by reading ''clk_summary'': {{Board$}} {{highlight|cat /sys/kernel/debug/clk/clk_summary}} | grep adc adc12_k 1 1 0 24000000 0 0 adc12 1 1 0 196607910 0 0 * '''regulator'''<ref name="Regulator overview">[[Regulator overview]]</ref> tree and usage can be verified (e.g. use count, open count or regulator reference voltage) as follows: {{Board$}} {{highlight|cat /sys/kernel/debug/regulator/regulator_summary}} regulator use open bypass voltage current min max ------------------------------------------------------------------------------- v3v3 4 5 0 3300mV 0mA 3300mV 3300mV vdda 1 2 0 2900mV 0mA 2900mV 2900mV 40017000.dac 0mV 0mV 48003000.adc 0mV 0mV * '''pinctrl'''<ref name="Pinctrl_overview">[[Pinctrl overview]]</ref> usage can be verified by reading ''pinmux-pins'': {{Board$}} cd /sys/kernel/debug/pinctrl/soc\:pin-controller@50002000/ {{Board$}} {{highlight|cat pinmux-pins}} | grep adc pin 92 (PF12): device 48003000.adc function {{highlight|analog}} group PF12 # check pin is assigned to ADC and is configured as "analog" * '''interrupts''' can be verified by reading "interrupts": {{Board$}} {{highlight|cat /proc/interrupts}} CPU0 CPU1 56: 2 0 dummy 0 Edge 48003000.adc:adc@0 == Source code location == The ADC source code is composed of: * {{CodeSource | Linux kernel | drivers/iio/adc/stm32-adc-core.c | stm32-adc-core driver}} to handle common resources such as clock (selection, prescaler), [[Regulator overview|regulator]] used as reference voltage, interrupt and common registers. * {{CodeSource | Linux kernel | drivers/iio/adc/stm32-adc.c | stm32-adc driver}} to handle the resources available for each ADC such as channel configuration and buffer handling. ==References== <references /> <noinclude> [[Category:IIO]] {{PublicationRequestId | 9337 | 2018-10-23 | AnneJ}} {{ArticleBasedOnModel | Linux driver article model}} </noinclude>
该页面使用的模板:
模板:Board$
(
查看源代码
)
模板:CodeSource
(
查看源代码
)
模板:Highlight
(
查看源代码
)
模板:Info
(
查看源代码
)
模板:STDarkBlue
(
查看源代码
)
返回至
ADC Linux driver
。
导航
导航
WIKI首页
官方店铺
资料下载
交流社区
所有页面
所有产品
MPU-Linux开发板
MCU-单片机开发板
Linux开发系列视频
单片机开发系列视频
所有模块配件
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志