![]() |
RT-Thread RTOS
An open source embedded real-time operating system
|
Device-tree **io-channels** binding and DM integration: IIO device model (DM).
drivers/iio.h offers a small channel discovery API: rt_iio_channel_get_by_index and rt_iio_channel_get_by_name resolve a channel handle and index from a rt_device. IIO is a light abstraction for ADC, DAC, temperature, accelerometer, and similar sensors; data format and calibration are driver-specific.
io-channels / io-channel-names or private matching.get helpers for an opaque channel pointer and logical index, then use the provider’s read/write path (usually wrapped inside the driver).Providers are commonly platform devices: probe brings up clocks, resets, and calibration, then registers the device. Phandle-based dependencies mirror Linux IIO bindings and ease porting.
drivers/iio.h only exposes **rt_iio_channel_get_by_index** and **rt_iio_channel_get_by_name** returning an opaque void * channel cookie plus **out_channel** index. There is no standard put in this header—lifetime is owned by the provider rt_device; do not use the handle after the provider unregisters.
| Use IIO discovery when… | Skip it when… |
|---|---|
Porting Linux io-channels consumers and you want matching property names. | You already have a private ioctl between two in-tree drivers. |
get_by_*** after provider probe has finished (phandles resolved).out_channel** index into your provider’s read/write routine (implemented alongside the ADC driver).rt_device** only—no separate channel free unless your provider documents one.struct iio_channel like Linux—do not cast blindly across drivers.NULL**—always check before dereference.components/drivers/include/drivers/iio.hdocumentation/6.components/device-driver/platform/platform.md