{"id":310449,"date":"2020-09-24T15:01:16","date_gmt":"2020-09-24T15:01:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=310449"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=310449","title":{"rendered":"\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u043e Linux IIO"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/520488\/\">\n<p>IIO (\u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u0432\u043e\u0434 \/ \u0432\u044b\u0432\u043e\u0434) \u2014 \u044d\u0442\u043e \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u044f\u0434\u0440\u0430 Linux \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u043e-\u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 (\u0410\u0426\u041f), \u0446\u0438\u0444\u0440\u043e-\u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 (\u0426\u0410\u041f) \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432. \u041c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u044b\u0441\u043e\u043a\u043e\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u043d\u044b\u0445 \u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u0445. \u041e\u043d\u0430, \u0442\u0430\u043a\u0436\u0435, \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 API \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ks\/xf\/ir\/ksxfirvgxfdfeueuz73cjyotbt4.jpeg\"><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430 Industrial I\/O Linux \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443 \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 (\u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438) \u0441 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430\u043c\u0438, \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u043c\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432. \u041e\u043d \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u0434\u0430\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 sysfs \u0438 devfs.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432 \u0432 IIO:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0410\u0426\u041f \/ \u0426\u0410\u041f<\/li>\n<li>\u0430\u043a\u0441\u0435\u043b\u0435\u0440\u043e\u043c\u0435\u0442\u0440\u044b<\/li>\n<li>\u043c\u0430\u0433\u043d\u0435\u0442\u043e\u043c\u0435\u0442\u0440\u044b<\/li>\n<li>\u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u044b<\/li>\n<li>\u0434\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/li>\n<li>\u0432\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u044c<\/li>\n<li>\u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430<\/li>\n<li>\u0434\u0430\u043b\u044c\u043d\u043e\u043c\u0435\u0442\u0440\u044b<\/li>\n<\/ul>\n<p>  <\/p>\n<p>IIO \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041d\u0438\u0437\u043a\u043e\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u043d\u0430\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u043c\u0435\u043d\u044f\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 (\u043f\u0440\u0438\u043c\u0435\u0440: \u0437\u0430\u043f\u0438\u0441\u044c \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0432 \u0444\u0430\u0439\u043b)<\/li>\n<li>\u0412\u044b\u0441\u043e\u043a\u043e-\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u043d\u043e\u0439 \u0441\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0410\u0426\u041f, DFSDM \u0438\u043b\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0443\u0434\u0438\u043e, \u0438\u0437\u043c\u0435\u0440\u0438\u0442\u0435\u043b\u044c \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438)<\/li>\n<li>\u0421\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0443\u0440\u043d\u043e\u0433\u043e \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430 TIM \u0438\u043b\u0438 LPTIM<\/li>\n<li>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0447\u0435\u0440\u0435\u0437 \u0426\u0410\u041f<\/li>\n<li>\u0412\u043d\u0435\u0448\u043d\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 SPI \u0438\u043b\u0438 I2C<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c \u043f\u0440\u043e IIO \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u043d\u043e \u043e\u043d\u0430 \u0435\u0441\u0442\u044c, \u0430 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0431\u0437\u043e\u0440\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u044f \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 &#8230;<\/p>\n<p>  <\/p>\n<h1 id=\"sosredotochimsya-na-momentah-pochemu-iio-eto-horosho\">\u0421\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445 \u043f\u043e\u0447\u0435\u043c\u0443 IIO \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e<\/h1>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438\/\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c\u0438 \u0442\u0438\u043f\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># https:\/\/www.kernel.org\/doc\/Documentation\/i2c\/dev-interface open(&quot;\/dev\/i2c-1&quot;, O_RDWR); # https:\/\/www.kernel.org\/doc\/Documentation\/spi\/spidev.rst open(&quot;\/dev\/spidev2.0&quot;, O_RDWR);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043c\u043d\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432, \u044f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044e \u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0447\u0438\u0442\u0430\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u043d\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439<\/li>\n<li>\u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u041d\u0443 \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u0437\u0430\u0447\u0435\u043c \u0432\u0441\u0451 \u044d\u0442\u043e \u2014 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 ?<\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u043f\u044f\u0442\u044c \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0441 &quot;\u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e&quot; \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 (\u043a\u0430\u043a \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431 \u043a\u0430\u043b\u0438\u0431\u0440\u043e\u0432\u043a\u0438 \u0438\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c).<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e IIO \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c poll \u043f\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044e \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p>\u0421\u0430\u043c IIO \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d \u043d\u0430 \u0434\u0432\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u2014 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043a\u0430\u043d\u0430\u043b\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0434\u0435\u043b\u0438\u043c \u0434\u0432\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u044f\u0434\u0440\u0435.<\/p>\n<p>  <\/p>\n<h1 id=\"prostoe-ispolzovanie-iio\">\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 IIO<\/h1>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 sysfs (\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0434\u043b\u044f \u0430\u043a\u0441\u0435\u043b\u0435\u0440\u043e\u043c\u0435\u0442\u0440\u0430):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># cat \/sys\/bus\/iio\/devices\/iio\\:device0\/in_accel_x_raw -493<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438 &quot;\u0441\u044b\u0440\u044b\u0435&quot; \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f, \u0438\u0445 \u0435\u0449\u0435 \u043d\u0430\u0434\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u0432\u0438\u0434\u0443.<\/p>\n<p>  <\/p>\n<p>\u041b\u0438\u0431\u043e \u0447\u0435\u0440\u0435\u0437 read():<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># \u0412\u043a\u043b\u044e\u0447\u0438\u043c \u0437\u0430\u0445\u0432\u0430\u0442 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430 (cd \/sys\/bus\/iio\/devices\/iio:device0\/scan_elements\/ &amp;&amp; for file in *_en; do echo 1 &gt; $file; done)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0432\u0435\u0441\u0442\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043a \u0432\u0438\u0434\u0443 :<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">int fd = open(&quot;\/dev\/iio:device0&quot;); read(fd, buffer, scan_size); # \u0433\u0434\u0435 scan_size \u044d\u0442\u043e \u0441\u0443\u043c\u043c\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0441\u0435\u0445 \u0437\u0430\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 1 \u0432 \/sys\/bus\/iio\/devices\/iio:device0\/scan_elements\/*_en<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043a\u0440\u0430\u0442\u0435\u043d scan_size, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c &quot;\u0441\u044b\u0440\u044b\u0435&quot; \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u0432\u0438\u0434\u0443, \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>  <\/p>\n<h2 id=\"vnutrennee-ustroystvo\">\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e<\/h2>\n<p>  <\/p>\n<h3 id=\"kanaly\">\u041a\u0430\u043d\u0430\u043b\u044b<\/h3>\n<p>  <\/p>\n<p>\u041b\u044e\u0431\u043e\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 IIO \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f\u0445 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u0430\u043d\u0430\u043b\u043e\u0432 <strong>struct iio_chan_spec<\/strong>:<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/elixir.bootlin.com\/linux\/v5.9-rc1\/source\/include\/uapi\/linux\/iio\/types.h#L14\" rel=\"nofollow\">IIO types<\/a><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0434\u0430\u0442\u0447\u0438\u043a\u0430 BME280<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/* https:\/\/elixir.bootlin.com\/linux\/v5.9-rc1\/source\/drivers\/iio\/pressure\/bmp280-core.c#L132*\/ static const struct iio_chan_spec bmp280_channels[] = {     {         .type = IIO_PRESSURE,         .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |                       BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),     },     {         .type = IIO_TEMP,         .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |                       BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),     },     {         .type = IIO_HUMIDITYRELATIVE,         .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |                       BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),     }, };<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0438\u0434\u0435\u0442\u044c, \u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b, \u0432\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u0438 \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u2014 \u0442\u0440\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u0430\u043d\u0430\u043b\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0443 \u0441 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0432 \u044f\u0434\u0440\u0435 Linux \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0438 \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445.<\/p>\n<p>  <\/p>\n<h3 id=\"kolcevoy-bufer\">\u041a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u0439 \u0431\u0443\u0444\u0435\u0440<\/h3>\n<p>  <\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u0438\u043d\u0442\u0440\u0438\u0433\u0443\u044e\u0449\u0435\u0435 \u043a\u0430\u043a \u0437\u0432\u0443\u0447\u0438\u0442, \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 <a href=\"https:\/\/elixir.bootlin.com\/linux\/latest\/source\/include\/linux\/kfifo.h\" rel=\"nofollow\">kfifo<\/a> \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0451 \u0447\u0442\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043e \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u043c\u0443 \u0431\u0443\u0444\u0444\u0435\u0440\u0443.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0442\u0435\u0441\u043d\u044f\u044e\u0442 \u0441\u0442\u0430\u0440\u044b\u0435, \u0447\u0442\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c\u0443 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044e \u0432 \u043b\u044e\u0431\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0442\u043e, \u0447\u0442\u043e \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0442\u0435\u0440\u044f\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0440\u044b\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<h3 id=\"metka-vremeni\">\u041c\u0435\u0442\u043a\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. \u041d\u0430\u043c \u0432\u0430\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u043a\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u0445\u0443\u0436\u0435 \u0447\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043c\u0435\u0442\u043a\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0430, \u043d\u043e \u043b\u0443\u0447\u0448\u0435\u0435 \u043d\u0430 \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u0435\u0437 \u043d\u0435\u0451.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f CLOCK_REALTIME.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/www.kernel.org\/doc\/html\/latest\/driver-api\/iio\/triggered-buffers.html\" rel=\"nofollow\">IIO Triggered Buffers<\/a><\/p>\n<p>  <\/p>\n<h2 id=\"triggery\">\u0422\u0440\u0438\u0433\u0433\u0435\u0440\u044b<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f &quot;\u0432\u043d\u0435\u0448\u043d\u0435\u0435&quot; \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0445\u0432\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u043d\u0430\u0432\u0435\u0440\u0445 \u0432 user space.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0442\u0440\u0438\u0433\u0433\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0442\u0440\u0438\u0433\u0433\u0435\u0440 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># cat \/sys\/bus\/iio\/devices\/iio\\:device0\/trigger\/current_trigger icm20608-dev0 # echo &gt; \/sys\/bus\/iio\/devices\/iio\\:device0\/trigger\/current_trigger # cat \/sys\/bus\/iio\/devices\/iio\\:device0\/trigger\/current_trigger # echo &quot;icm20608-dev0&quot; &gt; \/sys\/bus\/iio\/devices\/iio\\:device0\/trigger\/current_trigger<\/code><\/pre>\n<p>  <\/p>\n<p><a href=\"https:\/\/www.kernel.org\/doc\/html\/latest\/driver-api\/iio\/triggers.html\" rel=\"nofollow\">Official Trigger Documentation<\/a><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/wiki.analog.com\/software\/linux\/docs\/iio\/iio-trig-sysfs\" rel=\"nofollow\">IIO sysfs trigger<\/a><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/www.kernel.org\/doc\/Documentation\/iio\/iio_configfs.txt\" rel=\"nofollow\">Industrial IIO configfs support<br \/>  <\/a><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/programmer.group\/5cbf67db154ab.html\" rel=\"nofollow\">Triggered buffer support trigger buffer support for IIO subsystem of Linux device driver<br \/>  <\/a><\/p>\n<p>  <\/p>\n<h3 id=\"device-owned-triggers\">Device owned triggers<\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u0432 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u043e\u043d\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0432 device tree:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">icm20608: imu@0 {     ...     interrupt-parent = &lt;&amp;gpio5&gt;;     interrupts = &lt;11 IRQ_TYPE_EDGE_RISING&gt;;     ... };<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0442\u0440\u0438\u0433\u0433\u0435\u0440 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">cat \/sys\/bus\/iio\/devices\/trigger0\/name icm20608-dev0<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0440\u0438\u0433\u0433\u0435\u0440 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0445\u043e\u0434 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043d\u043e\u0436\u043a\u0443 gpio, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0430\u043a, \u0442\u0430\u043a\u0438\u043c \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043b\u044e\u0431\u043e\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c.<\/p>\n<p>  <\/p>\n<h3 id=\"interrupt-triggers-also-known-as-gpio-trigger\">Interrupt triggers (also known as gpio trigger)<\/h3>\n<p>  <\/p>\n<p><a href=\"https:\/\/elixir.bootlin.com\/linux\/v5.9-rc1\/source\/drivers\/iio\/trigger\/iio-trig-interrupt.c\" rel=\"nofollow\">iio-trig-interrupt<\/a><\/p>\n<p>  <\/p>\n<p>\u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0447\u0442\u043e \u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0442\u0438\u043f, \u043d\u043e \u043e\u043d \u043d\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043d\u0438 \u043a \u043a\u0430\u043a\u043e\u043c\u0443 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043d\u043e\u043f\u043a\u0430 \u043f\u043e\u0434\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u0430\u044f \u043a gpio, \u0442\u0430\u043a \u0438 \u043b\u044e\u0431\u043e\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d \u0432 \u044f\u0434\u0440\u0435 \u0432 \u043f\u043e\u043b\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u0432\u0432\u0438\u0434\u0443 \u0441\u043e\u043c\u043d\u0435\u043d\u0438\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e maintainer&#8217;a IIO Jonathan Cameron, \u0445\u043e\u0442\u044f \u043e\u043d \u0442\u0430\u043a \u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0430\u0432\u0442\u043e\u0440\u043e\u043c.<\/p>\n<p>  <\/p>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u044f\u0434\u0440\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0434\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442 <a href=\"https:\/\/programmer.group\/5cbf67db154ab.html\" rel=\"nofollow\">Triggered buffer support trigger buffer support for IIO subsystem of Linux device driver<br \/>  <\/a>.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u043a\u043e\u043c\u0443 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0438\u0435\u0439 \u043f\u0430\u0442\u0447\u0435\u0439:<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/lore.kernel.org\/patchwork\/patch\/764358\/\" rel=\"nofollow\">[v3,1\/6] dt-bindings: iio: introduce trigger providers, consumers<\/a><\/p>\n<p>  <\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 device tree \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">trig0: interrupt-trigger0 {     #io-trigger-cells = &lt;0&gt;;     compatible = &quot;interrupt-trigger&quot;;     interrupts = &lt;11 0&gt;;     interrupt-parent = &lt;&amp;gpioa&gt;; };<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sysfs-trigger\">sysfs trigger<\/h3>\n<p>  <\/p>\n<p><a href=\"https:\/\/elixir.bootlin.com\/linux\/v5.9-rc1\/source\/drivers\/iio\/trigger\/iio-trig-sysfs.c\" rel=\"nofollow\">iio-trig-sysfs<\/a><\/p>\n<p>  <\/p>\n<p>\u0422\u0443\u0442 \u0432\u0441\u0451 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435\u043c \u0432 sysfs \u2014 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0440\u0438\u0433\u0433\u0435\u0440, \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># echo 10 &gt; \/sys\/bus\/iio\/devices\/iio_sysfs_trigger\/add_trigger<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0438\u0441\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u043c\u0435\u043d\u0438 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430 \u0432 \u0432\u0438\u0434\u0435 &quot;sysfstrig%d&quot;, \u0435\u0433\u043e \u0436\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443.<\/p>\n<p>  <\/p>\n<h3 id=\"high-resolution-timer-trigger\">High resolution timer trigger<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0442\u0430\u0439\u043c\u0435\u0440 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0432 1 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># mkdir \/sys\/kernel\/config\/iio\/triggers\/hrtimer\/my_trigger_name # cat \/sys\/bus\/iio\/devices\/trigger4\/name my_trigger_name # cat \/sys\/bus\/iio\/devices\/trigger4\/sampling_frequency 100<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u043e\u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0431\u0435\u0437 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u2014 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c &quot;\u0437\u0430\u0431\u044b\u043b\u0438&quot; \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 SoC.<\/p>\n<p>  <\/p>\n<h3 id=\"loop-trigger\">loop trigger<\/h3>\n<p>  <\/p>\n<p><a href=\"https:\/\/elixir.bootlin.com\/linux\/v5.9-rc1\/source\/drivers\/iio\/trigger\/iio-trig-loop.c\" rel=\"nofollow\">iio-trig-loop<\/a><\/p>\n<p>  <\/p>\n<p>\u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0440\u0438\u0433\u0433\u0435\u0440 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <a href=\"https:\/\/www.spinics.net\/lists\/linux-iio\/msg23004.html\" rel=\"nofollow\">PATCH v1 5\/5 iio:pressure:ms5611: continuous sampling support<br \/>  <\/a>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043c\u044b\u0441\u043b \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u043f\u0440\u043e\u0441\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043a \u043a\u043e\u043c\u043c\u0438\u0442\u0443:<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/torvalds\/linux\/commit\/bc2e1126eccb47517b9d1c685020c38600f99a3d#diff-0d329fecbdfa98eba57fd93cd6350578\" rel=\"nofollow\">iio:trigger: Experimental kthread tight loop trigger<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u043d\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 DT, \u0442\u0430\u043a \u0447\u0442\u043e \u043b\u0438\u0431\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0442\u0447, \u043b\u0438\u0431\u043e \u0447\u0435\u0440\u0435\u0437 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>  <\/p>\n<h2 id=\"device-tree\">Device tree<\/h2>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0445\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u043e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0442\u044c label \u0434\u043b\u044f \u0443\u0437\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043c\u043d\u043e\u0433\u043e \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0443\u0437\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 of_node \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e iio:device \u2014 \/sys\/bus\/iio\/devices\/iio\\:device0\/of_node\/.<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a\u043e\u0439 \u043e\u0431\u0449\u0435\u0439 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u2014 \u0432\u0441\u0451 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 <a href=\"https:\/\/elixir.bootlin.com\/linux\/v5.9-rc1\/source\/Documentation\/devicetree\/bindings\/iio\" rel=\"nofollow\">https:\/\/elixir.bootlin.com\/linux\/v5.9-rc1\/source\/Documentation\/devicetree\/bindings\/iio<\/a><\/p>\n<p>  <\/p>\n<h2 id=\"tipy-kanalov-izmereniy\">\u0422\u0438\u043f\u044b \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439<\/h2>\n<p>  <\/p>\n<p>\u041c\u043d\u043e\u0433\u0438\u0435 \u0434\u0430\u0442\u0447\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u043d\u044c\u0448\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043d\u044b \u043d\u0430 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 IIO, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435 \u0442\u0443\u0442 <a href=\"https:\/\/elixir.bootlin.com\/linux\/v5.9-rc1\/source\/include\/uapi\/linux\/iio\/types.h#L14\" rel=\"nofollow\">enum iio_chan_type<\/a> \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u0447\u0442\u0438 \u043b\u044e\u0431\u043e\u0439 \u0442\u0438\u043f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439. \u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442 <a href=\"https:\/\/elixir.bootlin.com\/linux\/v5.9-rc1\/source\/tools\/iio\/iio_event_monitor.c#L28\" rel=\"nofollow\">iio_event_monitor<\/a>.<\/p>\n<p>  <\/p>\n<h2 id=\"format-dannyh\">\u0424\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  <\/p>\n<p>IIO \u0443\u043c\u0435\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043d\u0430\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 <a href=\"https:\/\/01.org\/linuxgraphics\/gfx-docs\/drm\/driver-api\/iio\/buffers.html#iio-buffer-sysfs-interface\" rel=\"nofollow\">iio-buffer-sysfs-interface<\/a>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[be|le]:[s|u]bits\/storagebitsXrepeat[&gt;&gt;shift]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0416\u0438\u0432\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f icm20608:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># cat \/sys\/bus\/iio\/devices\/iio\\:device0\/scan_elements\/*_type be:s16\/16&gt;&gt;0 be:s16\/16&gt;&gt;0 be:s16\/16&gt;&gt;0 be:s16\/16&gt;&gt;0 be:s16\/16&gt;&gt;0 be:s16\/16&gt;&gt;0 le:s64\/64&gt;&gt;0<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0443\u0442 \u0431\u043e\u043b\u0435\u0435 \u043b\u0438 \u043c\u0435\u043d\u0435\u0435 \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u0435\u0440\u0432\u044b\u043c \u0438\u0434\u0451\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0430\u0439\u0442 le \u0438\u043b\u0438 be \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e \u0442\u043e\u043c \u0447\u0442\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043d\u0430\u0448\u0435\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439 \u0438\u043b\u0438 c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u043c \u043d\u0430\u043c\u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c \u0431\u0430\u0439\u0442<\/li>\n<li>\u0437\u0430\u0442\u0435\u043c \u0438\u0434\u0435\u0442 \u0442\u0438\u043f \u2014 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0438\u043b\u0438 \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435, s \u0438\u043b\u0438 u \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e<\/li>\n<li>\u0437\u0430\u0442\u0435\u043c \u0438\u0434\u0435\u0442 \u0434\u043b\u0438\u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0431\u0438\u0442\u0430\u0445 \u0438 \u0447\u0435\u0440\u0435\u0437 \/ \u0434\u043b\u0438\u043d\u0430 \u043f\u043e\u043b\u044f \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u0432 \u0431\u0438\u0442\u0430\u0445, \u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0431\u0438\u0442\u043e\u0432 \u0432 \u0431\u0430\u0439\u0442\u0435<\/li>\n<li>\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0438\u0434\u0435\u0442 \u0441\u0434\u0432\u0438\u0433<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u0431\u044b \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u043e \u0434\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0438\u0442\u0430 \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435 \u043f\u043e\u043b\u0435 \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0431\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">be:u4\/8&gt;&gt;0 be:u4\/8&gt;&gt;4<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432 \u0436\u0438\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043b\u0435 repeat \u2014 \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 1 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<h2 id=\"scaling-and-offset\">Scaling and offset<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u044b\u0440\u043e\u043c \u0432\u0438\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/sys\/bus\/iio\/devices\/iio:deviceX\/in_*_raw \/sys\/bus\/iio\/devices\/iio:deviceX\/in_*_offset \/sys\/bus\/iio\/devices\/iio:deviceX\/in_*_scale<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434 (raw + offset)*scale, \u0434\u043b\u044f \u043a\u0430\u043a\u043e\u0433\u043e \u0442\u043e \u0438\u0437 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432 offset&#8217;a \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0431\u044b\u0442\u044c.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/wiki.st.com\/stm32mpu\/wiki\/How_to_use_the_IIO_user_space_interface#How_to_do_a_simple_ADC_conversion_using_the_sysfs_interface\" rel=\"nofollow\">How to do a simple ADC conversion using the sysfs interface<\/a><\/p>\n<p>  <\/p>\n<h2 id=\"iio_simple_dummy\">iio_simple_dummy<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f <strong>iio_simple_dummy<\/strong> \u2014 \u043c\u043e\u0434\u0443\u043b\u044c \u044f\u0434\u0440\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e IIO \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043a\u0430\u043d\u0430\u043b\u043e\u0432:<\/p>\n<p>  <\/p>\n<ul>\n<li>IIO_VOLTAGE<\/li>\n<li>IIO_ACCEL<\/li>\n<li>IIO_ACTIVITY<\/li>\n<\/ul>\n<p>  <\/p>\n<p><a href=\"https:\/\/flusp.ime.usp.br\/iio\/iio-dummy-anatomy\" rel=\"nofollow\">The iio_simple_dummy Anatomy<\/a><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/elixir.bootlin.com\/linux\/latest\/source\/drivers\/iio\/dummy\/iio_simple_dummy.c\" rel=\"nofollow\">iio_simple_dummy<\/a><\/p>\n<p>  <\/p>\n<h1 id=\"libiio\">libiio<\/h1>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0432\u0430\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u2014 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043a \u0432\u0430\u043c \u0438\u0434\u0435\u0442 <a href=\"https:\/\/github.com\/analogdevicesinc\/libiio\" rel=\"nofollow\">libiio<\/a> \u043e\u0442 Analog Devices.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u043d\u0430 \u0431\u0435\u0440\u0435\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0440\u0443\u0442\u0438\u043d\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u043a\u0430\u043d\u0430\u043b\u0430 \u0438\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\/\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043d\u0430\u043b\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0423 \u043d\u0435\u0451 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u0432\u0438\u0434\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\/\u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u0441\u043b\u0443\u0436\u0438\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u043a\u043b\u0438\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 Linux, Windows \u0438\u043b\u0438 Mac \u043c\u0430\u0448\u0438\u043d\u0435, \u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 USB, Ethernet \u0438\u043b\u0438 Serial.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u043c \u0443\u0437\u043b\u043e\u043c iiod:<\/p>\n<p>  <\/p>\n<p>On remote :<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">host # iiod<\/code><\/pre>\n<p>  <\/p>\n<p>On local :<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">local $ iio_info -n [host_address] local $ iio_attr -u ip:[host_address] -d local $ iio_readdev -u ip:[host_address] -b 256 -s 0 icm20608<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 <a href=\"https:\/\/wiki.analog.com\/resources\/tools-software\/linux-software\/libiio\/clients\/matlab_simulink\" rel=\"nofollow\">Matlab<\/a>, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 <a href=\"https:\/\/wiki.analog.com\/resources\/tools-software\/linux-software\/iio_oscilloscope\" rel=\"nofollow\">\u043e\u0441\u0446\u0438\u043b\u043b\u043e\u0433\u0440\u0430\u0444\u0430<\/a>.<\/p>\n<p>  <\/p>\n<h1 id=\"primer-programmy-dlya-chteniya-akselerometra\">\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0430\u043a\u0441\u0435\u043b\u0435\u0440\u043e\u043c\u0435\u0442\u0440\u0430<\/h1>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u043a\u0430\u043a \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c libiio \u0442\u0430\u043a \u0438 \u0431\u0435\u0437.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/maquefel\/icm20608-iio\" rel=\"nofollow\">https:\/\/github.com\/maquefel\/icm20608-iio<\/a><\/p>\n<p>  <\/p>\n<h2 id=\"rabota-bez-ispolzovaniya-libiio\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f libiio<\/h2>\n<p>  <\/p>\n<p>\u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043a\u0430\u0441\u0430\u0442\u044c\u0441\u044f \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 sysfs \u0442\u0430\u043a, \u0447\u0442\u043e \u0432 \u043e\u0431\u0449\u0438\u0445 \u0447\u0435\u0440\u0442\u0430\u0445 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0438\u0441\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043d\u0430 \/sys\/bus\/iio\/iio:deviceN\/name, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \/sys\/bus\/iio\/iio:deviceN \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \/dev\/iio:deviceN<\/li>\n<li>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0432 \/sys\/bus\/iio\/iio:deviceN\/scan_elements\/, \u043d\u0430\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u0435\u0445 \u043a\u0430\u043d\u0430\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0437\u0430\u043a\u0430\u0437\u0430\u043b\u0438 \u0432 *_en<\/li>\n<li>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0443\u0444\u0435\u0440\u0430 \/sys\/bus\/iio\/iio:deviceN\/enable<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0435\u0441\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>  <\/p>\n<h3 id=\"vyravnivanie\">\u0412\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>E\u0433\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0430\u043c\u0438\u043c \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 libiio.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/elixir.bootlin.com\/linux\/v5.9-rc1\/source\/drivers\/iio\/industrialio-buffer.c#L574\" rel=\"nofollow\">https:\/\/elixir.bootlin.com\/linux\/v5.9-rc1\/source\/drivers\/iio\/industrialio-buffer.c#L574<\/a><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">    # bytes - \u0432\u0441\u0435\u0433\u043e \u0434\u043b\u0438\u043d\u0430 \u0432\u0441\u0435\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445     # length - \u0434\u043b\u0438\u043d\u0430 \u043a\u0430\u043d\u0430\u043b\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445     # offset - \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 \u0434\u043b\u044f \u043a\u0430\u043d\u0430\u043b\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445     if (bytes % length == 0)         offset = bytes;     else         offset = bytes - bytes % length + length;      bytes = offset + length;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0435\u0437 libiio, \u0447\u0442\u043e \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0430\u0439\u0442 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c<\/li>\n<li>\u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044c \u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/li>\n<li>\u043e\u0431\u0440\u0435\u0437\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0435<\/li>\n<li>\u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435, \u0442\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u043a\u0430 (Sign extension)<\/li>\n<li>\u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c offset, \u0442\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0448\u043a\u0430\u043b\u044b<\/li>\n<li>\u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c scale, \u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0448\u043a\u0430\u043b\u0443<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"plaintext\">    input = is_be ? betoh(input) : letoh(input);     input &gt;&gt;= shift;     input &amp;= BIT_MASK(bits);     value = is_signed ? (float)sext(input, bits) : (float)input;     if(with_offset) value += offset;     if(with_scale) value *= scale;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u043a\u0430 (Sign extension) \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043d\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e \u0442\u0435\u043c\u0435 \u043c\u043e\u0436\u043d\u043e \u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0442\u0443\u0442 <a href=\"https:\/\/graphics.stanford.edu\/~seander\/bithacks.html#FixedSignExtend\" rel=\"nofollow\">SignExtend<\/a>.<\/p>\n<p>  <\/p>\n<h2 id=\"rabota-s-ispolzovaniem-libiio\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c libiio<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0442\u0443\u0442 <a href=\"https:\/\/github.com\/maquefel\/icm20608-iio\/blob\/master\/src\/libiio-loop.c\" rel=\"nofollow\">libiio-loop.c<br \/>  <\/a>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434 \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438\u0437 uri # uri = &quot;ip:127.0.0.1&quot; # uri = &quot;local:&quot; # uri = &quot;usb:&quot; ctx = iio_create_context_from_uri(uri);  # \u041d\u0430\u0439\u0442\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e # \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c device = icm20608 dev = iio_context_find_device(ctx, device);  # \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 nb_channels = iio_device_get_channels_count(dev);  # \u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u043d\u0430\u043b for(int i = 0; i &lt; nb_channels; i++)     iio_channel_enable(iio_device_get_channel(dev, i));  # buffer_size = SAMPLES_PER_READ, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 (\u043f\u043e \u0432\u0441\u0435\u043c \u043a\u0430\u043d\u0430\u043b\u0430\u043c) buffer = iio_device_create_buffer(dev, buffer_size, false);  # \u0417\u0430\u0434\u0430\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0436\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u044b iio_buffer_set_blocking_mode(buffer, true);  while(true) {     # \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0431\u0443\u0444\u0435\u0440     iio_buffer_refill(buffer);      # \u0421\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e - \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f libiio     # \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 &quot;\u043a\u0430\u043d\u043e\u043d\u0438\u0447\u043d\u044b\u0439&quot; \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u043d\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f     # \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430     # ssize_t print_sample(const struct iio_channel *chn, void *buffer, size_t bytes, __notused void *d)     # const struct iio_channel *chn - \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043a\u0430\u043d\u0430\u043b \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c     # void *buffer - \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0435\u0440 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430     # size_t bytes - \u0434\u043b\u0438\u043d\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u0439\u0442\u0430\u0445     # __notused void *d - \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u043c iio_buffer_foreach_sample     iio_buffer_foreach_sample(buffer, print_sample, NULL); }  # \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u0431\u0443\u0444\u0435\u0440 iio_buffer_destroy(buffer);  # \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 iio_context_destroy(ctx); <\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"para-slov-ob-alternativnom-mehanizme-dlya-chteniya-dannyh\">\u041f\u0430\u0440\u0430 \u0441\u043b\u043e\u0432 \u043e\u0431 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0435 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h1>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0431\u044b\u043b \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0441\u0440\u0430\u0437\u0443 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0431\u0443\u0444\u0435\u0440, \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c Zero-Copy.<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0451 \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b\u0441\u043e\u043a\u043e\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (\u0442\u0435\u0437\u0438\u0441\u044b \u0438\u0437 \u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u0438):<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0435 \u2014 \u0411\u043b\u043e\u043a\u0438<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0413\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0432 \u0431\u043b\u043e\u043a<\/li>\n<li>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u043b\u043e\u043a<\/li>\n<li>\u0423\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/li>\n<li>\u0420\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u043c<\/li>\n<li>\u041f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0438 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u043c\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u0430\u043c\u0438<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u0442\u043e\u0440\u043e\u0435 \u2014 DMA + mmap()<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c DMA \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043a \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0431\u043b\u043e\u043a\u0443 \u043f\u0430\u043c\u044f\u0442\u0438<\/li>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c mmap() \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430<\/li>\n<li>\u0418\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li>&quot;\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0435&quot; \u0434\u0435\u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435<\/li>\n<\/ul>\n<p>  <\/p>\n<p><a href=\"https:\/\/elinux.org\/images\/8\/8d\/Clausen--high-speed_data_acquisition_with_the_linux_iio_framework.pdf\" rel=\"nofollow\">High-speed Data Acquisition<br \/>  using the<br \/>  Linux Industrial IO framework<\/a><\/p>\n<p>  <\/p>\n<p>\u041f\u043e \u043c\u043d\u0435 \u0442\u0430\u043a \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f SDR.<\/p>\n<p>  <\/p>\n<p>\u0418\u0437 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0438 \u0441 \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u044f\u0434\u0440\u043e, \u0445\u043e\u0442\u044f \u0438 \u043d\u0435 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u0438 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u043a\u043e\u0433\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u0410\u0432\u0442\u043e\u0440 \u043b\u044e\u0431\u0435\u0437\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u044f\u0434\u0440\u0430 <a href=\"https:\/\/github.com\/larsclausen\/linux\/tree\/iio-high-speed-4.19\" rel=\"nofollow\">4.19<\/a> \u0438 <a href=\"https:\/\/github.com\/larsclausen\/linux\/tree\/iio-high-speed-5.4\" rel=\"nofollow\">5.4<\/a>.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/patchwork.kernel.org\/project\/linux-iio\/list\/?series=284793\" rel=\"nofollow\">\u0421 \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u0435\u0439 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u043c\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0442\u0443\u0442<br \/>  <\/a><\/p>\n<p>  <\/p>\n<h2 id=\"rekomenduemye-materialy\">\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b<\/h2>\n<p>  <\/p>\n<p><a href=\"https:\/\/bootlin.com\/pub\/conferences\/2012\/fosdem\/iio-a-new-subsystem\/iio-a-new-subsystem.pdf\" rel=\"nofollow\">https:\/\/bootlin.com\/pub\/conferences\/2012\/fosdem\/iio-a-new-subsystem\/iio-a-new-subsystem.pdf<\/a><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/archive.fosdem.org\/2012\/schedule\/event\/693\/127_iio-a-new-subsystem.pdf\" rel=\"nofollow\">https:\/\/archive.fosdem.org\/2012\/schedule\/event\/693\/127_iio-a-new-subsystem.pdf<\/a><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/events19.linuxfoundation.org\/wp-content\/uploads\/2017\/12\/Bandan-Das_Drone_SITL_bringup_with_the_IIO_framework.pdf\" rel=\"nofollow\">https:\/\/events19.linuxfoundation.org\/wp-content\/uploads\/2017\/12\/Bandan-Das_Drone_SITL_bringup_with_the_IIO_framework.pdf<\/a><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/programmer.group\/5cbf67db154ab.html\" rel=\"nofollow\">https:\/\/programmer.group\/5cbf67db154ab.html<\/a><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/elinux.org\/images\/b\/ba\/ELC_2017_-_Industrial_IO_and_You-_Nonsense_Hacks%21.pdf\" rel=\"nofollow\">https:\/\/elinux.org\/images\/b\/ba\/ELC_2017_-_Industrial_IO_and_You-_Nonsense_Hacks%21.pdf<\/a><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/elinux.org\/images\/8\/8d\/Clausen--high-speed_data_acquisition_with_the_linux_iio_framework.pdf\" rel=\"nofollow\">https:\/\/elinux.org\/images\/8\/8d\/Clausen&#8212;high-speed_data_acquisition_with_the_linux_iio_framework.pdf<\/a><\/p>\n<p>  <\/p>\n<h2 id=\"dlya-dopolnitelnogo-izucheniya\">\u0414\u043b\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<p><a href=\"https:\/\/linux.ime.usp.br\/~marcelosc\/2019\/09\/Simple-IIO-driver\" rel=\"nofollow\">https:\/\/linux.ime.usp.br\/~marcelosc\/2019\/09\/Simple-IIO-driver<\/a><\/p>\n<p>  <\/p>\n<p>P.S.<\/p>\n<p>  <\/p>\n<p><del>\u041f\u0440\u0438\u043d\u043e\u0448\u0443 \u0438\u0437\u0432\u0438\u043d\u0435\u043d\u0438\u044f \u0437\u0430 \u0441\u0441\u044b\u043b\u043a\u0438, \u044f \u043d\u0435 \u0441\u043c\u043e\u0433 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043d\u0430 markdown \u043a\u0430\u043a \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043e, \u0438 \u043c\u043d\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443.<\/del><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0431\u0435\u043b\u0430 \u0440\u0435\u0448\u0438\u043b\u0430\u0441\u044c \u2014 \u0441\u043f\u0430\u0441\u0438\u0431\u043e <a href=\"https:\/\/habr.com\/ru\/users\/exosphere\/\" class=\"user_link\">Exosphere<\/a> \u2014 \u044f \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u044f\u043b \u0441\u0441\u044b\u043b\u043a\u0438.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/520488\/\"> https:\/\/habr.com\/ru\/post\/520488\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/520488\/\">\n<p>IIO (\u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u0432\u043e\u0434 \/ \u0432\u044b\u0432\u043e\u0434) \u2014 \u044d\u0442\u043e \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u044f\u0434\u0440\u0430 Linux \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u043e-\u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 (\u0410\u0426\u041f), \u0446\u0438\u0444\u0440\u043e-\u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 (\u0426\u0410\u041f) \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432. \u041c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u044b\u0441\u043e\u043a\u043e\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u043d\u044b\u0445 \u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u0445. \u041e\u043d\u0430, \u0442\u0430\u043a\u0436\u0435, \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 API \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ks\/xf\/ir\/ksxfirvgxfdfeueuz73cjyotbt4.jpeg\"><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-310449","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/310449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=310449"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/310449\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=310449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=310449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=310449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}