{"id":463734,"date":"2025-06-18T21:00:11","date_gmt":"2025-06-18T21:00:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=463734"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=463734","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 #1<\/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 \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u043f\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e ESP32 \u043d\u0430 ESP\u2011IDF. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439 RTOS \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 (tasks). \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0436\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 GPIO \u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f\u043c\u0438 (ISR), \u0430 \u0437\u0430\u043e\u0434\u043d\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u0442\u0435\u043a\u0430 \u0437\u0430\u0434\u0430\u0447 \u0432 ESP\u2011IDF (\u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0441\u043e\u0432\u0435\u0442 <a class=\"mention\" href=\"\/users\/0x6b73ca\">@0x6b73ca<\/a>).<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6c5\/030\/157\/6c5030157db90bd3a72d7135db611d76.png\" width=\"2938\" height=\"1614\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/6c5\/030\/157\/6c5030157db90bd3a72d7135db611d76.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6c5\/030\/157\/6c5030157db90bd3a72d7135db611d76.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<hr\/>\n<h2>\u0421\u0442\u0435\u043a<\/h2>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<blockquote>\n<p><strong><em>FreeRTOS<\/em><\/strong><\/p>\n<p>\u201c<a href=\"https:\/\/www.freertos.org\/Documentation\/02-Kernel\/04-API-references\/01-Task-creation\/01-xTaskCreate?utm_source=chatgpt.com\" rel=\"noopener noreferrer nofollow\">The number of words (not bytes!) to allocate for use as the task\u2019s stack. For example, if the stack is 16\u2011bits wide and <code>uxStackDepth<\/code> is 100, then 200 bytes will be allocated.<\/a>\u201d<\/p>\n<p>\u0412 FreeRTOS \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u0441\u043b\u043e\u0432\u0430\u0445.<\/p>\n<\/blockquote>\n<blockquote>\n<p><strong><em>ESP-IDF<\/em><\/strong><\/p>\n<p>&#171;<a href=\"https:\/\/docs.espressif.com\/projects\/esp-idf\/en\/v4.3\/esp32\/api-reference\/system\/freertos.html\" rel=\"noopener noreferrer nofollow\"><code>usStackDepth<\/code>\u00a0\u2013 The size of the task stack specified as the number of bytes.  Note that this differs from vanilla FreeRTOS.<\/a>&#171;<\/p>\n<p>\u0412 ESP-IDF \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u0431\u0430\u0439\u0442\u0430\u0445.<\/p>\n<\/blockquote>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c FreeRTOS \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>usStackDepth<\/code>\u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f <strong>\u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0445 \u0441\u043b\u043e\u0432\u0430\u0445<\/strong> (StackType_t), \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0432 ESP\u2011IDF \u0442\u043e\u0442 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442\u0441\u044f <strong>\u0432 \u0431\u0430\u0439\u0442\u0430\u0445<\/strong>. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u0441\u0442\u0435\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<hr\/>\n<h2>GPIO<\/h2>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0430\u043a\u0442 (pad) ESP32 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2014 \u043e\u0442 \u0410\u0426\u041f \u0438 touch\u2011\u0441\u0435\u043d\u0441\u043e\u0440\u0430 \u0434\u043e UART, SPI \u0438 LED\u2011\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c pad \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0432\u0432\u043e\u0434\u2011\u0432\u044b\u0432\u043e\u0434, \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e <strong>\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c<\/strong> \u0432 \u0440\u0435\u0436\u0438\u043c GPIO.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0443\u0436\u0438\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/p>\n<pre><code>esp_rom_gpio_pad_select_gpio(pin);<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (ADC, touch, UART, SPI, LEDC \u0438 \u043f\u0440\u043e\u0447\u0438\u0435) \u0438 \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 pad \u043a \u043c\u043e\u0434\u0443\u043b\u044e GPIO.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0443\u0440\u043e\u0432\u043d\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 API. \u041d\u0438\u0436\u0435 \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 GPIO:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 GPIO<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f<\/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>esp_rom_gpio_pad_select_gpio(gpio_num)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 pad \u043a \u043c\u043e\u0434\u0443\u043b\u044e GPIO, \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0441\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_reset_pin(gpio_num)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043f\u0438\u043d\u0430 \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e (\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>esp_rom_gpio_pad_select_gpio<\/code>).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_set_direction(gpio_num, mode)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435: <code>GPIO_MODE_INPUT<\/code>, <code>GPIO_MODE_OUTPUT<\/code>\u0438 \u0434\u0440.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_set_level(gpio_num, level)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c (0 \u0438\u043b\u0438 1) \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u043f\u0438\u043d\u0435.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_get_level(gpio_num)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0427\u0438\u0442\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 (0\/1) \u043d\u0430 \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0438\u043b\u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u043f\u0438\u043d\u0435.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_config(&amp;gpio_config_t)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u043e\u0432\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f: \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043f\u043e\u0434\u0442\u044f\u0436\u043a\u0438, \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, \u043c\u0430\u0441\u043a\u0430 \u043f\u0438\u043d\u043e\u0432.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_pullup_en(gpio_num)<\/strong><\/code><strong> \/ <\/strong><code><strong>gpio_pullup_dis(gpio_num)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 pull\u2011up \u0440\u0435\u0437\u0438\u0441\u0442\u043e\u0440.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_pulldown_en(gpio_num)<\/strong><\/code><strong> \/ <\/strong><code><strong>gpio_pulldown_dis(gpio_num)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 pull\u2011down \u0440\u0435\u0437\u0438\u0441\u0442\u043e\u0440.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>\u041f\u043e\u043c\u0438\u0433\u0430\u0435\u043c)<\/h2>\n<h3>\u0410 \u0447\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0438\u0433\u0430\u0435\u043c?<\/h3>\n<p>\u041d\u0430 \u043f\u043b\u0430\u0442\u0435 <strong>NodeMCU\u201132S<\/strong> (\u0438 \u043d\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u00abdevkit\u00bb-\u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u0434\u043b\u044f ESP32) <strong>\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434<\/strong> \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d \u043a \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0443 <strong>GPIO2<\/strong>. \u0422\u0430\u043a\u0436\u0435 \u0441\u0440\u0430\u0437\u0443 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u0438\u0433\u0430\u043d\u0438\u044f:<\/p>\n<pre><code>#define LED_GPIO GPIO_NUM_2 \/\/ \u041f\u043e\u0440\u0442 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 TaskHandle_t Blink_Handle = NULL; \/\/ \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 Blink<\/code><\/pre>\n<h3>Blink_Task<\/h3>\n<p>\u0414\u0443\u043c\u0430\u044e, \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0437\u0430\u0434\u0430\u0447, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<pre><code>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          while(1){         gpio_set_level(LED_GPIO, 1);        \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c 1         vTaskDelay(pdMS_TO_TICKS(1000));    \/\/ \u0416\u0434\u0435\u043c         gpio_set_level(LED_GPIO, 0);        \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c 0         vTaskDelay(pdMS_TO_TICKS(1000));    \/\/ \u0416\u0434\u0435\u043c     } }<\/code><\/pre>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h3>\n<pre><code>#include \"freertos\/FreeRTOS.h\" #include \"freertos\/task.h\"            #include \"driver\/gpio.h\"               #define LED_GPIO GPIO_NUM_2 \/\/ \u041f\u043e\u0440\u0442 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430  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          while(1){         gpio_set_level(LED_GPIO, 1);        \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c 1         vTaskDelay(pdMS_TO_TICKS(1000));    \/\/ \u0416\u0434\u0435\u043c         gpio_set_level(LED_GPIO, 0);        \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c 0         vTaskDelay(pdMS_TO_TICKS(1000));    \/\/ \u0416\u0434\u0435\u043c     } }   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\/91f\/289\/f06\/91f289f063c64e6a1d6fbb03f1e1d90b.gif\" alt=\"Blink\" title=\"Blink\" width=\"460\" height=\"584\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/91f\/289\/f06\/91f289f063c64e6a1d6fbb03f1e1d90b.gif 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/91f\/289\/f06\/91f289f063c64e6a1d6fbb03f1e1d90b.gif 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>Blink<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<h2>\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f (ISR)<\/h2>\n<p><strong>\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 (Interrupt)<\/strong> \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 (ISR). <\/p>\n<p>\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u044b\u0432\u0430\u044e\u0442 \u0434\u0432\u0443\u0445 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><strong>\u0410\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0435<\/strong> \u2014 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0436\u0435\u043b\u0435\u0437\u043e\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0439\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 GPIO, \u0442\u0430\u0439\u043c\u0435\u0440\u0430\u043c\u0438, UART);<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0435<\/strong> \u2014 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0432 \u043a\u043e\u0434\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0439 \u00ab\u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u00bb \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a.<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432 ESP32 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c <strong>\u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 (IPC)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<ol>\n<li>\n<p><strong>Task Context<\/strong> \u2014 \u043a\u043e\u043b\u0431\u044d\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 IPC\u2011\u0442\u0430\u0441\u043a\u0438, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 FreeRTOS \u0438 ESP\u2011IDF.<\/p>\n<\/li>\n<li>\n<p><strong>ISR Context<\/strong> \u2014 \u0432\u044b\u0437\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0440\u0430\u0437\u0443 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f (Inter\u2011Processor Interrupt). \u0412 \u044d\u0442\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043a\u043e\u043b\u0431\u044d\u043a <strong>\u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 IRAM<\/strong> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0444\u043b\u0435\u0448\u2011\u043a\u0435\u0448\u0430 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e IPC:<br \/> <a href=\"https:\/\/docs.espressif.com\/projects\/esp-idf\/en\/stable\/esp32\/api-reference\/system\/ipc.html\" rel=\"noopener noreferrer nofollow\">https:\/\/docs.espressif.com\/projects\/esp-idf\/en\/stable\/esp32\/api-reference\/system\/ipc.html<\/a><\/p>\n<\/blockquote>\n<h3>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0432 ESP-IDF<\/h3>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0438\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 ISR:<\/p>\n<pre><code>gpio_set_intr_type(gpio_num, intr_type);<\/code><\/pre>\n<ul>\n<li>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong>: \u0437\u0430\u0434\u0430\u0451\u0442 \u0442\u0438\u043f \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f (\u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443) \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e GPIO\u2011\u043f\u0438\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>gpio_num<\/code>\u00a0\u2013 \u043d\u043e\u043c\u0435\u0440 \u043f\u0438\u043d\u0430 (<code>GPIO_NUM_0<\/code> \u2026 <code>GPIO_NUM_39<\/code>).<\/p>\n<\/li>\n<li>\n<p><code>intr_type<\/code> &#8212; \u0442\u0438\u043f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><code>GPIO_INTR_DISABLE<\/code> &#8212; \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><code>GPIO_INTR_POSEDGE<\/code> &#8212; \u043f\u043e <strong>\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443<\/strong> \u0444\u0440\u043e\u043d\u0442\u0443<\/p>\n<\/li>\n<li>\n<p><code>GPIO_INTR_NEGEDGE<\/code> &#8212; \u043f\u043e <strong>\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443<\/strong> \u0444\u0440\u043e\u043d\u0442\u0443<\/p>\n<\/li>\n<li>\n<p><code>GPIO_INTR_ANYEDGE<\/code> &#8212; \u043f\u043e <strong>\u043b\u044e\u0431\u043e\u043c\u0443<\/strong> \u0444\u0440\u043e\u043d\u0442\u0443 <\/p>\n<\/li>\n<li>\n<p><code>GPIO_INTR_LOW_LEVEL<\/code> &#8212; \u043f\u043e \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044e <strong>\u043d\u0438\u0437\u043a\u043e\u0433\u043e<\/strong> \u0443\u0440\u043e\u0432\u043d\u044f<\/p>\n<\/li>\n<li>\n<p><code>GPIO_INTR_HIGH_LEVEL<\/code> &#8212; \u043f\u043e \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044e <strong>\u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e<\/strong> \u0443\u0440\u043e\u0432\u043d\u044f<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 GPIO\u2011\u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u0442\u0435\u0440\u043c\u0438\u043d <strong>\u00ab\u0444\u0440\u043e\u043d\u0442\u00bb<\/strong> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 <strong>\u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/strong> \u0443\u0440\u043e\u0432\u043d\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u0430, \u0430 <strong>\u00ab\u0443\u0440\u043e\u0432\u0435\u043d\u044c\u00bb<\/strong> (level) \u2014 <strong>\u0441\u0430\u043c \u0444\u0430\u043a\u0442 \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f<\/strong> \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0432 \u0442\u043e\u043c \u0438\u043b\u0438 \u0438\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code><strong>GPIO_INTR_POSEDGE<\/strong><\/code> (\u00ab\u043f\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443\u00bb) \u2014 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 <strong>\u043e\u0434\u0438\u043d \u0440\u0430\u0437<\/strong> \u0432 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u043b <strong>\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 0 \u0432 1<\/strong> (\u043d\u0438\u0437\u043a\u0438\u0439 \u2192 \u0432\u044b\u0441\u043e\u043a\u0438\u0439). <code><strong>GPIO_INTR_ANYEDGE<\/strong><\/code> (\u00ab\u043f\u043e \u043b\u044e\u0431\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443\u00bb) \u2014 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 0\u21921, \u0442\u0430\u043a \u0438 \u043f\u0440\u0438 1\u21920.<\/p>\n<\/blockquote>\n<pre><code>gpio_install_isr_service(intr_alloc_flags);<\/code><\/pre>\n<ul>\n<li>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong>: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 <strong>\u043e\u0431\u0449\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 GPIO<\/strong>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0437\u0430\u0442\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 (<code>gpio_isr_handler_add<\/code>) \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0438\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/strong> <code>intr_alloc_flags<\/code> :<\/p>\n<ul>\n<li>\n<p><code>0<\/code>\u00a0\u2013 \u0431\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432 (\u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0438 \u0440\u0435\u0436\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439)<\/p>\n<\/li>\n<li>\n<p><code>ESP_INTR_FLAG_IRAM<\/code> &#8212; \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0432 IRAM<\/p>\n<\/li>\n<li>\n<p><code>ESP_INTR_FLAG_LOWMED<\/code> &#8212; \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \/ \u043d\u0438\u0437\u043a\u0438\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0412\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0444\u043b\u0430\u0433 <code>ESP_INTR_FLAG_IRAM<\/code> \u0432 <code>gpio_install_isr_service()<\/code>, \u0432\u044b <strong>\u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0435<\/strong>, \u0447\u0442\u043e:<\/p>\n<ul>\n<li>\n<p><strong>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f (ISR)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u043f\u043e\u0437\u0436\u0435, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f <strong>\u0438\u0437 IRAM<\/strong>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u0441\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u0430 ISR<\/strong> \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u044b \u0432 IRAM.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 SPI Flash \u0438\u043b\u0438 DMA) <strong>\u043a\u0435\u0448 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u043a\u043b\u044e\u0447\u0451\u043d<\/strong>, \u0438 \u043a\u043e\u0434, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u0441\u044f \u0432\u043e \u0444\u043b\u0435\u0448\u2011\u043f\u0430\u043c\u044f\u0442\u0438, \u0441\u0442\u0430\u043d\u0435\u0442 <strong>\u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c<\/strong>. \u0415\u0441\u043b\u0438 \u0432 \u0442\u0430\u043a\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443, \u043b\u0435\u0436\u0430\u0449\u0435\u043c\u0443 \u0432\u043e \u0444\u043b\u0435\u0448, \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 <strong>\u043a\u0440\u0430\u0448<\/strong>, <strong>watchdog reset<\/strong> \u0438\u043b\u0438 <strong>undefined behavior<\/strong>.<\/p>\n<\/blockquote>\n<blockquote>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u043f\u043e\u0437\u0430\u0431\u044b\u043b \u0438\u043b\u0438 \u043d\u0435 \u0437\u043d\u0430\u043b:<\/p>\n<p><strong>IRAM (Internal RAM)<\/strong> \u2014 \u044d\u0442\u043e <strong>\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0431\u044b\u0441\u0442\u0440\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c<\/strong> \u0432\u043d\u0443\u0442\u0440\u0438 ESP32. \u041e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 <strong>\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0439 SPI Flash<\/strong>, \u0447\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0439 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439.<\/p>\n<\/blockquote>\n<pre><code>gpio_isr_handler_add(gpio_num, isr_handler, args);<\/code><\/pre>\n<ul>\n<li>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong>: \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 <strong>\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<\/strong> (<code>isr_handler<\/code>) \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 GPIO\u2011\u043f\u0438\u043d.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/strong> <\/p>\n<ul>\n<li>\n<p><code>gpio_num<\/code> \u2014 \u043d\u043e\u043c\u0435\u0440 \u043f\u0438\u043d\u0430 (<code>GPIO_NUM_0<\/code> \u2026 <code>GPIO_NUM_39<\/code>)<\/p>\n<\/li>\n<li>\n<p><code>isr_handler<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 <strong>\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<\/strong><\/p>\n<\/li>\n<li>\n<p><code>args<\/code> \u2014 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u0432 <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/strong><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><code>gpio_intr_enable(gpio_num);<\/code><\/pre>\n<ul>\n<li>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong>: \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e GPIO-\u043f\u0438\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <\/strong><code>gpio_num<\/code> \u2014 \u043d\u043e\u043c\u0435\u0440 GPIO-\u043f\u0438\u043d\u0430.<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0432\u044b\u0437\u0432\u0430\u043b\u0438 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e (\u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u0435\u0433\u043e \u0440\u0430\u043d\u0435\u0435).<\/p>\n<p><code>gpio_intr_disable()<\/code>&#8212; \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/blockquote>\n<pre><code>\/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f void IRAM_ATTR gpio_isr_handler(void* arg) { }<\/code><\/pre>\n<blockquote>\n<p>IRAM_ATTR \u2014 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 (\u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440), \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 IRAM, \u0430 \u043d\u0435 \u0432\u043e \u0444\u043b\u0435\u0448.<\/p>\n<\/blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a \u0432\u043e\u043f\u0440\u043e\u0441 (\u043d\u0443 \u0432\u0434\u0440\u0443\u0433 \u00af\\_(\u30c4)_\/\u00af): <strong>\u00ab\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d <\/strong><code><strong>IRAM_ATTR<\/strong><\/code><strong>, \u0435\u0441\u043b\u0438 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c <\/strong><code><strong>ESP_INTR_FLAG_IRAM<\/strong><\/code><strong>?\u00bb<\/strong>, \u0442\u043e \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c.<\/p>\n<p>\u0424\u043b\u0430\u0433 <code>ESP_INTR_FLAG_IRAM<\/code> <strong>\u043e\u0431\u044f\u0437\u044b\u0432\u0430\u0435\u0442<\/strong> \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043b\u0435\u0436\u0430\u0449\u0438\u0439 \u0432 IRAM \u2014 \u043d\u043e <strong>\u0441\u0430\u043c \u043e\u043d \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442 \u0432\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0442\u0443\u0434\u0430!<\/strong> \u0427\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 <strong>\u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u043b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0432 IRAM<\/strong>, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u044f\u0432\u043d\u043e \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u2014 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>IRAM_ATTR<\/code>.<\/p>\n<hr\/>\n<h2>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/h2>\n<p>\u041d\u0430\u0448\u0430 \u0446\u0435\u043b\u044c \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 \u043a\u043d\u043e\u043f\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 <code>Blink_Task<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u0438\u0441\u0430\u043b\u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435:<\/p>\n<pre><code>uint8_t state = 0;                \/\/ \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0445\u0440\u0430\u043d\u044f\u0449\u0430\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 LED (0\u00a0\u2013 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d, 1\u00a0\u2013 \u0432\u043a\u043b\u044e\u0447\u0451\u043d)  TaskHandle_t Blink_Handle = NULL; \/\/ \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 Blink  \/\/ \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) {     while (1) {         gpio_set_level(LED_GPIO, state);     } }<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 <code>state<\/code>. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0439:<\/p>\n<pre><code>\/*     \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043e\u0442 \u043a\u043d\u043e\u043f\u043a\u0438.     \u041f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e state.     IRAM_ATTR \u2014 \u0430\u0442\u0440\u0438\u0431\u0443\u0442, \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 IRAM,     \u0430 \u043d\u0435 \u0432\u043e \u0444\u043b\u0435\u0448 (\u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0441\u0442\u0438 ISR). *\/ static void IRAM_ATTR gpio_isr_handler(void *arg) {     state = !state; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0430\u0436\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<ol>\n<li>\n<p><strong>\u0417\u0430\u0434\u0430\u0451\u043c \u0442\u0438\u043f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f:<\/strong><br \/> <code>gpio_set_intr_type(gpio_num, intr_type);<\/code><\/p>\n<\/li>\n<li>\n<p><strong>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0449\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439:<\/strong><br \/> <code>gpio_install_isr_service(intr_alloc_flags);<\/code><\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043f\u0438\u043d\u0430:<\/strong><br \/> <code>gpio_isr_handler_add(gpio_num, isr_handler, args);<\/code><\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u0438\u043d\u0430:<\/strong><br \/> <code>gpio_intr_enable(gpio_num);<\/code><\/p>\n<\/li>\n<\/ol>\n<pre><code>#include \"freertos\/FreeRTOS.h\" #include \"freertos\/task.h\" #include \"driver\/gpio.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  uint8_t state = 0;                 \/\/ \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0445\u0440\u0430\u043d\u044f\u0449\u0430\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 LED (0\u00a0\u2013 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d, 1\u00a0\u2013 \u0432\u043a\u043b\u044e\u0447\u0451\u043d)  TaskHandle_t Blink_Handle = NULL;  \/\/ \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 Blink  \/\/ \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) {     while (1) {         gpio_set_level(LED_GPIO, state);     } }  \/*     \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043e\u0442 \u043a\u043d\u043e\u043f\u043a\u0438.     \u041f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e state.     IRAM_ATTR \u2014 \u0430\u0442\u0440\u0438\u0431\u0443\u0442, \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 IRAM,     \u0430 \u043d\u0435 \u0432\u043e \u0444\u043b\u0435\u0448 (\u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0441\u0442\u0438 ISR). *\/ static void IRAM_ATTR gpio_isr_handler(void *arg) {     state = !state; }  void app_main() {     esp_rom_gpio_pad_select_gpio(LED_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(LED_GPIO, GPIO_MODE_OUTPUT);  \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 LED_GPIO \u043a\u0430\u043a \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0432\u044b\u0432\u043e\u0434      gpio_set_level(LED_GPIO, 0);   \/\/ \u0441\u0440\u0430\u0437\u0443 \u0433\u0430\u0441\u0438\u043c      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 \u0432\u0445\u043e\u0434\u0430      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      gpio_intr_enable(BUTTON_GPIO);  \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043d\u043e\u043f\u043a\u0438      \/\/ \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     xTaskCreate(         Blink_Task,       \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u2011\u0437\u0430\u0434\u0430\u0447\u0430         \"BLINK\",          \/\/ \u0438\u043c\u044f (\u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438)         2048,             \/\/ \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0435\u043a\u0430 (\u0432 \u0431\u0430\u0439\u0442\u0430\u0445)         NULL,             \/\/ \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0437\u0430\u0434\u0430\u0447\u0438         5,                \/\/ \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442         &amp;Blink_Handle     \/\/ \u0441\u044e\u0434\u0430 \u0437\u0430\u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0445\u044d\u043d\u0434\u043b \u0437\u0430\u0434\u0430\u0447\u0438     ); } <\/code><\/pre>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/137\/155\/6d3\/1371556d343ee3bc5d01a0f28aee86e9.gif\" alt=\"ISR\" title=\"ISR\" width=\"448\" height=\"598\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/137\/155\/6d3\/1371556d343ee3bc5d01a0f28aee86e9.gif 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/137\/155\/6d3\/1371556d343ee3bc5d01a0f28aee86e9.gif 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>ISR<\/figcaption><\/div>\n<\/figure>\n<blockquote>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 <code>gpio_intr_enable()<\/code> <a href=\"https:\/\/embetronicx.com%20+11%20esp32.com%20+11%20docs.espressif.com%20+11\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c<\/a>)<\/p>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430<\/strong>, \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 <code>gpio_isr_handler_add()<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0430 <strong>\u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435<\/strong>.<\/p>\n<\/blockquote>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\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, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u0442\u0430\u043b \u043f\u043e\u043b\u0435\u0437\u043d\u0435\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445, \u043a\u0442\u043e \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 ESP-IDF.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 \u043c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 ESP-IDF: \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 <strong>\u0428\u0418\u041c (PWM)<\/strong> \u0438 <strong>\u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u043e-\u0446\u0438\u0444\u0440\u043e\u0432\u044b\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c (ADC)<\/strong>. <\/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\/919362\/\"> https:\/\/habr.com\/ru\/articles\/919362\/<\/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 \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u043f\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e ESP32 \u043d\u0430 ESP\u2011IDF. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439 RTOS \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 (tasks). \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0436\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 GPIO \u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f\u043c\u0438 (ISR), \u0430 \u0437\u0430\u043e\u0434\u043d\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u0442\u0435\u043a\u0430 \u0437\u0430\u0434\u0430\u0447 \u0432 ESP\u2011IDF (\u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0441\u043e\u0432\u0435\u0442 <a class=\"mention\" href=\"\/users\/0x6b73ca\">@0x6b73ca<\/a>).<\/p>\n<figure class=\"full-width\"><\/figure>\n<hr\/>\n<h2>\u0421\u0442\u0435\u043a<\/h2>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<blockquote>\n<p><strong><em>FreeRTOS<\/em><\/strong><\/p>\n<p>\u201c<a href=\"https:\/\/www.freertos.org\/Documentation\/02-Kernel\/04-API-references\/01-Task-creation\/01-xTaskCreate?utm_source=chatgpt.com\" rel=\"noopener noreferrer nofollow\">The number of words (not bytes!) to allocate for use as the task\u2019s stack. For example, if the stack is 16\u2011bits wide and <code>uxStackDepth<\/code> is 100, then 200 bytes will be allocated.<\/a>\u201d<\/p>\n<p>\u0412 FreeRTOS \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u0441\u043b\u043e\u0432\u0430\u0445.<\/p>\n<\/blockquote>\n<blockquote>\n<p><strong><em>ESP-IDF<\/em><\/strong><\/p>\n<p>&#171;<a href=\"https:\/\/docs.espressif.com\/projects\/esp-idf\/en\/v4.3\/esp32\/api-reference\/system\/freertos.html\" rel=\"noopener noreferrer nofollow\"><code>usStackDepth<\/code>\u00a0\u2013 The size of the task stack specified as the number of bytes.  Note that this differs from vanilla FreeRTOS.<\/a>&#171;<\/p>\n<p>\u0412 ESP-IDF \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u0431\u0430\u0439\u0442\u0430\u0445.<\/p>\n<\/blockquote>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c FreeRTOS \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>usStackDepth<\/code>\u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f <strong>\u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0445 \u0441\u043b\u043e\u0432\u0430\u0445<\/strong> (StackType_t), \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0432 ESP\u2011IDF \u0442\u043e\u0442 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442\u0441\u044f <strong>\u0432 \u0431\u0430\u0439\u0442\u0430\u0445<\/strong>. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u0441\u0442\u0435\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<hr\/>\n<h2>GPIO<\/h2>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0430\u043a\u0442 (pad) ESP32 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2014 \u043e\u0442 \u0410\u0426\u041f \u0438 touch\u2011\u0441\u0435\u043d\u0441\u043e\u0440\u0430 \u0434\u043e UART, SPI \u0438 LED\u2011\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c pad \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0432\u0432\u043e\u0434\u2011\u0432\u044b\u0432\u043e\u0434, \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e <strong>\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c<\/strong> \u0432 \u0440\u0435\u0436\u0438\u043c GPIO.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0443\u0436\u0438\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/p>\n<pre><code>esp_rom_gpio_pad_select_gpio(pin);<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (ADC, touch, UART, SPI, LEDC \u0438 \u043f\u0440\u043e\u0447\u0438\u0435) \u0438 \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 pad \u043a \u043c\u043e\u0434\u0443\u043b\u044e GPIO.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0443\u0440\u043e\u0432\u043d\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 API. \u041d\u0438\u0436\u0435 \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 GPIO:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 GPIO<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f<\/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>esp_rom_gpio_pad_select_gpio(gpio_num)<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 pad \u043a \u043c\u043e\u0434\u0443\u043b\u044e GPIO, \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0441\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_reset_pin(gpio_num)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043f\u0438\u043d\u0430 \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e (\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>esp_rom_gpio_pad_select_gpio<\/code>).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_set_direction(gpio_num, mode)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435: <code>GPIO_MODE_INPUT<\/code>, <code>GPIO_MODE_OUTPUT<\/code>\u0438 \u0434\u0440.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_set_level(gpio_num, level)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c (0 \u0438\u043b\u0438 1) \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u043f\u0438\u043d\u0435.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_get_level(gpio_num)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0427\u0438\u0442\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 (0\/1) \u043d\u0430 \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0438\u043b\u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u043f\u0438\u043d\u0435.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_config(&amp;gpio_config_t)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u043e\u0432\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f: \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043f\u043e\u0434\u0442\u044f\u0436\u043a\u0438, \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, \u043c\u0430\u0441\u043a\u0430 \u043f\u0438\u043d\u043e\u0432.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_pullup_en(gpio_num)<\/strong><\/code><strong> \/ <\/strong><code><strong>gpio_pullup_dis(gpio_num)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 pull\u2011up \u0440\u0435\u0437\u0438\u0441\u0442\u043e\u0440.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code><strong>gpio_pulldown_en(gpio_num)<\/strong><\/code><strong> \/ <\/strong><code><strong>gpio_pulldown_dis(gpio_num)<\/strong><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 pull\u2011down \u0440\u0435\u0437\u0438\u0441\u0442\u043e\u0440.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>\u041f\u043e\u043c\u0438\u0433\u0430\u0435\u043c)<\/h2>\n<h3>\u0410 \u0447\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0438\u0433\u0430\u0435\u043c?<\/h3>\n<p>\u041d\u0430 \u043f\u043b\u0430\u0442\u0435 <strong>NodeMCU\u201132S<\/strong> (\u0438 \u043d\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u00abdevkit\u00bb-\u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u0434\u043b\u044f ESP32) <strong>\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434<\/strong> \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d \u043a \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0443 <strong>GPIO2<\/strong>. \u0422\u0430\u043a\u0436\u0435 \u0441\u0440\u0430\u0437\u0443 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u0438\u0433\u0430\u043d\u0438\u044f:<\/p>\n<pre><code>#define LED_GPIO GPIO_NUM_2 \/\/ \u041f\u043e\u0440\u0442 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 TaskHandle_t Blink_Handle = NULL; \/\/ \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 Blink<\/code><\/pre>\n<h3>Blink_Task<\/h3>\n<p>\u0414\u0443\u043c\u0430\u044e, \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0437\u0430\u0434\u0430\u0447, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<pre><code>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          while(1){         gpio_set_level(LED_GPIO, 1);        \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c 1         vTaskDelay(pdMS_TO_TICKS(1000));    \/\/ \u0416\u0434\u0435\u043c         gpio_set_level(LED_GPIO, 0);        \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c 0         vTaskDelay(pdMS_TO_TICKS(1000));    \/\/ \u0416\u0434\u0435\u043c     } }<\/code><\/pre>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h3>\n<pre><code>#include \"freertos\/FreeRTOS.h\" #include \"freertos\/task.h\"            #include \"driver\/gpio.h\"               #define LED_GPIO GPIO_NUM_2 \/\/ \u041f\u043e\u0440\u0442 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430  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          while(1){         gpio_set_level(LED_GPIO, 1);        \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c 1         vTaskDelay(pdMS_TO_TICKS(1000));    \/\/ \u0416\u0434\u0435\u043c         gpio_set_level(LED_GPIO, 0);        \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c 0         vTaskDelay(pdMS_TO_TICKS(1000));    \/\/ \u0416\u0434\u0435\u043c     } }   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>Blink<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<h2>\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f (ISR)<\/h2>\n<p><strong>\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 (Interrupt)<\/strong> \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 (ISR). <\/p>\n<p>\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u044b\u0432\u0430\u044e\u0442 \u0434\u0432\u0443\u0445 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><strong>\u0410\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0435<\/strong> \u2014 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0436\u0435\u043b\u0435\u0437\u043e\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0439\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 GPIO, \u0442\u0430\u0439\u043c\u0435\u0440\u0430\u043c\u0438, UART);<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0435<\/strong> \u2014 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0432 \u043a\u043e\u0434\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0439 \u00ab\u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u00bb \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a.<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432 ESP32 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c <strong>\u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 (IPC)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<ol>\n<li>\n<p><strong>Task Context<\/strong> \u2014 \u043a\u043e\u043b\u0431\u044d\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 IPC\u2011\u0442\u0430\u0441\u043a\u0438, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 FreeRTOS \u0438 ESP\u2011IDF.<\/p>\n<\/li>\n<li>\n<p><strong>ISR Context<\/strong> \u2014 \u0432\u044b\u0437\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0440\u0430\u0437\u0443 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f (Inter\u2011Processor Interrupt). \u0412 \u044d\u0442\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043a\u043e\u043b\u0431\u044d\u043a <strong>\u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 IRAM<\/strong> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0444\u043b\u0435\u0448\u2011\u043a\u0435\u0448\u0430 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e IPC:<br \/> <a href=\"https:\/\/docs.espressif.com\/projects\/esp-idf\/en\/stable\/esp32\/api-reference\/system\/ipc.html\" rel=\"noopener noreferrer nofollow\">https:\/\/docs.espressif.com\/projects\/esp-idf\/en\/stable\/esp32\/api-reference\/system\/ipc.html<\/a><\/p>\n<\/blockquote>\n<h3>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0432 ESP-IDF<\/h3>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0438\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 ISR:<\/p>\n<pre><code>gpio_set_intr_type(gpio_num, intr_type);<\/code><\/pre>\n<ul>\n<li>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong>: \u0437\u0430\u0434\u0430\u0451\u0442 \u0442\u0438\u043f \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f (\u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443) \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e GPIO\u2011\u043f\u0438\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>gpio_num<\/code>\u00a0\u2013 \u043d\u043e\u043c\u0435\u0440 \u043f\u0438\u043d\u0430 (<code>GPIO_NUM_0<\/code> \u2026 <code>GPIO_NUM_39<\/code>).<\/p>\n<\/li>\n<li>\n<p><code>intr_type<\/code> &#8212; \u0442\u0438\u043f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><code>GPIO_INTR_DISABLE<\/code> &#8212; \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><code>GPIO_INTR_POSEDGE<\/code> &#8212; \u043f\u043e <strong>\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443<\/strong> \u0444\u0440\u043e\u043d\u0442\u0443<\/p>\n<\/li>\n<li>\n<p><code>GPIO_INTR_NEGEDGE<\/code> &#8212; \u043f\u043e <strong>\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443<\/strong> \u0444\u0440\u043e\u043d\u0442\u0443<\/p>\n<\/li>\n<li>\n<p><code>GPIO_INTR_ANYEDGE<\/code> &#8212; \u043f\u043e <strong>\u043b\u044e\u0431\u043e\u043c\u0443<\/strong> \u0444\u0440\u043e\u043d\u0442\u0443 <\/p>\n<\/li>\n<li>\n<p><code>GPIO_INTR_LOW_LEVEL<\/code> &#8212; \u043f\u043e \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044e <strong>\u043d\u0438\u0437\u043a\u043e\u0433\u043e<\/strong> \u0443\u0440\u043e\u0432\u043d\u044f<\/p>\n<\/li>\n<li>\n<p><code>GPIO_INTR_HIGH_LEVEL<\/code> &#8212; \u043f\u043e \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044e <strong>\u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e<\/strong> \u0443\u0440\u043e\u0432\u043d\u044f<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 GPIO\u2011\u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u0442\u0435\u0440\u043c\u0438\u043d <strong>\u00ab\u0444\u0440\u043e\u043d\u0442\u00bb<\/strong> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 <strong>\u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/strong> \u0443\u0440\u043e\u0432\u043d\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u0430, \u0430 <strong>\u00ab\u0443\u0440\u043e\u0432\u0435\u043d\u044c\u00bb<\/strong> (level) \u2014 <strong>\u0441\u0430\u043c \u0444\u0430\u043a\u0442 \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f<\/strong> \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0432 \u0442\u043e\u043c \u0438\u043b\u0438 \u0438\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code><strong>GPIO_INTR_POSEDGE<\/strong><\/code> (\u00ab\u043f\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443\u00bb) \u2014 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 <strong>\u043e\u0434\u0438\u043d \u0440\u0430\u0437<\/strong> \u0432 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u043b <strong>\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 0 \u0432 1<\/strong> (\u043d\u0438\u0437\u043a\u0438\u0439 \u2192 \u0432\u044b\u0441\u043e\u043a\u0438\u0439). <code><strong>GPIO_INTR_ANYEDGE<\/strong><\/code> (\u00ab\u043f\u043e \u043b\u044e\u0431\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443\u00bb) \u2014 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 0\u21921, \u0442\u0430\u043a \u0438 \u043f\u0440\u0438 1\u21920.<\/p>\n<\/blockquote>\n<pre><code>gpio_install_isr_service(intr_alloc_flags);<\/code><\/pre>\n<ul>\n<li>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong>: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 <strong>\u043e\u0431\u0449\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 GPIO<\/strong>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0437\u0430\u0442\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 (<code>gpio_isr_handler_add<\/code>) \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0438\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/strong> <code>intr_alloc_flags<\/code> :<\/p>\n<ul>\n<li>\n<p><code>0<\/code>\u00a0\u2013 \u0431\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432 (\u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0438 \u0440\u0435\u0436\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439)<\/p>\n<\/li>\n<li>\n<p><code>ESP_INTR_FLAG_IRAM<\/code> &#8212; \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0432 IRAM<\/p>\n<\/li>\n<li>\n<p><code>ESP_INTR_FLAG_LOWMED<\/code> &#8212; \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \/ \u043d\u0438\u0437\u043a\u0438\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0412\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0444\u043b\u0430\u0433 <code>ESP_INTR_FLAG_IRAM<\/code> \u0432 <code>gpio_install_isr_service()<\/code>, \u0432\u044b <strong>\u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0435<\/strong>, \u0447\u0442\u043e:<\/p>\n<ul>\n<li>\n<p><strong>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f (ISR)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u043f\u043e\u0437\u0436\u0435, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f <strong>\u0438\u0437 IRAM<\/strong>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u0441\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u0430 ISR<\/strong> \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u044b \u0432 IRAM.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 SPI Flash \u0438\u043b\u0438 DMA) <strong>\u043a\u0435\u0448 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u043a\u043b\u044e\u0447\u0451\u043d<\/strong>, \u0438 \u043a\u043e\u0434, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u0441\u044f \u0432\u043e \u0444\u043b\u0435\u0448\u2011\u043f\u0430\u043c\u044f\u0442\u0438, \u0441\u0442\u0430\u043d\u0435\u0442 <strong>\u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c<\/strong>. \u0415\u0441\u043b\u0438 \u0432 \u0442\u0430\u043a\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443, \u043b\u0435\u0436\u0430\u0449\u0435\u043c\u0443 \u0432\u043e \u0444\u043b\u0435\u0448, \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 <strong>\u043a\u0440\u0430\u0448<\/strong>, <strong>watchdog reset<\/strong> \u0438\u043b\u0438 <strong>undefined behavior<\/strong>.<\/p>\n<\/blockquote>\n<blockquote>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u043f\u043e\u0437\u0430\u0431\u044b\u043b \u0438\u043b\u0438 \u043d\u0435 \u0437\u043d\u0430\u043b:<\/p>\n<p><strong>IRAM (Internal RAM)<\/strong> \u2014 \u044d\u0442\u043e <strong>\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0431\u044b\u0441\u0442\u0440\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c<\/strong> \u0432\u043d\u0443\u0442\u0440\u0438 ESP32. \u041e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 <strong>\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0439 SPI Flash<\/strong>, \u0447\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0439 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439.<\/p>\n<\/blockquote>\n<pre><code>gpio_isr_handler_add(gpio_num, isr_handler, args);<\/code><\/pre>\n<ul>\n<li>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong>: \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 <strong>\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<\/strong> (<code>isr_handler<\/code>) \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 GPIO\u2011\u043f\u0438\u043d.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/strong> <\/p>\n<ul>\n<li>\n<p><code>gpio_num<\/code> \u2014 \u043d\u043e\u043c\u0435\u0440 \u043f\u0438\u043d\u0430 (<code>GPIO_NUM_0<\/code> \u2026 <code>GPIO_NUM_39<\/code>)<\/p>\n<\/li>\n<li>\n<p><code>isr_handler<\/code> \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 <strong>\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<\/strong><\/p>\n<\/li>\n<li>\n<p><code>args<\/code> \u2014 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u0432 <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/strong><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><code>gpio_intr_enable(gpio_num);<\/code><\/pre>\n<ul>\n<li>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong>: \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e GPIO-\u043f\u0438\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <\/strong><code>gpio_num<\/code> \u2014 \u043d\u043e\u043c\u0435\u0440 GPIO-\u043f\u0438\u043d\u0430.<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0432\u044b\u0437\u0432\u0430\u043b\u0438 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e (\u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u0435\u0433\u043e \u0440\u0430\u043d\u0435\u0435).<\/p>\n<p><code>gpio_intr_disable()<\/code>&#8212; \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/blockquote>\n<pre><code>\/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f void IRAM_ATTR gpio_isr_handler(void* arg) { }<\/code><\/pre>\n<blockquote>\n<p>IRAM_ATTR \u2014 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 (\u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440), \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 IRAM, \u0430 \u043d\u0435 \u0432\u043e \u0444\u043b\u0435\u0448.<\/p>\n<\/blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a \u0432\u043e\u043f\u0440\u043e\u0441 (\u043d\u0443 \u0432\u0434\u0440\u0443\u0433 \u00af\\_(\u30c4)_\/\u00af): <strong>\u00ab\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d <\/strong><code><strong>IRAM_ATTR<\/strong><\/code><strong>, \u0435\u0441\u043b\u0438 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c <\/strong><code><strong>ESP_INTR_FLAG_IRAM<\/strong><\/code><strong>?\u00bb<\/strong>, \u0442\u043e \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c.<\/p>\n<p>\u0424\u043b\u0430\u0433 <code>ESP_INTR_FLAG_IRAM<\/code> <strong>\u043e\u0431\u044f\u0437\u044b\u0432\u0430\u0435\u0442<\/strong> \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043b\u0435\u0436\u0430\u0449\u0438\u0439 \u0432 IRAM \u2014 \u043d\u043e <strong>\u0441\u0430\u043c \u043e\u043d \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442 \u0432\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0442\u0443\u0434\u0430!<\/strong> \u0427\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 <strong>\u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u043b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0432 IRAM<\/strong>, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u044f\u0432\u043d\u043e \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u2014 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>IRAM_ATTR<\/code>.<\/p>\n<hr\/>\n<h2>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/h2>\n<p>\u041d\u0430\u0448\u0430 \u0446\u0435\u043b\u044c \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 \u043a\u043d\u043e\u043f\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 <code>Blink_Task<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u0438\u0441\u0430\u043b\u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435:<\/p>\n<pre><code>uint8_t state = 0;                \/\/ \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0445\u0440\u0430\u043d\u044f\u0449\u0430\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 LED (0\u00a0\u2013 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d, 1\u00a0\u2013 \u0432\u043a\u043b\u044e\u0447\u0451\u043d)  TaskHandle_t Blink_Handle = NULL; \/\/ \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 Blink  \/\/ \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) {     while (1) {         gpio_set_level(LED_GPIO, state);     } }<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 <code>state<\/code>. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0439:<\/p>\n<pre><code>\/*     \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043e\u0442 \u043a\u043d\u043e\u043f\u043a\u0438.     \u041f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e state.     IRAM_ATTR \u2014 \u0430\u0442\u0440\u0438\u0431\u0443\u0442, \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 <\/code><\/pre>\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-463734","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463734","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=463734"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463734\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=463734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=463734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=463734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}