{"id":317252,"date":"2021-01-31T21:00:50","date_gmt":"2021-01-31T21:00:50","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=317252"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=317252","title":{"rendered":"\u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 C++ \u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0421++ \u0432 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u0445 \u0442\u0435\u0440\u0437\u0430\u043b\u0430 \u043c\u0435\u043d\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u0414\u0435\u043b\u043e \u0431\u044b\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u044f \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435 \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043b, \u043a\u0430\u043a \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c. \u042f \u0438\u043c\u0435\u044e \u0432\u0432\u0438\u0434\u0443, \u043a\u0430\u043a \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0447\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0421\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0438 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f n-\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u044b, \u044f \u043f\u0440\u0438\u0448\u0451\u043b \u043a \u043a\u043e\u0435 \u043a\u0430\u043a\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c, \u043e \u0447\u0435\u043c \u0438 \u0445\u043e\u0447\u0443 \u043f\u043e\u0432\u0435\u0434\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0418\u043c\u0435\u044e\u0442 \u043b\u0438 \u043a\u0430\u043a\u0443\u044e \u043b\u0438\u0431\u043e \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438\u043b\u0438 \u043d\u0435\u0442 \u2014 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0443\u0434 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f. \u041c\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u0440\u0438\u0442\u0438\u043a\u0443 \u043a \u043c\u043e\u0435\u043c\u0443 \u043f\u043e\u0434\u0445\u043e\u0434\u0443, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u041a\u0430\u043a \u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c C++ \u043f\u0440\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432?\u00bb.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e, \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u044f, \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f USART \u0432 \u041c\u041a stm32 \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u0441 esp8266 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0438\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438 \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 C++ \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u2014 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u0443\u044e \u0440\u0430\u0437\u0432\u044f\u0437\u043a\u0443, \u0442.\u0435. \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u043e\u0442 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0442\u0435\u043a\u0430\u0442\u044c \u0432 \u0442\u043e, \u0447\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0442\u0430\u043d\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043f\u0440\u0438 \u043a\u0430\u043a\u0438\u0445 \u043b\u0438\u0431\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u0442\u0440\u0438 \u0443\u0440\u043e\u0432\u043d\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b:<\/p>\n<ol>\n<li>HW_USART \u2014 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c, \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b <\/li>\n<li>MW_USART \u2014 \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c, \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u0432\u044f\u0437\u043a\u0438 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439<\/li>\n<li>APP_ESP8266 \u2014 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u041c\u041a <\/li>\n<\/ol>\n<p>  <\/p>\n<h3>HW_USART<\/h3>\n<p>  \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043a\u0430\u043c\u0435\u043d\u044c stm32f411, USART \u21162, \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 DMA. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u0432\u0438\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0442\u0440\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c. <\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">bool usart2_init(uint32_t baud_rate) {   bool res = false;      \/*-------------GPIOA Enable, PA2-TX\/PA3-RX ------------*\/   BIT_BAND_PER(RCC-&gt;AHB1ENR, RCC_AHB1ENR_GPIOAEN) = true;      \/*----------GPIOA set-------------*\/   GPIOA-&gt;MODER |= (GPIO_MODER_MODER2_1 | GPIO_MODER_MODER3_1);   GPIOA-&gt;OSPEEDR |= (GPIO_OSPEEDER_OSPEEDR2 | GPIO_OSPEEDER_OSPEEDR3);   constexpr uint32_t USART_AF_TX = (7 &lt;&lt; 8);   constexpr uint32_t USART_AF_RX = (7 &lt;&lt; 12);   GPIOA-&gt;AFR[0] |= (USART_AF_TX | USART_AF_RX);              \/*!---------------USART2 Enable------------&gt;!*\/   BIT_BAND_PER(RCC-&gt;APB1ENR, RCC_APB1ENR_USART2EN) = true;      \/*-------------USART CONFIG------------*\/   USART2-&gt;CR3 |= (USART_CR3_DMAT | USART_CR3_DMAR);   USART2-&gt;CR1 |= (USART_CR1_TE | USART_CR1_RE | USART_CR1_UE);   USART2-&gt;BRR = (24000000UL + (baud_rate &gt;&gt; 1))\/baud_rate;      \/\/Current clocking for APB1      \/*-------------DMA for USART Enable------------*\/      BIT_BAND_PER(RCC-&gt;AHB1ENR, RCC_AHB1ENR_DMA1EN) = true;      \/*-----------------Transmit DMA--------------------*\/   DMA1_Stream6-&gt;PAR = reinterpret_cast&lt;uint32_t&gt;(&amp;(USART2-&gt;DR));   DMA1_Stream6-&gt;M0AR = reinterpret_cast&lt;uint32_t&gt;(&amp;(usart2_buf.tx));   DMA1_Stream6-&gt;CR = (DMA_SxCR_CHSEL_2| DMA_SxCR_MBURST_0 | DMA_SxCR_PL | DMA_SxCR_MINC | DMA_SxCR_DIR_0);         \/*-----------------Receive DMA--------------------*\/   DMA1_Stream5-&gt;PAR = reinterpret_cast&lt;uint32_t&gt;(&amp;(USART2-&gt;DR));   DMA1_Stream5-&gt;M0AR = reinterpret_cast&lt;uint32_t&gt;(&amp;(usart2_buf.rx));   DMA1_Stream5-&gt;CR = (DMA_SxCR_CHSEL_2 | DMA_SxCR_MBURST_0 | DMA_SxCR_PL | DMA_SxCR_MINC);      DMA1_Stream5-&gt;NDTR = MAX_UINT16_T;   BIT_BAND_PER(DMA1_Stream5-&gt;CR, DMA_SxCR_EN) = true;   return res; } <\/code><\/pre>\n<p>  \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442\u0443, \u043a\u0440\u043e\u043c\u0435 \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u043c\u0430\u0441\u043a\u0438 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u0422\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">bool usart2_write(const uint8_t* buf, uint16_t len) {    bool res = false;    static bool first_attempt = true;        \/*!&lt;-----Copy data to DMA USART TX buffer-----&gt;!*\/    memcpy(usart2_buf.tx, buf, len);        if(!first_attempt)    {      \/*!&lt;-----Checking copmletion of previous transfer-------&gt;!*\/      while(!(DMA1-&gt;HISR &amp; DMA_HISR_TCIF6)) continue;      BIT_BAND_PER(DMA1-&gt;HIFCR, DMA_HIFCR_CTCIF6) = true;    }        first_attempt = false;        \/*!&lt;------Sending data to DMA-------&gt;!*\/    BIT_BAND_PER(DMA1_Stream6-&gt;CR, DMA_SxCR_EN) = false;    DMA1_Stream6-&gt;NDTR = len;    BIT_BAND_PER(DMA1_Stream6-&gt;CR, DMA_SxCR_EN) = true;        return res; } <\/code><\/pre>\n<p>  \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u043a\u043e\u0441\u0442\u044b\u043b\u044c, \u0432 \u0432\u0438\u0434\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 first_attempt, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0430\u043c\u0430\u044f \u043b\u0438 \u043f\u0435\u0440\u0432\u0430\u044f \u044d\u0442\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u043e DMA \u0438\u043b\u0438 \u043d\u0435\u0442. \u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e? \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043e \u0442\u043e\u043c, \u0443\u0441\u043f\u0435\u0448\u043d\u0430 \u043b\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0432 DMA \u0438\u043b\u0438 \u043d\u0435\u0442 \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0414\u041e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438, \u0430 \u043d\u0435 \u041f\u041e\u0421\u041b\u0415. \u0421\u0434\u0435\u043b\u0430\u043b \u044f \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u0442\u0443\u043f\u043e \u0436\u0434\u0430\u0442\u044c \u0435\u0451 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f, \u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f. <\/p>\n<p>  \u0422\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">uint16_t usart2_read(uint8_t* buf) {    uint16_t len = 0;    constexpr uint16_t BYTES_MAX = MAX_UINT16_T; \/\/MAX Bytes in DMA buffer        \/*!&lt;---------Waiting until line become IDLE-----------&gt;!*\/    if(!(USART2-&gt;SR &amp; USART_SR_IDLE)) return len;    \/*!&lt;--------Clean the IDLE status bit-------&gt;!*\/    USART2-&gt;DR;        \/*!&lt;------Refresh the receive DMA buffer-------&gt;!*\/    BIT_BAND_PER(DMA1_Stream5-&gt;CR, DMA_SxCR_EN) = false;    len = BYTES_MAX - (DMA1_Stream5-&gt;NDTR);    memcpy(buf, usart2_buf.rx, len);    DMA1_Stream5-&gt;NDTR = BYTES_MAX;    BIT_BAND_PER(DMA1-&gt;HIFCR, DMA_HIFCR_CTCIF5) = true;    BIT_BAND_PER(DMA1_Stream5-&gt;CR, DMA_SxCR_EN) = true;        return len; } <\/code><\/pre>\n<p>  \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043c\u043d\u0435 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442 \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c. \u0414\u043b\u044f \u0438\u043d\u0434\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u0444\u043b\u0430\u0433 IDLE, \u0437\u0430\u0442\u0435\u043c, \u0435\u0441\u043b\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 IDLE \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u0447\u0438\u0449\u0443 \u0444\u043b\u0430\u0433 \u0438 \u0447\u0438\u0442\u0430\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 IDLE \u043d\u0435 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0443\u043b\u044c, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u0441 \u043d\u0438\u0437\u043a\u0438\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a C++ \u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u043c.<\/p>\n<h3>MW_USART<\/h3>\n<p>   \u0417\u0434\u0435\u0441\u044c \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 USART \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u00bb \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432 (\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 USART1 \u0438 USART2). \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u0432 \u0433\u0443\u0433\u043b\u0435, \u0430 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0438\u0436\u0435.<\/p>\n<pre><code class=\"cpp\">#pragma once #include &lt;stdint.h&gt; #include &lt;vector&gt; #include &lt;map&gt;  \/*!&lt;========Enumeration of USART=======&gt;!*\/ enum class USART_NUMBER : uint8_t {   _1,   _2 };   class USART; \/\/declaration of basic USART class  using usart_registry = std::map&lt;USART_NUMBER, USART*&gt;;    \/*!&lt;=========Registry of prototypes=========&gt;!*\/ extern usart_registry _instance; \/\/Global variable - IAR Crutch #pragma inline=forced  static usart_registry&amp; get_registry(void) { return _instance; }  \/*!&lt;=======Should be rewritten as========&gt;!*\/ \/* static usart_registry&amp; get_registry(void)  {    usart_registry _instance;   return _instance;  } *\/  \/*!&lt;=========Basic USART classes==========&gt;!*\/ class USART { private: protected:      static void add_prototype(USART_NUMBER num, USART* prot)   {     usart_registry&amp; r = get_registry();     r[num] = prot;   }      static void remove_prototype(USART_NUMBER num)   {     usart_registry&amp; r = get_registry();     r.erase(r.find(num));   } public:   static USART* create_USART(USART_NUMBER num)   {     usart_registry&amp; r = get_registry();     if(r.find(num) != r.end())     {       return r[num]-&gt;clone();     }     return nullptr;   }   virtual USART* clone(void) const = 0;   virtual ~USART(){}      virtual bool init(uint32_t baudrate) const = 0;   virtual bool send(const uint8_t* buf, uint16_t len) const = 0;   virtual uint16_t receive(uint8_t* buf) const = 0; };  \/*!&lt;=======Specific class USART 1==========&gt;!*\/ class USART_1 : public USART { private:   static USART_1 _prototype;      USART_1()    {       add_prototype( USART_NUMBER::_1, this);   } public:    virtual USART* clone(void) const override final   {    return new USART_1;  }    virtual bool init(uint32_t baudrate) const override final;  virtual bool send(const uint8_t* buf, uint16_t len) const override final;  virtual uint16_t receive(uint8_t* buf) const override final; };  \/*!&lt;=======Specific class USART 2==========&gt;!*\/ class USART_2 : public USART { private:   static USART_2 _prototype;      USART_2()    {       add_prototype( USART_NUMBER::_2, this);   } public:    virtual USART* clone(void) const override final   {    return new USART_2;  }    virtual bool init(uint32_t baudrate) const override final;  virtual bool send(const uint8_t* buf, uint16_t len) const override final;  virtual uint16_t receive(uint8_t* buf) const override final; };  <\/code><\/pre>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u0430\u0439\u043b\u0430 \u0438\u0434\u0451\u0442 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 enum <b>class USART_NUMBER<\/b> \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 USART, \u0434\u043b\u044f \u043c\u043e\u0435\u0433\u043e \u043a\u0430\u043c\u043d\u044f \u0438\u0445 \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430. \u0417\u0430\u0442\u0435\u043c \u0438\u0434\u0451\u0442 \u043e\u043f\u0435\u0440\u0435\u0436\u0430\u044e\u0449\u0435\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <b>class USART<\/b>. \u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0451\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0430 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u043e\u0432 <b>std::map&lt;USART_NUMBER, USART*&gt;<\/b> \u0438 \u0435\u0433\u043e \u0440\u0435\u0435\u0441\u0442\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u0432\u0438\u0434\u0435 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u0430 \u041c\u044d\u0439\u0435\u0440\u0441\u0430. <\/p>\n<p>  \u0422\u0443\u0442 \u044f \u043d\u0430\u043f\u043e\u0440\u043e\u043b\u0441\u044f \u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c IAR ARM, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430, \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u0432\u0445\u043e\u0434\u0435 \u0432 main. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d, \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <b>_instance<\/b> \u043d\u0430 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e. \u0422\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u0438\u0434\u0435\u0430\u043b\u0435, \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <b>USART<\/b>, \u0433\u0434\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430(\u0442\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u043a\u0430\u043a \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439, \u0434\u043b\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430).<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u0447\u0438\u0441\u0442\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <b>clone<\/b>, \u0438 \u0447\u0438\u0441\u0442\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c, \u043c\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0433\u0434\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0447\u0438\u0441\u0442\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435.<\/p>\n<p>  \u041a\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"cpp\">#include &quot;MW_USART.h&quot; #include &quot;HW_USART.h&quot;  usart_registry _instance; \/\/Crutch for IAR  \/*!&lt;========Initialization of global static USART value==========&gt;!*\/ USART_1 USART_1::_prototype = USART_1(); USART_2 USART_2::_prototype = USART_2();  \/*!&lt;======================UART1 functions========================&gt;!*\/ bool USART_1::init(uint32_t baudrate) const {  bool res = false;  \/\/res = usart_init(USART1, baudrate);  \/\/Platform depending function  return res; }  bool USART_1::send(const uint8_t* buf, uint16_t len) const {   bool res = false;      return res; }  uint16_t USART_1::receive(uint8_t* buf) const {   uint16_t len = 0;      return len; }   \/*!&lt;======================UART2 functions========================&gt;!*\/ bool USART_2::init(uint32_t baudrate) const {  bool res = false;  res = usart2_init(baudrate);   \/\/Platform depending function  return res; }  bool USART_2::send(const uint8_t* buf, const uint16_t len) const {   bool res = false;   res = usart2_write(buf, len); \/\/Platform depending function   return res; }  uint16_t USART_2::receive(uint8_t* buf) const {   uint16_t len = 0;   len = usart2_read(buf);       \/\/Platform depending function   return len; } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b \u041d\u0415 \u043f\u0443\u0441\u0442\u044b\u0448\u043a\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f USART2, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0433\u043e \u044f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 esp8266. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u043e\u0435, \u0442\u0430\u043a\u0436\u0435 \u043e\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0441\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0447\u0438\u043f\u0430.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0436\u0435 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a APP \u0443\u0440\u043e\u0432\u043d\u044e \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0437\u0430\u0447\u0435\u043c \u0436\u0435 \u0432\u0441\u0435 \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0443\u0436\u043d\u043e.<\/p>\n<h3>APP_ESP8266<\/h3>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f ESP8266 \u043f\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443 \u00ab\u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0430\u00bb. \u0412 \u043d\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <b>USART*<\/b>.<\/p>\n<pre><code class=\"cpp\">class ESP8266 { private:   ESP8266(){}   ESP8266(const ESP8266&amp; root) = delete;   ESP8266&amp; operator=(const ESP8266&amp;) = delete;      \/*!&lt;---------USART settings for ESP8266-------&gt;!*\/   static constexpr auto USART_BAUDRATE = ESP8266_USART_BAUDRATE;   static constexpr USART_NUMBER ESP8266_USART_NUMBER = USART_NUMBER::_2;   USART* usart;      static constexpr uint8_t LAST_COMMAND_SIZE = 32;   char last_command[LAST_COMMAND_SIZE] = {0};   bool send(uint8_t const *buf, const uint16_t len = 0);      static constexpr uint8_t ANSWER_BUF_SIZE = 32;   uint8_t answer_buf[ANSWER_BUF_SIZE] = {0};      bool receive(uint8_t* buf);   bool waiting_answer(bool (ESP8266::*scan_line)(uint8_t *));      bool scan_ok(uint8_t * buf);   bool if_str_start_with(const char* str, uint8_t *buf); public:     bool init(void);      static ESP8266&amp; Instance()   {     static ESP8266 esp8266;     return esp8266;   } }; <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u0435\u0441\u0442\u044c constexpr \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043d\u043e\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e USART. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 USART \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435! \u0421\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u0436\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"cpp\">bool ESP8266::init(void) {   bool res = false;      usart = USART::create_USART(ESP8266_USART_NUMBER);   usart-&gt;init(USART_BAUDRATE);      const uint8_t* init_commands[] =    {     &quot;AT&quot;,     &quot;ATE0&quot;,     &quot;AT+CWMODE=2&quot;,     &quot;AT+CIPMUX=0&quot;,     &quot;AT+CWSAP=\\&quot;Tortoise_assistant\\&quot;,\\&quot;00000000\\&quot;,5,0&quot;,     &quot;AT+CIPMUX=1&quot;,     &quot;AT+CIPSERVER=1,8888&quot;   };      for(const auto &amp;command: init_commands)   {     this-&gt;send(command);     while(this-&gt;waiting_answer(&amp;ESP8266::scan_ok)) continue;   }        return res; } <\/code><\/pre>\n<p>  \u0421\u0442\u0440\u043e\u043a\u0430 <b>usart = USART::create_USART(ESP8266_USART_NUMBER);<\/b> \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0448 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c USART \u043c\u043e\u0434\u0443\u043b\u0435\u043c.<\/p>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u043e\u0432, \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0443 \u043d\u0430\u0434\u0435\u0436\u0434\u0443, \u0447\u0442\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435!<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/540148\/\"> https:\/\/habr.com\/ru\/post\/540148\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0421++ \u0432 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u0445 \u0442\u0435\u0440\u0437\u0430\u043b\u0430 \u043c\u0435\u043d\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u0414\u0435\u043b\u043e \u0431\u044b\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u044f \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435 \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043b, \u043a\u0430\u043a \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c. \u042f \u0438\u043c\u0435\u044e \u0432\u0432\u0438\u0434\u0443, \u043a\u0430\u043a \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0447\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0421\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0438 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f n-\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u044b, \u044f \u043f\u0440\u0438\u0448\u0451\u043b \u043a \u043a\u043e\u0435 \u043a\u0430\u043a\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c, \u043e \u0447\u0435\u043c \u0438 \u0445\u043e\u0447\u0443 \u043f\u043e\u0432\u0435\u0434\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0418\u043c\u0435\u044e\u0442 \u043b\u0438 \u043a\u0430\u043a\u0443\u044e \u043b\u0438\u0431\u043e \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438\u043b\u0438 \u043d\u0435\u0442 \u2014 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0443\u0434 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f. \u041c\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u0440\u0438\u0442\u0438\u043a\u0443 \u043a \u043c\u043e\u0435\u043c\u0443 \u043f\u043e\u0434\u0445\u043e\u0434\u0443, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u041a\u0430\u043a \u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c C++ \u043f\u0440\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432?\u00bb.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e, \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-317252","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/317252","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=317252"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/317252\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=317252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=317252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=317252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}