{"id":298771,"date":"2020-02-16T21:00:16","date_gmt":"2020-02-16T21:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=298771"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=298771","title":{"rendered":"\u0421\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u043f\u0438\u0448\u0443\u0442 Uart \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u043b\u044f STM32F411"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/488574\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/i1\/n7\/5q\/i1n75qshrgbcmq2diq3ztb2fjgm.png\"><\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0437\u0434\u0440\u0430\u0432\u0438\u044f \u0432\u0441\u0435\u043c!<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u0432\u0430\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u0443\u0447\u0430\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u041f\u041e \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 UART \u043d\u0430 STM32F411. \u041a\u043e\u0434 \u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043c\u043e\u0438\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0430\u043c\u0438 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0437\u0434\u0435\u0441\u044c. <\/p>\n<p>  <\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0441\u0442\u0430\u0442\u0438\u043a\u043e\u0439, \u043a\u0430\u043a \u044f \u0443\u0447\u0438\u043b \ud83d\ude42 (\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0442\u0440\u0430\u043d\u043d\u043e-\u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435), \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b \u0442\u0430\u043a\u0430\u044f \u0436\u0435, \u043d\u043e \u043a\u043e\u0434\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u043a\u0430\u043a \u043f\u043e \u043e\u0431\u044a\u0435\u043c\u0443 \u0442\u0430\u043a \u0438 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u0442 \u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u0443, \u0430 \u043b\u0438\u0448\u044c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e Uart \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043d\u0430 \u0421++.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"ideya\">\u0418\u0434\u0435\u044f<\/h2>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a \u0431\u044b\u043b\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043c\u0435\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435<\/li>\n<li>\u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043c\u0435\u0442\u044c \u043e\u0442\u0441\u044b\u043b\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442<\/li>\n<li>\u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043c\u0435\u0442\u044c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442<\/li>\n<li>\u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0438 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0447\u0442\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li>\u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u043e \u043f\u0440\u0438\u0435\u043c\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"obschaya-arhitektura\">\u041e\u0431\u0449\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043d\u0438\u0436\u0435 \u043f\u043e\u044f\u0441\u043d\u044f\u0435\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 UART \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/g0\/iu\/5e\/g0iu5eucj60dkquwc4etuae7w84.png\"><\/p>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u044d\u0442\u043e \u0441\u043b\u043e\u0439 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u0439 \u043e\u0442 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 UART, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0447\u0435\u043d\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430, \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>  <\/p>\n<h2 id=\"arhitektura-drayvera\">\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0435\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043e\u0447\u0435\u043d\u044c \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sq\/ec\/te\/sqecte0m4pylo-hqn09zudzv-ss.png\"><\/p>\n<p>  <\/p>\n<p>\u0423 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>WriteData(const uint8_t *pData, uint8_t size)<\/code> \u2014 \u0434\u043b\u044f \u043f\u043e\u0441\u044b\u043b\u043a\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0431\u0430\u0439\u0442\u043e\u0432<\/li>\n<li><code>ReadData(uint8_t size)<\/code> \u2014 \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 <\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>OnTransmit()<\/code> \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f UART \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430<\/li>\n<li><code>OnTransmitComplete()<\/code> \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f UART \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u043f\u0440\u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 <\/li>\n<li><code>OnReceive()<\/code> \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f UART \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u043f\u0440\u0438 \u043f\u0440\u0438\u0435\u043c\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043f\u0438\u0441\u043a\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432. \u0412\u0441\u0435\u0433\u043e 2 \u0441\u043f\u0438\u0441\u043a\u0430: <\/p>\n<p>  <\/p>\n<ul>\n<li><code>UartDriverTransmitCompleteObservers<\/code> \u2014 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>OnTransmitComplete()<\/code> \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0443 \u0432\u0441\u0435\u0445 \u0441\u0432\u043e\u0438\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u043c\u0435\u0442\u043e\u0434 <code>OnTransmitComplete()<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 UartDriverTransmitCompleteObservers<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;typename ...Observers&gt; struct UartDriverTransmitCompleteObservers {   __forceinline static void OnWriteComplete()    {     (Observers::OnTransmitComplete(), ...) ;   } };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<ul>\n<li><code>UartDriverReceiveObservers<\/code> \u2014 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>OnReceiveComplete()<\/code>\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0443 \u0432\u0441\u0435\u0445 \u0441\u0432\u043e\u0438\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u043c\u0435\u0442\u043e\u0434 <code>OnReceiveComplete()<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 UartDriverReceiveObservers<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;typename ...Observers&gt; struct UartDriverReceiveCompleteObservers {   __forceinline static void OnReadComplete(tBuffer&amp; buffer, std::size_t bytesReceived)   {     (Observers::OnReceiveComplete(buffer, bytesReceived), ...) ;   } };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0445\u043e\u0442\u044c \u043a\u0442\u043e, \u0443 \u043a\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>OnReceiveComplete()<\/code> \u0438\u043b\u0438<br \/>  <code>OnTransmitComplete()<\/code>. \u041d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0434\u0432\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430 <code>SomeProtocol<\/code> \u0438 <code>OtherObserver<\/code>. <\/p>\n<p>  <\/p>\n<h2 id=\"realizaciya\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>  <\/p>\n<h3 id=\"metod-writedata\">\u041c\u0435\u0442\u043e\u0434 WriteData()<\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0441\u044b\u043b\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<p>  <\/p>\n<blockquote><p>\u041c\u0435\u0442\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d:  <\/p>\n<ul>\n<li>\u0417\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u0435\u043c (\u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c, \u0438 \u043f\u0440\u0438\u0435\u043c \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d)<\/li>\n<li>\u0417\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043f\u0440\u0438\u0435\u043c\u0443 (\u0442\u0430\u043a\u0436\u0435 \u043e\u043d\u043e \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435)<\/li>\n<li>\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0431\u0430\u0439\u0442 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <\/li>\n<li>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0430\u0439\u0442 \u0432 UART<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0430\u0439\u0442 \u0432 1, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0443\u0436\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438<\/li>\n<li>\u0418\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 <\/li>\n<\/ul>\n<p>  <\/p><\/blockquote>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0432 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">static void WriteData(const std::uint8_t *pData, std::uint8_t bytesTosend)   {     assert(bytesTosend &lt; txRxBuffer.size()) ;    \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438.     \/\/ \u0442.\u0435. \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0438\u0431\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044b \u043b\u0438\u0431\u043e \u0443\u0436\u0435 \u043e\u0442\u043e\u0441\u043b\u0430\u043d\u044b     if ((status != Status::Write) &amp;&amp; (status != Status::Read))    {       const CriticalSection cs;        Uart::DisableReceive();       Uart::DisableRxInterrupt();        bufferIndex = 0U;       bufferSize = bytesTosend;       std::memcpy(txRxBuffer.data(), pData, static_cast&lt;std::size_t&gt;(bytesTosend));        Uart::WriteByte(txRxBuffer[bufferIndex]);       bufferIndex++;       \/\/\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0440\u0435\u0436\u0438\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430       status = Status::Write;       Uart::StartTransmit();     }   }<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sobytie-ontransmit\">\u0421\u043e\u0431\u044b\u0442\u0438\u0435 OnTransmit()<\/h3>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u0430\u043a \u0431\u0430\u0439\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d (\u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u0449\u0435\u043b\u043a\u0443) UART \u043c\u043e\u0434\u0443\u043b\u044c \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>OnTransmit()<\/code> \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 <code>UartDriver<\/code> \u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0441\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0447\u0435\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f <code>OnTransmit()<\/code> \u2014 \u043e\u0442\u0441\u044b\u043b\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0431\u0430\u0439\u0442. <\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">__forceinline static void OnTransmit()   {     \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u0441\u0435 \u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b (\u0434\u043e \u0437\u0430\u0449\u0435\u043b\u043a\u0438)     if(bufferIndex &lt; bufferSize)         {       Uart::WriteByte(txRxBuffer[bufferIndex]) ;       bufferIndex ++ ;     }  else         {      \/\/\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b, \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0449\u0435\u043b\u043a\u0438       \/\/\u0427\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0431\u0430\u0439\u0442 \u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0448\u0435\u043b \u0432 \u043b\u0438\u043d\u0438\u044e        Uart::EnableTcInterrupt() ;     }   };<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sobytie-ontransmitcomplete\">\u0421\u043e\u0431\u044b\u0442\u0438\u0435 OnTransmitComplete()<\/h3>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u0443 UART \u043e\u0431\u044b\u0447\u043d\u043e \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f: \u043e\u0434\u043d\u043e \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0432\u0442\u043e\u0440\u043e\u0435 \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0449\u0435\u043b\u043a\u0438 (\u0442.\u0435. \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0431\u0430\u0439\u0442 \u0432\u044b\u0448\u0435\u043b \u0432 \u043b\u0438\u043d\u0438\u044e), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0431\u0430\u0439\u0442 \u0432\u044b\u0448\u0435\u043b \u0432 \u043b\u0438\u043d\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0449\u0435\u043b\u043a\u0438.<\/p>\n<p>  <\/p>\n<blockquote><p>\u041c\u0435\u0442\u043e\u0434 OnTransmitComplete() \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0449\u0435\u0439:  <\/p>\n<ul>\n<li>\u0421\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0430\u0439\u0442<\/li>\n<li>\u0421\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li>\u0417\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430<\/li>\n<li>\u041e\u043f\u043e\u0432\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>OnTransmitComplete()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 <code>UartDriverTransmitCompleteObservers<\/code><\/li>\n<\/ul>\n<p>  <\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"cpp\">static void OnTransmitComplete()   {     bufferIndex = 0U;     bufferSize = 0U;      Uart::DisableTcInterrupt();     Uart::DisableTxInterrupt() ;     Uart::DisableTransmit();      status = Status::WriteComplete;    \/\/ \u043e\u043f\u043e\u0432\u0435\u0449\u0430\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430     UartDriverTransmitCompleteObservers::OnWriteComplete() ;   }<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"metod-readdata\">\u041c\u0435\u0442\u043e\u0434 ReadData()<\/h3>\n<p>  <\/p>\n<p>\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>  <\/p>\n<blockquote><p>\u041c\u0435\u0442\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d:   <\/p>\n<ul>\n<li>\u0417\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443<\/li>\n<li>\u0417\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u044b\u0445 \u0431\u0430\u0439\u0442 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <\/li>\n<li>\u041e\u0431\u043d\u0443\u043b\u0438\u0442\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0431\u0430\u0439\u0442<\/li>\n<li>\u0418\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0435\u043c<\/li>\n<\/ul>\n<p>  <\/p><\/blockquote>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">static auto ReadData(std::uint8_t size)  {     assert(size &lt; txRxBuffer.size()) ;    \/\/  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0442\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438.     \/\/ \u0442.\u0435. \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0438\u0431\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044b \u043b\u0438\u0431\u043e \u0443\u0436\u0435 \u043e\u0442\u043e\u0441\u043b\u0430\u043d\u044b     if ((status != Status::Write) &amp;&amp; (status != Status::Read))     {       const CriticalSection cs;        Uart::DisableTcInterrupt();       Uart::DisableTxInterrupt();       Uart::DisableTransmit();        bufferIndex = 0U;             bufferSize = size;         \/\/\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0440\u0435\u0436\u0438\u043c \u043f\u0440\u0438\u0435\u043c\u0430       status = Status::Read;        Uart::EnableReceive();       Uart::EnableRxInterrupt();     }<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sobytie-onreceive\">\u0421\u043e\u0431\u044b\u0442\u0438\u0435 OnReceive()<\/h3>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u043c UART \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u0430\u043a \u0431\u044b\u043b \u043f\u0440\u0438\u043d\u044f\u0442 \u0431\u0430\u0439\u0442. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0431\u0430\u0439\u0442 \u0438 \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u0435\u043c \u0438 \u043e\u043f\u043e\u0432\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432, \u0447\u0442\u043e \u043f\u0440\u0438\u0435\u043c \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d.<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\"> static void OnReceive()    {     txRxBuffer[bufferIndex] = Uart::ReadByte() ;     bufferIndex ++ ;     if (bufferIndex == bufferSize)         {          status = Status::ReadComplete ;        UartDriverReceiveObservers::OnReadComplete(txRxBuffer, bufferIndex) ;     }   }<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"ves-kod-drayvera\">\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430<\/h3>\n<p>  <\/p>\n<p>\u041a\u043e\u0434 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">uartdriver.hpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef REGISTERS_UARTDRIVER_HPP #define REGISTERS_UARTDRIVER_HPP  #include &quot;susudefs.hpp&quot; \/\/for __forceinline #include &quot;hardwareuarttx.hpp&quot; \/\/ for HardwareUartTx #include &quot;hardwareuarttc.hpp&quot; \/\/for HardwareUartTc #include &quot;hardwareuartrx.hpp&quot; \/\/ for HardwareUartRx #include &lt;cstring&gt; \/\/ for memcpy #include &quot;criticalsectionconfig.hpp&quot; \/\/ for CriticalSection #include &quot;uartdriverconfig.hpp&quot; \/\/ for tBuffer  template&lt;typename UartModule, typename  UartDriverTransmitCompleteObservers, typename UartDriverReceiveObservers&gt; struct UartDriver {   using Uart = UartModule ;    enum class Status: std::uint8_t   {     None  = 0,     Write = 1,     WriteComplete = 2,     Read = 3,     ReadComplete = 4   } ;    static void WriteData(const std::uint8_t *pData, std::uint8_t bytesTosend)   {     assert(bytesTosend &lt; txRxBuffer.size()) ;     if ((status != Status::Write) &amp;&amp; (status != Status::Read))     {       const CriticalSection cs;        Uart::DisableReceive();       Uart::DisableRxInterrupt();        bufferIndex = 0U;       bufferSize = bytesTosend;       std::memcpy(txRxBuffer.data(), pData, static_cast&lt;std::size_t&gt;(bytesTosend));        Uart::WriteByte(txRxBuffer[bufferIndex]);       bufferIndex++;        status = Status::Write;       Uart::StartTransmit();       \/\/\u0435\u0441\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439, \u0442\u043e \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u043c \u043f\u0440\u044f\u043c\u043e \u0442\u0443\u0442       if constexpr (!std::is_base_of&lt;UartTxInterruptable, typename Uart::Base&gt;::value)       {         for(; bufferIndex &lt; bytesTosend; ++bufferIndex)         {           while (!Uart::IsDataRegisterEmpty())           {            }           Uart::WriteByte(txRxBuffer[bufferIndex]);                   }         while (!Uart::IsTransmitComplete())         {          }         \/\/Proceed() ;         status = Status::WriteComplete ;         UartDriverTransmitCompleteObservers::OnWriteComplete() ;       } else       {        }     }   }    __forceinline static void OnTransmit()   {     if(bufferIndex &lt; bufferSize)     {       Uart::WriteByte(txRxBuffer[bufferIndex]) ;       bufferIndex ++ ;     }     else     {       Uart::EnableTcInterrupt() ;     }   };    static void OnTransmitComplete()   {     bufferIndex = 0U;     bufferSize = 0U;      Uart::DisableTcInterrupt();     Uart::DisableTxInterrupt() ;     Uart::DisableTransmit();      status = Status::WriteComplete;     UartDriverTransmitCompleteObservers::OnWriteComplete() ;   }    static auto ReadData(std::uint8_t size)   {     assert(size &lt; txRxBuffer.size()) ;     if ((status != Status::Write) &amp;&amp; (status != Status::Read))     {       const CriticalSection cs;        Uart::DisableTcInterrupt();       Uart::DisableTxInterrupt();       Uart::DisableTransmit();        bufferIndex = 0U;             bufferSize = size;       status = Status::Read;        Uart::EnableReceive();       Uart::EnableRxInterrupt();     }    }    static void OnReceive()   {     txRxBuffer[bufferIndex] = Uart::ReadByte() ;     bufferIndex ++ ;     if (bufferIndex == bufferSize)     {          status = Status::ReadComplete ;        UartDriverReceiveObservers::OnReadComplete(txRxBuffer, static_cast&lt;std::size_t&gt;(bufferIndex)) ;     }   }    static Status GetStatus()   {     return status ;   }    static void ResetAll()   {     Uart::DisableTcInterrupt();     Uart::DisableTxInterrupt();     Uart::DisableTransmit();      Uart::DisableReceive();     Uart::DisableRxInterrupt() ;      bufferIndex = 0U;     bufferSize = 0U;     status = Status::None;       }  private:    inline static  tBuffer txRxBuffer = {} ;   inline static std::uint8_t bufferSize = 0U ;   inline static std::uint8_t bufferIndex = 0U ;   inline static Status status = Status::None ;  }; #endif \/\/REGISTERS_UARTDRIVER_HPP <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h2 id=\"kak-etim-polzovatsya\">\u041a\u0430\u043a \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f?<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>SomeProtocol<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 10 \u0431\u0430\u0439\u0442 \u0438 \u043e\u0442\u0441\u044b\u043b\u0430\u0435\u0442 10 \u0431\u0430\u0439\u0442. \u041d\u0443\u043b\u0435\u0432\u043e\u0439 \u0431\u0430\u0439\u0442 \u2014 \u044d\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u2014 \u044d\u0442\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430. \u0410 \u0434\u0430\u043d\u043d\u044b\u0445 8 \u0431\u0430\u0439\u0442, \u0442.\u0435. \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u0435\u043c\u0430 \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0431\u0430\u0439\u0442, \u0435\u0441\u043b\u0438 10, \u0442\u043e \u043f\u043e\u0441\u044b\u043b\u043a\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c. (\u041f\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e, \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043f\u043e\u0441\u044b\u043b\u043a\u0438 \u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e \u0442\u0430\u0439\u043c\u0435\u0440\u0443, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043b\u043e\u0434\u0438\u0442\u044c \u043a\u043e\u0434\u0430, \u044f \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b \u0434\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u043e\u0442 \u0441\u0443\u043f\u0435\u0440 \u043f\u0443\u043f\u0435\u0440 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430) <\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <code>OnTransmitComplete()<\/code> \u0438 <code>OnReceiveComplete()<\/code>.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043c\u043e\u0436\u0435\u0442 \u043a\u0430\u043a \u0442\u043e \u0442\u0430\u043a:<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template &lt;typename UartDriver&gt; struct SomeProtocol  {   __forceinline static void OnTransmitComplete()   {     \/\/\u0441\u043d\u043e\u0432\u0430 \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u043f\u0440\u0438\u0435\u043c\u0430 10 \u0431\u0430\u0439\u0442;      Proceed() ;   }    __forceinline static void OnReceiveComplete(tBuffer&amp; buffer, std::size_t length)     {      \/\/ \u041f\u0440\u0438\u043c\u0435\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d, \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e\u0441\u044b\u043b\u043a\u0443       assert(length &lt;= buffer.size()) ;     \/\/\u041d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0443 \u0441\u0443\u043c\u043c\u0443, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u0430 \u0441\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b     if (CheckData(buffer))          {       \/\/\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u043b\u0435\u0436\u0438\u0442 \u043f\u043e 0 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0431\u0443\u0444\u0435\u0440\u0430. \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443       \/\/ \u0432\u043e\u043e\u0431\u0449\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0431\u044b \u0442\u0443\u0442 \u0432\u044b\u0439\u0442\u0438 \u0438\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f. \u0422.\u0435. \u043e\u043f\u043e\u0432\u0435\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u0447\u0442\u043e \u043c\u043e\u043b       \/\/ \u0432\u0441\u0435 \u043f\u0440\u0438\u0448\u043b\u043e, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0443\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0443... \u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043c \u0432\u0441\u0435 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432        \/\/ \u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0438.             cmds::ProceedCmd(buffer[0], buffer); \/\/ \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442 \u0431\u0443\u0444\u0435\u0440 \u043e\u0442\u0432\u0435\u0442\u043e\u043c.       \/\/\u041e\u0442\u0441\u044b\u043b\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442       UartDriver::WriteData(buffer.data(), length) ;     } else         {       UartDriver::ResetAll() ;     }   }     __forceinline static void Proceed()     {     \/\/\u0417\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u043e 10 \u0431\u0430\u0439\u0442\u0443.     UartDriver::ReadData(10) ;   }   \/\/\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434   using cmds = CmdContainer&lt;       Singleton&lt;CmdWriteSomeData&gt;::GetInstance(),       Singleton&lt;CmdReadSomeData&gt;::GetInstance()   &gt; ; };  \/\/ \u041f\u0440\u043e\u0441\u0442\u043e \u0435\u0449\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a \u043d\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0445\u043e\u0442\u0438\u043c \u043c\u043e\u0440\u0433\u043d\u0443\u0442\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u043c struct TestObserver  {   __forceinline static void OnTransmitComplete()     {     Led1::Toggle() ;   } };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043d\u0430 UartDriver<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">struct MyUartDriver: UartDriver&lt;     \/\/\u042d\u0442\u043e \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c UART     HardwareUart,     \/\/ \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c SomeProtocol \u0438  TestObserver \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435  OnTransmitComplete()     UartDriverTransmitCompleteObservers&lt;SomeProtocol&lt;MyUartDriver&gt;, TestObserver&gt;,    \/\/ \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e SomeProtocol \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435  OnReceiveComplete()     UartDriverReceiveCompleteObservers&lt;SomeProtocol&lt;MyUartDriver&gt;&gt;     &gt; { };  using MyProtocol = SomeProtocol&lt;MyUartDriver&gt; ;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c \u0443\u0433\u043e\u0434\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u043d\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0435\u043c\u0430 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043b \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <code>TestObserver<\/code>\u0438 <code>SomeProtocol<\/code>, \u0430 \u043d\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0435\u043c\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u2014 <code>SomeProtocol<\/code>. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 UART \u043c\u043e\u0434\u0443\u043b\u044c.<\/p>\n<p>  <\/p>\n<p>\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">int main() {   \/\/\u0417\u0430\u043f\u0443\u0441\u043a \u0441\u0442\u0435\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430    MyProtocol::Proceed() ;    while(true)   {  }    return 1 ; }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"uart-modul\">UART \u043c\u043e\u0434\u0443\u043b\u044c<\/h2>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0435 \u0447\u0438\u0442\u0430\u0435\u0442\u0435, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a \u0440\u0435\u0437\u043e\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <code>HardwareUart<\/code> UART \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u043e\u043d \u0432\u0437\u044f\u043b\u0441\u044f. \u0415\u0433\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a: <\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/zm\/t-\/c1\/zmt-c1p3hohkqshtcv2sht4qc5g.png\"><\/p>\n<p>  <\/p>\n<p>\u041f\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u043c\u0443 \u0441\u0447\u0435\u0442\u0443 \u2014 \u044d\u0442\u043e \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u043c UART \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f 3 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439: <\/p>\n<p>  <\/p>\n<ul>\n<li><code>HardwareUartTx<\/code> \u2014 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432, \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u044d\u0442\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435<\/li>\n<li><code>HardwareUartTc<\/code> \u2014 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0449\u0435\u043b\u043a\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432, \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u044d\u0442\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435<\/li>\n<li><code>HardwareUartRx<\/code> \u2014 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0443 \u0431\u0430\u0439\u0442\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432, \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u044d\u0442\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>HandleInterrupt()<\/code> \u043a\u043b\u0430\u0441\u0441\u0430 <code>HardwareUartBase<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">template&lt;typename... Modules&gt; struct InterruptsList {   __forceinline static void OnInterrupt()   {     \/\/\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432     (Modules::HandleInterrupt(), ...) ;    } } ;  template&lt;typename UartModule, typename InterruptsList&gt; struct HardwareUartBase  {       static void HandleInterrupt()     {     \/\/\u043e\u0431\u044b\u0447\u043d\u043e \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 HardwareUartTx, HardwareUartTc, HardwareUartRx \u0438      \/\/ \u0437\u0434\u0435\u0441\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438     InterruptsList::OnInterrupt() ;   }  ... } ;<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043b\u0430\u0441\u0441\u044b HardwareUartTx , HardwareUartRx, HardwareUartTx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;typename UartModule, typename UartTransmitObservers&gt; struct HardwareUartTx  {   using Uart = typename UartModule::Uart ;   static void HandleInterrupt()     {    \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043b\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445     if(Uart::SR::TXE::DataRegisterEmpty::IsSet()  &amp;&amp;        Uart::CR1::TXEIE::InterruptWhenTXE::IsSet())         {       UartTransmitObservers::OnTxDataRegEmpty();     }   } };  template&lt;typename UartModule, typename UartReceiveObservers&gt; struct HardwareUartRx  {    using Uart = typename UartModule::Uart ;    static void HandleInterrupt()      {      \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043b\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043f\u0440\u0438\u0435\u043c\u0443 \u0431\u0430\u0439\u0442\u0430      if(Uart::CR1::RXNEIE::InterruptWhenRXNE::IsSet()  &amp;&amp;          Uart::SR::RXNE::DataRecieved::IsSet() )         {        UartReceiveObservers::OnRxData();      }   } };  template&lt;typename UartModule, typename UartTransmitCompleteObservers&gt; struct HardwareUartTc  {   using Uart = typename UartModule::Uart ;     static void HandleInterrupt()     {     \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043b\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0449\u0435\u043b\u043a\u0438     if(Uart::SR::TC::TransmitionComplete::IsSet()  &amp;&amp;        Uart::CR1::TCIE::InterruptWhenTC::IsSet())         {       UartTransmitCompleteObservers::OnComplete();       Uart::SR::TC::TransmitionNotComplete::Set() ;     }   } };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 HardwareUartBase<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef REGISTERS_UART_HPP #define REGISTERS_UART_HPP  #include &quot;susudefs.hpp&quot; \/\/for __forceinline #include &lt;array&gt; \/\/ for std::array #include &lt;cassert&gt; \/\/ for assert #include &lt;cstring&gt; \/\/ for memcpy #include &quot;criticalsectionguard.hpp&quot; \/\/for criticalsectionguard  template&lt;typename UartModule,  typename InterruptsList&gt; struct HardwareUartBase {   using Uart = UartModule ;   using Base = Interface ;      __forceinline static void EnableTransmit()   {     UartModule::CR1::TE::Enable::Set();   };    static void DisableTransmit()   {     UartModule::CR1::TE::Disable::Set();   };    static void EnableReceive()   {     UartModule::CR1::RE::Enable::Set();   };    static void DisableReceive()   {     UartModule::CR1::RE::Disable::Set();   };    static void EnableTxInterrupt()   {     UartModule::CR1::TXEIE::InterruptWhenTXE::Set();   };    static void EnableRxInterrupt()   {     UartModule::CR1::RXNEIE::InterruptWhenRXNE::Set();   };    static void DisableRxInterrupt()   {     UartModule::CR1::RXNEIE::InterruptInhibited::Set();   };    static void DisableTxInterrupt()   {     UartModule::CR1::TXEIE::InterruptInhibited::Set();   };    static void EnableTcInterrupt()   {     UartModule::CR1::TCIE::InterruptWhenTC::Set();   };    static void DisableTcInterrupt()   {     UartModule::CR1::TCIE::InterruptInhibited::Set();   };    static void HandleInterrupt()   {     InterruptsList::OnInterrupt() ;   }    __forceinline static void ClearStatus()   {     UartModule::SR::Write(0);   }    static void WriteByte(std::uint8_t chByte)   {     UartModule::DR::Write(static_cast&lt;std::uint32_t&gt;(chByte)) ;   }    static std::uint8_t ReadByte()   {     return static_cast&lt;std::uint8_t&gt;(UartModule::DR::Get()) ;   }     static void StartTransmit()   {     EnableTransmit() ;     if constexpr (std::is_base_of&lt;UartTxInterruptable, Interface&gt;::value)     {       EnableTxInterrupt() ;     }   }    static bool IsDataRegisterEmpty()   {     return UartModule::SR::TXE::DataRegisterEmpty::IsSet() ;   }    static bool IsTransmitComplete()   {     return UartModule::SR::TC::TransmitionComplete::IsSet() ;   }  }; #endif \/\/REGISTERS_UART_HPP<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 UART \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">struct HardwareUart : HardwareUartBase&lt;     USART2,         InterruptsList&lt;      \/\/\u0425\u043e\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445       HardwareUartTx&lt;HardwareUart,       \/\/\u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 Uart         UartTransmitObservers&lt;MyUartDriver&gt;&gt;,       \/\/\u0425\u043e\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0449\u0435\u043b\u043a\u0438       HardwareUartTc&lt;HardwareUart,       \/\/\u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0449\u0435\u043b\u043a\u0438         UartTransmitCompleteObservers&lt;MyUartDriver&gt;&gt;,       \/\/\u0425\u043e\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043f\u0440\u0438\u0435\u043c\u0443 \u0431\u0430\u0439\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445       HardwareUartRx&lt;HardwareUart,       \/\/\u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043f\u0440\u0438\u0435\u043c\u0443 \u0431\u0430\u0439\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445         UartReceiveObservers&lt;MyUartDriver&gt;&gt;     &gt;    &gt; { };<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043e, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430 \u0432\u0441\u0435 \u0442\u0440\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f UartDriver, \u043d\u043e \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0435\u0449\u0435 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u043b\u044e\u0431\u043e\u043c\u0443 UART, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u043a USART2.<\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 Uart \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0434\u0440\u0430\u0439\u0432\u0435\u0440, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0447\u0443\u0442\u044c \u0432\u044b\u0448\u0435. \u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u0436\u0435 \u0442\u0430\u043a\u0436\u0435 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e\u0442 Uart \u043c\u043e\u0434\u0443\u043b\u044f.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">struct MyUartDriver: UartDriver&lt;     \/\/\u042d\u0442\u043e \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c UART     HardwareUart,     \/\/ \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c SomeProtocol \u0438  TestObserver \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435  OnTransmitComplete()     UartDriverTransmitCompleteObservers&lt;SomeProtocol&lt;MyUartDriver&gt;, TestObserver&gt;,    \/\/ \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e SomeProtocol \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435  OnReceiveComplete()     UartDriverReceiveCompleteObservers&lt;SomeProtocol&lt;MyUartDriver&gt;&gt;     &gt; { };  using MyProtocol = SomeProtocol&lt;MyUartDriver&gt; ;<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h2 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0438 \u0446\u0435\u043b\u043e\u043c \u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0438 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438\u0441\u044c.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c inline, \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 1600 \u0431\u0430\u0439\u0442 \u0431\u0435\u0437 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u0421\u0434\u0435\u043b\u0430\u043d\u044b \u0434\u0432\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b: \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u0447\u0442\u0435\u043d\u0438\u0435 12 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0432\u043e Flash \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0432 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u043c\u043e\u0436\u043d\u043e \u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432, \u043a \u043b\u044e\u0431\u043e\u043c\u0443 UART. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u044b\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u0442\u044f\u043d\u0435\u0442 \u043d\u0430 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \ud83d\ude42 <\/p>\n<p>  <\/p>\n<p>\u0414\u0430, \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043e \u043d\u0430 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u044b\u043b\u043e 2 \u0446\u0435\u043b\u044b\u0445 \u0434\u043d\u044f (\u0434\u0443\u043c\u0430\u044e \u0447\u0430\u0441\u043e\u0432 20 \u0432 \u0441\u0443\u043c\u043c\u0435). \u041f\u043e\u043b\u0430\u0433\u0430\u044e, \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043c\u043d\u043e\u044e \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u043d\u044f\u0442\u0438\u044f\u0445, \u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u2014 \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0443\u0436\u0435 \u043d\u0435 \u0442\u0430\u043a\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435.<\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0434 \u0431\u044b\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d \u043c\u043d\u043e\u044e \u0432 PVS-Studio. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u044b 4 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f.<br \/>  \u0412\u0441\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u043c\u043d\u044e, \u043e\u0442\u0447\u0435\u0442 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b: \u043d\u043e \u0442\u043e\u0447\u043d\u043e \u0431\u044b\u043b\u0438 V2516 \u0438 V519, \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0435, \u043d\u043e \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \ud83d\ude42 \u0412\u0441\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e, \u043a\u0440\u043e\u043c\u0435 V2516, \u043e\u043d \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u0442\u0430\u043c \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b FIXME:.<\/p>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e <a href=\"https:\/\/yadi.sk\/d\/zmQ-19BUjx01Zg\" rel=\"nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430 IAR8.40.2 \u0437\u0434\u0435\u0441\u044c<\/a>, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u043e\u043f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043d\u043e \u043d\u0443\u0436\u043d\u0430 \u043f\u043b\u0430\u0442\u0430 Nucleo-F411RE, \u0441\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043b\u0435\u0436\u0438\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 <strong>FlashUart\\DinamicStand<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0438 Uart \u043c\u043e\u0434\u0443\u043b\u044f \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 <a href=\"https:\/\/github.com\/lamer0k\/CortexLib\/tree\/master\/AbstractHardware\/Uart\" rel=\"nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431\u0435 <\/a>.<\/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\/488574\/\"> https:\/\/habr.com\/ru\/post\/488574\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/488574\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/i1\/n7\/5q\/i1n75qshrgbcmq2diq3ztb2fjgm.png\"><\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0437\u0434\u0440\u0430\u0432\u0438\u044f \u0432\u0441\u0435\u043c!<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u0432\u0430\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u0443\u0447\u0430\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u041f\u041e \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 UART \u043d\u0430 STM32F411. \u041a\u043e\u0434 \u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043c\u043e\u0438\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0430\u043c\u0438 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0437\u0434\u0435\u0441\u044c. <\/p>\n<p>  <\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0441\u0442\u0430\u0442\u0438\u043a\u043e\u0439, \u043a\u0430\u043a \u044f \u0443\u0447\u0438\u043b \ud83d\ude42 (\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0442\u0440\u0430\u043d\u043d\u043e-\u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435), \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b \u0442\u0430\u043a\u0430\u044f \u0436\u0435, \u043d\u043e \u043a\u043e\u0434\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u043a\u0430\u043a \u043f\u043e \u043e\u0431\u044a\u0435\u043c\u0443 \u0442\u0430\u043a \u0438 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u0442 \u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u0443, \u0430 \u043b\u0438\u0448\u044c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e Uart \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043d\u0430 \u0421++.<\/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-298771","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298771","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=298771"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298771\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}