In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The AD interface on the sunychip-RK3288 development board is divided into: high-speed ADC stream interface (High-speed ADC Stream Interface), temperature sensor (Temperature Sensor), successive approximation ADC (Successive Approximation Register). This paper mainly introduces the basic configuration method of ADC. The kernel uses the industrial Icano subsystem to control the ADC, which is mainly designed for sensors with AD conversion or DA conversion. The related data structures and configuration methods are as follows:
The data structure iio_channel structure struct iio_channel {struct iio_dev * indio_dev;// Industrial I Row O device const struct iio_chan_spec * channel;//I/O channel void * data;}; iio_dev structure this structure is mainly used to describe the device to which the IO port belongs, and its specific definition is as follows: struct iio_dev {int id; int modes Int currentmode; struct device dev; struct iio_event_interface * event_interface; struct iio_buffer * buffer; struct list_head buffer_list; int scan_bytes; struct mutex mlock; const unsigned long * available_scan_masks; unsigned masklength; const unsigned long * active_scan_mask Bool scan_timest unsigned scan_index_timest struct iio_trigger * trig; struct iio_poll_func * pollfunc; struct iio_chan_spec const * channels; int num_channels; struct list_head channel_attr_list; struct attribute_group chan_attr_group; const char * name Const struct iio_info * info; struct mutex info_exist_lock; const struct iio_buffer_setup_ops * setup_ops; struct cdev chrdev; # define IIO_MAX_GROUPS 6 const struct attribute_group * groups [IIO _ MAX_GROUPS + 1]; int groupcounter; unsigned long flags # if defined (CONFIG_DEBUG_FS) struct dentry * debugfs_dentry; unsigned cached_reg_addr; # endif}; iio_chan_spec structure struct iio_chan_spec {enum iio_chan_type type; / / describe the channel type int channel; / / channel number int channel2; / / channel number unsigned long address; / / channel address int scan_index Struct {char sign; U8 realbits; U8 storagebits; U8 shift; enum iio_endian endianness;} scan_type; long info_mask; long info_mask_separate; long info_mask_shared_by_type; long event_mask; const struct iio_chan_spec_ext_info * ext_info Const char * extend_name; const char * datasheet_name; unsigned modified:1; unsigned indexed:1; unsigned output:1; unsigned differential:1;}; configure steps to configure the DTS node
The DTS node for ADC is defined in the kernel/arch/arm/boot/dts/rk3288.dtsi file, as follows:
Adc: adc@ff100000 {compatible = "rockchip,saradc"; reg =; interrupts =; # io-channel-cells =; io-channel-ranges;rockchip,adc-vref =; clock-frequency =; clocks =,; clock-names = "saradc", "pclk_saradc"; status = "disabled";}
Users only need to add the channel definition in the firefly-rk3288.dts file and change its status to "okay":
& adc {status = "okay"; adc_test {compatible = "rockchip,adc_test"; io-channels =;};}; match the DTS node in the driver file
Define the of_device_id structure array in the driver file:
Static const struct of_device_id of_XXX_match [] = {{.clients = "rockchip,adc_test"}, {/ * Sentinel * /}}
Populate the structure array into the platform_driver where you want to use ADC.
Static struct platform_driver XXX_driver = {.probe =..., .remove =..., .driver = {.name = "..", .owner = THIS_MODULE, # ifdef CONFIG_OF. Of _ match_table = of_XXX_match, # endif},}; get AD channel struct iio_channel * chan / / define the IIO channel structure chan = iio_channel_get (& pdev- > dev, NULL); / / get the IIO channel structure
Note: iio_channel_get obtains the IIO channel structure through the parameter pdev passed in the probe function. The probe function is as follows:
Static int XXX_probe (struct platform_device * pdev); read the raw data collected by AD int val,ret;ret = iio_read_channel_raw (chan, & val)
Call the iio_read_channel_raw function to read the original data collected by AD and store it in val.
Calculate the collected voltage
Use the standard voltage to convert the value of the AD conversion to the voltage value required by the user. The calculation formula is as follows:
Vref / (2 ^ n-1) = Vresult / raw
Note: Vref is the standard voltage n is the number of digits converted by AD Vresult is the acquisition voltage required by the user raw is the original data collected by AD, for example, the standard voltage is 1.8 V, the number of AD acquisition bits is 10 bits, and the original data collected by AD is 568.
Function: get iio channel description parameter: dev: device description pointer using this channel consumer_channel: IIO channel description pointer void iio_channel_release (struct iio_channel * chan) used by the device Function: release the channel parameters obtained by the iio_channel_get function: chan: the channel description pointer int iio_read_channel_raw (struct iio_channel * chan, int * val) to be released; function: read the raw data parameters collected by the chan channel AD: chan: the acquisition channel pointer to be read val: the pointer to store the read results
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.