Linux驱动开发—IIO子系统

一、IIO子系统简介

        IIO全称为Industrial I/O,该驱动框架常常用于ADC/DAC传感器,如陀螺仪、加速度计、电压/电流测量芯片、光照传感器、压力传感器等,他们通过内部ADC将原始的模拟数据转换为数字量,然后通过其他的通信接口,如IIC、SPI等将数据传递给SOC,IIO驱动框架就是服务于这些数据的。

        IIO驱动框架基于设备和通道架构。设备代表传感器芯片本身,位于整个层次结构的顶层;通道代表设备的单个采集线,设备可能有一个或者多个通道(如加速度计具有三个通道的设备,每个轴x,y,z都有一个通道)。

        IIO驱动框架为用户空间提供两种访问的方式,字符设备(/dev/iio:deviceX/)和sys目录项(/sys/bus/iio/iio:deviceX/),sys目录项中一个文件代表一个通道,通过访问该文件则可完成一次采集操作,如下是其流程框图。

二、struct iio_dev结构体

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_timestamp;
	unsigned			scan_index_timestamp;
	struct iio_trigger		*trig;
	bool				trig_readonly;
	struct iio_poll_func		*pollfunc;
	struct iio_poll_func		*pollfunc_event;

	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;
	clockid_t			clock_id;
	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
};

(定义在include/linux/iio/iio.h中)

  • Modes:modes 为设备支持的模式,一般选择sysfs接口

        

    • 13
      点赞
    • 15
      收藏
      觉得还不错? 一键收藏
    • 0
      评论
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值