{"id":322814,"date":"2021-05-09T21:00:17","date_gmt":"2021-05-09T21:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=322814"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=322814","title":{"rendered":"\u041e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u0445: \u043a\u0430\u043a Concepts \u0438 Ranges \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u043c\u043e\u0439 printf \u043d\u0430 \u043f\u043e\u043a\u043e\u0439"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0438 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u043c \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432.<\/p>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u044f \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e \u043d\u0430\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043b \u0432 project tree \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0432\u0441\u044f\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442. \u0418 \u043d\u0430 \u0445\u0435\u0434\u0435\u0440\u0435 app_debug.h \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0437\u0430\u0432\u0438\u0441. <\/p>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0434\u0435\u043a\u0430\u0431\u0440\u0435 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0433\u043e\u0434\u0430 \u0443 <a href=\"https:\/\/developer.arm.com\/tools-and-software\/open-source-software\/developer-tools\/gnu-toolchain\/gnu-rm\/downloads\" rel=\"noopener noreferrer nofollow\">GNU Arm Embedded Toolchain<\/a> \u0432\u044b\u0448\u0435\u043b \u0440\u0435\u043b\u0438\u0437 10-2020-q4-major, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439 \u0432\u0441\u0435 GCC 10.2 features, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 Concepts, Ranges, Coroutines \u0432\u043a\u0443\u043f\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438, \u043c\u0435\u043d\u0435\u0435 &#171;\u0433\u0440\u043e\u043c\u043a\u0438\u043c\u0438&#187; \u043d\u043e\u0432\u0438\u043d\u043a\u0430\u043c\u0438 \u0421++20. <\/p>\n<p>\u0412\u043e\u043e\u0434\u0443\u0448\u0435\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u043d\u043e\u0432\u044b\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c \u0432\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0438\u0441\u043e\u0432\u0430\u043b\u043e \u043c\u043e\u0439 \u0431\u0443\u0434\u0443\u0449\u0438\u0439 \u0421++ \u043a\u043e\u0434 \u0443\u043b\u044c\u0442\u0440\u0430\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e-\u043f\u043e\u044d\u0442\u0438\u0447\u043d\u044b\u043c. \u0418 \u0441\u0442\u0430\u0440\u044b\u0439, \u0434\u043e\u0431\u0440\u044b\u0439 <em>printf(&#171;Debug message\\n&#187;)<\/em> \u0432 \u044d\u0442\u043e \u0431\u043b\u0430\u0433\u043e\u0441\u0442\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c-\u0442\u043e \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0441\u044f.<\/p>\n<p>\u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u0435\u0441\u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u043d\u043e\u0439 \u043f\u043b\u044e\u0441\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0443\u0434\u043e\u0431\u0441\u0442\u0432!<\/p>\n<pre><code class=\"cpp\">float raw[] = {3.1416, 2.7183, 1.618}; array&lt;int, 3&gt; arr{123, 456, 789};  cout &lt;&lt; int{2021}       &lt;&lt; '\\n'      &lt;&lt; float{9.806}    &lt;&lt; '\\n'      &lt;&lt; raw             &lt;&lt; '\\n'      &lt;&lt; arr             &lt;&lt; '\\n'      &lt;&lt; \"Hello, Habr!\"  &lt;&lt; '\\n'      &lt;&lt; (\"esreveR me!\" | views::take(7) | views::reverse ) &lt;&lt; '\\n';<\/code><\/pre>\n<p>\u041d\u0443 \u0430 \u0435\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e, \u0437\u0430\u0447\u0435\u043c \u0436\u0435 \u0441\u0435\u0431\u0435 \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c?<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043d\u0430 \u0421++20 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u041c\u041a, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043b\u044e\u0431\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0439 \u0432\u0435\u043d\u0434\u0440\u043e\u043c \u043a\u0430\u043c\u043d\u044f. \u041b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0439 \u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u0431\u0435\u0437 \u0431\u043e\u0439\u043b\u0435\u0440\u043f\u043b\u0435\u0439\u0442\u0430. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u0430\u043a \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 &#8212; \u0434\u043b\u044f \u043d\u0435\u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u0447\u0430\u0441\u0442\u043a\u043e\u0432 \u043a\u043e\u0434\u0430, \u0442\u0430\u043a \u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439, \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. <\/p>\n<p>\u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0430\u043b\u0438\u0430\u0441\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">using base_t = std::uint32_t; using fast_t = std::uint_fast32_t; using index_t = std::size_t;<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0432 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u0445 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f\u0445 \u0438 DMA. \u0414\u043b\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0430\u0432\u0435\u0434\u0435\u043c <em>enum<\/em>:<\/p>\n<pre><code class=\"cpp\">enum class BusMode{ \tBLOCKING, \tIT, \tDMA, };<\/code><\/pre>\n<p>\u041e\u043f\u0438\u0448\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432, \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0437\u0430 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<details class=\"spoiler\">\n<summary>class BusInterface<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template&lt;typename T&gt; class BusInterface{  public:  \tusing derived_ptr = T*;      \tstatic constexpr BusMode mode = T::mode;  \tvoid send (const char arr[], index_t num) noexcept {  \t\tif constexpr (BusMode::BLOCKING == mode){  \t\t\tderived()-&gt;send_block(arr, num);  \t\t} else if (BusMode::IT == mode){  \t\t\tderived()-&gt;send_it(arr, num);  \t\t} else if (BusMode::DMA == mode){  \t\t\tderived()-&gt;send_dma(arr, num); \t\t} \t}  private:  \tderived_ptr derived(void) noexcept{ \t\treturn static_cast&lt;derived_ptr&gt;(this); \t}  \tvoid send_block (const char arr[], const index_t num) noexcept {}  \tvoid send_it (const char arr[], const index_t num) noexcept {}  \tvoid send_dma (const char arr[], const index_t num) noexcept {} };<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041a\u043b\u0430\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043f\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Curiously_recurring_template_pattern\" rel=\"noopener noreferrer nofollow\">CRTP<\/a>, \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.  \u041a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <em>send(), <\/em>\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0436\u0438\u043c\u0430 \u0432\u044b\u0432\u043e\u0434\u0430, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0435\u0440 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0435\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440. \u041d\u0430 \u043c\u043e\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 HAL-\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0432\u0435\u043d\u0434\u043e\u0440\u043e\u0432 \u041c\u041a.<\/p>\n<p>\u0418 \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043b\u0430\u0441\u0441 Uart, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0439 \u043e\u0442 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<details class=\"spoiler\">\n<summary>class Uart<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template&lt;BusMode Mode&gt; class Uart final : public BusInterface&lt;Uart&lt;Mode&gt;&gt; {  private:  \tstatic constexpr BusMode mode = Mode;  \tvoid send_block (const char arr[], const index_t num) noexcept{  \t\tHAL_UART_Transmit( \t\t\t\t&amp;huart, \t\t\t\tbit_cast&lt;std::uint8_t*&gt;(arr), \t\t\t\tstd::uint16_t(num), \t\t\t\tbase_t{5000} \t\t); \t}      void send_it (const char arr[], const index_t num) noexcept {  \t\tHAL_UART_Transmit_IT( \t\t\t\t\t&amp;huart, \t\t\t\t\tbit_cast&lt;std::uint8_t*&gt;(arr), \t\t\t\t\tstd::uint16_t(num) \t\t); \t}  \tvoid send_dma (const char arr[], const index_t num) noexcept {  \t\tHAL_UART_Transmit_DMA( \t\t\t\t\t&amp;huart, \t\t\t\t\tbit_cast&lt;std::uint8_t*&gt;(arr), \t\t\t\t\tstd::uint16_t(num) \t\t); \t}  \tfriend class BusInterface&lt;Uart&lt;BusMode::BLOCKING&gt;&gt;; \tfriend class BusInterface&lt;Uart&lt;BusMode::IT&gt;&gt;; \tfriend class BusInterface&lt;Uart&lt;BusMode::DMA&gt;&gt;; };<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441s \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c, \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 <em>send_block(), send_it()<\/em> \u0438 <em>send_dma()<\/em> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 HAL. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435 \u0432\u0441\u0435 \u0440\u0435\u0436\u0438\u043c\u044b, \u0442\u043e\u0433\u0434\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c.<\/p>\n<p>\u0418 \u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0430\u043b\u0438\u0430\u0441\u044b \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Uart:<\/p>\n<pre><code class=\"cpp\">using UartBlocking = BusInterface&lt;Uart&lt;BusMode::BLOCKING&gt;&gt;; using UartIt = BusInterface&lt;Uart&lt;BusMode::IT&gt;&gt;; using UartDma = BusInterface&lt;Uart&lt;BusMode::DMA&gt;&gt;;<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0442\u043e\u043a\u0430 \u0432\u044b\u0432\u043e\u0434\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>class StreamBase<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template &lt;class Bus, char Delim&gt; class StreamBase final: public StreamStorage {  public:  \tusing bus_t = Bus;   using stream_t = StreamBase&lt;Bus, Delim&gt;;  \tstatic constexpr BusMode mode = bus_t::mode;  \tStreamBase() = default; \t~StreamBase(){ if constexpr (BusMode::BLOCKING != mode) flush(); }   StreamBase(const StreamBase&amp;) = delete; \tStreamBase&amp; operator= (const StreamBase&amp;) = delete;  \tstream_t&amp; operator &lt;&lt; (const char_type auto c){  \t\tif constexpr (BusMode::BLOCKING == mode){  \t\t\tbus.send(&amp;c, 1);  \t\t} else {  \t\t\t*it = c; \t\t\tit = std::next(it); \t\t} \t\treturn *this; \t}  \tstream_t&amp; operator &lt;&lt; (const std::floating_point auto f){  \t\tif constexpr (BusMode::BLOCKING == mode){  \t\t\tauto [ptr, cnt] = NumConvert::to_string_float(f, buffer.data());  \t\t\tbus.send(ptr, cnt);  \t\t} else {  \t\t\tauto [ptr, cnt] = NumConvert::to_string_float(f, buffer.data() + std::distance(buffer.begin(), it));  \t\t\tit = std::next(it, cnt); \t\t} \t\treturn *this; \t}  \tstream_t&amp; operator &lt;&lt; (const num_type auto n){  \t\tauto [ptr, cnt] = NumConvert::to_string_integer( n, &amp;buffer.back() );  \t\tif constexpr (BusMode::BLOCKING == mode){  \t\t\tbus.send(ptr, cnt);  \t\t} else {  \t\t\tauto src = std::prev(buffer.end(), cnt + 1);  \t\t\tit = std::copy(src, buffer.end(), it); \t\t} \t\treturn *this; \t}  \tstream_t&amp; operator &lt;&lt; (const std::ranges::range auto&amp; r){          std::ranges::for_each(r, [this](const auto val) {                          if constexpr (char_type&lt;decltype(val)&gt;){                              *this &lt;&lt; val;              } else if (num_type&lt;decltype(val)&gt; || std::floating_point&lt;decltype(val)&gt;){                  *this &lt;&lt; val &lt;&lt; Delim;             }         }); \t\treturn *this; \t}  private:  \tvoid flush (void) {  \t\tbus.send(buffer.data(), std::distance(buffer.begin(), it));  \t\tit = buffer.begin(); \t}  \tstd::span&lt;char&gt; buffer{storage}; \tstd::span&lt;char&gt;::iterator it{buffer.begin()};  \tbus_t bus; }; <\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0435 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c Delim \u0442\u0438\u043f\u0430 <em>char<\/em> \u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <em>StreamStorage.<\/em> \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e &#8212; \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043c\u0430\u0441\u0441\u0438\u0432\u0443 <em>char<\/em>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u0436\u0438\u043c\u0435. \u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0436\u0443, \u043e\u043d\u0430 \u0432\u0442\u043e\u0440\u0438\u0447\u043d\u0430 \u043a \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0442\u0435\u043c\u0435; \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u043d\u0430 \u0432\u0430\u0448\u0435 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0443\u0442\u044f\u043d\u0438\u0442\u0435 \u0438\u0437 \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.  \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u0442\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 &#8212; <em>storage<\/em>) \u043c\u044b \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u0434\u0432\u0430 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0445 \u0447\u043b\u0435\u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0430: <\/p>\n<pre><code class=\"cpp\">std::span&lt;char&gt; buffer{storage}; std::span&lt;char&gt;::iterator it{buffer.begin()};<\/code><\/pre>\n<p>Delim  &#8212; \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043c\u0435\u0436\u0434\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432\/\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432.<\/p>\n<p>\u041f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 &#8212; \u044d\u0442\u043e \u0447\u0435\u0442\u044b\u0440\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 <strong><em>operator&lt;&lt;.<\/em><\/strong> \u0422\u0440\u0438 \u0438\u0437 \u043d\u0438\u0445 &#8212; \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043d\u0430\u0448 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c (<em>char, float \u0438 integral type<\/em>), \u0430 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f &#8212; \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432.<\/p>\n<p>\u0412\u043e\u0442 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u0430\u044f \u0432\u043a\u0443\u0441\u043d\u043e\u0442\u0430.<\/p>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 &#8212; \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0430. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u044b <em>char_type, num_type<\/em>&#8230;<\/p>\n<pre><code class=\"cpp\">template &lt;typename T&gt; concept char_type = std::same_as&lt;T, char&gt;;  template &lt;typename T&gt; concept num_type = std::integral&lt;T&gt; &amp;&amp; !char_type&lt;T&gt;;<\/code><\/pre>\n<p>&#8230; \u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u044b \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 &#8212;  <em>std::floating_point<\/em> \u0438 <em>std::ranges::range.<\/em><\/p>\n<p>\u041a\u043e\u043d\u0446\u0435\u043f\u0442\u044b \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0437\u0430\u0449\u0438\u0449\u0430\u044e\u0442 \u043d\u0430\u0441 \u043e\u0442 \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a, \u0438 \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u0435 \u0441  \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u043e\u043c <em>range <\/em>\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432.<\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u0440\u043e\u0441\u0442\u0430. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0436\u0438\u043c\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 (\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \/ \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439) \u043c\u044b \u0438\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u044c, \u043b\u0438\u0431\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u0442\u0440\u043e\u043a\u0443. \u0418 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0440\u0430\u0437\u0440\u0443\u0448\u0430\u0435\u0442\u0441\u044f, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u0433\u0434\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <em>flush()<\/em> \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u044c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 IT \u0438\u043b\u0438 DMA.<\/p>\n<p>\u041f\u0440\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 <em>char<\/em>-\u043e\u0432 \u044f \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043e\u0442 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u0438\u0434\u0438\u043e\u043c\u044b \u0441 <em>snprintf()<\/em>  \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043e\u043a <a href=\"http:\/\/we.easyelectronics.ru\/blog\/Soft\/2400.html\" rel=\"noopener noreferrer nofollow\">neiver<\/a>. \u0410\u0432\u0442\u043e\u0440 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f\u0445 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0447\u0438\u0441\u0435\u043b \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u0430\u043a \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0430, \u0442\u0430\u043a \u0438 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f.  \u041f\u043e\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0443 \u043d\u0435\u0433\u043e \u043a\u043e\u0434 \u044f \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <em>NumConvert<\/em>, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b <em>to_string_integer() <\/em>\u0438 <em>to_string_float().<\/em> <\/p>\n<p>\u0412 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\/\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043c\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <em>std::ranges::for_each()<\/em> \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443 \u0440\u044d\u0439\u043d\u0434\u0436\u0430 \u0438 \u0435\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0443 <em>char_type<\/em>, \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441\u043b\u0438\u0442\u043d\u043e. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0430\u043c <em>num_type<\/em> \u0438\u043b\u0438 <em>std::floating_point<\/em>, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f Delim.<\/p>\n<p>\u041d\u0443 \u0445\u043e\u0440\u043e\u0448\u043e, \u043c\u044b \u0442\u0443\u0442 \u043d\u0430\u0432\u043e\u0440\u043e\u0442\u0438\u043b\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0435\u0439 \u043f\u043b\u044e\u0441\u043e\u0432\u043e\u0439 \u0442\u044f\u0436\u0435\u043b\u043e\u0439 \u0430\u0440\u0442\u0438\u043b\u043b\u0435\u0440\u0438\u0438. \u042d\u0442\u043e \u0436 \u043a\u0430\u043a\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u0443\u044e \u043f\u043e\u0440\u0442\u044f\u043d\u043a\u0443 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435? \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">int main() {      using StreamUartBlocking = StreamBase&lt;UartBlocking, ' '&gt;;      StreamUartBlocking cout;      cout &lt;&lt; 'A'; \/\/ 1   cout &lt;&lt; (\"esreveR me!\" | std::views::take(7) | std::views::reverse); \/\/ 2      return 0; }<\/code><\/pre>\n<p>\u0412\u044b\u0441\u0442\u0430\u0432\u0438\u043c \u0444\u043b\u0430\u0433\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430: -std=gnu++20 -Os -fno-exceptions -fno-rtti. \u0422\u043e\u0433\u0434\u0430 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433:<\/p>\n<pre><code class=\"cpp\">main:         push    {r3, lr}         movs    r0, #65         bl      putchar         movs    r0, #0         pop     {r3, pc}<\/code><\/pre>\n<p>\u041d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">.LC0:         .ascii  \"esreveR me!\\000\" main:         push    {r3, r4, r5, lr}         ldr     r5, .L4         movs    r4, #5 .L3:         subs    r4, r4, #1         bcc     .L2         ldrb    r0, [r5, r4]    @ zero_extendqisi2         bl      putchar         b       .L3 .L2:         movs    r0, #0         pop     {r3, r4, r5, pc} .L4:         .word   .LC0<\/code><\/pre>\n<p>\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0432\u0435\u0441\u044c\u043c\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e. \u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 \u043f\u043b\u044e\u0441\u043e\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u0442\u043e\u043a\u0430, \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432\/\u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0440\u044d\u043d\u0434\u0436\u0435\u0439 \u043f\u0440\u044f\u043c\u043e \u0432 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 \u0438 \u0432\u0441\u0435 \u044d\u0442\u043e \u0441 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0443\u043b\u0435\u0432\u044b\u043c \u043e\u0432\u0435\u0440\u0445\u0435\u0434\u043e\u043c.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u0441\u044f \u0435\u0449\u0435 \u043a\u043e\u0434 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>\u041f\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u043d\u043b\u0430\u0439\u043d \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/gcc.godbolt.org\/z\/eYbdd3hxq\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a> (hardware dependent \u043a\u043e\u0434 \u0437\u0430\u043c\u0435\u043d\u0438\u043b \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 <em>putchar() <\/em>).<\/p>\n<p>\u0420\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435\/\u0437\u0430\u0431\u0438\u0440\u0430\u0439\u0442\u0435 <a href=\"https:\/\/github.com\/ALSCode\/BareMetalStream\/tree\/master\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>. \u0422\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u0438. <\/p>\n<p>\u042d\u0442\u043e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0434\u043b\u044f \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0435\u0449\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0442\u0435\u0441\u0442\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0435 &#8212; \u043a\u043e\u0433\u0434\u0430, \u0441\u043a\u0430\u0436\u0435\u043c, \u0432\u044b\u0432\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0435\u0449\u0435 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d, \u0430 \u043c\u044b \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0436\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0431\u0443\u0444\u0435\u0440 \u043d\u043e\u0432\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439. \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0435\u0449\u0435 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 std::views. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <em>std::views::drop()<\/em> \u043f\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0435\u0435 \u043a \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u043c\u0443 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0443 \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 <em>char<\/em>-\u043e\u0432, \u0432\u0437\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u043e\u0439 <em>&#171;inconsistent directions for distance and bound&#187;<\/em>.  \u041d\u0443 \u0447\u0442\u043e \u0436, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u043d\u043e\u0432\u044b\u0439, \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043e\u0441\u0432\u043e\u0438\u043c.<\/p>\n<p>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/youtu.be\/f6rMz3c4b4E\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u0434\u043d\u044f\u0442 \u043d\u0430 \u0434\u0432\u0443\u0445\u044f\u0434\u0435\u0440\u043d\u043e\u043c STM32H745; \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u044f\u0434\u0440\u0430 (480\u041c\u0413\u0446) \u0432\u044b\u0432\u043e\u0434 \u0438\u0434\u0435\u0442 \u0432 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 SWO, \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430 9,2 \u043c\u043a\u0441,  \u0441\u043e \u0432\u0442\u043e\u0440\u043e\u0433\u043e(240\u041c\u0413\u0446)  &#8212; \u0447\u0435\u0440\u0435\u0437 Uart \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 DMA, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0437\u0430 20 \u043c\u043a\u0441.<\/p>\n<p>\u041a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u043e\u0442\u0437\u044b\u0432\u0430\u043c \u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0434\u0435\u044f\u043c \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u0435\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/556144\/\"> https:\/\/habr.com\/ru\/post\/556144\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0438 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u043c \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432.<\/p>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u044f \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e \u043d\u0430\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043b \u0432 project tree \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0432\u0441\u044f\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442. \u0418 \u043d\u0430 \u0445\u0435\u0434\u0435\u0440\u0435 app_debug.h \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0437\u0430\u0432\u0438\u0441. <\/p>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0434\u0435\u043a\u0430\u0431\u0440\u0435 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0433\u043e\u0434\u0430 \u0443 <a href=\"https:\/\/developer.arm.com\/tools-and-software\/open-source-software\/developer-tools\/gnu-toolchain\/gnu-rm\/downloads\" rel=\"noopener noreferrer nofollow\">GNU Arm Embedded Toolchain<\/a> \u0432\u044b\u0448\u0435\u043b \u0440\u0435\u043b\u0438\u0437 10-2020-q4-major, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439 \u0432\u0441\u0435 GCC 10.2 features, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 Concepts, Ranges, Coroutines \u0432\u043a\u0443\u043f\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438, \u043c\u0435\u043d\u0435\u0435 &#171;\u0433\u0440\u043e\u043c\u043a\u0438\u043c\u0438&#187; \u043d\u043e\u0432\u0438\u043d\u043a\u0430\u043c\u0438 \u0421++20. <\/p>\n<p>\u0412\u043e\u043e\u0434\u0443\u0448\u0435\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u043d\u043e\u0432\u044b\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c \u0432\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0438\u0441\u043e\u0432\u0430\u043b\u043e \u043c\u043e\u0439 \u0431\u0443\u0434\u0443\u0449\u0438\u0439 \u0421++ \u043a\u043e\u0434 \u0443\u043b\u044c\u0442\u0440\u0430\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e-\u043f\u043e\u044d\u0442\u0438\u0447\u043d\u044b\u043c. \u0418 \u0441\u0442\u0430\u0440\u044b\u0439, \u0434\u043e\u0431\u0440\u044b\u0439 <em>printf(&#171;Debug message\\n&#187;)<\/em> \u0432 \u044d\u0442\u043e \u0431\u043b\u0430\u0433\u043e\u0441\u0442\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c-\u0442\u043e \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0441\u044f.<\/p>\n<p>\u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u0435\u0441\u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u043d\u043e\u0439 \u043f\u043b\u044e\u0441\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0443\u0434\u043e\u0431\u0441\u0442\u0432!<\/p>\n<pre><code class=\"cpp\">float raw[] = {3.1416, 2.7183, 1.618}; array&lt;int, 3&gt; arr{123, 456, 789};  cout &lt;&lt; int{2021}       &lt;&lt; '\\n'      &lt;&lt; float{9.806}    &lt;&lt; '\\n'      &lt;&lt; raw             &lt;&lt; '\\n'      &lt;&lt; arr             &lt;&lt; '\\n'      &lt;&lt; \"Hello, Habr!\"  &lt;&lt; '\\n'      &lt;&lt; (\"esreveR me!\" | views::take(7) | views::reverse ) &lt;&lt; '\\n';<\/code><\/pre>\n<p>\u041d\u0443 \u0430 \u0435\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e, \u0437\u0430\u0447\u0435\u043c \u0436\u0435 \u0441\u0435\u0431\u0435 \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c?<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043d\u0430 \u0421++20 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u041c\u041a, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043b\u044e\u0431\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0439 \u0432\u0435\u043d\u0434\u0440\u043e\u043c \u043a\u0430\u043c\u043d\u044f. \u041b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0439 \u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u0431\u0435\u0437 \u0431\u043e\u0439\u043b\u0435\u0440\u043f\u043b\u0435\u0439\u0442\u0430. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u0430\u043a \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 &#8212; \u0434\u043b\u044f \u043d\u0435\u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u0447\u0430\u0441\u0442\u043a\u043e\u0432 \u043a\u043e\u0434\u0430, \u0442\u0430\u043a \u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439, \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. <\/p>\n<p>\u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0430\u043b\u0438\u0430\u0441\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">using base_t = std::uint32_t; using fast_t = std::uint_fast32_t; using index_t = std::size_t;<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0432 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u0445 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f\u0445 \u0438 DMA. \u0414\u043b\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0430\u0432\u0435\u0434\u0435\u043c <em>enum<\/em>:<\/p>\n<pre><code class=\"cpp\">enum class BusMode{ \tBLOCKING, \tIT, \tDMA, };<\/code><\/pre>\n<p>\u041e\u043f\u0438\u0448\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432, \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0437\u0430 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<details class=\"spoiler\">\n<summary>class BusInterface<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template&lt;typename T&gt; class BusInterface{  public:  \tusing derived_ptr = T*;      \tstatic constexpr BusMode mode = T::mode;  \tvoid send (const char arr[], index_t num) noexcept {  \t\tif constexpr (BusMode::BLOCKING == mode){  \t\t\tderived()-&gt;send_block(arr, num);  \t\t} else if (BusMode::IT == mode){  \t\t\tderived()-&gt;send_it(arr, num);  \t\t} else if (BusMode::DMA == mode){  \t\t\tderived()-&gt;send_dma(arr, num); \t\t} \t}  private:  \tderived_ptr derived(void) noexcept{ \t\treturn static_cast&lt;derived_ptr&gt;(this); \t}  \tvoid send_block (const char arr[], const index_t num) noexcept {}  \tvoid send_it (const char arr[], const index_t num) noexcept {}  \tvoid send_dma (const char arr[], const index_t num) noexcept {} };<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041a\u043b\u0430\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043f\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Curiously_recurring_template_pattern\" rel=\"noopener noreferrer nofollow\">CRTP<\/a>, \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.  \u041a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <em>send(), <\/em>\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0436\u0438\u043c\u0430 \u0432\u044b\u0432\u043e\u0434\u0430, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0435\u0440 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0435\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440. \u041d\u0430 \u043c\u043e\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 HAL-\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0432\u0435\u043d\u0434\u043e\u0440\u043e\u0432 \u041c\u041a.<\/p>\n<p>\u0418 \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043b\u0430\u0441\u0441 Uart, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0439 \u043e\u0442 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<details class=\"spoiler\">\n<summary>class Uart<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template&lt;BusMode Mode&gt; class Uart final : public BusInterface&lt;Uart&lt;Mode&gt;&gt; {  private:  \tstatic constexpr BusMode mode = Mode;  \tvoid send_block (const char arr[], const index_t num) noexcept{  \t\tHAL_UART_Transmit( \t\t\t\t&amp;huart, \t\t\t\tbit_cast&lt;std::uint8_t*&gt;(arr), \t\t\t\tstd::uint16_t(num), \t\t\t\tbase_t{5000} \t\t); \t}      void send_it (const char arr[], const index_t num) noexcept {  \t\tHAL_UART_Transmit_IT( \t\t\t\t\t&amp;huart, \t\t\t\t\tbit_cast&lt;std::uint8_t*&gt;(arr), \t\t\t\t\tstd::uint16_t(num) \t\t); \t}  \tvoid send_dma (const char arr[], const index_t num) noexcept {  \t\tHAL_UART_Transmit_DMA( \t\t\t\t\t&amp;huart, \t\t\t\t\tbit_cast&lt;std::uint8_t*&gt;(arr), \t\t\t\t\tstd::uint16_t(num) \t\t); \t}  \tfriend class BusInterface&lt;Uart&lt;BusMode::BLOCKING&gt;&gt;; \tfriend class BusInterface&lt;Uart&lt;BusMode::IT&gt;&gt;; \tfriend class BusInterface&lt;Uart&lt;BusMode::DMA&gt;&gt;; };<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441s \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c, \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 <em>send_block(), send_it()<\/em> \u0438 <em>send_dma()<\/em> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 HAL. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435 \u0432\u0441\u0435 \u0440\u0435\u0436\u0438\u043c\u044b, \u0442\u043e\u0433\u0434\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c.<\/p>\n<p>\u0418 \u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0430\u043b\u0438\u0430\u0441\u044b \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Uart:<\/p>\n<pre><code class=\"cpp\">using UartBlocking = BusInterface&lt;Uart&lt;BusMode::BLOCKING&gt;&gt;; using UartIt = BusInterface&lt;Uart&lt;BusMode::IT&gt;&gt;; using UartDma = BusInterface&lt;Uart&lt;BusMode::DMA&gt;&gt;;<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0442\u043e\u043a\u0430 \u0432\u044b\u0432\u043e\u0434\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>class StreamBase<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template &lt;class Bus, char Delim&gt; class StreamBase final: public StreamStorage {  public:  \tusing bus_t = Bus;   using stream_t = StreamBase&lt;Bus, Delim&gt;;  \tstatic constexpr BusMode mode = bus_t::mode;  \tStreamBase() = default; \t~StreamBase(){ if constexpr (BusMode::BLOCKING != mode) flush(); }   StreamBase(const StreamBase&amp;) = delete; \tStreamBase&amp; operator= (const StreamBase&amp;) = delete;  \tstream_t&amp; operator &lt;&lt; (const char_type auto c){  \t\tif constexpr (BusMode::BLOCKING == mode){  \t\t\tbus.send(&amp;c, 1);  \t\t} else {  \t\t\t*it = c; \t\t\tit = std::next(it); \t\t} \t\treturn *this; \t}  \tstream_t&amp; operator &lt;&lt; (const std::floating_point auto f){  \t\tif constexpr (BusMode::BLOCKING == mode){  \t\t\tauto [ptr, cnt] = NumConvert::to_string_float(f, buffer.data());  \t\t\tbus.send(ptr, cnt);  \t\t} else {  \t\t\tauto [ptr, cnt] = NumConvert::to_string_float(f, buffer.data() + std::distance(buffer.begin(), it));  \t\t\tit = std::next(it, cnt); \t\t} \t\treturn *this; \t}  \tstream_t&amp; operator &lt;&lt; (const num_type auto n){  \t\tauto [ptr, cnt] = NumConvert::to_string_integer( n, &amp;buffer.back() );  \t\tif constexpr (BusMode::BLOCKING == mode){  \t\t\tbus.send(ptr, cnt);  \t\t} else {  \t\t\tauto src = std::prev(buffer.end(), cnt + 1);  \t\t\tit = std::copy(src, buffer.end(), it); \t\t} \t\treturn *this; \t}  \tstream_t&amp; operator &lt;&lt; (const std::ranges::range auto&amp; r){          std::ranges::for_each(r, [this](const auto val) {                          if constexpr (char_type&lt;decltype(val)&gt;){                              *this &lt;&lt; val;              } else if (num_type&lt;decltype(val)&gt; || std::floating_point&lt;decltype(val)&gt;){                  *this &lt;&lt; val &lt;&lt; Delim;             }         }); \t\treturn *this; \t}  private:  \tvoid flush (void) {  \t\tbus.send(buffer.data(), std::distance(buffer.begin(), it));  \t\tit = buffer.begin(); \t}  \tstd::span&lt;char&gt; buffer{storage}; \tstd::span&lt;char&gt;::iterator it{buffer.begin()};  \tbus_t bus; }; <\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0435 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c Delim \u0442\u0438\u043f\u0430 <em>char<\/em> \u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <em>StreamStorage.<\/em> \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e &#8212; \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043c\u0430\u0441\u0441\u0438\u0432\u0443 <em>char<\/em>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u0436\u0438\u043c\u0435. \u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0436\u0443, \u043e\u043d\u0430 \u0432\u0442\u043e\u0440\u0438\u0447\u043d\u0430 \u043a \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0442\u0435\u043c\u0435; \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u043d\u0430 \u0432\u0430\u0448\u0435 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0443\u0442\u044f\u043d\u0438\u0442\u0435 \u0438\u0437 \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.  \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u0442\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 &#8212; <em>storage<\/em>) \u043c\u044b \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u0434\u0432\u0430 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0445 \u0447\u043b\u0435\u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0430: <\/p>\n<pre><code class=\"cpp\">std::span&lt;char&gt; buffer{storage}; std::span&lt;char&gt;::iterator it{buffer.begin()};<\/code><\/pre>\n<p>Delim  &#8212; \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043c\u0435\u0436\u0434\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432\/\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432.<\/p>\n<p>\u041f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 &#8212; \u044d\u0442\u043e \u0447\u0435\u0442\u044b\u0440\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 <strong><em>operator&lt;&lt;.<\/em><\/strong> \u0422\u0440\u0438 \u0438\u0437 \u043d\u0438\u0445 &#8212; \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043d\u0430\u0448 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c (<em>char, float \u0438 integral type<\/em>), \u0430 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f &#8212; \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432.<\/p>\n<p>\u0412\u043e\u0442 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u0430\u044f \u0432\u043a\u0443\u0441\u043d\u043e\u0442\u0430.<\/p>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 &#8212; \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0430. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u044b <em>char_type, num_type<\/em>&#8230;<\/p>\n<pre><code class=\"cpp\">template &lt;typename T&gt; concept char_type = std::same_as&lt;T, char&gt;;  template &lt;typename T&gt; concept num_type = std::integral&lt;T&gt; &amp;&amp; !char_type&lt;T&gt;;<\/code><\/pre>\n<p>&#8230; \u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u044b \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 &#8212;  <em>std::floating_point<\/em> \u0438 <em>std::ranges::range.<\/em><\/p>\n<p>\u041a\u043e\u043d\u0446\u0435\u043f\u0442\u044b \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0437\u0430\u0449\u0438\u0449\u0430\u044e\u0442 \u043d\u0430\u0441 \u043e\u0442 \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a, \u0438 \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u0435 \u0441  \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u043e\u043c <em>range <\/em>\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432.<\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u0440\u043e\u0441\u0442\u0430. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0436\u0438\u043c\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 (\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \/ \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439) \u043c\u044b \u0438\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u044c, \u043b\u0438\u0431\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u0442\u0440\u043e\u043a\u0443. \u0418 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0440\u0430\u0437\u0440\u0443\u0448\u0430\u0435\u0442\u0441\u044f, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u0433\u0434\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <em>flush()<\/em> \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u044c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 IT \u0438\u043b\u0438 DMA.<\/p>\n<p>\u041f\u0440\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 <em>char<\/em>-\u043e\u0432 \u044f \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043e\u0442 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u0438\u0434\u0438\u043e\u043c\u044b \u0441 <em>snprintf()<\/em>  \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043e\u043a <a href=\"http:\/\/we.easyelectronics.ru\/blog\/Soft\/2400.html\" rel=\"noopener noreferrer nofollow\">neiver<\/a>. \u0410\u0432\u0442\u043e\u0440 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f\u0445 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0447\u0438\u0441\u0435\u043b \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u0430\u043a \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0430, \u0442\u0430\u043a \u0438 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f.  \u041f\u043e\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0443 \u043d\u0435\u0433\u043e \u043a\u043e\u0434 \u044f \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <em>NumConvert<\/em>, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b <em>to_string_integer() <\/em>\u0438 <em>to_string_float().<\/em> <\/p>\n<p>\u0412 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\/\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043c\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <em>std::ranges::for_each()<\/em> \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443 \u0440\u044d\u0439\u043d\u0434\u0436\u0430 \u0438 \u0435\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0443 <em>char_type<\/em>, \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441\u043b\u0438\u0442\u043d\u043e. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0430\u043c <em>num_type<\/em> \u0438\u043b\u0438 <em>std::floating_point<\/em>, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f Delim.<\/p>\n<p>\u041d\u0443 \u0445\u043e\u0440\u043e\u0448\u043e, \u043c\u044b \u0442\u0443\u0442 \u043d\u0430\u0432\u043e\u0440\u043e\u0442\u0438\u043b\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0435\u0439 \u043f\u043b\u044e\u0441\u043e\u0432\u043e\u0439 \u0442\u044f\u0436\u0435\u043b\u043e\u0439 \u0430\u0440\u0442\u0438\u043b\u043b\u0435\u0440\u0438\u0438. \u042d\u0442\u043e \u0436 \u043a\u0430\u043a\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u0443\u044e \u043f\u043e\u0440\u0442\u044f\u043d\u043a\u0443 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435? \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">int main() {      using StreamUartBlocking = StreamBase&lt;UartBlocking, ' '&gt;;      StreamUartBlocking cout;      cout &lt;&lt; 'A'; \/\/ 1   cout &lt;&lt; (\"esreveR me!\" | std::views::take(7) | std::views::reverse); \/\/ 2      return 0; }<\/code><\/pre>\n<p>\u0412\u044b\u0441\u0442\u0430\u0432\u0438\u043c \u0444\u043b\u0430\u0433\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430: -std=gnu++20 -Os -fno-exceptions -fno-rtti. \u0422\u043e\u0433\u0434\u0430 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433:<\/p>\n<pre><code class=\"cpp\">main:         push    {r3, lr}         movs    r0, #65         bl      putchar         movs    r0, #0         pop     {r3, pc}<\/code><\/pre>\n<p>\u041d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">.LC0:         .ascii  \"esreveR me!\\000\" main:         push    {r3, r4, r5, lr}         ldr     r5, .L4         movs    r4, #5 .L3:         subs    r4, r4, #1         bcc     .L2         ldrb    r0, [r5, r4]    @<\/code><\/pre>\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-322814","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322814","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=322814"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322814\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}