{"id":262762,"date":"2015-08-02T23:52:02","date_gmt":"2015-08-02T19:52:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=262762"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=262762","title":{"rendered":"STM32, C++ \u0438 FreeRTOS. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441 \u043d\u0443\u043b\u044f. \u0427\u0430\u0441\u0442\u044c 4 (\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, UART \u0438 \u043d\u0435\u0434\u043eHART)"},"content":{"rendered":"<br \/>\n<h4>\u0412\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041f\u043e\u043f\u0430\u0432 \u0432 \u043e\u0442\u043f\u0443\u0441\u043a\u0435 \u0432 \u0433\u043e\u0440\u043e\u0434 \u043d\u0430 \u041d\u0435\u0432\u0435 \u0438 \u043f\u043e\u0441\u0435\u0442\u0438\u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0445 \u043c\u0435\u0441\u0442, \u044f \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0432\u0435\u0447\u0435\u0440\u0430\u043c\u0438 \u0437\u0430 \u0447\u0430\u0448\u043a\u043e\u0439 \u043f\u0438\u0432\u0430, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 UART\u043e\u043c. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0447\u0442\u043e \u044f \u043a\u0443\u043f\u0438\u043b \u043d\u0435 \u043f\u043b\u043e\u0445\u0438\u0435 \u043d\u0430\u0443\u0448\u043d\u0438\u043a\u0438 Fisher FA011, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043a\u0443\u043f\u0438\u0442\u044c USB SOUND BLASTER X-FI HD \u0438 \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0441\u043b\u0443\u0448\u0430\u0442\u044c \u043c\u0443\u0437\u044b\u043a\u0443.<br \/>  \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u043b\u0438 \u043d\u0430 Geektime \u043f\u043e\u0442\u043e\u043c \u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0438\u0445 \u043f\u0435\u0440\u0435\u0433\u043d\u0430\u043b, \u0434\u0430\u0436\u0435 \u0438 \u043d\u0435 \u0437\u043d\u0430\u044e, \u043a\u0443\u0434\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0445 \u0434\u0435\u0442\u044c \ud83d\ude42<br \/>  \u041d\u043e \u0442\u0430\u043a \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043e\u043d\u0438 \u0442\u0443\u0442: <br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/261807\/\/\"> STM32, C++ \u0438 FreeRTOS. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441 \u043d\u0443\u043b\u044f. \u0427\u0430\u0441\u0442\u044c 1<\/a> <br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/261823\/\">STM32, C++ \u0438 FreeRTOS. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441 \u043d\u0443\u043b\u044f. \u0427\u0430\u0441\u0442\u044c 2<\/a> \u0438 <br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/261837\/\">STM32, C++ \u0438 FreeRTOS. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441 \u043d\u0443\u043b\u044f. \u0427\u0430\u0441\u0442\u044c 3 (LCD \u0438 \u042d\u043a\u0440\u0430\u043d\u044b)<\/a><\/p>\n<h4>UART<\/h4>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043c\u043d\u0435 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0430\u044f \u043f\u043e\u0441\u044b\u043b\u043a\u0430 \u0431\u0430\u0439\u0442\u0430 \u0432 \u043f\u043e\u0440\u0442 \u043f\u0440\u043e\u0448\u043b\u0430 \u0431\u0435\u0437 \u0437\u0430\u0434\u043e\u0440\u0438\u043d\u043a\u0438, \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043a\u0430\u043a \u0447\u0430\u0441\u044b, \u0438 \u0442\u0443\u0442 \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f. \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u044b\u043b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430. \u0418 IAR \u0432 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0442\u0430\u043a \u0438 \u043f\u0438\u0441\u0430\u043b:  <\/p>\n<blockquote><p>Special function types can be used for static member functions. For example, in the<br \/>  following example, the function handler is declared as an interrupt function:  <\/p>\n<pre><code class=\"cpp\">class Device {  static __irq void handler(); }; <\/code><\/pre>\n<\/blockquote>\n<p>  \u041d\u043e \u0432\u043e\u0442 \u043d\u0435\u0437\u0430\u0434\u0430\u0447\u0430, \u0434\u043b\u044f Cortex M \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0438   <\/p>\n<blockquote><p>On ARM Cortex-M, an interrupt service routine enters and returns in the same way as a<br \/>  normal function, which means no special keywords are required. <b>Thus, the keywords<br \/>  __irq, __fiq, and __nested are not available when you compile for ARM Cortex-M.<\/b><br \/>  These exception function names are defined in cstartup_M.c and cstartup_M.s.<br \/>  They are referred to by the library exception vector code:<br \/>  NMI_Handler<br \/>  HardFault_Handler<br \/>  MemManage_Handler<br \/>  BusFault_Handler<br \/>  \u2026<br \/>  The vector table is implemented as an array. It should always have the name<br \/>  __vector_table,   <\/p><\/blockquote>\n<p>  \u0418\u043b\u0438 \u043f\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443, \u0432\u0430\u0448 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u0438\u043c\u044f, \u043a\u0430\u043a\u043e\u0435 \u043e\u043d \u0438\u043c\u0435\u0435\u0442 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 startup \u0444\u0430\u0439\u043b\u0435. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u2014 \u0441\u043b\u0430\u0431\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 __weak (\u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 PUBWEAK), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440\u0430, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442\u0441\u044f \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0435 \u043f\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0431\u0435\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 __week. \u041d\u0443 \u0442.\u0435., \u0435\u0441\u043b\u0438 \u0432\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0438\u043c\u0435\u043d\u0435\u043c \u0431\u0435\u0437 \u044d\u0442\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b, \u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u0440\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435, \u0442\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043e __weak. <br \/>  \u041f\u043e\u043d\u044f\u0442\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u0447\u0442\u043e \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u0432 \u0444\u0430\u0439\u043b <b>startup_stm32l1xx_md.s<\/b> \u0438\u043b\u0438 <b>startup_stm32l1xx_md.\u0441<\/b> \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0421++ \u0438\u043c\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0442\u0438\u043f\u0430 <i>cUart::USART2_IRQHandler()<\/i>, \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u043e\u0439\u043c\u0435\u0442. <br \/>  \u0410 \u043f\u0440\u043e\u0441\u0442\u043e <i>\u00abUSART2_IRQHandler\u00bb<\/i> \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c <i>\u00abcUart::USART2_IRQHandler()\u00bb<\/i>. <br \/>  \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <i>extern \u00abC\u00bb { void USART2_IRQHandler(void) {&#8230;}}<\/i>, \u043d\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044f \u0442\u0443\u0442 \u0431\u0443\u0434\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0442\u0430\u043a\u0438 \u0438\u0437 \u0421\u0438, \u0447\u0442\u043e \u043c\u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043d\u0430\u0434\u043e, \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438\u0437 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u043c\u043e\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0431\u0443\u0444\u0435\u0440\u0443 \u2014 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0438 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u043a\u0443\u0447\u0443 \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0430 :). <br \/>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0439\u0442\u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0435\u043c \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b <b>startup_stm32l1xx_md.cpp<\/b>. \u041f\u043e\u0438\u0441\u043a \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043b\u044e\u0434\u0435\u0439 <br \/>  \u0412 \u043e\u0431\u0449\u0435\u043c \u0438\u0434\u0435\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c: \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c <b>startup_stm32l1xx_md.cpp<\/b> \u0432 \u043a\u043b\u0430\u0441\u0441\u044b \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0431\u0443\u0434\u0443\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439), \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 __vector_table, \u0433\u0434\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u0441\u0442\u043e\u0438\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043d\u0430 \u044d\u0442\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u0414\u0430\u043b\u044c\u0448\u0435 \u0434\u0435\u043b\u0430\u0435\u043c __weak \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430<br \/>  \u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0433\u0434\u0430 \u0432 \u043a\u043e\u0434\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u0438\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <i>void cUart1::handler()<\/i>, \u043e\u043d \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u044f\u0441\u044c \u0431\u0435\u0440\u0435\u0442 \u0435\u0451. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0430\u0448\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u0447\u044c \u0432 \u0442\u043e\u0447\u044c \u0442\u0430\u043a, \u043a\u0430\u043a \u043e\u043d\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 <b>startup_stm32l1xx_md.cpp<\/b>. <br \/>  \u041d\u0443\u0436\u043d\u043e \u0435\u0449\u0435 \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 FreeRtos: <i>vPortSVCHandler<\/i>, <i>xPortPendSVHandler<\/i>, <i>xPortSysTickHandler <\/i> \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u043d\u0443\u0436\u043d\u043e\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0438 \u0432\u0443\u0430\u043b\u044f \u2014 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">startup_stm32l1xx_md.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#pragma language = extended #pragma segment = &quot;CSTACK&quot; extern &quot;C&quot; void __iar_program_start( void ); extern &quot;C&quot; void vPortSVCHandler(void); extern &quot;C&quot; void xPortPendSVHandler(void); extern &quot;C&quot; void xPortSysTickHandler(void); class cNMI { public:     static void handler(void); }; class cHardFault { public:     static void handler(void); }; class cMemManage { public:     static void handler(void); }; class cBusFault { public:     static void handler(void); }; class cUsageFault { public:     static void handler(void); }; class cDebugMon { public:     static void handler(void); }; class cWindowWatchdog { public:     static void handler(void);     }; class cPvd { public:     static void handler(void);     }; class cTamperTimeStamp { public:     static void handler(void);     }; class cRtcWakeup { public:     static void handler(void);     }; class cFlash { public:     static void handler(void);     }; class cRcc { public:     static void handler(void);     }; class cExti { public:     static void line0Handler(void);     static void line1Handler(void);     static void line2Handler(void);     static void line3Handler(void);     static void line4Handler(void);     static void line9Handler(void);     static void line15_10Handler(void); }; class cDma { public:     static void channellHandler(void);         static void channel2Handler(void);         static void channel3Handler(void);         static void channel4Handler(void);         static void channel5Handler(void);         static void channel6Handler(void);         static void channel7Handler(void);     }; class cAdc { public:     static void handler(void);     }; class cDac { public:     static void handler(void);     }; class cUsb { public:     static void highPriorityHandler(void);         static void lowPriorityHandler(void);     static void fsWakeupHandler(void); }; class cComp { public:     static void handler(void);     }; class cLcdDriver { public:     static void handler(void);     }; class cTim9 { public:     static void handler(void);     }; class cTim2 { public:     static void handler(void);     }; class cTim3 { public:     static void handler(void);     }; class cTim4 { public:     static void handler(void);     }; class cTim10 { public:     static void handler(void);     }; class cTim6 { public:     static void handler(void);     }; class cTim7 { public:     static void handler(void);     }; class cTim11 { public:     static void handler(void);     }; class cI2C1 { public:     static void eventHandler(void);     static void errorHandler(void); }; class cI2C2 { public:     static void eventHandler(void);     static void errorHandler(void); }; class cSpi1 { public:     static void handler(void);     }; class cSpi2 { public:     static void handler(void);     }; class cUart1 { public:     static void handler(void);     }; class cUart2 { public:     static void handler(void);     }; class cUart3 { public:     static void handler(void);     }; class cRtcAlarm { public:     static void handler(void);     }; typedef void( *intfunc )( void ); typedef union { intfunc __fun; void * __ptr; } intvec_elem; \/\/ The vector table is normally located at address 0. \/\/ When debugging in RAM, it can be located in RAM, aligned to at least 2^6. \/\/ If you need to define interrupt service routines, \/\/ make a copy of this file and include it in your project. \/\/ The name &quot;__vector_table&quot; has special meaning for C-SPY: \/\/ it is where the SP start value is found, and the NVIC vector \/\/ table register (VTOR) is initialized to this address if != 0. #pragma location = &quot;.intvec&quot; extern &quot;C&quot; const intvec_elem __vector_table[] = {   { .__ptr = __sfe( &quot;CSTACK&quot; ) },   __iar_program_start,    cNMI::handler,   cHardFault::handler,   cMemManage::handler,   cBusFault::handler,   cUsageFault::handler,   0,   0,   0,   0,   vPortSVCHandler,             \/\/\u0444\u0443\u043d\u043a\u0446\u0438\u0438 freeRTOS \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0442\u044c!   cDebugMon::handler,   0,   xPortPendSVHandler,          \/\/\u0444\u0443\u043d\u043a\u0446\u0438\u0438 freeRTOS \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0442\u044c!   xPortSysTickHandler,         \/\/\u0444\u0443\u043d\u043a\u0446\u0438\u0438 freeRTOS \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0442\u044c!   \/\/External Interrupts   cWindowWatchdog::handler,    \/\/Window Watchdog   cPvd::handler,               \/\/PVD through EXTI Line detect   cTamperTimeStamp::handler,   \/\/Tamper and Time Stamp   cRtcWakeup::handler,         \/\/RTC Wakeup   cFlash::handler,             \/\/FLASH   cRcc::handler,               \/\/RCC   cExti::line0Handler,         \/\/EXTI Line 0   cExti::line1Handler,         \/\/EXTI Line 1   cExti::line2Handler,         \/\/EXTI Line 2   cExti::line3Handler,         \/\/EXTI Line 3   cExti::line4Handler,         \/\/EXTI Line 4   cDma::channellHandler,       \/\/DMA1 Channel 1   cDma::channel2Handler,       \/\/DMA1 Channel 2   cDma::channel3Handler,       \/\/DMA1 Channel 3   cDma::channel4Handler,       \/\/DMA1 Channel 4   cDma::channel5Handler,       \/\/DMA1 Channel 5   cDma::channel6Handler,       \/\/DMA1 Channel 6   cDma::channel7Handler,       \/\/DMA1 Channel 7   cAdc::handler,               \/\/ADC1   cUsb::highPriorityHandler,   \/\/USB High Priority   cUsb::lowPriorityHandler,    \/\/USB Low  Priority   cDac::handler,               \/\/DAC   cComp::handler,              \/\/COMP through EXTI Line   cExti::line9Handler,         \/\/EXTI Line 9..5   cLcdDriver::handler,         \/\/LCD   cTim9::handler,               \/\/TIM9   cTim10::handler,             \/\/TIM10   cTim11::handler,             \/\/TIM11   cTim2::handler,             \/\/TIM2   cTim3::handler,              \/\/TIM3   cTim4::handler,              \/\/TIM4   cI2C1::eventHandler,         \/\/I2C1 Event   cI2C1::errorHandler,         \/\/I2C1 Error   cI2C2::eventHandler,         \/\/I2C2 Event   cI2C2::errorHandler,         \/\/I2C2 Error   cSpi1::handler,              \/\/SPI1   cSpi2::handler,              \/\/SPI2   cUart1::handler,             \/\/USART1   cUart2::handler,             \/\/USART2   cUart3::handler,             \/\/USART3   cExti::line15_10Handler,     \/\/EXTI Line 15..10   cRtcAlarm::handler,          \/\/RTC Alarm through EXTI Line   cUsb::fsWakeupHandler,       \/\/USB FS Wakeup from suspend   cTim6::handler,              \/\/TIM6   cTim7::handler                \/\/TIM7 }; __weak void cNMI::handler()          { while (1) {} } __weak void cHardFault::handler()    { while (1) {} } __weak void cMemManage::handler()    { while (1) {} } __weak void cBusFault::handler()     { while (1) {} } __weak void cUsageFault::handler()   { while (1) {} } __weak void cDebugMon::handler()     { while (1) {} } __weak void cWindowWatchdog::handler()  { while (1) {} } __weak void cPvd::handler()             { while (1) {} } __weak void cTamperTimeStamp::handler() { while (1) {} } __weak void cRtcWakeup::handler()       { while (1) {} } __weak void cFlash::handler()           { while (1) {} } __weak void cRcc::handler()             { while (1) {} } __weak void cExti::line0Handler()       { while (1) {} } __weak void cExti::line1Handler()       { while (1) {} } __weak void cExti::line2Handler()       { while (1) {} } __weak void cExti::line3Handler()       { while (1) {} } __weak void cExti::line4Handler()       { while (1) {} } __weak void cExti::line9Handler()       { while (1) {} } __weak void cExti::line15_10Handler()   { while (1) {} } __weak void cDma::channellHandler()     { while (1) {} } __weak void cDma::channel2Handler()     { while (1) {} } __weak void cDma::channel3Handler()     { while (1) {} } __weak void cDma::channel4Handler()     { while (1) {} } __weak void cDma::channel5Handler()     { while (1) {} } __weak void cDma::channel6Handler()     { while (1) {} } __weak void cDma::channel7Handler()     { while (1) {} } __weak void cAdc::handler()             { while (1) {} } __weak void cUsb::fsWakeupHandler()     { while (1) {} } __weak void cUsb::highPriorityHandler() { while (1) {} } __weak void cUsb::lowPriorityHandler()  { while (1) {} } __weak void cDac::handler()             { while (1) {} } __weak void cComp::handler()            { while (1) {} } __weak void cLcdDriver::handler()       { while (1) {} } __weak void cTim2::handler()            { while (1) {} } __weak void cTim3::handler()            { while (1) {} } __weak void cTim4::handler()            { while (1) {} } __weak void cTim6::handler()            { while (1) {} } __weak void cTim7::handler()            { while (1) {} } __weak void cTim9::handler()            { while (1) {} } __weak void cTim10::handler()           { while (1) {} } __weak void cTim11::handler()           { while (1) {} } __weak void cI2C1::errorHandler()       { while (1) {} } __weak void cI2C1::eventHandler()       { while (1) {} } __weak void cI2C2::errorHandler()       { while (1) {} } __weak void cI2C2::eventHandler()       { while (1) {} } __weak void cSpi1::handler()            { while (1) {} } __weak void cSpi2::handler()            { while (1) {} } __weak void cUart1::handler()           { while (1) {} } __weak void cUart2::handler()           { while (1) {} } __weak void cUart3::handler()           { while (1) {} } __weak void cRtcAlarm::handler()        { while (1) {} } extern &quot;C&quot; void __cmain( void ); extern &quot;C&quot; __weak void __iar_init_core( void ); extern &quot;C&quot; __weak void __iar_init_vfp( void );  #pragma required=__vector_table void __iar_program_start( void ) {   __iar_init_core();   __iar_init_vfp();   __cmain(); } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/90c\/88d\/ced\/90c88dcedc674d00b441b6193653f0e0.png\" alt=\"image\"\/><\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h4>DWART. \u041f\u0440\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u0441 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0437\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430. Modbus \u043e\u0442\u043f\u0430\u043b \u0441\u0440\u0430\u0437\u0443 \u2014 \u0443\u0436 \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 :). \u041f\u043e\u0438\u0441\u043a \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432 \u0434\u043b\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0432\u044b\u0434\u0430\u043b \u2014 HART, \u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0434\u043b\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0442\u0438\u043f\u0430 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432 \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u043c\u0435\u0440\u043e\u0432 \u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442.<br \/>  \u0418 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0431\u043e\u0439, \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 \u0441 \u043f\u0440\u043e\u0433\u0440\u043c\u043c\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u0441\u043a\u0430\u0436\u0435\u043c <b>Pactware<\/b>, \u0438\u043b\u0438 <b>\u042d\u043b\u0435\u043c\u0435\u0440\u043e\u0432\u043a\u0438\u043c<\/b> <a href=\"http:\/\/www.elemer.ru\/po\/hart_config.php\">HARTConfig<\/a>, \u043f\u043e\u0434\u0434\u0435\u043b\u0430\u0432\u0448\u0438\u0441\u044c, \u043a\u0430\u043a\u0438\u043c-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c, \u0441\u043a\u0430\u0436\u0435\u043c \u0434\u0430\u0442\u0447\u0438\u043a \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u2014 Yokogawa EJA, \u0442\u0430\u043a \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u043e\u0434\u0432\u043e\u0445\u0430 \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0430. \u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \ud83d\ude42<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c0b\/6bb\/118\/c0b6bb11812a4019ae5b1259db13da75.png\" alt=\"image\"\/><br \/>  \u0418 \u0434\u0430\u0436\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043d\u044f\u0442\u044c \u0442\u0440\u0435\u043d\u0434 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0432\u043e\u0437\u0434\u0443\u0445\u0430, \u0438\u0437\u043c\u0435\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u0441\u0435\u043d\u0441\u043e\u0440\u043e\u043c \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/20a\/8de\/226\/20a8de226020413fb04a83fe55cbe3cd.png\" alt=\"image\"\/><\/p>\n<p>  \u0410 \u0432\u043e\u0442 \u0442\u0430\u043a \u0432\u043e\u0442 \u0432\u0438\u0434\u0438\u0442 \u043c\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e Pactware \ud83d\ude42<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ff7\/db5\/a14\/ff7db5a146c14330bf1469aa0397218a.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 HART \u0437\u0430\u043a\u0440\u044b\u0442\u0430. \u041d\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u043e\u0442\u0440\u044b\u0432\u043e\u0447\u043d\u044b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u043e\u0439\u0434\u0443\u0442 \u0434\u043b\u044f \u043c\u043e\u0435\u0433\u043e \u0434\u0435\u043c\u043e-\u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432: <a href=\"http:\/\/hart2dde.narod.ru\/hartdesc.html\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 HART<\/a> \u0438\u043b\u0438 \u0432\u043e\u0442 <a href=\"http:\/\/cyberleninka.ru\/article\/n\/realizatsiya-hart-protokola-na-osnove-modeli-iso-osi\"> \u041c\u043e\u0434\u0435\u043b\u044c OSI HART \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430<\/a><br \/>  \u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u2014 \u043d\u0430 \u043b\u0438\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0442\u0435\u0440(\u0433\u043b\u0430\u0432\u043d\u043e\u0435) \u0438 \u0441\u043b\u0435\u0439\u0432(\u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u043d\u043e\u0435) \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u0448\u043b\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 1200 \u0431\u0438\u0442 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u2014 \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e. <br \/>  \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438 \u0434\u0432\u0430 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0430 \u043b\u0438\u043d\u0438\u0438, \u043d\u043e \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0442\u043e\u0442\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0434\u0443 \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u041e\u0414\u041d\u0418\u041c \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u043c \u043f\u043e RS232. <br \/>  \u041f\u043e \u044d\u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043c\u043d\u0435 \u043d\u0435 \u043d\u0430\u0434\u043e \u043e\u0441\u043e\u0431\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0430\u0440\u0431\u0438\u0442\u0440\u0430\u0436\u0435\u043c \u0448\u0438\u043d\u044b \u0438 \u043f\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u043c\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u043e\u0433\u0434\u0430 \u0442\u043e\u043a\u0435\u043d \u0443 \u043c\u0435\u043d\u044f, \u0430 \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0442, \u0438 \u0432\u0435\u0441\u044c \u0430\u0440\u0431\u0438\u0442\u0440\u0430\u0436 \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u2014 \u0442\u043e\u043a\u0435\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0443 \u043c\u0435\u043d\u044f, \u043f\u043e\u0441\u043b\u0435 2 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0442\u0438\u0448\u0438\u043d\u044b \u043d\u0430 \u043b\u0438\u043d\u0438\u0438. \u041d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 1200 \u0431\u0438\u0442 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 19 \u043c\u0441. \u0422.\u0435. \u0435\u0441\u043b\u0438 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0438 19 \u043c\u0441, \u0443 \u043c\u0435\u043d\u044f \u043d\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u043f\u0440\u0438\u0435\u043c\u0443 \u2014 \u043f\u043e\u0441\u044b\u043b\u043a\u0430 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0439, \u0438 \u0442\u043e\u043a\u0435\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0443 \u043c\u0435\u043d\u044f, \u044f \u043c\u043e\u0433\u0443 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 250 \u043c\u0441, \u0438\u043d\u0430\u0447\u0435 \u0442\u043e\u043a\u0435\u043d \u0441\u043d\u043e\u0432\u0430 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u0443.<br \/>  \u0412 \u043e\u0431\u0449\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043b \u044f \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <b>Dwart<\/b>, \u0441\u0438\u043c\u0431\u0438\u043e\u0437 \u043c\u0435\u0436\u0434\u0443 Dwarf \u2014 \u043a\u0430\u0440\u043b\u0438\u043a, \u0433\u043d\u043e\u043c \u0438 HART.<br \/>   \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\u041a\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c (<b>LinkLayer<\/b>) \u2014 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430 \u043f\u043e\u0441\u044b\u043b\u043a\u0443 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0446\u0430 \u043f\u0440\u0438\u0435\u043c\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043e\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u0430<\/li>\n<li>\u0422\u0430\u0439\u043c\u0435\u0440 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0446\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 (<b>LinkLayerTimer<\/b>) \u2014 \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0430 19 \u043c\u0441, \u043f\u043e \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u043f\u0440\u0438\u043d\u044f\u0442. \u0422\u0430\u0439\u043c\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430.<\/li>\n<li>\u041a\u0430\u0434\u0440 (<b>Frame<\/b>) \u2014 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0440\u0430\u0437\u0431\u043e\u0440 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0434\u0440\u043e\u0432 HART \u043f\u043e\u0441\u044b\u043b\u043e\u043a <\/li>\n<li>\u041a\u043e\u043c\u0430\u043d\u0434\u044b (<b>Command<\/b>) \u2014 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <\/li>\n<li>\u0421\u0430\u043c \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 (<b>Dwart<\/b>) \u2014 \u043e\u043d \u0432\u0441\u0435\u043c \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c<\/li>\n<\/ul>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u043b\u044e\u0441\u0442\u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0441\u043b\u043e\u0435\u043d\u043e\u0433\u043e \u043f\u0438\u0440\u043e\u0433\u0430 \u2014 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0438\u0436\u043d\u0435\u0433\u043e \u0441\u043b\u043e\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0438 \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e \u043a\u043b\u0430\u0441\u0441\u044b \u0441\u043b\u043e\u044f \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u0432\u044b\u0448\u0435, \u0442.\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Command \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 Frame, \u0430 Frame c LinkLayer.<br \/>  \u0418\u0442\u0430\u043a \u0432 \u0447\u0435\u043c \u0436\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0434\u0435\u044f \u2014 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u0430\u0439\u0442\u044b \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0442\u0430\u0439\u043c\u0435\u0440 \u0442\u0438\u0448\u0438\u043d\u044b, \u0437\u0430\u0442\u0435\u043c \u043e\u043f\u043e\u0432\u0435\u0441\u0442\u0438\u0442\u044c Dwart, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443.<br \/>  \u0412 \u043e\u0431\u0449\u0435\u043c \u0432 \u0438\u0434\u0435\u0430\u043b\u0435, \u0441\u043a\u0430\u0436\u0435\u043c \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b 1 \u043e\u0442 \u043c\u0430\u0441\u0442\u0430\u0440\u0435, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043d\u0435\u0451 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:   <\/p>\n<pre><code class=\"cpp\">Command1.Response.PrimaryVariable = 3.54 Command1.Send(); <\/code><\/pre>\n<p>  \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u0438\u043a\u0438\u043d\u0435\u043c \u043a\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c, \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0441\u043e\u0440\u044f\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/792\/bdc\/a96\/792bdca962244370aa6fc3deca463561.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u044f\u0441\u043d\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438, \u0438 \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u0438 \u043f\u043e\u043b\u044f\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u044d\u0442\u0438\u0445 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043b\u0438\u0431\u043e \u043f\u043e\u043b\u044f \u0431\u044b\u043b\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0442\u043e\u0436\u0435 \u0431\u044b\u043b\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438, \u043b\u0438\u0431\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0432\u0435\u043d\u043d\u043e \u043a \u044d\u043a\u0437\u0435\u043f\u043b\u044f\u0440\u0443 \u043a\u043b\u0430\u0441\u0441\u0430. \u042f \u043f\u043e\u0448\u0435\u043b \u0432\u0442\u043e\u0440\u044b\u043c \u2014 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u043c, \u043e\u0431\u0440\u0430\u0449\u0430\u044e\u0441\u044c \u043a \u043a\u043e\u043a\u0440\u0435\u043d\u0442\u043d\u043e\u043c\u0443 \u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c <b>this<\/b>.<br \/>  LinkLayer \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u0430\u0439\u0442\u044b \u0438\u0437 UART \u043f\u043e\u0440\u0442\u0430 \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0431\u0443\u0444\u0435\u0440 \u043f\u0440\u0438\u0435\u043c\u0430. <br \/>  \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 HART \u0435\u0441\u0442\u044c \u0441\u0438\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0431\u0430\u0439\u0442\u044b 0xFF, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u0440\u0435\u0430\u043c\u0443\u0431\u043b\u0430\u043c\u0438, \u0438 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e 20, (\u0430 \u043e\u043d\u0438 \u043d\u0430\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435 \u043d\u0435\u0441\u0443\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u043e\u0444\u0440\u043c\u0430\u0446\u0438\u0438, \u0438 \u0432\u0441\u0435 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u043e \u043a\u0430\u0434\u0440\u0430 \u043f\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438( 0xFF 0xFF &lt;\u0421\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0431\u0430\u0439\u0442&gt;)), \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0442\u0440\u0430\u0442\u043d\u043e \u0441\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c 20 \u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b \u0432 \u0431\u0443\u0444\u0444\u0435\u0440, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0434\u0443 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043d\u0438\u043c\u0438 \u043f\u0440\u044f\u043c\u043e \u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0438 \u0438 \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0438 \u043a\u043e\u043d\u0447\u0430\u0442\u0441\u044f, \u044f \u043d\u0430\u0447\u043d\u0443 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0431\u0430\u0439\u0442\u044b \u0432 \u0431\u0443\u0444\u0444\u0435\u0440. <br \/>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u0435\u043c\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 \u044f \u0431\u0443\u0434\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0430 19 \u043c\u0441, \u0435\u0441\u043b\u0438 \u043e\u043d \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0442\u043e \u043f\u043e\u0441\u044b\u043b\u043a\u0430 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0439.<br \/>  \u0415\u0449\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u043f\u043e\u0432\u0435\u0441\u0442\u0438\u0442\u044c linklayer \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430 linklayertimer, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 \u0442\u0430\u0439\u043c\u0435\u0440\u0430, \u0433\u043e\u0432\u043e\u0440\u044f\u0449\u0435\u0435 \u043e \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u0438\u0435\u043c\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043e\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c, \u0432 \u0438\u0442\u043e\u0433\u0435 LinkLayer \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e\u0442 LinkLayerTimer, \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">linklayertimer.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;types.h&quot;            \/\/lint !e537 \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 #include &quot;observable.h&quot;       \/\/lint !e537 \u0414\u043b\u044f iObservable class cLinkLayerTimer : public iObservable {     public:     explicit  cLinkLayerTimer(tU16 timeout);        void start(void) const;   private:     static void irqHandler(void);     static cLinkLayerTimer* instance;     }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">linklayertimer.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;linklayertimer.h&quot;   \/\/lint !e537 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430  #include &quot;susuassert.h&quot;       \/\/lint !e537 \u0434\u043b\u044f ASSERT #include &lt;stdio.h&gt;            \/\/lint !e537 \u0434\u043b\u044f NULL       cLinkLayerTimer* cLinkLayerTimer::instance = NULL; \/******************************************************************************* * Function:  constructor * Description: \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0442\u0430\u0439\u043c\u0435\u0440 TIM2 ******************************************************************************\/ cLinkLayerTimer::cLinkLayerTimer(tU16 timeout) {   ASSERT(instance != NULL);    this-&gt;instance =  this;    TIM2-&gt;ARR = (uint16_t)timeout;       } \/******************************************************************************* * Function:  start * Description: \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440. \u0412\u044b\u0437\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f ******************************************************************************\/ void cLinkLayerTimer::start(void) const {   TIM2-&gt;CNT = (uint16_t)0;    TIM2-&gt;CR1 |= TIM_CR1_CEN; } \/******************************************************************************* * Function:  irqHandler * Description: \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044e \u0442\u0430\u0439\u043c\u0435\u0440\u0443.  *            \u042d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0435\u0446 \u043f\u043e\u0441\u044b\u043b\u043a\u0438, \u041e\u043f\u043e\u0432\u0435\u0449\u0430\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 ******************************************************************************\/ void cLinkLayerTimer::irqHandler(void) {   ASSERT(instance != NULL);   instance-&gt;notifyObservers();   TIM2-&gt;CR1 &=~ TIM_CR1_CEN;     TIM2-&gt;SR &= ~TIM_SR_UIF;   } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">linklayer.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;types.h&quot;            \/\/lint !e537 \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 #include &quot;linklayertimer.h&quot;   \/\/lint !e537 \u0414\u043b\u044f cLinkLayerTimer #include &quot;observer.h&quot;         \/\/lint !e537 \u0414\u043b\u044f iObserver #define PREAMBUL_SYMBOL (uint16_t) 0xFF typedef enum    {     LLS_none  = 0,     LLS_write = 1,     LLS_writeComplete = 2,     LLS_readComplete = 3,     LLS_error = 4   } tLinkLayerStatus;  class cLinkLayer : private iObserver, public iObservable {   public:     explicit cLinkLayer(tU8 *pRxBuf, const tU8 rxBufSize,tU8 *pTxBuf, const tU8 preambulCount);        void writeData(tU8 dataSize);     tLinkLayerStatus getStatus() const { return eStatus; };          virtual void eventHandle(const iObservable* pObservable);     tU8* pTxBuffer;         tU8* pRxBuffer;        private:     static void irqHandler(void);     static cLinkLayer* instance;     void endMessageHandler(void);     void enableReceive(void) const { USART2-&gt;CR1 |= USART_CR1_RXNEIE;}; \/\/lint !e639 !e511 \u0422\u0443\u0442 \u0432\u0441\u0435 \u0432\u0435\u0440\u043d\u043e      void disableReceive(void){USART2-&gt;CR1 &=~ USART_CR1_RXNEIE;};\/\/lint !e639 !e511 \u0422\u0443\u0442 \u0432\u0441\u0435 \u0432\u0435\u0440\u043d\u043e     void enableTransmit(void) const { USART2-&gt;CR1 |= USART_CR1_TCIE; };\/\/lint !e639 !e511 \u0422\u0443\u0442 \u0432\u0441\u0435 \u0432\u0435\u0440\u043d\u043e      void disableTransmit(void) const { USART2-&gt;CR1 &=~ USART_CR1_TCIE; };\/\/lint !e639 !e511 \u0422\u0443\u0442 \u0432\u0441\u0435 \u0432\u0435\u0440\u043d\u043e      tLinkLayerStatus eStatus;     cLinkLayerTimer* pEndTransmitTimer;     tU8  rxBufferSize;     tU8  rxBufferIndex;     tU8  txBufferIndex;     tU8  txBufferSize;      tU8 preambulsCount;     tU8 preambulIndex;     tBoolean readPreambuls; }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">linllayer.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;stm32l1xx.h&gt;        \/\/lint !e537 \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u044b STM32 #include &quot;linklayer.h&quot;        \/\/lint !e537 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430  #include &quot;susuassert.h&quot;       \/\/lint !e537 \u0434\u043b\u044f ASSERT #include &quot;bitutil.h&quot;          \/\/lint !e537 \u0434\u043b\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 SETBIT, CLRBIT #include &lt;stdio.h&gt;            \/\/lint !e537 \u0434\u043b\u044f NULL        #define END_MESSAGE_TIMEOUT (tU16) 19 #define GOOD_COUNT_RX_PREAMBULS (tU8) 2 cLinkLayer* cLinkLayer::instance = NULL; \/******************************************************************************* * Function:  constructor * Description: \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0446\u0430 \u043f\u043e\u0441\u044b\u043b\u043a\u0438 ******************************************************************************\/ cLinkLayer::cLinkLayer(tU8 *pRxBuf, const tU8 rxBufSize,tU8 *pTxBuf, const tU8 preambulCount)  {   ASSERT (rxBuffer != NULL);   ASSERT (txBuffer != NULL);   \/\/\u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 3   ASSERT(preambulCount &gt; (tU8)2);      this-&gt;preambulsCount = preambulCount;   this-&gt;preambulIndex = (tU8)0;   this-&gt;readPreambuls =  TRUE;       this-&gt;pRxBuffer = pRxBuf;   this-&gt;rxBufferSize = rxBufSize;   this-&gt;rxBufferIndex =  (tU8)0;       this-&gt;pTxBuffer =  pTxBuf;   this-&gt;txBufferSize = (tU8)0;   this-&gt;txBufferIndex = (tU8)0;    this-&gt;eStatus = LLS_none;   this-&gt;instance =  this;      this-&gt;pEndTransmitTimer = new cLinkLayerTimer(END_MESSAGE_TIMEOUT);   \/\/\u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u0430   this-&gt;pEndTransmitTimer-&gt;addObserver(this);      this-&gt;disableTransmit();   this-&gt;enableReceive(); }  \/******************************************************************************* * Function:  writeData * Description: \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 ******************************************************************************\/ void cLinkLayer::writeData(tU8 dataSize) {   \/\/\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0431\u0443\u0444\u0435\u0440\u0430 \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438, \u0435\u0441\u043b\u0438 \u0431\u0443\u0444\u0435\u0440 \u0435\u0449\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d, \u043d\u0435 \u043d\u0430\u0434\u043e \u0435\u0433\u043e    \/\/\u043c\u0435\u043d\u044f\u0442\u044c   if (this-&gt;eStatus != LLS_write)   {     this-&gt;disableReceive();     this-&gt;txBufferSize = dataSize;     this-&gt;eStatus = LLS_write;     USART2-&gt;DR = PREAMBUL_SYMBOL;     this-&gt;preambulIndex ++;         this-&gt;enableTransmit();       } } \/******************************************************************************* * Function:  handler * Description: \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f ******************************************************************************\/ void cLinkLayer::irqHandler(void) {   ASSERT(instance != NULL);   \/\/\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430   if (USART2-&gt;SR & USART_SR_TC)   {     \/\/ \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b\u044b, \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 3 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c     if (instance-&gt;preambulIndex != instance-&gt;preambulsCount)     {       USART2-&gt;DR = PREAMBUL_SYMBOL;       instance-&gt;preambulIndex ++;     }     else     {       \/\/\u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b\u044b \u043f\u0435\u0440\u0435\u0434\u0435\u043d\u0430 - \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0431\u0443\u0444\u0444\u0435\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438       if(instance-&gt;txBufferIndex &lt; instance-&gt;txBufferSize)       {         USART2-&gt;DR = (uint16_t)instance-&gt;pTxBuffer[instance-&gt;txBufferIndex++];             }       else       {         instance-&gt;txBufferIndex = (tU8)0;         instance-&gt;txBufferSize = (tU8)0;         instance-&gt;disableTransmit();         instance-&gt;eStatus = LLS_writeComplete;         instance-&gt;preambulIndex = (tU8)0;         instance-&gt;readPreambuls = TRUE;         instance-&gt;enableReceive();       }     }         USART2-&gt;SR &=~ USART_SR_TC;   };      \/\/\u041f\u0440\u0438\u0435\u043c   if (USART2-&gt;SR & USART_SR_RXNE)   {     instance-&gt;pRxBuffer[instance-&gt;rxBufferIndex] = (tU8)USART2-&gt;DR;     instance-&gt;pEndTransmitTimer-&gt;start();     \/\/\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0430\u0434\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b\u044b     if (instance-&gt;readPreambuls)     {       if (instance-&gt;pRxBuffer[instance-&gt;rxBufferIndex] == (tU8)PREAMBUL_SYMBOL)       {         instance-&gt;preambulIndex++;       }       else       {         instance-&gt;readPreambuls =  FALSE;         instance-&gt;rxBufferIndex++;       }     }     else     {       \/\/\u041f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u043f\u0440\u0435\u0430\u043c\u0431\u0443 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 2       if ((instance-&gt;rxBufferIndex &lt;= instance-&gt;rxBufferSize) &&            (instance-&gt;preambulIndex &gt;= GOOD_COUNT_RX_PREAMBULS))       {         instance-&gt;rxBufferIndex++;              }       else       {         instance-&gt;eStatus = LLS_error;         instance-&gt;preambulIndex = (tU8)0;       }             }        }   } \/******************************************************************************* * Function:  endMessageHandler * Description: \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043d\u0446\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 ******************************************************************************\/ void cLinkLayer::endMessageHandler(void) {   this-&gt;eStatus = LLS_readComplete;     this-&gt;rxBufferIndex = (tU8) 0;    this-&gt;readPreambuls = TRUE;   instance-&gt;preambulIndex = (tU8)0; } \/******************************************************************************* * Function:  eventHandle * Description: \u0420\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c ******************************************************************************\/ void cLinkLayer::eventHandle(const iObservable* pObservable) {   this-&gt;endMessageHandler();    this-&gt;notifyObservers(); } \/\/lint !e715 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c pObservable <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u0430\u043c LinkLayer \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u043e\u0432\u0435\u0449\u0430\u0435\u0442 \u043e \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u0438\u0435\u043c\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043e\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0441\u0432\u043e\u0438\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u2014 \u044d\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0437\u0436\u0435<\/p>\n<h4>DWART. \u0420\u0430\u0437\u0431\u043e\u0440 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 HART \u043a\u0430\u0434\u0440\u0430<\/h4>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u043c cFrame, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0434\u0440\u044b \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f LinkLayer \u043e\u0442\u0441\u044b\u043b\u0430\u0442\u044c \u0438\u0445:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/2bf\/dcb\/294\/2bfdcb294773472eadbd57fc162eca95.png\" alt=\"image\"\/><\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">frame.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;types.h&quot;            \/\/lint !e537 \u0422\u0438\u043f\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043b\u044f tBoolean #include &quot;linklayer.h&quot;        \/\/lint !e537 \u0414\u043b\u044f cLinkLayer  #define LONG_ADDRESS_LENGTH   (tU8)5 #define DATA_LENGTH        (tU8)255 typedef enum {    FE_good            = 0,    FE_addrError       = 1,    FE_comError        = 2,    FE_dataCountError  = 3,    FE_checkSummError  = 4,    FE_preambulsError  = 5,      FE_genericError    = 6 \t } tFrameError; typedef struct   {    \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b    tU8 preambulsCount;       \/\/ \u0421\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0431\u0430\u0439\u0442    tU8 startByte;    \/\/ \u0410\u0434\u0440\u0435\u0441\u0441 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439    tU8 shortAddr;    \/\/ \u0410\u0434\u0440\u0435\u0441\u0441 \u0434\u043b\u0438\u043d\u043d\u044b\u0439     tU8 longAddr[LONG_ADDRESS_LENGTH];    \/\/ \u041a\u043e\u043c\u0430\u043d\u0434\u0430     tU8 command;    \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445     tU8 dataCount;     \/\/\u0434\u0430\u043d\u043d\u044b\u0435    tU8 *pData;    \/\/ \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430    tU8 checkSumm;       } tMasterFrame; class cFrame {   public:     cFrame(tU8* pLongAddress, const tU8 shortAddress, cLinkLayer *pLnkLayer);     tU8* buildFrameBeforeData  (const tU8 commandNumber, const tU8 dataLength);     tU8 getCurrentCommand(void) const { return this-&gt;masterFrame.command; }     tFrameError decode(void);         void setCheckSumm(void);     void send(void);      private:     tU8 getCheckSumm(const tU8 *pData, const tU8 dataLength) const;     cLinkLayer *pLinkLayer;     tU8 deviceShortAddress;     tU8 *pDeviceId;     tU8 bufferSize;            tMasterFrame masterFrame;     }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">frame.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;susuassert.h&quot;       \/\/lint !e537 \u0434\u043b\u044f ASSERT #include &quot;frame.h&quot;            \/\/lint !e537 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 #include &lt;stddef.h&gt;           \/\/lint !e537 \u0434\u043b\u044f NULL  #define LONG_ADDRESS_MASK  (tU8)0x80 #define SLAVE_MASK         (tU8)0x7F  #define START_BYTE_SLAVE_SHORT_FRAME  (tU8) 6 #define START_BYTE_SLAVE_LONG_FRAME   (tU8) 0x86  \/******************************************************************************* * Function:  constructor * Description:  ******************************************************************************\/ cFrame::cFrame(tU8* pLongAddress, const tU8 shortAddress, cLinkLayer *pLnkLayer) {   ASSERT(pLnkLayer != NULL);   ASSERT(pLongAddress != NULL);   \/\/\u041a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0430\u0434\u0440\u0435\u0441 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 64   ASSERT(shortAddress &lt;= (tU8)64);   this-&gt;pLinkLayer = pLnkLayer;   this-&gt;pDeviceId = pLongAddress;   this-&gt;deviceShortAddress = shortAddress;   this-&gt;bufferSize = (tU8)0; } \/******************************************************************************* * Function:  decode * Description: \u0414\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u0441\u044b\u043b\u043a\u0443, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441  ******************************************************************************\/ tFrameError cFrame::decode(void) {   tU8 index = (tU8)0;       tU8 cnt = (tU8)0;         tFrameError eResult =  FE_good;    this-&gt;masterFrame.startByte  = this-&gt;pLinkLayer-&gt;pRxBuffer[index];   index ++;   \/\/ \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0438\u043b\u0438 \u043a\u043e\u0440\u0442\u043e\u0442\u043a\u0438\u0439 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0430\u0434\u0440\u0435\u0441\u0441    if (this-&gt;masterFrame.startByte & LONG_ADDRESS_MASK)   {     for (tU8 i = (tU8)0;  i &lt; LONG_ADDRESS_LENGTH; i ++)     {       this-&gt;masterFrame.longAddr[i]  =   this-&gt;pLinkLayer-&gt;pRxBuffer[index];       index ++;            }   }    else   {     this-&gt;masterFrame.shortAddr   = this-&gt;pLinkLayer-&gt;pRxBuffer[index];     index ++;   }   \/\/ \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443   this-&gt;masterFrame.command   = this-&gt;pLinkLayer-&gt;pRxBuffer[index];   index ++;   \/\/ \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u0434\u0430\u043d\u043d\u044b\u0445   this-&gt;masterFrame.dataCount = this-&gt;pLinkLayer-&gt;pRxBuffer[index];   index ++;   \/\/ \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0445     if (this-&gt;masterFrame.dataCount != (tU8)0)   {     this-&gt;masterFrame.pData = (tU8*)&this-&gt;pLinkLayer-&gt;pRxBuffer[index];   }   index = index + this-&gt;masterFrame.dataCount;         \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u043d\u044c\u0448\u0435 DATA_LENGTH    if(masterFrame.dataCount &lt; DATA_LENGTH )   {     \/\/ \u041f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443           this-&gt;masterFrame.checkSumm =        this-&gt;getCheckSumm((tU8*)&this-&gt;pLinkLayer-&gt;pRxBuffer[cnt], index - cnt);                                                                     \/\/************************ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0449\u0438\u0431\u043e\u043a ***********************     \/\/ \u041d\u0435\u0432\u0435\u0440\u043d\u0430\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430     if(this-&gt;pLinkLayer-&gt;pRxBuffer[index] != this-&gt;masterFrame.checkSumm)     {       eResult = FE_checkSummError;     }     \/\/ \u041d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u043e\u0442\u0432\u0435\u0442     if (this-&gt;masterFrame.startByte & LONG_ADDRESS_MASK)     {       if ((this-&gt;masterFrame.longAddr[0] & SLAVE_MASK) !=  (this-&gt;pDeviceId[0] & SLAVE_MASK))       {         eResult = FE_addrError;          }        else       {         for (tU8 i = (tU8)1; i &lt; LONG_ADDRESS_LENGTH; i ++)         {           if (this-&gt;masterFrame.longAddr[i] != this-&gt;pDeviceId[i])           {             eResult = FE_addrError;             break;           }          this-&gt;pDeviceId[0] = this-&gt;masterFrame.longAddr[0];          }       }     }     else     {       if((this-&gt;masterFrame.shortAddr & SLAVE_MASK) != (this-&gt;deviceShortAddress & SLAVE_MASK))       {         eResult = FE_addrError;       }       else       {         this-&gt;deviceShortAddress = this-&gt;masterFrame.shortAddr;       }     }   }   else   {     eResult = FE_dataCountError;   }   return eResult; } \/******************************************************************************* * Function:  buildFrameBeforeData * Description:  \u0421\u0442\u0440\u043e\u0438\u0442 \u0431\u0443\u0444\u0435\u0440 \u0434\u043e \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0435\u0442\u043b\u044c \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0431\u0430\u0439\u0442  *               \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0444\u0435\u0440\u0435. \u0414\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u043a\u043e\u043d\u043a\u0442\u0440\u0435\u0442\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439  ******************************************************************************\/ tU8* cFrame::buildFrameBeforeData(const tU8 commandNumber, const tU8 dataLength) {    tU8 index = (tU8)0;       \/\/\u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0430\u0434\u0440\u0435\u0441, \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0438\u043b\u0438 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u0430\u0441\u0442\u0435\u0440\u0430    if (!(this-&gt;masterFrame.startByte & LONG_ADDRESS_MASK))    {      this-&gt;pLinkLayer-&gt;pTxBuffer[index] = START_BYTE_SLAVE_SHORT_FRAME;      index ++;      this-&gt;pLinkLayer-&gt;pTxBuffer[index] = this-&gt;deviceShortAddress;      index ++;    }    else    {      this-&gt;pLinkLayer-&gt;pTxBuffer[index] = START_BYTE_SLAVE_LONG_FRAME;      index ++;            for (tU8 i = (tU8)0; i &lt; LONG_ADDRESS_LENGTH; i ++)      {        this-&gt;pLinkLayer-&gt;pTxBuffer[index] = this-&gt;pDeviceId[i];        index ++;        }       }       \/\/\u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0431\u0430\u0439\u0442 \u0434\u043b\u0438\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0445    this-&gt;pLinkLayer-&gt;pTxBuffer[index] = commandNumber;    index ++;    this-&gt;pLinkLayer-&gt;pTxBuffer[index] = dataLength;    index ++;        this-&gt;bufferSize = index + dataLength;           return (tU8*)&this-&gt;pLinkLayer-&gt;pTxBuffer[index]; } \/******************************************************************************* * Function:  setCheckSumm * Description: \u0420\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430  ******************************************************************************\/ void cFrame::setCheckSumm(void) {   this-&gt;pLinkLayer-&gt;pTxBuffer[this-&gt;bufferSize] =      this-&gt;getCheckSumm(this-&gt;pLinkLayer-&gt;pTxBuffer, this-&gt;bufferSize);   this-&gt;bufferSize++; } \/******************************************************************************* * Function:  getCheckSumm * Description:  \u041f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 ******************************************************************************\/ tU8 cFrame::getCheckSumm(const tU8 *pData, const tU8 dataLength) const {   tU8 index = (tU8) 0;    tU8 checkSumm = (tU8)0;      for (index = (tU8)0; index &lt; dataLength; index ++)               {                                                                  if(pData != NULL)     {       checkSumm =  checkSumm ^ pData[index];       }     else      {       checkSumm = (tU8) 0;     }   }   return checkSumm;             } \/******************************************************************************* * Function:  send * Description:  \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u0442 \u043a\u0430\u0434\u0440 ******************************************************************************\/ void cFrame::send(void) {   this-&gt;pLinkLayer-&gt;writeData(this-&gt;bufferSize); } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h4>DWART. \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u2014 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u0430\u043a \u044f \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u043e, \u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c \u2014 \u0432\u043e\u0442 \u0442\u0430\u043a<\/p>\n<pre><code class=\"cpp\"> Command0.Responce.PrimaryVariable = 3.54<\/code><\/pre>\n<p>  \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u044f \u0431\u0443\u0434\u0443 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 Responce, \u0430 \u043a\u043e\u043c\u0430\u043d\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c 254, \u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0431\u0443\u0434\u0443 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 Responce, \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u043c\u0443 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e, \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 buildFrameBeforeData \u043a\u043b\u0430\u0441\u0441\u0430 \u0441Frame. <br \/>  \u0414\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0441\u0434\u0435\u043b\u0430\u044e \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 iBaseDwartCommand \u0441 \u043e\u0431\u0449\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0430 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043c\u0435\u043d\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u043e\u0442\u0432\u0435\u0442\u044b \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0440\u0430\u0437\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b, \u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u0442\u043e \u044f \u0441\u043e\u0437\u0434\u0430\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a iDwartCommand. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/043\/332\/ce9\/043332ce9f194ae1a7c3065fd08ee131.png\" alt=\"image\"\/><br \/>  \u041a\u043e\u043c\u0430\u043d\u0434\u0430 0 \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435.<br \/>  \u041a\u043e\u043c\u0430\u043d\u0434 1 \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0441Trimmer, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0434\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 cVariablesDirector, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435.<br \/>  \u0412 \u0438\u0442\u043e\u0433\u0435, \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434\u044b 1 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">void cCommand1::setNewData(void) {   \/\/\u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u043e \u043a\u0430\u0434\u0440\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0444\u0435\u0440 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445   this-&gt;pResponse = (tCommand1Response*) this-&gt;pFrame-&gt;buildFrameBeforeData(COMMAND1,                     (tU8)sizeof(tCommand1Response)); \/\/lint !e826 \u0442\u0430\u043a\u0430\u044f \u0437\u0430\u0434\u0443\u043c\u043a\u0430   this-&gt;pResponse-&gt;status1 = (tU8)0;   this-&gt;pResponse-&gt;status2 = (tU8)0;   this-&gt;pResponse-&gt;PrimaryVariableUnits =  (tU8) pVariablesDirector-&gt;pTrimmer-&gt;getUnits();   this-&gt;pResponse-&gt;PrimaryVariableValue =  cConversion&lt;tF32&gt;::swap(pVariablesDirector-&gt;pTrimmer-&gt;getValue());   this-&gt;pFrame-&gt;setCheckSumm(); } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043a\u043b\u0430\u0441\u0441 \u043c\u0435\u0442\u043e\u0434 swap \u043a\u043b\u0430\u0441\u0441\u0430 cConversion \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0431\u0430\u0439\u0442\u043e\u0432 \u043c\u0435\u0441\u0442\u0430\u043c\u0438, \u0442\u0430\u043a \u043a\u0430\u043a HART \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Big Endian \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0430 \u043c\u043e\u0439 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 Little Endian. \u041d\u0443 \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u044f \u0445\u043e\u0442\u0435\u043b \ud83d\ude42<br \/>  \u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">basedwartcommand.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">class iBaseDwartCommand {   public:         virtual void send(void) = 0;        virtual void setNewData(void) = 0;   }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">dwartcommand.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;frame.h&quot;              \/\/lint !e537 \u0434\u043b\u044f cFrame #include &quot;basecommand.h&quot;        \/\/lint !e537 \u0434\u043b\u044f iBaseDwartCommand #include &quot;susuassert.h&quot;         \/\/lint !e537 \u0434\u043b\u044f ASSERT template &lt;class req, class resp&gt; class iDwartCommand : public iBaseDwartCommand  {   public:     explicit iDwartCommand(cFrame *pDwratFrame);     req *pRequest;     resp *pResponse;     void send(void);       protected:     cFrame *pFrame;         }; \/******************************************************************************* * Function:  constructor * Description:  ******************************************************************************\/ template &lt;class req, class resp&gt; iDwartCommand&lt;req, resp&gt;::iDwartCommand(cFrame *pDwartFrame) {   ASSERT (pFrame != NULL);   this-&gt;pFrame = pDwartFrame;  } \/******************************************************************************* * Function:  send * Description: \u043f\u043e\u0441\u044b\u043b\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b ******************************************************************************\/ template &lt;class req, class resp&gt; void iDwartCommand&lt;req, resp&gt;::send(void) {   this-&gt;pFrame-&gt;send(); } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">command0.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;command.h&quot;   \/\/lint !e537 \u0434\u043b\u044f iDwartCommand #define COMMAND0 (tU8)0 #pragma pack(push, 1) typedef struct   {    tU8 status1;    tU8 status2;    tU8 expansion;    tU8 manufacturer;    tU8 deviceType;    tU8 numberOfpreambuls;    tU8 universalCommandRevision;    tU8 deviceSpecificCommandRevision;    tU8 softwareRevision;    tU8 hardwareRevision;    tU8 deviceFlags;    tU8 deviceID[3];            } tCommand0Response; typedef struct  { } tCommand0Request; #pragma pack(pop) class cCommand0: public iDwartCommand&lt;tCommand0Request, tCommand0Response&gt; {   public:     explicit cCommand0(cFrame *pDwartFrame);     virtual void setNewData(void); }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">command0.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">include &quot;susuassert.h&quot;       \/\/lint !e537 \u0434\u043b\u044f ASSERT #include &quot;command0.h&quot;          \/\/lint !e537 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 #include &quot;frame.h&quot;            \/\/lint !e537 \u0434\u043b\u044f \u0441Frame #include &quot;conversion.h&quot;       \/\/lint !e537 \u0434\u043b\u044f cConversion \/******************************************************************************* * Function:  constructor * Description:  ******************************************************************************\/ cCommand0::cCommand0(cFrame *pDwartFrame): iDwartCommand(pDwartFrame) {   } \/******************************************************************************* * Function:  setNewData * Description: \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434\u044b ******************************************************************************\/ void cCommand0::setNewData(void) {     \/\/\u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u043e \u043a\u0430\u0434\u0440\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0444\u0435\u0440 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445   this-&gt;pResponse = (tCommand0Response*) this-&gt;pFrame-&gt;buildFrameBeforeData(COMMAND0,                                                               (tU8)sizeof(tCommand0Response)); \/\/lint !e826 \u0442\u0430\u043a\u0430\u044f \u0437\u0430\u0434\u0443\u043c\u043a\u0430   this-&gt;pResponse-&gt;status1 = (tU8)0;   this-&gt;pResponse-&gt;status2 = (tU8)0;   this-&gt;pResponse-&gt;manufacturer = (tU8)0x37;   this-&gt;pResponse-&gt;deviceType = (tU8)0x04;   this-&gt;pResponse-&gt;expansion = (tU8)0;   this-&gt;pResponse-&gt;deviceSpecificCommandRevision = (tU8)5;   this-&gt;pResponse-&gt;universalCommandRevision = (tU8)5;   this-&gt;pResponse-&gt;hardwareRevision = (tU8)1;   this-&gt;pResponse-&gt;softwareRevision = (tU8)201;   this-&gt;pResponse-&gt;numberOfpreambuls = (tU8)5;   this-&gt;pResponse-&gt;deviceID[0] = (tU8)0;   this-&gt;pResponse-&gt;deviceID[1] = (tU8)0;   this-&gt;pResponse-&gt;deviceID[2] = (tU8)1;   this-&gt;pResponse-&gt;deviceFlags = (tU8)0;   this-&gt;pFrame-&gt;setCheckSumm(); } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">command1.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;command.h&quot;          \/\/lint !e537 \u0434\u043b\u044f iDwartCommand #include &quot;variablesdirector.h&quot; \/\/lint !e537 \u0434\u043b\u044f cVariablesDirector  #define COMMAND1 (tU8)1 #pragma pack(push, 1) typedef struct   {    tU8 status1;    tU8 status2;    tU8 PrimaryVariableUnits;    tF32 PrimaryVariableValue;             } tCommand1Response; typedef struct  { } tCommand1Request; #pragma pack(pop) class cCommand1: public iDwartCommand&lt;tCommand1Request, tCommand1Response&gt; {   public:     explicit cCommand1(cFrame *pDwartFrame,cVariablesDirector *pVarsDirector);     virtual void setNewData(void);   private:    cVariablesDirector *pVariablesDirector; }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">command1.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;susuassert.h&quot;       \/\/lint !e537 \u0434\u043b\u044f ASSERT #include &quot;command1.h&quot;          \/\/lint !e537 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 #include &quot;frame.h&quot;            \/\/lint !e537 \u0434\u043b\u044f \u0441Frame #include &quot;conversion.h&quot;       \/\/lint !e537 \u0434\u043b\u044f cConversion \/******************************************************************************* * Function:  constructor * Description:  ******************************************************************************\/ cCommand1::cCommand1(cFrame *pDwartFrame, cVariablesDirector *pVarsDirector):          iDwartCommand(pDwartFrame)                          {   ASSERT(pVarsDirector != NULL);   this-&gt;pVariablesDirector = pVarsDirector; } \/******************************************************************************* * Function:  setNewData * Description: \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434\u044b ******************************************************************************\/ void cCommand1::setNewData(void) {     \/\/\u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u043e \u043a\u0430\u0434\u0440\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0444\u0435\u0440 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445   this-&gt;pResponse = (tCommand1Response*) this-&gt;pFrame-&gt;buildFrameBeforeData(COMMAND1,                     (tU8)sizeof(tCommand1Response)); \/\/lint !e826 \u0442\u0430\u043a\u0430\u044f \u0437\u0430\u0434\u0443\u043c\u043a\u0430   this-&gt;pResponse-&gt;status1 = (tU8)0;   this-&gt;pResponse-&gt;status2 = (tU8)0;   this-&gt;pResponse-&gt;PrimaryVariableUnits =  (tU8) pVariablesDirector-&gt;pTrimmer-&gt;getUnits();   this-&gt;pResponse-&gt;PrimaryVariableValue =  cConversion&lt;tF32&gt;::swap(pVariablesDirector-&gt;pTrimmer-&gt;getValue());   this-&gt;pFrame-&gt;setCheckSumm(); } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u0436\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0423 \u043c\u0435\u043d\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0437\u0430\u043f\u0430\u0441 \u043f\u0430\u043c\u044f\u0442\u0438, \u044f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0432\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0430 \u0438\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e 254 \u0441\u043a\u0438\u043d\u0443\u0442\u044c \u0432 \u043e\u0434\u0438\u043d \u043c\u0430\u0441\u0441\u0438\u0432, \u0434\u0430\u043b\u0435\u0435 \u044f \u043f\u043e\u044f\u0441\u043d\u044e \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u043c. \u042f \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043b \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 cCommandSet:  <\/p>\n<pre><code class=\"cpp\">#include &quot;command.h&quot;        \/\/lint !e537 \u0434\u043b\u044f iDwartCommand #include &quot;variablesdirector.h&quot; \/\/lint !e537 \u0434\u043b\u044f cVariablesDirector   #define COMMANDS_COUNT 254 class cCommandSet {   public:     cCommandSet(cFrame *pFrame, cVariablesDirector *pVariablesDirector);     iBaseDwartCommand *pCommands[COMMANDS_COUNT];     }; <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0432\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b Pactware \u0438 HartConfig \u043f\u0440\u0438\u043d\u044f\u043b\u0438 \u043c\u0435\u043d\u044f \u0437\u0430 Yokogawa, \u043c\u043d\u0435 \u043d\u0430\u0434\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u043c\u0430\u043d\u0434, \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0438\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. <br \/>  commandset.cpp \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">#include &quot;susuassert.h&quot;       \/\/lint !e537 \u0434\u043b\u044f ASSERT #include &quot;commandset.h&quot;       \/\/lint !e537 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 #include &quot;command0.h&quot;         \/\/lint !e537 \u0434\u043b\u044f cCommand0 #include &quot;command1.h&quot;         \/\/lint !e537 \u0434\u043b\u044f cCommand1 #include &quot;command2.h&quot;         \/\/lint !e537 \u0434\u043b\u044f cCommand2 #include &quot;command3.h&quot;         \/\/lint !e537 \u0434\u043b\u044f cCommand3 #include &quot;command12.h&quot;        \/\/lint !e537 \u0434\u043b\u044f cCommand12 #include &quot;command13.h&quot;        \/\/lint !e537 \u0434\u043b\u044f cCommand13 #include &quot;command14.h&quot;        \/\/lint !e537 \u0434\u043b\u044f cCommand14 #include &quot;command15.h&quot;        \/\/lint !e537 \u0434\u043b\u044f cCommand15 #include &quot;command157.h&quot;       \/\/lint !e537 \u0434\u043b\u044f cCommand157 #include &quot;command159.h&quot;       \/\/lint !e537 \u0434\u043b\u044f cCommand159 #include &quot;command160.h&quot;       \/\/lint !e537 \u0434\u043b\u044f cCommand160 #include &quot;command180.h&quot;       \/\/lint !e537 \u0434\u043b\u044f cCommand180  cCommandSet::cCommandSet(cFrame *pFrame, cVariablesDirector *pVariablesDirector)      {   this-&gt;pCommands[COMMAND0] =  new cCommand0(pFrame);   this-&gt;pCommands[COMMAND1] =  new cCommand1(pFrame, pVariablesDirector );   this-&gt;pCommands[COMMAND2] =  new cCommand2(pFrame, pVariablesDirector );   this-&gt;pCommands[COMMAND3] =  new cCommand3(pFrame, pVariablesDirector );   this-&gt;pCommands[COMMAND13] = new cCommand13(pFrame);   this-&gt;pCommands[COMMAND12] = new cCommand12(pFrame);   this-&gt;pCommands[COMMAND14] = new cCommand14(pFrame);   this-&gt;pCommands[COMMAND15] = new cCommand15(pFrame, pVariablesDirector);   this-&gt;pCommands[COMMAND160] = new cCommand160(pFrame);   this-&gt;pCommands[COMMAND157] = new cCommand157(pFrame);   this-&gt;pCommands[COMMAND159] = new cCommand159(pFrame);   this-&gt;pCommands[COMMAND180] = new cCommand180(pFrame); } <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0443 \u043c\u0435\u043d\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0447\u0442\u0438 \u0432\u0435\u0441\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d, \u043d\u043e \u043c\u043d\u0435 \u043b\u0435\u043d\u044c \u0431\u044b\u043b\u043e \u0435\u0433\u043e \u0437\u0430\u0431\u0438\u0432\u0430\u0442\u044c \ud83d\ude42 \u0414\u0435\u0440\u0436\u0438\u043c \u0432 \u0443\u043c\u0435, \u0447\u0442\u043e \u0442\u0430\u043c \u043e\u0448\u0438\u0431\u043a\u0430. <br \/>  \u042f \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u044e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b 157, 159 \u0438 160, (\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e \u0442\u043e\u043b\u044c\u043a\u043e, \u0447\u0442\u043e \u0442\u0430\u043c \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043f\u0435\u0440\u043c\u0435\u043d\u043d\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0440\u0430\u0441\u0445\u043e\u0434\u0430 (\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0440\u0430\u0441\u0445\u043e\u0434 \u044d\u0442\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u0440\u043d\u0435\u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043e\u0442 \u0434\u0438\u0444\u0444\u0438\u0440\u0438\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0438\u043b\u0438 \u0441\u043a\u0430\u0436\u0435\u043c \u0447\u0442\u043e\u0431\u044b \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0443\u0440\u043e\u0432\u0435\u043d\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u044f)), \u043d\u043e \u0447 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043b \u0438\u0445 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0431\u0438\u043b\u0438\u0431\u0435\u0440\u0434\u043e\u0439, \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u044d\u0442\u043e \u043f\u0440\u043e\u0433\u043b\u043e\u0442\u0438\u043b\u0438. <br \/>  \u0418\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u043c\u0430\u043d\u0434, \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e \u2014 \u0432\u043e\u0442 \u0442\u0430\u043a  <\/p>\n<pre><code class=\"cpp\">pCommandSet-&gt;pCommands[this-&gt;pFrame-&gt;getCurrentCommand()]-&gt;setNewData(); pCommandSet-&gt;pCommands[this-&gt;pFrame-&gt;getCurrentCommand()]-&gt;send(); <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u043d\u0438\u043a\u0430\u043a\u0438\u0435 swit\u0441h case, \u043d\u043e \u044d\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e \u00ab\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u0438\u00bb \ud83d\ude42<\/p>\n<h4>DWART. \u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0412\u0441\u0435, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0439 \u043e\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0437\u0430\u043f\u0440\u043e\u0441. <br \/>  \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0432\u044b\u0448\u0435\u043b, \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u043c\u0430 \u043e\u0442 \u0441LinkLayer, <br \/>  \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0439\u043c\u0435\u0440\u0430, \u0438 \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0441\u0442\u0440\u043e \u0432 \u043d\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0432\u044b\u0439\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0442\u0430\u043c \u0444\u043b\u0430\u0436\u043e\u043a \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043e\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443, \u0430 \u0432 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0431\u0443\u0434\u0443 \u044d\u0442\u043e \u0444\u043b\u0430\u0436\u043e\u043a \u043e\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043e\u043d \u0441\u0442\u043e\u0438\u0442, \u0442\u043e \u043e\u0431\u0440\u0430\u0449\u0443\u0441\u044c \u043a cFrame, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043c\u043d\u0435 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0443 \u043d\u0443\u0436\u043d\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438 \u043e\u0442\u043e\u0448\u043b\u044e \u0435\u0451. <br \/>  \u042d\u0442\u043e\u0442 \u0436\u0435 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b cFrame, cLinkLayer \u0438 \u0441CommandSet \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 cLinkLayer \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0444\u0435\u0440 \u043f\u0440\u0438\u0435\u043c\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438. \u0410 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043c\u0435\u043d\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0437\u0430\u043f\u0440\u043e\u0441-\u043e\u0442\u0432\u0435\u0442, \u0442\u043e \u0431\u0443\u0444\u0444\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d \u0438 \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0438 \u043d\u0430 \u043f\u0440\u0438\u0435\u043c, \u0437\u0430\u043e\u0434\u043d\u043e \u0438 \u043f\u0430\u043c\u044f\u0442\u044c \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043c.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/5c6\/168\/4d1\/5c61684d197c409693d6363c1d290015.png\" alt=\"image\"\/>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">dwart.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;types.h&quot;        \/\/lint !e537 \u0422\u0438\u043f\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043b\u044f tBoolean    #include &quot;frame.h&quot;        \/\/lint !e537 \u0434\u043b\u044f oFrame  #include &quot;observer.h&quot;     \/\/lint !e537 \u0434\u043b\u044f iObserver #include &quot;linklayer.h&quot;    \/\/lint !e537 \u0434\u043b\u044f cLinkLayer #include &quot;variablesdirector.h&quot;  \/\/lint !e537 \u0434\u043b\u044f cVariablesDirector #include &quot;commandset.h&quot;   \/\/lint !e537 \u0434\u043b\u044f cCommandSet #include &quot;frtosWrapper.h&quot; \/\/lint !e537 \u0414\u043b\u044f iActiveObject  #define MAX_BUFFER_SIZE (tU8)255 class cDwart: private iObserver, public iActiveObject {   public:     cDwart(cVariablesDirector *pVariableDirector);     virtual void eventHandle(const iObservable* pObservable);     virtual void run(void);   private:     cCommandSet *pCommandSet;     cLinkLayer *pLinkLayer;     cFrame *pFrame;       tU8 buffer[MAX_BUFFER_SIZE];     tBoolean isToken;     static const tU8 deviceID[5]; }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">dwart.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;susuassert.h&quot;       \/\/lint !e537 \u0434\u043b\u044f ASSERT #include &quot;frame.h&quot;            \/\/lint !e537 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 #include &lt;stddef.h&gt;           \/\/lint !e537 \u0434\u043b\u044f NULL #include &quot;dwart.h&quot;           \/\/lint !e537 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430  #define SHORT_ADDR  (tU8)0 #define PREAMBULS_COUNT (tU8)7 #define DWART_WAITING (tU32) (50\/portTICK_PERIOD_MS) const tU8 cDwart::deviceID[5] = {(tU8)0x37,(tU8)0x04,(tU8)0x00,(tU8)0x00,(tU8)0x01};  \/******************************************************************************* * Function:  constructor * Description: \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 cLinkLayer, cFrame cCommandSet \u0438  *        \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043e\u0442 \u043c\u0430\u0441\u0442\u0435\u0440\u0430 ******************************************************************************\/ cDwart::cDwart(cVariablesDirector *pVariablesDirector)     {   this-&gt;pLinkLayer = new cLinkLayer(this-&gt;buffer,MAX_BUFFER_SIZE, this-&gt;buffer, PREAMBULS_COUNT);    this-&gt;pFrame =  new cFrame((tU8*)deviceID, SHORT_ADDR,this-&gt;pLinkLayer);   this-&gt;pCommandSet = new cCommandSet(this-&gt;pFrame, pVariablesDirector);   this-&gt;pLinkLayer-&gt;addObserver(this);     this-&gt;isToken = FALSE; } \/******************************************************************************* * Function:  eventHandle * Description: \u0420\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c. \u0421\u0442\u0430\u0432\u0438\u0442 \u0444\u043b\u0430\u043a \u0447\u0442\u043e \u0442\u043e\u043a\u0435\u043d \u0443 \u043d\u0430\u0441 ******************************************************************************\/ void cDwart::eventHandle(const iObservable* pObservable)  {   ASSERT(pObservable != NULL);   this-&gt;isToken = TRUE; } \/\/lint !e715 \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c pObservable \/******************************************************************************* * Function:  run * Description: \u0417\u0430\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f ******************************************************************************\/ void cDwart::run(void) {   for(;;)   {     if (this-&gt;isToken)     {       this-&gt;isToken = FALSE;       if (this-&gt;pFrame-&gt;decode() == FE_good)       {         pCommandSet-&gt;pCommands[this-&gt;pFrame-&gt;getCurrentCommand()]-&gt;setNewData();         pCommandSet-&gt;pCommands[this-&gt;pFrame-&gt;getCurrentCommand()]-&gt;send();       }     }     oRTOS.taskDelay(DWART_WAITING);   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 cDwart \u0432 main.cpp \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443  <\/p>\n<pre><code class=\"cpp\">void main( void ) {     const cAdcDirector* pAdcDirector = new cAdcDirector();   \/\/lint !e429 \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c.   pAdcDirector-&gt;startConversion();    cVariablesDirector *pVariablesDirector = new cVariablesDirector(pAdcDirector);    oRTOS.taskCreate(pVariablesDirector, VARIABLESDIRECTOR_STACK_SIZE, VARIABLESDIRECTOR_PRIORITY, &quot;Var&quot;);   cDwart *pDwart = new cDwart(pVariablesDirector);   oRTOS.taskCreate(pDwart, DWART_STACK_SIZE, DWART_PRIORITY, &quot;Dwart&quot;);    ...   oRTOS.startScheduler(); } \/\/lint !e429 \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438. <\/code><\/pre>\n<p>  \u0418 \u0432\u043e\u0442 \u043d\u0435\u043c\u0435\u0446\u043a\u043e\u0435 \u0447\u0443\u0434\u043e \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c Pactware \u0432\u0438\u0434\u0438\u0442 \u042f\u043f\u043e\u043d\u0441\u043a\u0438\u0439 \u0434\u0430\u0442\u0447\u0438\u043a \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0434\u0430\u0436\u0435 \u043d\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u043c\u0443\u043b\u044f\u0436.<\/p>\n<p>  <iframe loading=\"lazy\" width=\"560\" height=\"349\" src=\"\/\/www.youtube.com\/embed\/S0qeAysH2Jk?wmode=opaque\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>  \u0418 \u043d\u0430\u0448\u0435 \u043e\u0442\u0435\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u041f\u041e \u0442\u043e\u0436\u0435 \u043d\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0435\u0442 \u043f\u043e\u0434\u0432\u043e\u0445.<\/p>\n<p>  <iframe loading=\"lazy\" width=\"560\" height=\"349\" src=\"\/\/www.youtube.com\/embed\/hR5AvBr2c-k?wmode=opaque\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043d\u043e\u0433\u043e\u0435 \u0442\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 255 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c, \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 switch case, \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d placeholder \u043d\u0430 \u0432\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0440\u0430\u0432\u043d\u043e\u0439 \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441\u0430\u043c\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432 \u043d\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u044f\u0442\u044c.<br \/>  \u041d\u043e \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043c\u0435\u043d\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0435\u043c\u0435\u0440\u0435\u043d\u043d\u043e, \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u0431\u044b\u043b\u043e.<br \/>  \u0421\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0432 <a href=\"https:\/\/yadi.sk\/d\/XHXC4v1BiECdQ\">\u0441\u0435\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435<\/a>     \t<\/p>\n<div class=\"clear\"><\/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=\"http:\/\/geektimes.ru\/post\/259660\/\"> http:\/\/geektimes.ru\/post\/259660\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<br \/>\n<h4>\u0412\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041f\u043e\u043f\u0430\u0432 \u0432 \u043e\u0442\u043f\u0443\u0441\u043a\u0435 \u0432 \u0433\u043e\u0440\u043e\u0434 \u043d\u0430 \u041d\u0435\u0432\u0435 \u0438 \u043f\u043e\u0441\u0435\u0442\u0438\u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0445 \u043c\u0435\u0441\u0442, \u044f \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0432\u0435\u0447\u0435\u0440\u0430\u043c\u0438 \u0437\u0430 \u0447\u0430\u0448\u043a\u043e\u0439 \u043f\u0438\u0432\u0430, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 UART\u043e\u043c. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0447\u0442\u043e \u044f \u043a\u0443\u043f\u0438\u043b \u043d\u0435 \u043f\u043b\u043e\u0445\u0438\u0435 \u043d\u0430\u0443\u0448\u043d\u0438\u043a\u0438 Fisher FA011, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043a\u0443\u043f\u0438\u0442\u044c USB SOUND BLASTER X-FI HD \u0438 \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0441\u043b\u0443\u0448\u0430\u0442\u044c \u043c\u0443\u0437\u044b\u043a\u0443.<br \/>  \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u043b\u0438 \u043d\u0430 Geektime \u043f\u043e\u0442\u043e\u043c \u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0438\u0445 \u043f\u0435\u0440\u0435\u0433\u043d\u0430\u043b, \u0434\u0430\u0436\u0435 \u0438 \u043d\u0435 \u0437\u043d\u0430\u044e, \u043a\u0443\u0434\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0445 \u0434\u0435\u0442\u044c \ud83d\ude42<br \/>  \u041d\u043e \u0442\u0430\u043a \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043e\u043d\u0438 \u0442\u0443\u0442: <br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/261807\/\/\"> STM32, C++ \u0438 FreeRTOS. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441 \u043d\u0443\u043b\u044f. \u0427\u0430\u0441\u0442\u044c 1<\/a> <br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/261823\/\">STM32, C++ \u0438 FreeRTOS. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441 \u043d\u0443\u043b\u044f. \u0427\u0430\u0441\u0442\u044c 2<\/a> \u0438 <br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/261837\/\">STM32, C++ \u0438 FreeRTOS. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441 \u043d\u0443\u043b\u044f. \u0427\u0430\u0441\u0442\u044c 3 (LCD \u0438 \u042d\u043a\u0440\u0430\u043d\u044b)<\/a><\/p>\n<h4>UART<\/h4>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043c\u043d\u0435 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0430\u044f \u043f\u043e\u0441\u044b\u043b\u043a\u0430 \u0431\u0430\u0439\u0442\u0430 \u0432 \u043f\u043e\u0440\u0442 \u043f\u0440\u043e\u0448\u043b\u0430 \u0431\u0435\u0437 \u0437\u0430\u0434\u043e\u0440\u0438\u043d\u043a\u0438, \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043a\u0430\u043a \u0447\u0430\u0441\u044b, \u0438 \u0442\u0443\u0442 \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f. \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u044b\u043b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430. \u0418 IAR \u0432 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0442\u0430\u043a \u0438 \u043f\u0438\u0441\u0430\u043b:  <\/p>\n<blockquote><p>Special function types can be used for static member functions. For example, in the<br \/>  following example, the function handler is declared as an interrupt function:  <\/p>\n<pre><code class=\"cpp\">class Device {  static __irq void handler(); }; <\/code><\/pre>\n<\/blockquote>\n<p>  \u041d\u043e \u0432\u043e\u0442 \u043d\u0435\u0437\u0430\u0434\u0430\u0447\u0430, \u0434\u043b\u044f Cortex M \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0438   <\/p>\n<blockquote><p>On ARM Cortex-M, an interrupt service routine enters and returns in the same way as a<br \/>  normal function, which means no special keywords are required. <b>Thus, the keywords<br \/>  __irq, __fiq, and __nested are not available when you compile for ARM Cortex-M.<\/b><br \/>  These exception function names are defined in cstartup_M.c and cstartup_M.s.<br \/>  They are referred to by the library exception vector code:<br \/>  NMI_Handler<br \/>  HardFault_Handler<br \/>  MemManage_Handler<br \/>  BusFault_Handler<br \/>  \u2026<br \/>  The vector table is implemented as an array. It should always have the name<br \/>  __vector_table,   <\/p><\/blockquote>\n<p>  \u0418\u043b\u0438 \u043f\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443, \u0432\u0430\u0448 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u0438\u043c\u044f, \u043a\u0430\u043a\u043e\u0435 \u043e\u043d \u0438\u043c\u0435\u0435\u0442 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 startup \u0444\u0430\u0439\u043b\u0435. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u2014 \u0441\u043b\u0430\u0431\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 __weak (\u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 PUBWEAK), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440\u0430, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442\u0441\u044f \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0435 \u043f\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0431\u0435\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 __week. \u041d\u0443 \u0442.\u0435., \u0435\u0441\u043b\u0438 \u0432\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0438\u043c\u0435\u043d\u0435\u043c \u0431\u0435\u0437 \u044d\u0442\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b, \u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u0440\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435, \u0442\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043e __weak. <br \/>  \u041f\u043e\u043d\u044f\u0442\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u0447\u0442\u043e \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u0432 \u0444\u0430\u0439\u043b <b>startup_stm32l1xx_md.s<\/b> \u0438\u043b\u0438 <b>startup_stm32l1xx_md.\u0441<\/b> \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0421++ \u0438\u043c\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0442\u0438\u043f\u0430 <i>cUart::USART2_IRQHandler()<\/i>, \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u043e\u0439\u043c\u0435\u0442. <br \/>  \u0410 \u043f\u0440\u043e\u0441\u0442\u043e <i>\u00abUSART2_IRQHandler\u00bb<\/i> \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c <i>\u00abcUart::USART2_IRQHandler()\u00bb<\/i>. <br \/>  \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <i>extern \u00abC\u00bb { void USART2_IRQHandler(void) {&#8230;}}<\/i>, \u043d\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044f \u0442\u0443\u0442 \u0431\u0443\u0434\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0442\u0430\u043a\u0438 \u0438\u0437 \u0421\u0438, \u0447\u0442\u043e \u043c\u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043d\u0430\u0434\u043e, \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438\u0437 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u043c\u043e\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0431\u0443\u0444\u0435\u0440\u0443 \u2014 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0438 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u043a\u0443\u0447\u0443 \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0430 :). <br \/>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0439\u0442\u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0435\u043c \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b <b>startup_stm32l1xx_md.cpp<\/b>. \u041f\u043e\u0438\u0441\u043a \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043b\u044e\u0434\u0435\u0439 <br \/>  \u0412 \u043e\u0431\u0449\u0435\u043c \u0438\u0434\u0435\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c: \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c <b>startup_stm32l1xx_md.cpp<\/b> \u0432 \u043a\u043b\u0430\u0441\u0441\u044b \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0431\u0443\u0434\u0443\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439), \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 __vector_table, \u0433\u0434\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u0441\u0442\u043e\u0438\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043d\u0430 \u044d\u0442\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u0414\u0430\u043b\u044c\u0448\u0435 \u0434\u0435\u043b\u0430\u0435\u043c __weak \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430<br \/>  \u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0433\u0434\u0430 \u0432 \u043a\u043e\u0434\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u0438\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <i>void cUart1::handler()<\/i>, \u043e\u043d \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u044f\u0441\u044c \u0431\u0435\u0440\u0435\u0442 \u0435\u0451. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0430\u0448\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u0447\u044c \u0432 \u0442\u043e\u0447\u044c \u0442\u0430\u043a, \u043a\u0430\u043a \u043e\u043d\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 <b>startup_stm32l1xx_md.cpp<\/b>. <br \/>  \u041d\u0443\u0436\u043d\u043e \u0435\u0449\u0435 \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 FreeRtos: <i>vPortSVCHandler<\/i>, <i>xPortPendSVHandler<\/i>, <i>xPortSysTickHandler <\/i> \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u043d\u0443\u0436\u043d\u043e\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0438 \u0432\u0443\u0430\u043b\u044f \u2014 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">startup_stm32l1xx_md.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#pragma language = extended #pragma segment = &quot;CSTACK&quot; extern &quot;C&quot; void __iar_program_start( void ); extern &quot;C&quot; void vPortSVCHandler(void); extern &quot;C&quot; void xPortPendSVHandler(void); extern &quot;C&quot; void xPortSysTickHandler(void); class cNMI { public:     static void handler(void); }; class cHardFault { public:     static void handler(void); }; class cMemManage { public:     static void handler(void); }; class cBusFault { public:     static void handler(void); }; class cUsageFault { public:     static void handler(void); }; class cDebugMon { public:     static void handler(void); }; class cWindowWatchdog { public:     static void handler(void);     }; class cPvd { public:     static void handler(void);     }; class cTamperTimeStamp { public:     static void handler(void);     }; class cRtcWakeup { public:     static void handler(void);     }; class cFlash { public:     static void handler(void);     }; class cRcc { public:     static void handler(void);     }; class cExti { public:     static void line0Handler(void);     static void line1Handler(void);     static void line2Handler(void);     static void line3Handler(void);     static void line4Handler(void);     static void line9Handler(void);     static void line15_10Handler(void); }; class cDma { public:     static void channellHandler(void);         static void channel2Handler(void);         static void channel3Handler(void);         static void channel4Handler(void);         static void channel5Handler(void);         static void channel6Handler(void);         static void channel7Handler(void);     }; class cAdc { public:     static void handler(void);     }; class cDac { public:     static void handler(void);     }; class cUsb { public:     static void highPriorityHandler(void);         static void lowPriorityHandler(void);     static void fsWakeupHandler(void); }; class cComp { public:     static void handler(void);     }; class cLcdDriver { public:     static void handler(void);     }; class cTim9 { public:     static void handler(void);     }; class cTim2 { public:     static void handler(void);     }; class cTim3 { public:     static void handler(void);     }; class cTim4 { public:     static void handler(void);     }; class cTim10 { public:     static void handler(void);     }; class cTim6 { public:     static void handler(void);     }; class cTim7 { public:     static void handler(void);     }; class cTim11 { public:     static void handler(void);     }; class cI2C1 { public:     static void eventHandler(void);     static void errorHandler(void); }; class cI2C2 { public:     static void eventHandler(void);     static void errorHandler(void); }; class cSpi1 { public:     static void handler(void);     }; class cSpi2 { public:     static void handler(void);     }; class cUart1 { public:     static void handler(void);     }; class cUart2 { public:     static void handler(void);     }; class cUart3 { public:     static void handler(void);     }; class cRtcAlarm { public:     static void handler(void);     }; typedef void( *intfunc )( void ); typedef union { intfunc __fun; void * __ptr; } intvec_elem; \/\/ The vector table is normally located at address 0. \/\/ When debugging in RAM, it can be located in RAM, aligned to at least 2^6. \/\/ If you need to define interrupt service routines, \/\/ make a copy of this file and include it in your project. \/\/ The name &quot;__vector_table&quot; has special meaning for C-SPY: \/\/ it is where the SP start value is found, and the NVIC vector \/\/ table register (VTOR) is initialized to this address if != 0. #pragma location = &quot;.intvec&quot; extern &quot;C&quot; const intvec_elem __vector_table[] = {   { .__ptr = __sfe( &quot;CSTACK&quot; ) },   __iar_program_start,    cNMI::handler,   cHardFault::handler,   cMemManage::handler,   cBusFault::handler,   cUsageFault::handler,   0,   0,   0,   0,   vPortSVCHandler,             \/\/\u0444\u0443\u043d\u043a\u0446\u0438\u0438 freeRTOS \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0442\u044c!   cDebugMon::handler,   0,   xPortPendSVHandler,          \/\/\u0444\u0443\u043d\u043a\u0446\u0438\u0438 freeRTOS \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0442\u044c!   xPortSysTickHandler,         \/\/\u0444\u0443\u043d\u043a\u0446\u0438\u0438 freeRTOS \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0442\u044c!   \/\/External Interrupts   cWindowWatchdog::handler,    \/\/Window Watchdog   cPvd::handler,               \/\/PVD through EXTI Line detect   cTamperTimeStamp::handler,   \/\/Tamper and Time Stamp   cRtcWakeup::handler,         \/\/RTC Wakeup   cFlash::handler,             \/\/FLASH   cRcc::handler,               \/\/RCC   cExti::line0Handler,         \/\/EXTI Line 0   cExti::line1Handler,         \/\/EXTI Line 1   cExti::line2Handler,         \/\/EXTI Line 2   cExti::line3Handler,         \/\/EXTI Line 3   cExti::line4Handler,         \/\/EXTI Line 4   cDma::channellHandler,       \/\/DMA1 Channel 1   cDma::channel2Handler,       \/\/DMA1 Channel 2   cDma::channel3Handler,       \/\/DMA1 Channel 3   cDma::channel4Handler,       \/\/DMA1 Channel 4   cDma::channel5Handler,       \/\/DMA1 Channel 5   cDma::channel6Handler,       \/\/DMA1 Channel 6   cDma::channel7Handler,       \/\/DMA1 Channel 7   cAdc::handler,               \/\/ADC1   cUsb::highPriorityHandler,   \/\/USB High Priority   cUsb::lowPriorityHandler,    \/\/USB Low  Priority   cDac::handler,               \/\/DAC   cComp::handler,              \/\/COMP through EXTI Line   cExti::line9Handler,         \/\/EXTI Line 9..5   cLcdDriver::handler,         \/\/LCD   cTim9::handler,               \/\/TIM9   cTim10::handler,             \/\/TIM10   cTim11::handler,             \/\/TIM11   cTim2::handler,             \/\/TIM2   cTim3::handler,              \/\/TIM3   cTim4::handler,              \/\/TIM4   cI2C1::eventHandler,         \/\/I2C1 Event   cI<\/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-262762","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/262762","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=262762"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/262762\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=262762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=262762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=262762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}