{"id":33930,"date":"2025-04-28T22:08:23","date_gmt":"2025-04-28T14:08:23","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/33930.html"},"modified":"2025-04-28T22:08:23","modified_gmt":"2025-04-28T14:08:23","slug":"%e6%ad%a3%e7%82%b9%e5%8e%9f%e5%ad%90-stm32mp257-%e5%90%8c%e6%9e%84%e5%a4%9a%e6%a0%b8%e6%9e%b6%e6%9e%84%e4%b8%8b%e7%9a%84-adc-%e7%94%b5%e5%8e%8b%e9%87%87%e9%9b%86%e4%b8%8e%e5%a4%84%e7%90%86%e5%ba%94","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/33930.html","title":{"rendered":"\u6b63\u70b9\u539f\u5b50 STM32MP257 \u540c\u6784\u591a\u6838\u67b6\u6784\u4e0b\u7684 ADC \u7535\u538b\u91c7\u96c6\u4e0e\u5904\u7406\u5e94\u7528\u5f00\u53d1\u5b9e\u6218"},"content":{"rendered":"<p>\u5728\u5d4c\u5165\u5f0f\u7cfb\u7edf\u4e2d&#xff0c;ADC\u6a21\u62df\u7535\u538b\u7684\u8bfb\u53d6\u662f\u5e38\u89c1\u7684\u9700\u6c42\u3002\u5982\u4f55\u9ad8\u6548\u3001\u5e76\u53d1\u3001\u4e14\u53ef\u63a7\u5730\u5b8c\u6210\u6570\u636e\u91c7\u96c6\u4e0e\u5904\u7406&#xff1f;\u672c\u7bc7\u6587\u7ae0\u901a\u8fc7\u53cc\u7ebf\u7a0b\u5206\u522b\u7ed1\u5b9a\u5728 Linux \u7cfb\u7edf\u7684\u4e0d\u540c CPU \u6838\u5fc3\u4e0a&#xff0c;\u91c7\u96c6 \/sys\/bus\/iio \u63a5\u53e3\u7684 ADC \u539f\u59cb\u503c\u4e0e\u7f29\u653e\u7cfb\u6570 scale&#xff0c;\u5e76\u5728\u53e6\u4e00\u4e2a\u6838\u4e0a\u8ba1\u7b97\u771f\u5b9e\u7535\u538b\u503c&#xff0c;\u9002\u7528\u4e8e\u9ad8\u6027\u80fd\u3001\u4f4e\u5ef6\u8fdf\u7684\u5de5\u4e1a\u63a7\u5236\u573a\u666f\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250428140818-680f8bd2eab93.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u6b63\u70b9\u539f\u5b50STM32MP257\u5f00\u53d1\u677f ARM\u5d4c\u5165\u5f0fLinux\u5f02\u6838A35&amp;M33 AI\u5de5\u63a7<\/p>\n<\/p>\n<h4>\u6b63\u70b9\u539f\u5b50 STM32MP257 \u540c\u6784\u591a\u6838\u67b6\u6784\u4e0b\u7684 ADC \u7535\u538b\u91c7\u96c6\u4e0e\u5904\u7406\u5e94\u7528\u5f00\u53d1\u5b9e\u6218<\/h4>\n<ul>\n<li>\u4e00\u3001\u80cc\u666f\u4ecb\u7ecd&#xff1a;\u4e3a\u4ec0\u4e48\u8981\u7528\u591a\u6838\u5e76\u53d1\u8bfb\u53d6ADC&#xff1f;<\/li>\n<li>\u4e8c\u3001\u7cfb\u7edf\u67b6\u6784\u4e0e\u6e90\u7801\u89e3\u6790<\/li>\n<li>\n<ul>\n<li>1\u3001\u6570\u636e\u91c7\u96c6\u7ebf\u7a0b&#xff08;CPU0&#xff09;<\/li>\n<li>2\u3001\u6570\u636e\u5904\u7406\u7ebf\u7a0b&#xff08;CPU1&#xff09;<\/li>\n<li>3\u3001\u4e24\u7ebf\u7a0b\u540c\u6b65\u673a\u5236<\/li>\n<li>4\u3001\u5b8c\u6574\u4ee3\u7801\u53ca\u4f7f\u7528\u65b9\u6cd5<\/li>\n<li>\n<ul>\n<li>1.\u5b8c\u6574\u4ee3\u7801\u5c55\u793a<\/li>\n<li>2.\u4f7f\u7528\u65b9\u6cd5<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001\u5e94\u7528\u573a\u666f\u4e0e\u5b9e\u9645\u90e8\u7f72\u5efa\u8bae<\/li>\n<li>\n<ul>\n<li>1\u3001\u5de5\u4e1a\u81ea\u52a8\u5316\u63a7\u5236<\/li>\n<li>2\u3001\u8fb9\u7f18AI\u4e0e\u4fe1\u53f7\u9884\u5904\u7406<\/li>\n<li>3\u3001\u591a\u4efb\u52a1\u5b9e\u65f6\u7cfb\u7edf\u8c03\u5ea6<\/li>\n<\/ul>\n<\/li>\n<li>\u56db\u3001\u6d4b\u8bd5\u6548\u679c\u4e0e\u8f93\u51fa\u793a\u4f8b<\/li>\n<li>\u4e94\u3001\u603b\u7ed3\u4e0e\u62d3\u5c55\u5efa\u8bae<\/li>\n<\/ul>\n<h2>\u4e00\u3001\u80cc\u666f\u4ecb\u7ecd&#xff1a;\u4e3a\u4ec0\u4e48\u8981\u7528\u591a\u6838\u5e76\u53d1\u8bfb\u53d6ADC&#xff1f;<\/h2>\n<p>\u5728\u5d4c\u5165\u5f0f Linux \u5e73\u53f0&#xff08;\u5982 STM32MP257\u3001i.MX93 \u7b49&#xff09;\u4e2d&#xff0c;\u6211\u4eec\u5e38\u4f7f\u7528\u5de5\u4e1a\u7ea7 ADC \u8fdb\u884c\u4f20\u611f\u5668\u6570\u636e\u91c7\u96c6\u3002\u901a\u8fc7\u5185\u6838 IIO \u5b50\u7cfb\u7edf&#xff0c;\u7528\u6237\u53ef\u4ee5\u5728 \/sys\/bus\/iio\/devices\/iio:deviceX\/ \u76ee\u5f55\u4e0b\u8bfb\u53d6\u539f\u59cb\u7535\u538b\u503c\u548c\u7535\u538b\u7f29\u653e\u56e0\u5b50&#xff08;scale&#xff09;&#xff0c;\u4ece\u800c\u8ba1\u7b97\u51fa\u771f\u5b9e\u7535\u538b\u3002<\/p>\n<p>\u800c\u672c\u9879\u76ee\u7684\u8bbe\u8ba1\u76ee\u6807&#xff0c;\u662f\u5b9e\u73b0 \u91c7\u96c6\u7ebf\u7a0b &#043; \u5904\u7406\u7ebf\u7a0b\u5206\u6838\u8fd0\u884c&#xff0c;\u5145\u5206\u5229\u7528 A\u6838\u591a\u6838\u7cfb\u7edf\u7684\u8d44\u6e90&#xff0c;\u63d0\u9ad8\u6570\u636e\u91c7\u96c6\u5b9e\u65f6\u6027&#xff0c;\u964d\u4f4e\u4e3b\u7ebf\u7a0b\u963b\u585e\u98ce\u9669\u3002<\/p>\n<h2>\u4e8c\u3001\u7cfb\u7edf\u67b6\u6784\u4e0e\u6e90\u7801\u89e3\u6790<\/h2>\n<p>\u8be5\u9879\u76ee\u901a\u8fc7\u4e24\u4e2a\u7ebf\u7a0b\u5206\u522b\u8fd0\u884c\u5728 CPU0 \u548c CPU1&#xff0c;\u7ebf\u7a0b\u95f4\u901a\u8fc7\u4e92\u65a5\u9501\u548c\u6761\u4ef6\u53d8\u91cf\u8fdb\u884c\u6570\u636e\u540c\u6b65&#xff1a;<\/p>\n<h3>1\u3001\u6570\u636e\u91c7\u96c6\u7ebf\u7a0b&#xff08;CPU0&#xff09;<\/h3>\n<ul>\n<li>\u7ed1\u5b9a\u5728 CPU0<\/li>\n<li>\u5b9a\u65f6\u8bfb\u53d6&#xff1a;\n<ul>\n<li>\u539f\u59cb ADC\u503c&#xff1a;\/sys\/bus\/iio\/devices\/iio:device0\/in_voltage15_raw<\/li>\n<li>\u7f29\u653e\u7cfb\u6570&#xff1a;\/sys\/bus\/iio\/devices\/iio:device0\/in_voltage_scale<\/li>\n<\/ul>\n<\/li>\n<li>\u901a\u8fc7\u5171\u4eab\u5185\u5b58\u533a shared_data \u548c shared_scale&#xff0c;\u5c06\u6570\u636e\u4f20\u7ed9\u5904\u7406\u7ebf\u7a0b<\/li>\n<\/ul>\n<p><span class=\"token keyword\">int<\/span> val <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">read_sysfs_int<\/span><span class=\"token punctuation\">(<\/span>SYSFS_ADC_PATH<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">float<\/span> scale <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">read_sysfs_float<\/span><span class=\"token punctuation\">(<\/span>SYSFS_ADC_SCALE<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\nshared_data <span class=\"token operator\">&#061;<\/span> val<span class=\"token punctuation\">;<\/span><br \/>\nshared_scale <span class=\"token operator\">&#061;<\/span> scale<span class=\"token punctuation\">;<\/span><\/p>\n<h3>2\u3001\u6570\u636e\u5904\u7406\u7ebf\u7a0b&#xff08;CPU1&#xff09;<\/h3>\n<ul>\n<li>\u7ed1\u5b9a\u5728 CPU1<\/li>\n<li>\u963b\u585e\u7b49\u5f85\u6570\u636e\u66f4\u65b0\u4fe1\u53f7<\/li>\n<li>\u8ba1\u7b97\u771f\u5b9e\u7535\u538b&#xff1a;voltage &#061; val \u00d7 scale \u00d7 0.001<\/li>\n<li>\u53ef\u62d3\u5c55\u6ee4\u6ce2\u3001\u7279\u5f81\u63d0\u53d6\u3001\u9608\u503c\u62a5\u8b66\u7b49\u7b97\u6cd5\u5904\u7406<\/li>\n<\/ul>\n<p><span class=\"token keyword\">float<\/span> voltage <span class=\"token operator\">&#061;<\/span> val <span class=\"token operator\">*<\/span> scale <span class=\"token operator\">*<\/span> <span class=\"token number\">0.001<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u5904\u7406\u7ebf\u7a0b: \u5904\u7406 %d \u00d7 %.6f x 0.001 &#061; %.2f V\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> val<span class=\"token punctuation\">,<\/span> scale<span class=\"token punctuation\">,<\/span> voltage<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h3>3\u3001\u4e24\u7ebf\u7a0b\u540c\u6b65\u673a\u5236<\/h3>\n<ul>\n<li>\u4f7f\u7528 pthread_mutex_t \u548c pthread_cond_t \u8fdb\u884c\u6570\u636e\u540c\u6b65&#xff0c;\u786e\u4fdd\u7ebf\u7a0b\u5b89\u5168\u3002<\/li>\n<li>data_ready \u6807\u5fd7\u4f4d\u63a7\u5236\u6570\u636e\u66f4\u65b0\u901a\u77e5\u3002<\/li>\n<\/ul>\n<h3>4\u3001\u5b8c\u6574\u4ee3\u7801\u53ca\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<h4>1.\u5b8c\u6574\u4ee3\u7801\u5c55\u793a<\/h4>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">_GNU_SOURCE<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdlib.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;unistd.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;pthread.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;fcntl.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;string.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;errno.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;sched.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">SYSFS_ADC_PATH<\/span> <span class=\"token string\">&#034;\/sys\/bus\/iio\/devices\/iio:device0\/in_voltage15_raw&#034;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">SYSFS_ADC_SCALE<\/span> <span class=\"token string\">&#034;\/sys\/bus\/iio\/devices\/iio:device0\/in_voltage_scale&#034;<\/span><\/span><\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">ACQ_INTERVAL_US<\/span> <span class=\"token expression\"><span class=\"token number\">500000<\/span>  <\/span><span class=\"token comment\">\/\/ 500 ms<\/span><\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">int<\/span> shared_data <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">static<\/span> <span class=\"token keyword\">float<\/span> shared_scale <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0.0f<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">static<\/span> <span class=\"token keyword\">int<\/span> data_ready <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token class-name\">pthread_mutex_t<\/span> data_lock <span class=\"token operator\">&#061;<\/span> PTHREAD_MUTEX_INITIALIZER<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">static<\/span> <span class=\"token class-name\">pthread_cond_t<\/span> data_cond <span class=\"token operator\">&#061;<\/span> PTHREAD_COND_INITIALIZER<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">bind_thread_to_cpu<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">pthread_t<\/span> tid<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> cpu<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token class-name\">cpu_set_t<\/span> cpuset<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">CPU_ZERO<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>cpuset<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">CPU_SET<\/span><span class=\"token punctuation\">(<\/span>cpu<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>cpuset<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">pthread_setaffinity_np<\/span><span class=\"token punctuation\">(<\/span>tid<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>cpuset<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>cpuset<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">!&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">fprintf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">stderr<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u8b66\u544a&#xff1a;\u65e0\u6cd5\u5c06\u7ebf\u7a0b\u7ed1\u5b9a\u5230 CPU%d: %s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n                cpu<span class=\"token punctuation\">,<\/span> <span class=\"token function\">strerror<\/span><span class=\"token punctuation\">(<\/span>errno<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">int<\/span> <span class=\"token function\">read_sysfs_int<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>path<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> fd <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">open<\/span><span class=\"token punctuation\">(<\/span>path<span class=\"token punctuation\">,<\/span> O_RDONLY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>fd <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">char<\/span> buf<span class=\"token punctuation\">[<\/span><span class=\"token number\">32<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token class-name\">ssize_t<\/span> len <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">read<\/span><span class=\"token punctuation\">(<\/span>fd<span class=\"token punctuation\">,<\/span> buf<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>buf<span class=\"token punctuation\">)<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span>fd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>len <span class=\"token operator\">&lt;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    buf<span class=\"token punctuation\">[<\/span>len<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;\\\\0&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token function\">atoi<\/span><span class=\"token punctuation\">(<\/span>buf<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">float<\/span> <span class=\"token function\">read_sysfs_float<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>path<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> fd <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">open<\/span><span class=\"token punctuation\">(<\/span>path<span class=\"token punctuation\">,<\/span> O_RDONLY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>fd <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1.0f<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">char<\/span> buf<span class=\"token punctuation\">[<\/span><span class=\"token number\">32<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token class-name\">ssize_t<\/span> len <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">read<\/span><span class=\"token punctuation\">(<\/span>fd<span class=\"token punctuation\">,<\/span> buf<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>buf<span class=\"token punctuation\">)<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span>fd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>len <span class=\"token operator\">&lt;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1.0f<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    buf<span class=\"token punctuation\">[<\/span>len<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;\\\\0&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token function\">atof<\/span><span class=\"token punctuation\">(<\/span>buf<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token function\">acquisition_thread<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>arg<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token class-name\">pthread_t<\/span> tid <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">pthread_self<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">bind_thread_to_cpu<\/span><span class=\"token punctuation\">(<\/span>tid<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u91c7\u96c6\u7ebf\u7a0b\u7ed1\u5b9a\u5230 CPU0\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">int<\/span> val <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">read_sysfs_int<\/span><span class=\"token punctuation\">(<\/span>SYSFS_ADC_PATH<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">float<\/span> scale <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">read_sysfs_float<\/span><span class=\"token punctuation\">(<\/span>SYSFS_ADC_SCALE<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>val <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span> <span class=\"token operator\">||<\/span> scale <span class=\"token operator\">&lt;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u8bfb\u53d6ADC\u6216Scale\u5931\u8d25&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token function\">usleep<\/span><span class=\"token punctuation\">(<\/span>ACQ_INTERVAL_US<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">continue<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token function\">pthread_mutex_lock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>data_lock<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        shared_data <span class=\"token operator\">&#061;<\/span> val<span class=\"token punctuation\">;<\/span><br \/>\n        shared_scale <span class=\"token operator\">&#061;<\/span> scale<span class=\"token punctuation\">;<\/span><br \/>\n        data_ready <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">pthread_cond_signal<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>data_cond<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">pthread_mutex_unlock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>data_lock<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u91c7\u96c6\u7ebf\u7a0b: \u539f\u59cb\u503c&#061;%d, scale&#061;%.6f\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> val<span class=\"token punctuation\">,<\/span> scale<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">usleep<\/span><span class=\"token punctuation\">(<\/span>ACQ_INTERVAL_US<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token function\">processing_thread<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>arg<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token class-name\">pthread_t<\/span> tid <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">pthread_self<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">bind_thread_to_cpu<\/span><span class=\"token punctuation\">(<\/span>tid<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u5904\u7406\u7ebf\u7a0b\u7ed1\u5b9a\u5230 CPU1\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">pthread_mutex_lock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>data_lock<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span>data_ready<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token function\">pthread_cond_wait<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>data_cond<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>data_lock<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token keyword\">int<\/span> val <span class=\"token operator\">&#061;<\/span> shared_data<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">float<\/span> scale <span class=\"token operator\">&#061;<\/span> shared_scale<span class=\"token punctuation\">;<\/span><br \/>\n        data_ready <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">pthread_mutex_unlock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>data_lock<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token keyword\">float<\/span> voltage <span class=\"token operator\">&#061;<\/span> val <span class=\"token operator\">*<\/span> scale <span class=\"token operator\">*<\/span> <span class=\"token number\">0.001<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u5904\u7406\u7ebf\u7a0b: \u5904\u7406 %d \u00d7 %.6f x 0.001 &#061; %.2f V\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> val<span class=\"token punctuation\">,<\/span> scale<span class=\"token punctuation\">,<\/span> voltage<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> argc<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>argv<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token class-name\">pthread_t<\/span> tid_acq<span class=\"token punctuation\">,<\/span> tid_proc<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> ret<span class=\"token punctuation\">;<\/span><\/p>\n<p>    ret <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">pthread_create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>tid_acq<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> acquisition_thread<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>ret<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">fprintf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">stderr<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u521b\u5efa\u91c7\u96c6\u7ebf\u7a0b\u5931\u8d25: %s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">strerror<\/span><span class=\"token punctuation\">(<\/span>ret<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    ret <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">pthread_create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>tid_proc<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> processing_thread<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>ret<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">fprintf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">stderr<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u521b\u5efa\u5904\u7406\u7ebf\u7a0b\u5931\u8d25: %s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">strerror<\/span><span class=\"token punctuation\">(<\/span>ret<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token function\">pthread_join<\/span><span class=\"token punctuation\">(<\/span>tid_acq<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">pthread_join<\/span><span class=\"token punctuation\">(<\/span>tid_proc<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h4>2.\u4f7f\u7528\u65b9\u6cd5<\/h4>\n<p>\u5c06\u4ee5\u4e0a\u4ee3\u7801\u7f16\u8f91\u4e3a adc_app.c \u6587\u4ef6&#xff0c;\u5728 ubuntu \u7cfb\u7edf\u91cc\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4ea4\u53c9\u7f16\u8bd1\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u5373\u53ef&#xff1a;<\/p>\n<p><span class=\"token builtin class-name\">source<\/span> \/opt\/st\/stm32mp2\/5.0.3-snapshot\/environment-setup-cortexa35-ostl-linux<br \/>\n<span class=\"token variable\">${CC}<\/span> -o adc_app adc_app.c<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250428140821-680f8bd5db604.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u6700\u7ec8\u751f\u6210\u7684 adc_app \u6587\u4ef6\u5c31\u662f\u6211\u4eec\u9700\u8981\u653e\u5230 STM32MP257 \u6587\u4ef6\u7cfb\u7edf\u91cc\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<p>\u6ce8\u610f\u4e8b\u9879&#xff1a;\u5728STM32MP257\u7684\u767e\u5ea6\u8d44\u6599\u7f51\u76d8\u91cc\u5df2\u7ecf\u63d0\u4f9b\u4e86\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177\u94fe\u7684\u5b89\u88c5\u811a\u672c&#xff0c;\u6587\u4ef6\u8def\u5f84\u662f \u201cSTM32MP257\u5f00\u53d1\u677f\\\\05\u3001\u5f00\u53d1\u5de5\u5177\\\\01\u3001\u51fa\u5382\u7cfb\u7edf\u4ea4\u53c9\u7f16\u8bd1\u5668\u201d &#xff0c;\u8bf7\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u53bb\u4e0b\u8f7d\u4f7f\u7528\u3002<\/p>\n<p>atk-image-openstlinux-weston-stm32mp2.rootfs-x86_64-toolchain-5.0.3-snapshot-20250115-v1.0<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250428140822-680f8bd61d206.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u4e09\u3001\u5e94\u7528\u573a\u666f\u4e0e\u5b9e\u9645\u90e8\u7f72\u5efa\u8bae<\/h2>\n<p>\u672c\u65b9\u6848\u9002\u7528\u4e8e\u4ee5\u4e0b\u5178\u578b\u573a\u666f&#xff1a;<\/p>\n<h3>1\u3001\u5de5\u4e1a\u81ea\u52a8\u5316\u63a7\u5236<\/h3>\n<ul>\n<li>\u5b9e\u65f6\u8bfb\u53d6\u4f20\u611f\u5668\u7535\u538b\u4fe1\u53f7&#xff08;\u5982\u538b\u529b\u3001\u6e29\u6e7f\u5ea6\u3001\u5149\u5f3a\u7b49&#xff09;<\/li>\n<li>\u591a\u6838\u5904\u7406\u786e\u4fdd\u4e3b\u7ebf\u7a0b\u54cd\u5e94\u4e0d\u4e2d\u65ad<\/li>\n<li>\u7535\u538b\u8ba1\u7b97\u540e\u53ef\u76f4\u63a5\u7528\u4e8e\u95ed\u73af PID \u63a7\u5236\u903b\u8f91<\/li>\n<\/ul>\n<h3>2\u3001\u8fb9\u7f18AI\u4e0e\u4fe1\u53f7\u9884\u5904\u7406<\/h3>\n<ul>\n<li>\u91c7\u96c6\u6a21\u62df\u6570\u636e\u540e\u53ef\u76f4\u63a5\u8fdb\u884c\u6570\u5b57\u6ee4\u6ce2\u3001\u5085\u91cc\u53f6\u53d8\u6362\u7b49\u524d\u5904\u7406<\/li>\n<li>\u6570\u636e\u5904\u7406\u7ebf\u7a0b\u4e5f\u53ef\u901a\u8fc7 RPMsg \u53d1\u9001\u5230 Cortex-M33 \u534f\u5904\u7406\u6838\u505a\u8fdb\u4e00\u6b65\u5904\u7406<\/li>\n<\/ul>\n<h3>3\u3001\u591a\u4efb\u52a1\u5b9e\u65f6\u7cfb\u7edf\u8c03\u5ea6<\/h3>\n<ul>\n<li>\u591a\u6838\u7ed1\u5b9a\u53ef\u9632\u6b62\u7ebf\u7a0b\u201c\u6f02\u79fb\u201d&#xff0c;\u9002\u7528\u4e8e\u5e26\u6709\u8c03\u5ea6\u5668\u7684 RT-PREEMPT \u7cfb\u7edf<\/li>\n<li>\u5f3a\u5316\u7ebf\u7a0b\u7684\u786e\u5b9a\u6027\u548c\u6027\u80fd\u9694\u79bb<\/li>\n<\/ul>\n<h2>\u56db\u3001\u6d4b\u8bd5\u6548\u679c\u4e0e\u8f93\u51fa\u793a\u4f8b<\/h2>\n<p>\u8fd0\u884c\u540e&#xff0c;\u7ec8\u7aef\u5c06\u5468\u671f\u6027\u6253\u5370\u5982\u4e0b\u4fe1\u606f&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250428140822-680f8bd647c97.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>in_voltage15_raw &#061; 4095 \u8868\u793aADC\u539f\u59cb\u6570\u503c<\/li>\n<li>scale &#061; 0.439453 mV\/LSB \u662f ADC \u7684\u7535\u538b\u7cbe\u5ea6<\/li>\n<li>\u6700\u7ec8\u7535\u538b &#061; 4095* 0.439453 * 0.001 \u2248 1.8V<\/li>\n<\/ul>\n<p>\u6267\u884c adc_app \u53ef\u6267\u884c\u6587\u4ef6\u540e&#xff0c;\u6211\u4eec\u7528 ssh \u6253\u5f00 STM32MP257 \u7684\u65b0\u7ec8\u7aef&#xff0c;\u7528\u4ee5\u4e0b\u6307\u4ee4\u53ef\u4ee5\u67e5\u770b \u8fd9\u4e2a\u4f8b\u7a0b\u7684\u8c03\u7528 cpu \u4f7f\u7528\u60c5\u51b5&#xff1a;<\/p>\n<p><span class=\"token function\">top<\/span> -H -p <span class=\"token variable\"><span class=\"token variable\">$(<\/span>pidof adc_app<span class=\"token variable\">)<\/span><\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250428140822-680f8bd673495.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u901a\u8fc7\u7ec8\u7aef\u663e\u793a\u7684\u6d88\u606f&#xff0c;\u53ef\u4ee5\u770b\u5230 adc_app \u4e3b\u7ebf\u7a0b\u5728 CPU1 \u91cc\u4f7f\u7528&#xff0c;\u91c7\u96c6\u6570\u636e \u548c \u5904\u7406\u6570\u636e\u7684\u7ebf\u7a0b \u5206\u522b\u5728 CPU0 \u548c CPU1 \u91cc\u5206\u522b\u4f7f\u7528\u3002<\/p>\n<h2>\u4e94\u3001\u603b\u7ed3\u4e0e\u62d3\u5c55\u5efa\u8bae<\/h2>\n<p>\u901a\u8fc7\u7ed1\u5b9a\u7ebf\u7a0b\u81f3\u7279\u5b9a CPU \u6838\u5fc3&#xff0c;\u5e76\u4f7f\u7528\u6761\u4ef6\u53d8\u91cf\u8fdb\u884c\u7ebf\u7a0b\u540c\u6b65&#xff0c;\u6211\u4eec\u5b9e\u73b0\u4e86\u4e00\u4e2a \u4f4e\u5ef6\u8fdf\u3001\u9ad8\u7a33\u5b9a\u6027 \u7684 ADC \u7535\u538b\u91c7\u96c6\u5904\u7406\u65b9\u6848\u3002\u5b83\u53ef\u8f7b\u677e\u9002\u914d\u5230\u4efb\u610f\u652f\u6301 Linux \u7684 ARM \u591a\u6838\u5e73\u53f0&#xff0c;\u63a8\u8350\u7528\u4e8e\u5de5\u4e1a\u63a7\u5236\u3001\u4fe1\u53f7\u5904\u7406\u3001\u8fb9\u7f18AI\u7b49\u9ad8\u5b9e\u65f6\u573a\u666f\u3002<\/p>\n<p>\u540e\u7eed\u53ef\u4ee5\u62d3\u5c55&#xff1a;<\/p>\n<ul>\n<li>\u5c06\u6570\u636e\u901a\u8fc7 Socket\/UDP\/CanOpen \u53d1\u9001<\/li>\n<li>\u5199\u5165\u5171\u4eab\u5185\u5b58\u4f9b GUI \u4f7f\u7528<\/li>\n<li>\u589e\u52a0\u591a\u901a\u9053\u91c7\u96c6<\/li>\n<li>\u4e0e Cortex-M \u6838\u901a\u4fe1&#xff08;RPMsg&#xff09;<\/li>\n<\/ul>\n<p>\u5982\u679c\u4f60\u4e5f\u5728\u505a STM32MP257 \/ i.MX93 \/ RK3588 \u7b49\u5e73\u53f0\u7684\u5f02\u6784\u6838\u534f\u540c\u5904\u7406&#xff0c;\u4e0d\u59a8\u8bd5\u8bd5\u8fd9\u79cd\u65b9\u6848&#xff01;\u6709\u95ee\u9898\u6b22\u8fce\u8bc4\u8bba\u533a\u4e00\u8d77\u63a2\u8ba8\u4ea4\u6d41&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e28\u6b21\uff0c\u6536\u85cf25\u6b21\u3002\u5728\u5d4c\u5165\u5f0f Linux \u5e73\u53f0\uff08\u5982 STM32MP257\u3001i.MX93 \u7b49\uff09\u4e2d\uff0c\u6211\u4eec\u5e38\u4f7f\u7528\u5de5\u4e1a\u7ea7 ADC \u8fdb\u884c\u4f20\u611f\u5668\u6570\u636e\u91c7\u96c6\u3002\u901a\u8fc7\u5185\u6838 IIO \u5b50\u7cfb\u7edf\uff0c\u7528\u6237\u53ef\u4ee5\u5728 \/sys\/bus\/iio\/devices\/iio:deviceX\/ \u76ee\u5f55\u4e0b\u8bfb\u53d6\u539f\u59cb\u7535\u538b\u503c\u548c\u7535\u538b\u7f29\u653e\u56e0\u5b50\uff08scale\uff09\uff0c\u4ece\u800c\u8ba1\u7b97\u51fa\u771f\u5b9e\u7535\u538b\u3002\u800c\u672c\u9879\u76ee\u7684\u8bbe\u8ba1\u76ee\u6807\uff0c\u662f\u5b9e\u73b0\u91c7\u96c6\u7ebf\u7a0b + \u5904\u7406\u7ebf\u7a0b\u5206\u6838\u8fd0\u884c\uff0c\u5145\u5206\u5229\u7528 A\u6838\u591a\u6838\u7cfb\u7edf\u7684\u8d44\u6e90\uff0c\u63d0\u9ad8\u6570\u636e\u91c7\u96c6\u5b9e\u65f6\u6027\uff0c\u964d\u4f4e\u4e3b\u7ebf\u7a0b\u963b\u585e\u98ce\u9669\u3002\u901a\u8fc7\u7ed1\u5b9a\u7ebf\u7a0b\u81f3\u7279\u5b9a CPU \u6838\u5fc3\uff0c\u5e76\u4f7f\u7528\u6761\u4ef6\u53d8\u91cf\u8fdb\u884c\u7ebf\u7a0b\u540c\u6b65\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86\u4e00\u4e2a\u3002_stm32mp257\u8dd1\u5206<\/p>\n","protected":false},"author":2,"featured_media":33925,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2860,2861,217,188,2862],"topic":[],"class_list":["post-33930","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-stm32mp257","tag-arm-linux","tag-stm32","tag-188","tag-2862"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6b63\u70b9\u539f\u5b50 STM32MP257 \u540c\u6784\u591a\u6838\u67b6\u6784\u4e0b\u7684 ADC \u7535\u538b\u91c7\u96c6\u4e0e\u5904\u7406\u5e94\u7528\u5f00\u53d1\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/33930.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6b63\u70b9\u539f\u5b50 STM32MP257 \u540c\u6784\u591a\u6838\u67b6\u6784\u4e0b\u7684 ADC \u7535\u538b\u91c7\u96c6\u4e0e\u5904\u7406\u5e94\u7528\u5f00\u53d1\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e28\u6b21\uff0c\u6536\u85cf25\u6b21\u3002\u5728\u5d4c\u5165\u5f0f Linux \u5e73\u53f0\uff08\u5982 STM32MP257\u3001i.MX93 \u7b49\uff09\u4e2d\uff0c\u6211\u4eec\u5e38\u4f7f\u7528\u5de5\u4e1a\u7ea7 ADC \u8fdb\u884c\u4f20\u611f\u5668\u6570\u636e\u91c7\u96c6\u3002\u901a\u8fc7\u5185\u6838 IIO \u5b50\u7cfb\u7edf\uff0c\u7528\u6237\u53ef\u4ee5\u5728 \/sys\/bus\/iio\/devices\/iio:deviceX\/ \u76ee\u5f55\u4e0b\u8bfb\u53d6\u539f\u59cb\u7535\u538b\u503c\u548c\u7535\u538b\u7f29\u653e\u56e0\u5b50\uff08scale\uff09\uff0c\u4ece\u800c\u8ba1\u7b97\u51fa\u771f\u5b9e\u7535\u538b\u3002\u800c\u672c\u9879\u76ee\u7684\u8bbe\u8ba1\u76ee\u6807\uff0c\u662f\u5b9e\u73b0\u91c7\u96c6\u7ebf\u7a0b + \u5904\u7406\u7ebf\u7a0b\u5206\u6838\u8fd0\u884c\uff0c\u5145\u5206\u5229\u7528 A\u6838\u591a\u6838\u7cfb\u7edf\u7684\u8d44\u6e90\uff0c\u63d0\u9ad8\u6570\u636e\u91c7\u96c6\u5b9e\u65f6\u6027\uff0c\u964d\u4f4e\u4e3b\u7ebf\u7a0b\u963b\u585e\u98ce\u9669\u3002\u901a\u8fc7\u7ed1\u5b9a\u7ebf\u7a0b\u81f3\u7279\u5b9a CPU \u6838\u5fc3\uff0c\u5e76\u4f7f\u7528\u6761\u4ef6\u53d8\u91cf\u8fdb\u884c\u7ebf\u7a0b\u540c\u6b65\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86\u4e00\u4e2a\u3002_stm32mp257\u8dd1\u5206\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/33930.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-28T14:08:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250428140818-680f8bd2eab93.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/33930.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/33930.html\",\"name\":\"\u6b63\u70b9\u539f\u5b50 STM32MP257 \u540c\u6784\u591a\u6838\u67b6\u6784\u4e0b\u7684 ADC \u7535\u538b\u91c7\u96c6\u4e0e\u5904\u7406\u5e94\u7528\u5f00\u53d1\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-28T14:08:23+00:00\",\"dateModified\":\"2025-04-28T14:08:23+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/33930.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/33930.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/33930.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6b63\u70b9\u539f\u5b50 STM32MP257 \u540c\u6784\u591a\u6838\u67b6\u6784\u4e0b\u7684 ADC \u7535\u538b\u91c7\u96c6\u4e0e\u5904\u7406\u5e94\u7528\u5f00\u53d1\u5b9e\u6218\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u6b63\u70b9\u539f\u5b50 STM32MP257 \u540c\u6784\u591a\u6838\u67b6\u6784\u4e0b\u7684 ADC \u7535\u538b\u91c7\u96c6\u4e0e\u5904\u7406\u5e94\u7528\u5f00\u53d1\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/33930.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6b63\u70b9\u539f\u5b50 STM32MP257 \u540c\u6784\u591a\u6838\u67b6\u6784\u4e0b\u7684 ADC \u7535\u538b\u91c7\u96c6\u4e0e\u5904\u7406\u5e94\u7528\u5f00\u53d1\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e28\u6b21\uff0c\u6536\u85cf25\u6b21\u3002\u5728\u5d4c\u5165\u5f0f Linux \u5e73\u53f0\uff08\u5982 STM32MP257\u3001i.MX93 \u7b49\uff09\u4e2d\uff0c\u6211\u4eec\u5e38\u4f7f\u7528\u5de5\u4e1a\u7ea7 ADC \u8fdb\u884c\u4f20\u611f\u5668\u6570\u636e\u91c7\u96c6\u3002\u901a\u8fc7\u5185\u6838 IIO \u5b50\u7cfb\u7edf\uff0c\u7528\u6237\u53ef\u4ee5\u5728 \/sys\/bus\/iio\/devices\/iio:deviceX\/ \u76ee\u5f55\u4e0b\u8bfb\u53d6\u539f\u59cb\u7535\u538b\u503c\u548c\u7535\u538b\u7f29\u653e\u56e0\u5b50\uff08scale\uff09\uff0c\u4ece\u800c\u8ba1\u7b97\u51fa\u771f\u5b9e\u7535\u538b\u3002\u800c\u672c\u9879\u76ee\u7684\u8bbe\u8ba1\u76ee\u6807\uff0c\u662f\u5b9e\u73b0\u91c7\u96c6\u7ebf\u7a0b + \u5904\u7406\u7ebf\u7a0b\u5206\u6838\u8fd0\u884c\uff0c\u5145\u5206\u5229\u7528 A\u6838\u591a\u6838\u7cfb\u7edf\u7684\u8d44\u6e90\uff0c\u63d0\u9ad8\u6570\u636e\u91c7\u96c6\u5b9e\u65f6\u6027\uff0c\u964d\u4f4e\u4e3b\u7ebf\u7a0b\u963b\u585e\u98ce\u9669\u3002\u901a\u8fc7\u7ed1\u5b9a\u7ebf\u7a0b\u81f3\u7279\u5b9a CPU \u6838\u5fc3\uff0c\u5e76\u4f7f\u7528\u6761\u4ef6\u53d8\u91cf\u8fdb\u884c\u7ebf\u7a0b\u540c\u6b65\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86\u4e00\u4e2a\u3002_stm32mp257\u8dd1\u5206","og_url":"https:\/\/www.wsisp.com\/helps\/33930.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-28T14:08:23+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250428140818-680f8bd2eab93.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/33930.html","url":"https:\/\/www.wsisp.com\/helps\/33930.html","name":"\u6b63\u70b9\u539f\u5b50 STM32MP257 \u540c\u6784\u591a\u6838\u67b6\u6784\u4e0b\u7684 ADC \u7535\u538b\u91c7\u96c6\u4e0e\u5904\u7406\u5e94\u7528\u5f00\u53d1\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-28T14:08:23+00:00","dateModified":"2025-04-28T14:08:23+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/33930.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/33930.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/33930.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6b63\u70b9\u539f\u5b50 STM32MP257 \u540c\u6784\u591a\u6838\u67b6\u6784\u4e0b\u7684 ADC \u7535\u538b\u91c7\u96c6\u4e0e\u5904\u7406\u5e94\u7528\u5f00\u53d1\u5b9e\u6218"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/33930","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=33930"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/33930\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/33925"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=33930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=33930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=33930"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=33930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}