{"id":464368,"date":"2025-06-24T21:05:11","date_gmt":"2025-06-24T21:05:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=464368"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=464368","title":{"rendered":"<span>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 ESP32 \u0441 ESP-IDF \u0432 \u0441\u0440\u0435\u0434\u0435 platformio #2<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u042d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u043f\u043e ESP-IDF. \u0420\u0430\u043d\u0435\u0435 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0441\u0442\u0435\u043a \u0437\u0430\u0434\u0430\u0447, \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 GPIO \u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c FreeRTOS \u2014 \u043c\u043e\u0449\u043d\u043e\u043c\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0443 \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 ISR \u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438. \u041f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e60\/ea6\/3a7\/e60ea63a7c4d2c45588dbb65bd29280e.png\" width=\"2938\" height=\"1628\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e60\/ea6\/3a7\/e60ea63a7c4d2c45588dbb65bd29280e.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e60\/ea6\/3a7\/e60ea63a7c4d2c45588dbb65bd29280e.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<hr\/>\n<h2>\u0422\u0435\u043e\u0440\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c\u0438 (Queues) \u0432 FreeRTOS \/ ESP-IDF<\/h2>\n<p>\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u2014 \u044d\u0442\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 FIFO (\u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0438\u0448\u0435\u043b, \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0448\u0435\u043b), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0434\u043b\u044f <strong>\u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/strong> \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u0438\u043b\u0438 \u0438\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 (ISR) \u0432 \u0437\u0430\u0434\u0430\u0447\u0438. \u0412 ESP-IDF \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 FreeRTOS API.<\/p>\n<h3>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b \u043e\u0447\u0435\u0440\u0435\u0434\u0438?<\/h3>\n<ul>\n<li>\n<p><strong>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><br \/> \u041e\u0447\u0435\u0440\u0435\u0434\u044c \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447 \u043c\u043e\u0433\u0443\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f      \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0438\u043b\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u043d\u0435 \u043e\u043f\u0430\u0441\u0430\u044f\u0441\u044c \u0433\u043e\u043d\u043e\u043a.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f<\/strong><br \/> \u0417\u0430\u0434\u0430\u0447\u0430 \u043c\u043e\u0436\u0435\u0442 <strong>\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f<\/strong>, \u043e\u0436\u0438\u0434\u0430\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0432\u043c\u0435\u0441\u0442\u043e \u00ab\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f\u00bb (polling).<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0438\u0437 ISR<\/strong><br \/> \u0418\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 ISR-\u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h2>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 API \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c\u0438<\/h2>\n<h3>1. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/h3>\n<pre><code>xQueueCreate(uxQueueLength, uxItemSize);<\/code><\/pre>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/strong> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0451 <strong>\u0445\u044d\u043d\u0434\u043b<\/strong> (<strong>\u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440<\/strong>). \u0412\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435 \u0438 \u043d\u0435 \u0432\u0438\u0434\u0438\u0442\u0435, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u00ab\u0432\u043d\u0443\u0442\u0440\u0438\u00bb \u2014 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043b\u0438\u0448\u044c \u0435\u0451 <strong>\u0445\u044d\u043d\u0434\u043b<\/strong>. \u0412\u0441\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430, \u043f\u0440\u0438\u0451\u043c, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435) \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u044d\u0442\u043e\u0442 <strong>\u0445\u044d\u043d\u0434\u043b<\/strong> \u0432 API-\u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>uxQueueLength<\/code> \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><code>uxItemSize<\/code> \u2014 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0425\u044d\u043d\u0434\u043b \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 (<code>QueueHandle_t<\/code>), \u0438\u043b\u0438 <code>NULL<\/code> \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0430\u043c\u044f\u0442\u0438).<\/p>\n<\/li>\n<\/ul>\n<h3>2. \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/h3>\n<pre><code>xQueueSend(xQueue, *pvItemToQueue, xTicksToWait);<\/code><\/pre>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/strong> \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 <code>pvItemToQueue<\/code> \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 <code>xQueue<\/code>.<\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><code>xQueue<\/code> \u2014 \u0445\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pvItemToQueue<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<\/li>\n<li>\n<p><code>xTicksToWait<\/code> \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u0442\u0438\u043a\u0430\u0445 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u043c\u0435\u0441\u0442\u0430, \u0435\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u043b\u043d\u0430 (<code>portMAX_DELAY<\/code> \u2014 \u0436\u0434\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e).<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p><code>pdTRUE<\/code> \u2014 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<\/li>\n<li>\n<p><code>errQUEUE_FULL<\/code> \u2014 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u0430 \u043e\u0442\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<\/li>\n<\/ul>\n<h3>3. \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 (\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 ISR)<\/h3>\n<pre><code>xQueueSendFromISR(xQueue, *pvItemToQueue, *pxHigherPriorityTaskWoken);<\/code><\/pre>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/strong> \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 ISR.<\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><code>xQueue<\/code> \u2014 \u0445\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pvItemToQueue<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><code>pxHigherPriorityTaskWoken<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u043b\u0430\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 <code>pdTRUE<\/code>, \u0435\u0441\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c (\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <code>portYIELD_FROM_ISR<\/code>).<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p><code>pdTRUE<\/code> \u2014\u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<\/li>\n<li>\n<p><code>errQUEUE_FULL<\/code> \u2014 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u0430 \u043e\u0442\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<\/li>\n<\/ul>\n<h3>4. \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/h3>\n<pre><code>xQueueReceive(xQueue, *pvBuffer, xTicksToWait);<\/code><\/pre>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/strong> \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 <code>xQueue<\/code> \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 <code>pvBuffer<\/code>.<\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><code>xQueue<\/code> \u2014 \u0445\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pvBuffer<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0435\u0440 , \u043a\u0443\u0434\u0430 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<\/li>\n<li>\n<p><code>xTicksToWait<\/code> \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0443\u0441\u0442\u0430 (<code>portMAX_DELAY<\/code> \u2014 \u0436\u0434\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e).<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p><code>pdTRUE<\/code> \u2014 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0438 \u0443\u0434\u0430\u043b\u0451\u043d \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pdFALSE<\/code> \u2014 \u043f\u043e \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<h3>5. \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 (\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 ISR)<\/h3>\n<pre><code>xQueueReceiveFromISR(xQueue, *pvBuffer, *pxHigherPriorityTaskWoken);<\/code><\/pre>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/strong> \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432 ISR.<\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><code>xQueue<\/code> \u2014 \u0445\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pvBuffer<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0435\u0440 \u0434\u043b\u044f \u043f\u0440\u0438\u0451\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p><code>pxHigherPriorityTaskWoken<\/code> \u2014 \u0444\u043b\u0430\u0433, \u043a\u0430\u043a \u0438 \u0432 <code>xQueueSendFromISR<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p><code>pdTRUE<\/code> \u2014 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0438 \u0443\u0434\u0430\u043b\u0451\u043d \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pdFALSE<\/code> \u2014 \u043f\u043e \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h2>\u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<blockquote>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0412\u0430\u043c \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c API <a href=\"https:\/\/docs.espressif.com\/projects\/esp-idf\/en\/v4.4\/esp32\/api-reference\/system\/log.html?utm_source=chatgpt.com#logging-library\" rel=\"noopener noreferrer nofollow\">Logging<\/a>. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442 \u043d\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0443. <\/p>\n<\/blockquote>\n<p>ESP-IDF \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043e\u0449\u043d\u0443\u044e \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u0445:<\/p>\n<pre><code>ESP_LOGE(TAG, \"Error! code=%d\", err_code);    \/\/ Error   (E) ESP_LOGW(TAG, \"Warning: %s\", warn_msg);       \/\/ Warning (W) ESP_LOGI(TAG, \"Info: init complete\");         \/\/ Info    (I) ESP_LOGD(TAG, \"Debug: x=%d, y=%d\", x, y);     \/\/ Debug   (D) ESP_LOGV(TAG, \"Verbose: raw data=%02X\", b);   \/\/ Verbose (V)<\/code><\/pre>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0423\u0440\u043e\u0432\u0435\u043d\u044c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>ERROR<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0431\u043e\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>WARN<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>INFO<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f (\u0441\u0442\u0430\u0440\u0442, \u0441\u0442\u043e\u043f, \u2026)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>DEBUG<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u0435\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>VERBOSE<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<ul>\n<li>\n<p><code><strong>TAG<\/strong><\/code> (\u043e\u0431\u044b\u0447\u043d\u043e <code>static const char* TAG = \"MyModule\";<\/code>) \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043a\u043e\u0434\u0430 \u0438 <strong>\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c<\/strong> \u0438\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c \u043b\u043e\u0433\u0435 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f <strong>\u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c<\/strong>, <strong>\u0443\u0440\u043e\u0432\u043d\u0435\u043c<\/strong> \u0438 <strong>\u0442\u0435\u0433\u043e\u043c<\/strong>:<\/p>\n<\/li>\n<\/ul>\n<pre><code>I (1234) MyModule: Info: init complete<\/code><\/pre>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0434\u043e\u043f\u044b\u0442\u043d\u043e\u0433\u043e \u0431\u0435\u0440\u0435\u043c \u043d\u0430\u0448 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 <a href=\"https:\/\/habr.com\/ru\/articles\/919362\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439<\/a> \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043b\u044f \u043c\u0438\u0433\u0430\u043d\u0438\u044f \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u043c:<\/p>\n<pre><code>#include \"freertos\/FreeRTOS.h\" #include \"freertos\/task.h\"            #include \"driver\/gpio.h\"   #include \"esp_log.h\"             #define LED_GPIO GPIO_NUM_2 \/\/ \u041f\u043e\u0440\u0442 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 static const char* TAG = \"blink_task\"; \/\/ \u0422\u044d\u0433  TaskHandle_t Blink_Handle = NULL; \/\/ \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 Blink  void Blink_Task(void *arg){     esp_rom_gpio_pad_select_gpio(LED_GPIO); \/\/ \"\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\" \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c GPIO     gpio_set_direction(LED_GPIO, GPIO_MODE_OUTPUT); \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u0432\u044b\u0445\u043e\u0434          bool led_on = false;     while (1) {         led_on = !led_on;         gpio_set_level(LED_GPIO, led_on);         ESP_LOGI(TAG, \"LED is now %s\", led_on ? \"ON\" : \"OFF\");         vTaskDelay(pdMS_TO_TICKS(500));     } }   void app_main() {     xTaskCreate(         Blink_Task,     \/\/ \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u2011\u0437\u0430\u0434\u0430\u0447\u0443         \"BLINK\",        \/\/ \u0438\u043c\u044f \u0437\u0430\u0434\u0430\u0447\u0438 (\u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438)         4096,           \/\/ \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0435\u043a\u0430         NULL,           \/\/ \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e (\u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d)         10,             \/\/ \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0438         &amp;Blink_Handle   \/\/ \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0448\u0443\u0442 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438     ); }<\/code><\/pre>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aa4\/713\/39d\/aa471339d1c6d6a57c31c54e5aea68b7.gif\" alt=\"\u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430\" title=\"\u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430\" width=\"388\" height=\"692\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aa4\/713\/39d\/aa471339d1c6d6a57c31c54e5aea68b7.gif 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aa4\/713\/39d\/aa471339d1c6d6a57c31c54e5aea68b7.gif 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<h2>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 Queue<\/h2>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 1<\/h2>\n<p>\u0414\u0443\u043c\u0430\u044e \u0432\u0430\u043c \u0432\u0441\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0438 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 5 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code>static QueueHandle_t int_queue = NULL; \/\/ \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438. int_queue = xQueueCreate(5, sizeof(int)); \/\/ \u0421\u043e\u0430\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 5 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0435\u043c 2 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 (\u0437\u0430\u0434\u0430\u0447\u0438), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u044d\u0442\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u044c\u044e. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043e\u0434\u043d\u0430 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 &#8212; <strong>Producer<\/strong> \u0431\u0443\u0434\u0435\u0442 \u043a\u043b\u0430\u0441\u0442\u044c (\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c) \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0430 \u0432\u0442\u043e\u0440\u0430\u044f &#8212; <strong>Consumer<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0435\u0433\u043e. <\/p>\n<h3>\u0417\u0430\u0434\u0430\u0447\u0430-\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c (Producer)<\/h3>\n<pre><code>void producer_task(void *arg) {     int counter = 0;     while (1) {         if (xQueueSend(int_queue, &amp;counter, pdMS_TO_TICKS(100)) == pdTRUE) {             ESP_LOGI(TAG, \"Sent: %d\", counter);             counter++;         } else {             ESP_LOGW(TAG, \"Queue full, could not send\");         }         vTaskDelay(pdMS_TO_TICKS(1000));     } } <\/code><\/pre>\n<ul>\n<li>\n<p><code><strong>counter<\/strong><\/code> \u2014 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 (<code>counter++<\/code>).<\/p>\n<\/li>\n<li>\n<p><code><strong>xQueueSend<\/strong><\/code> \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>counter<\/code> \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c <code>int_queue<\/code>.<\/p>\n<\/li>\n<li>\n<p><code>pdMS_TO_TICKS(100)<\/code> \u2014 <strong>\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f<\/strong>, \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430-\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 <strong>\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f<\/strong>, \u043e\u0436\u0438\u0434\u0430\u044f <strong>\u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430<\/strong> \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0443\u0436\u0435 \u043f\u043e\u043b\u043d\u0430.<\/p>\n<ul>\n<li>\n<p><strong>\u0415\u0441\u043b\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0441\u043b\u043e\u0442<\/strong>, <code>xQueueSend<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 <code>pdTRUE<\/code> <strong>\u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e<\/strong>, \u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443, <strong>\u043d\u0435 \u0434\u043e\u0436\u0438\u0434\u0430\u044f\u0441\u044c<\/strong> 100 \u043c\u0441.<\/p>\n<\/li>\n<li>\n<p><strong>\u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u043b\u043d\u0430<\/strong>, \u0442\u0430\u0441\u043a\u0430 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 Blocked \u0438 \u0431\u0443\u0434\u0435\u0442 <strong>\u0436\u0434\u0430\u0442\u044c \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0441\u0442\u0430<\/strong> \u0434\u043e \u0442\u0435\u0445 \u0441\u0430\u043c\u044b\u0445 100 \u043c\u0441.<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430 \u044d\u0442\u0438 100 \u043c\u0441 \u0441\u043b\u043e\u0442 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u0441\u044f (\u0432\u0437\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438), <code>xQueueSend<\/code> \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442 \u0432\u0430\u0448 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438 \u0432\u0435\u0440\u043d\u0451\u0442 <code>pdTRUE<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0437\u0430 100 \u043c\u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0442\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0439, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0451\u0442 <code>pdFALSE<\/code> (\u043e\u0448\u0438\u0431\u043a\u0430 <code>errQUEUE_FULL<\/code>), \u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u043b\u043e\u0433\u0435 \u00abQueue full, could not send\u00bb.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><code><strong>vTaskDelay(pdMS_TO_TICKS(1000))<\/strong><\/code> \u2014 \u0437\u0430\u0434\u0430\u0447\u0430 \u0437\u0430\u0441\u044b\u043f\u0430\u0435\u0442 \u043d\u0430 1000 \u043c\u0441.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0417\u0430\u0434\u0430\u0447\u0430-\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c (Consumer)<\/h3>\n<pre><code>void consumer_task(void *arg) {     int received;     while (1) {         if (xQueueReceive(int_queue, &amp;received, portMAX_DELAY) == pdTRUE) {             ESP_LOGI(TAG, \"Received: %d\", received);         }     } } <\/code><\/pre>\n<ul>\n<li>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 <strong>\u0436\u0434\u0451\u0442<\/strong> (<code>portMAX_DELAY<\/code> \u2014 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e) \u043f\u043e\u043a\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e <code>xQueueReceive<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>pdTRUE<\/code>, \u0432 <code>received<\/code> \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u2014 \u0435\u0433\u043e \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>\u0426\u0438\u043a\u043b \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f, \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043d\u043e\u0432\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h3>\n<pre><code>#include \"freertos\/FreeRTOS.h\" #include \"freertos\/task.h\" #include \"freertos\/queue.h\" #include \"esp_log.h\"  static const char *TAG = \"queue_example\";  \/\/ \u0425\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438 static QueueHandle_t int_queue = NULL; \/\/ \u0425\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 producer_task (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e) TaskHandle_t Producer_Handle = NULL;  \/\/ \u0425\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 consumer_task (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e) TaskHandle_t Consumer_Handle = NULL;   \/\/ Producer: \u043a\u0430\u0436\u0434\u044b\u0435 1000 \u043c\u0441 \u043a\u043b\u0430\u0434\u0451\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a void producer_task(void *arg) {     int counter = 0;     while (1) {         if (xQueueSend(int_queue, &amp;counter, pdMS_TO_TICKS(100)) == pdTRUE) {             ESP_LOGI(TAG, \"Sent: %d\", counter);             counter++;         } else {             ESP_LOGW(TAG, \"Queue full, could not send\");         }         vTaskDelay(pdMS_TO_TICKS(1000));     } }  \/\/ Consumer: \u0436\u0434\u0451\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0435\u0433\u043e void consumer_task(void *arg) {     int received;     while (1) {         \/\/ \u0436\u0434\u0435\u043c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442 \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435         if (xQueueReceive(int_queue, &amp;received, portMAX_DELAY) == pdTRUE) {             ESP_LOGI(TAG, \"Received: %d\", received);         }     } }  void app_main(void) {     \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 5 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 int     int_queue = xQueueCreate(5, sizeof(int));     \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0430, \u0438\u043d\u0430\u0447\u0435 \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043c     if (int_queue == NULL) {         ESP_LOGE(TAG, \"Failed to create queue\");         return;     }      \/*         \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0432         \u0423\u0447\u0438\u043c\u0441\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c)     *\/     if (xTaskCreate(producer_task, \"producer\", 2048, NULL, 5, &amp;Producer_Handle) != pdPASS) {         ESP_LOGE(TAG, \"Failed to create producer task\");     }     if (xTaskCreate(consumer_task, \"consumer\", 2048, NULL, 5, &amp;Consumer_Handle) != pdPASS) {         ESP_LOGE(TAG, \"Failed to create consumer task\");     } }<\/code><\/pre>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/688\/74b\/02a\/68874b02ab99b19ba14e7a3ca70cc6fb.gif\" alt=\"queue_example\" title=\"queue_example\" width=\"388\" height=\"692\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/688\/74b\/02a\/68874b02ab99b19ba14e7a3ca70cc6fb.gif 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/688\/74b\/02a\/68874b02ab99b19ba14e7a3ca70cc6fb.gif 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>queue_example<\/figcaption><\/div>\n<\/figure>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 2<\/h2>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 <strong>ISR<\/strong> \u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432 \u043d\u0430\u0448\u0435\u043c <a href=\"https:\/\/habr.com\/ru\/articles\/919362\/#:~:text=%D0%BF%D0%BE%D0%BC%D0%BE%D1%89%D1%8C%D1%8E%20IRAM_ATTR.-,%D0%9F%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D0%BA%D0%B0,-%D0%9D%D0%B0%D1%88%D0%B0%20%D1%86%D0%B5%D0%BB%D1%8C%20%E2%80%94%20%D1%80%D0%B5%D0%B0%D0%BB%D0%B8%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D1%8C\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0434\u0435<\/a>:<\/p>\n<ul>\n<li>\n<p>\u041d\u0435\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u0438: \u0435\u0441\u043b\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 (\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0444\u043b\u0430\u0433), \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0440\u0443\u0434\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c: \u043d\u0435\u043b\u044c\u0437\u044f \u043b\u0435\u0433\u043a\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c \u00ab\u043a\u0430\u043a\u043e\u0435\u00bb \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u0448\u043b\u043e.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u043a\u0441\u0442\u0430\u0442\u0438.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a: \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f (<code>gpio_isr_handler<\/code>) \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0431\u0443\u043b\u0435\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (<code>true<\/code>\/<code>false<\/code>), \u0430 \u0437\u0430\u0434\u0430\u0447\u0430 <code>Blink_Task<\/code> \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u0438\u0451\u043c\u0435 \u0438\u0437 \u044d\u0442\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043d\u043e\u0432\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0433\u043e\u043d\u043a\u0438 \u043f\u0440\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 ISR \u0438 \u0442\u0430\u0441\u043a\u0438 \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f: ISR \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 \u0431\u044b\u0441\u0442\u0440\u0443\u044e \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0430 \u0432\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f GPIO \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0435\u043d\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u2014 \u0432 \u0437\u0430\u0434\u0430\u0447\u0435, \u0447\u0442\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043e\u0442\u043b\u0430\u0434\u043a\u0443.<\/p>\n<pre><code>#include \"freertos\/FreeRTOS.h\" #include \"freertos\/task.h\" #include \"freertos\/queue.h\" #include \"driver\/gpio.h\" #include \"esp_attr.h\" #include \"esp_log.h\"  #define LED_GPIO    GPIO_NUM_2     \/\/ \u041f\u0438\u043d, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434 #define BUTTON_GPIO GPIO_NUM_23    \/\/ \u041f\u0438\u043d, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0430  TaskHandle_t Blink_Handle = NULL;  \/\/ \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 Blink  static const char* TAG = \"led_queue_no_yield\"; \/\/ \u0414\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f  \/\/ \u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u043e\u0442 ISR static QueueHandle_t led_queue = NULL;    \/\/ ISR-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a: \u0448\u043b\u0451\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c static void IRAM_ATTR gpio_isr_handler(void *arg) {     uint8_t cmd = 1;     xQueueSendFromISR(led_queue, &amp;cmd, NULL); }  \/\/ \u0417\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043d\u0430 LED_GPIO \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e state void Blink_Task(void *arg) {     \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f     esp_rom_gpio_pad_select_gpio(LED_GPIO);     gpio_set_direction(LED_GPIO, GPIO_MODE_OUTPUT);     gpio_set_level(LED_GPIO, 0);      uint8_t cmd;     bool state = false;     while (1) {         \/\/ \u0411\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u0434\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0436\u0434\u0435\u043c portMAX_DELAY(\u0431\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439)         if(xQueueReceive(led_queue, &amp;cmd, portMAX_DELAY) == pdTRUE){                 if (cmd == 1) {                     \/\/ \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434                     state = !state;                     gpio_set_level(LED_GPIO, state);                     ESP_LOGI(TAG, \"LED toggled to %s\", state ? \"ON\" : \"OFF\");             }         }     } }  void app_main() {         \/\/ 1) \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 10 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432     led_queue = xQueueCreate(10, sizeof(uint8_t));     if (!led_queue) {         ESP_LOGE(TAG, \"Queue creation failed\");         return;     }      esp_rom_gpio_pad_select_gpio(BUTTON_GPIO);                  \/\/ \"\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\" \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c GPIO     gpio_set_direction(BUTTON_GPIO, GPIO_MODE_INPUT);           \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 BUTTON_GPIO \u043a\u0430\u043a \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0432\u0445\u043e\u0434     gpio_pullup_en(BUTTON_GPIO);                                \/\/ \u041f\u043e\u0434\u0442\u044f\u0436\u043a\u0430 \u043a VCC     gpio_set_intr_type(BUTTON_GPIO, GPIO_INTR_POSEDGE);         \/\/ \u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 (\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0440\u043e\u043d\u0442)     gpio_install_isr_service(ESP_INTR_FLAG_IRAM);               \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 ISR      gpio_isr_handler_add(BUTTON_GPIO, gpio_isr_handler, NULL);  \/\/ \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f      \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u201c\u043c\u0438\u0433\u0430\u0442\u044c\u201d LED \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 state     if(xTaskCreate(Blink_Task, \"BLINK\", 2048, NULL, 5, &amp;Blink_Handle) != pdPASS) {         ESP_LOGE(TAG, \"Failed to create Blink_Task\");     } }<\/code><\/pre>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6c2\/b57\/735\/6c2b577351e6af084619a683c6a049f7.gif\" alt=\"ISR_QUEUE\" title=\"ISR_QUEUE\" width=\"388\" height=\"692\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6c2\/b57\/735\/6c2b577351e6af084619a683c6a049f7.gif 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6c2\/b57\/735\/6c2b577351e6af084619a683c6a049f7.gif 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>ISR_QUEUE<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u043e\u0448\u0438\u0431\u043a\u0438 \u0438\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e \u0441\u0442\u0430\u0442\u044c\u0438 \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u043f\u0438\u0448\u0438\u0442\u0435\u0441\u044c \u0432 \u0434\u0438\u0430\u043b\u043e\u0433\u0435 \u0438\u043b\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445. \u042f \u0441 \u0440\u0430\u0434\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u044e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043e\u0431\u0449\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u043e\u0432 \u0438 \u0441\u0435\u043c\u0430\u0444\u043e\u0440\u043e\u0432.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/920636\/\"> https:\/\/habr.com\/ru\/articles\/920636\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u042d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u043f\u043e ESP-IDF. \u0420\u0430\u043d\u0435\u0435 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0441\u0442\u0435\u043a \u0437\u0430\u0434\u0430\u0447, \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 GPIO \u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c FreeRTOS \u2014 \u043c\u043e\u0449\u043d\u043e\u043c\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0443 \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 ISR \u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438. \u041f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<figure class=\"full-width\"><\/figure>\n<hr\/>\n<h2>\u0422\u0435\u043e\u0440\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c\u0438 (Queues) \u0432 FreeRTOS \/ ESP-IDF<\/h2>\n<p>\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u2014 \u044d\u0442\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 FIFO (\u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0438\u0448\u0435\u043b, \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0448\u0435\u043b), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0434\u043b\u044f <strong>\u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/strong> \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u0438\u043b\u0438 \u0438\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 (ISR) \u0432 \u0437\u0430\u0434\u0430\u0447\u0438. \u0412 ESP-IDF \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 FreeRTOS API.<\/p>\n<h3>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b \u043e\u0447\u0435\u0440\u0435\u0434\u0438?<\/h3>\n<ul>\n<li>\n<p><strong>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><br \/> \u041e\u0447\u0435\u0440\u0435\u0434\u044c \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447 \u043c\u043e\u0433\u0443\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f      \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0438\u043b\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u043d\u0435 \u043e\u043f\u0430\u0441\u0430\u044f\u0441\u044c \u0433\u043e\u043d\u043e\u043a.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f<\/strong><br \/> \u0417\u0430\u0434\u0430\u0447\u0430 \u043c\u043e\u0436\u0435\u0442 <strong>\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f<\/strong>, \u043e\u0436\u0438\u0434\u0430\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0432\u043c\u0435\u0441\u0442\u043e \u00ab\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f\u00bb (polling).<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0438\u0437 ISR<\/strong><br \/> \u0418\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 ISR-\u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h2>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 API \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c\u0438<\/h2>\n<h3>1. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/h3>\n<pre><code>xQueueCreate(uxQueueLength, uxItemSize);<\/code><\/pre>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/strong> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0451 <strong>\u0445\u044d\u043d\u0434\u043b<\/strong> (<strong>\u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440<\/strong>). \u0412\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435 \u0438 \u043d\u0435 \u0432\u0438\u0434\u0438\u0442\u0435, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u00ab\u0432\u043d\u0443\u0442\u0440\u0438\u00bb \u2014 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043b\u0438\u0448\u044c \u0435\u0451 <strong>\u0445\u044d\u043d\u0434\u043b<\/strong>. \u0412\u0441\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430, \u043f\u0440\u0438\u0451\u043c, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435) \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u044d\u0442\u043e\u0442 <strong>\u0445\u044d\u043d\u0434\u043b<\/strong> \u0432 API-\u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>uxQueueLength<\/code> \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><code>uxItemSize<\/code> \u2014 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0425\u044d\u043d\u0434\u043b \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 (<code>QueueHandle_t<\/code>), \u0438\u043b\u0438 <code>NULL<\/code> \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0430\u043c\u044f\u0442\u0438).<\/p>\n<\/li>\n<\/ul>\n<h3>2. \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/h3>\n<pre><code>xQueueSend(xQueue, *pvItemToQueue, xTicksToWait);<\/code><\/pre>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/strong> \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 <code>pvItemToQueue<\/code> \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 <code>xQueue<\/code>.<\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><code>xQueue<\/code> \u2014 \u0445\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pvItemToQueue<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<\/li>\n<li>\n<p><code>xTicksToWait<\/code> \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u0442\u0438\u043a\u0430\u0445 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u043c\u0435\u0441\u0442\u0430, \u0435\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u043b\u043d\u0430 (<code>portMAX_DELAY<\/code> \u2014 \u0436\u0434\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e).<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p><code>pdTRUE<\/code> \u2014 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<\/li>\n<li>\n<p><code>errQUEUE_FULL<\/code> \u2014 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u0430 \u043e\u0442\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<\/li>\n<\/ul>\n<h3>3. \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 (\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 ISR)<\/h3>\n<pre><code>xQueueSendFromISR(xQueue, *pvItemToQueue, *pxHigherPriorityTaskWoken);<\/code><\/pre>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/strong> \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 ISR.<\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><code>xQueue<\/code> \u2014 \u0445\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pvItemToQueue<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><code>pxHigherPriorityTaskWoken<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u043b\u0430\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 <code>pdTRUE<\/code>, \u0435\u0441\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c (\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <code>portYIELD_FROM_ISR<\/code>).<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p><code>pdTRUE<\/code> \u2014\u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<\/li>\n<li>\n<p><code>errQUEUE_FULL<\/code> \u2014 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u0430 \u043e\u0442\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<\/li>\n<\/ul>\n<h3>4. \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/h3>\n<pre><code>xQueueReceive(xQueue, *pvBuffer, xTicksToWait);<\/code><\/pre>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/strong> \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 <code>xQueue<\/code> \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 <code>pvBuffer<\/code>.<\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><code>xQueue<\/code> \u2014 \u0445\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pvBuffer<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0435\u0440 , \u043a\u0443\u0434\u0430 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<\/li>\n<li>\n<p><code>xTicksToWait<\/code> \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0443\u0441\u0442\u0430 (<code>portMAX_DELAY<\/code> \u2014 \u0436\u0434\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e).<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p><code>pdTRUE<\/code> \u2014 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0438 \u0443\u0434\u0430\u043b\u0451\u043d \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pdFALSE<\/code> \u2014 \u043f\u043e \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<h3>5. \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 (\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 ISR)<\/h3>\n<pre><code>xQueueReceiveFromISR(xQueue, *pvBuffer, *pxHigherPriorityTaskWoken);<\/code><\/pre>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/strong> \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432 ISR.<\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><code>xQueue<\/code> \u2014 \u0445\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pvBuffer<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0435\u0440 \u0434\u043b\u044f \u043f\u0440\u0438\u0451\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p><code>pxHigherPriorityTaskWoken<\/code> \u2014 \u0444\u043b\u0430\u0433, \u043a\u0430\u043a \u0438 \u0432 <code>xQueueSendFromISR<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p><code>pdTRUE<\/code> \u2014 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0438 \u0443\u0434\u0430\u043b\u0451\u043d \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><code>pdFALSE<\/code> \u2014 \u043f\u043e \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h2>\u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<blockquote>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0412\u0430\u043c \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c API <a href=\"https:\/\/docs.espressif.com\/projects\/esp-idf\/en\/v4.4\/esp32\/api-reference\/system\/log.html?utm_source=chatgpt.com#logging-library\" rel=\"noopener noreferrer nofollow\">Logging<\/a>. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442 \u043d\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0443. <\/p>\n<\/blockquote>\n<p>ESP-IDF \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043e\u0449\u043d\u0443\u044e \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u0445:<\/p>\n<pre><code>ESP_LOGE(TAG, \"Error! code=%d\", err_code);    \/\/ Error   (E) ESP_LOGW(TAG, \"Warning: %s\", warn_msg);       \/\/ Warning (W) ESP_LOGI(TAG, \"Info: init complete\");         \/\/ Info    (I) ESP_LOGD(TAG, \"Debug: x=%d, y=%d\", x, y);     \/\/ Debug   (D) ESP_LOGV(TAG, \"Verbose: raw data=%02X\", b);   \/\/ Verbose (V)<\/code><\/pre>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0423\u0440\u043e\u0432\u0435\u043d\u044c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>ERROR<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0431\u043e\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>WARN<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>INFO<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f (\u0441\u0442\u0430\u0440\u0442, \u0441\u0442\u043e\u043f, \u2026)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>DEBUG<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u0435\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>VERBOSE<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<ul>\n<li>\n<p><code><strong>TAG<\/strong><\/code> (\u043e\u0431\u044b\u0447\u043d\u043e <code>static const char* TAG = \"MyModule\";<\/code>) \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043a\u043e\u0434\u0430 \u0438 <strong>\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c<\/strong> \u0438\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c \u043b\u043e\u0433\u0435 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f <strong>\u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c<\/strong>, <strong>\u0443\u0440\u043e\u0432\u043d\u0435\u043c<\/strong> \u0438 <strong>\u0442\u0435\u0433\u043e\u043c<\/strong>:<\/p>\n<\/li>\n<\/ul>\n<pre><code>I (1234) MyModule: Info: init complete<\/code><\/pre>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0434\u043e\u043f\u044b\u0442\u043d\u043e\u0433\u043e \u0431\u0435\u0440\u0435\u043c \u043d\u0430\u0448 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 <a href=\"https:\/\/habr.com\/ru\/articles\/919362\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439<\/a> \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043b\u044f \u043c\u0438\u0433\u0430\u043d\u0438\u044f \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u043c:<\/p>\n<pre><code>#include \"freertos\/FreeRTOS.h\" #include \"freertos\/task.h\"            #include \"driver\/gpio.h\"   #include \"esp_log.h\"             #define LED_GPIO GPIO_NUM_2 \/\/ \u041f\u043e\u0440\u0442 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 static const char* TAG = \"blink_task\"; \/\/ \u0422\u044d\u0433  TaskHandle_t Blink_Handle = NULL; \/\/ \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 Blink  void Blink_Task(void *arg){     esp_rom_gpio_pad_select_gpio(LED_GPIO); \/\/ \"\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\" \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c GPIO     gpio_set_direction(LED_GPIO, GPIO_MODE_OUTPUT); \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u0432\u044b\u0445\u043e\u0434          bool led_on = false;     while (1) {         led_on = !led_on;         gpio_set_level(LED_GPIO, led_on);         ESP_LOGI(TAG, \"LED is now %s\", led_on ? \"ON\" : \"OFF\");         vTaskDelay(pdMS_TO_TICKS(500));     } }   void app_main() {     xTaskCreate(         Blink_Task,     \/\/ \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u2011\u0437\u0430\u0434\u0430\u0447\u0443         \"BLINK\",        \/\/ \u0438\u043c\u044f \u0437\u0430\u0434\u0430\u0447\u0438 (\u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438)         4096,           \/\/ \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0435\u043a\u0430         NULL,           \/\/ \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e (\u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d)         10,             \/\/ \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0438         &amp;Blink_Handle   \/\/ \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0448\u0443\u0442 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438     ); }<\/code><\/pre>\n<figure class=\"\">\n<div><figcaption>\u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<h2>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 Queue<\/h2>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 1<\/h2>\n<p>\u0414\u0443\u043c\u0430\u044e \u0432\u0430\u043c \u0432\u0441\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0438 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 5 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code>static QueueHandle_t int_queue = NULL; \/\/ \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438. int_queue = xQueueCreate(5, sizeof(int)); \/\/ \u0421\u043e\u0430\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 5 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0435\u043c 2 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 (\u0437\u0430\u0434\u0430\u0447\u0438), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u044d\u0442\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u044c\u044e. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043e\u0434\u043d\u0430 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 &#8212; <strong>Producer<\/strong> \u0431\u0443\u0434\u0435\u0442 \u043a\u043b\u0430\u0441\u0442\u044c (\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c) \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0430 \u0432\u0442\u043e\u0440\u0430\u044f &#8212; <strong>Consumer<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0435\u0433\u043e. <\/p>\n<h3>\u0417\u0430\u0434\u0430\u0447\u0430-\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c (Producer)<\/h3>\n<pre><code>void producer_task(void *arg) {     int counter = 0;     while (1) {         if (xQueueSend(int_queue, &amp;counter, pdMS_TO_TICKS(100)) == pdTRUE) {             ESP_LOGI(TAG, \"Sent: %d\", counter);             counter++;         } else {             ESP_LOGW(TAG, \"Queue full, could not send\");         }         vTaskDelay(pdMS_TO_TICKS(1000));     } } <\/code><\/pre>\n<ul>\n<li>\n<p><code><strong>counter<\/strong><\/code> \u2014 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 (<code>counter++<\/code>).<\/p>\n<\/li>\n<li>\n<p><code><strong>xQueueSend<\/strong><\/code> \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>counter<\/code> \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c <code>int_queue<\/code>.<\/p>\n<\/li>\n<li>\n<p><code>pdMS_TO_TICKS(100)<\/code> \u2014 <strong>\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f<\/strong>, \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430-\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 <strong>\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f<\/strong>, \u043e\u0436\u0438\u0434\u0430\u044f <strong>\u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430<\/strong> \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0443\u0436\u0435 \u043f\u043e\u043b\u043d\u0430.<\/p>\n<ul>\n<li>\n<p><strong>\u0415\u0441\u043b\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0441\u043b\u043e\u0442<\/strong>, <code>xQueueSend<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 <code>pdTRUE<\/code> <strong>\u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e<\/strong>, \u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443, <strong>\u043d\u0435 \u0434\u043e\u0436\u0438\u0434\u0430\u044f\u0441\u044c<\/strong> 100 \u043c\u0441.<\/p>\n<\/li>\n<li>\n<p><strong>\u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u043b\u043d\u0430<\/strong>, \u0442\u0430\u0441\u043a\u0430 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 Blocked \u0438 \u0431\u0443\u0434\u0435\u0442 <strong>\u0436\u0434\u0430\u0442\u044c \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0441\u0442\u0430<\/strong> \u0434\u043e \u0442\u0435\u0445 \u0441\u0430\u043c\u044b\u0445 100 \u043c\u0441.<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430 \u044d\u0442\u0438 100 \u043c\u0441 \u0441\u043b\u043e\u0442 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u0441\u044f (\u0432\u0437\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438), <code>xQueueSend<\/code> \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442 \u0432\u0430\u0448 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438 \u0432\u0435\u0440\u043d\u0451\u0442 <code>pdTRUE<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0437\u0430 100 \u043c\u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0442\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0439, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0451\u0442 <code>pdFALSE<\/code> (\u043e\u0448\u0438\u0431\u043a\u0430 <code>errQUEUE_FULL<\/code>), \u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u043b\u043e\u0433\u0435 \u00abQueue full, could not send\u00bb.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><code><strong>vTaskDelay(pdMS_TO_TICKS(1000))<\/strong><\/code> \u2014 \u0437\u0430\u0434\u0430\u0447\u0430 \u0437\u0430\u0441\u044b\u043f\u0430\u0435\u0442 \u043d\u0430 1000 \u043c\u0441.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0417\u0430\u0434\u0430\u0447\u0430-\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c (Consumer)<\/h3>\n<pre><code>void consumer_task(void *arg) {     int received;     while (1) {         if (xQueueReceive(int_queue, &amp;received, portMAX_DELAY) == pdTRUE) {             ESP_LOGI(TAG, \"Received: %d\", received);         }     } } <\/code><\/pre>\n<ul>\n<li>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 <strong>\u0436\u0434\u0451\u0442<\/strong> (<code>portMAX_DELAY<\/code> \u2014 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e) \u043f\u043e\u043a\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e <code>xQueueReceive<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>pdTRUE<\/code>, \u0432 <code>received<\/code> \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u2014 \u0435\u0433\u043e \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>\u0426\u0438\u043a\u043b \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f, \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043d\u043e\u0432\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h3>\n<pre><code>#include \"freertos\/FreeRTOS.h\" #include \"freertos\/task.h\" #include \"freertos\/queue.h\" #include \"esp_log.h\"  static const char *TAG = \"queue_example\";  \/\/ \u0425\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438 static QueueHandle_t int_queue = NULL; \/\/ \u0425\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 producer_task (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e) TaskHandle_t Producer_Handle = NULL;  \/\/ \u0425\u044d\u043d\u0434\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 consumer_task (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e) TaskHandle_t Consumer_Handle = NULL;   \/\/ Producer: \u043a\u0430\u0436\u0434\u044b\u0435 1000 \u043c\u0441 \u043a\u043b\u0430\u0434\u0451\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a void producer_task(void *arg) {     int counter = 0;     while (1) {         if (xQueueSend(int_queue, &amp;counter, pdMS_TO_TICKS(100)) == pdTRUE) {             ESP_LOGI(TAG, \"Sent: %d\", counter);             counter++;         } else {             ESP_LOGW(TAG, \"Queue full, could not send\");         }         vTaskDelay(pdMS_TO_TICKS(1000));     } }  \/\/ Consumer: \u0436\u0434\u0451\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0435\u0433\u043e void consumer_task(void *arg) {     int received;     while (1) {         \/\/ \u0436\u0434\u0435\u043c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442 \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435         if (xQueueReceive(int_queue, &amp;received, portMAX_DELAY) == pdTRUE) {             ESP_LOGI(TAG, \"Received: %d\", received);         }     } }  void app_main(void) {     \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 5 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 int     int_queue = xQueueCreate(5, sizeof(int));     \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0430, \u0438\u043d\u0430\u0447\u0435 \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043c     if (int_queue == NULL) {         ESP_LOGE(TAG, \"Failed to create queue\");         return;     }      \/*         \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0432         \u0423\u0447\u0438\u043c\u0441\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c)     *\/     if (xTaskCreate(producer_task, \"producer\", 2048, NULL, 5, &amp;Producer_Handle) != pdPASS) {         ESP_LOGE(TAG, \"Failed to create producer task\");     }     if (xTaskCreate(consumer_task, \"consumer\", 2048, NULL, 5, &amp;Consumer_Handle) != pdPASS) {         ESP_LOGE(TAG, \"Failed to create consumer task\");     } }<\/code><\/pre>\n<figure class=\"\">\n<div><figcaption>queue_example<\/figcaption><\/div>\n<\/figure>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 2<\/h2>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 <strong>ISR<\/strong> \u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432 \u043d\u0430\u0448\u0435\u043c <a href=\"https:\/\/habr.com\/ru\/articles\/919362\/#:~:text=%D0%BF%D0%BE%D0%BC%D0%BE%D1%89%D1%8C%D1%8E%20IRAM_ATTR.-,%D0%9F%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D0%BA%D0%B0,-%D0%9D%D0%B0%D1%88%D0%B0%20%D1%86%D0%B5%D0%BB%D1%8C%20%E2%80%94%20%D1%80%D0%B5%D0%B0%D0%BB%D0%B8%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D1%8C\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0434\u0435<\/a>:<\/p>\n<ul>\n<li>\n<p>\u041d\u0435\u0442<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-464368","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/464368","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=464368"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/464368\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=464368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=464368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=464368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}