{"id":313194,"date":"2020-11-16T09:00:22","date_gmt":"2020-11-16T09:00:22","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=313194"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=313194","title":{"rendered":"\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0437\u0430 1 \u0442\u0430\u043a\u0442 \u0438\u043b\u0438 \u043c\u0430\u0433\u0438\u044f 500 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/m6\/5v\/6n\/m65v6nk2ktzzuhm0wofwz8bff4o.png\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e, \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u043a\u043e\u0433\u0434\u0430 \u0431\u0430\u0439\u0442\u0438\u043a\u0438 \u043d\u0435 \u0431\u0435\u0433\u0430\u044e\u0442 \u043f\u043e UART, \u0432\u044b \u0432\u043e\u0441\u043a\u043b\u0438\u0446\u0430\u0435\u0442\u0435: \u00ab\u0410\u0430\u0430, \u0442\u043e\u0447\u043d\u043e! \u041d\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435!\u00bb. \u0418\u043b\u0438, \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u043d\u043e\u0436\u043a\u0438 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430, \u0437\u0430\u0431\u044b\u0432\u0430\u043b\u0438 \u00ab\u043f\u043e\u0434\u0430\u0442\u044c \u043f\u0438\u0442\u0430\u043d\u0438\u0435\u00bb \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0440\u0442? \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e. \u042f, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u2014 \u0443\u0436 \u0442\u043e\u0447\u043d\u043e. <\/p>\n<p>  \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e: \u0437\u0430\u043f\u0438\u0441\u0430\u043b 1 \u2014 \u0432\u043a\u043b\u044e\u0447\u0438\u043b, 0 \u2014 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u043b. <\/p>\n<p>  \u041d\u043e \u00ab\u043f\u0440\u043e\u0441\u0442\u043e\u00bb, \u2014 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u2026<br \/>  <a name=\"habracut\"><\/a> \u2003  <\/p>\n<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0435\u0433\u043e \u043e\u0446\u0435\u043d\u043a\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\u0412\u043e \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u2014 \u044d\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e-\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0437\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f <\/li>\n<li>\u041b\u0435\u0433\u043a\u0430\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f code review \u0432\u0441\u0435\u0445 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\/\u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <\/li>\n<li>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043b\u0438\u0448\u0435\u043d \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443, \u043b\u0438\u0431\u043e, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u044d\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0441\u0432\u0435\u0434\u0435\u043d\u0430 \u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0443<\/li>\n<li>\u041d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0431\u0438\u0442\u0430\u043c\u0438 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u043c\u0438<\/li>\n<li>\u0423\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0438 \u043e\u0434\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 <\/li>\n<li>\u041f\u043e\u043c\u0438\u043c\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b (\u043e \u043d\u0435\u043c \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u0434\u0430\u043b\u0435\u0435) <\/li>\n<\/ul>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u043e\u0446\u0435\u043d\u043a\u0438, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0438 \u00ab\u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435\u00bb \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440: <i>GCC 10.1.1 + Make<\/i><br \/>  \u042f\u0437\u044b\u043a: <i>C++17<\/i><br \/>  \u0421\u0440\u0435\u0434\u0430: <i>Visual Studio Code<\/i><br \/>  \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440: <i>stm32f103c8t6 (cortex-m3)<\/i><br \/>  \u0417\u0430\u0434\u0430\u0447\u0430: <i>\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f SPI2, USART1 (\u043e\u0431\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c DMA)<\/i><\/p>\n<p>  \u0412\u044b\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0445 \u043d\u0430\u0440\u043e\u0434\u043d\u044b\u0445 \u043f\u0440\u043e\u043c\u044b\u0441\u043b\u043e\u0432 \u2013 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0443 \u043f\u043b\u0430\u0442 Blue Pill.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dy\/kr\/tr\/dykrtr_rya_ezallc1rlr01dpak.png\"\/><\/p>\n<p>  \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u043e\u043b\u043e\u0433\u0438\u0438, \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435\u0432\u0430\u0436\u043d\u043e, \u043a\u0430\u043a\u043e\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432\u044b\u0431\u0440\u0430\u043d: stmf1, stmf4 \u0438\u043b\u0438 lpc, \u0442.\u043a. \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043a \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0431\u0438\u0442 \u043b\u0438\u0431\u043e 0 \u0434\u043b\u044f \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043b\u0438\u0431\u043e 1 \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. <\/p>\n<p>  \u0412 stm32f103c8t6 \u0438\u043c\u0435\u0435\u0442\u0441\u044f 3 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b \u0437\u0430 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438: AHBENR, APB1ENR, APB2ENR. <\/p>\n<p>  \u0410\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 SPI2 \u0438 USART1 \u0432\u044b\u0431\u0440\u0430\u043d\u044b \u043d\u0435\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u0438\u0445 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0431\u0438\u0442\u044b \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0432\u043e \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445 \u2013 \u0431\u0438\u0442\u044b \u0441\u0430\u043c\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, DMA1, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u0438\u0442\u044b \u043f\u043e\u0440\u0442\u043e\u0432 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 (GPIOB \u0434\u043b\u044f SPI2 \u0438 GPIOA \u0434\u043b\u044f USART1).<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/3n\/x3\/cy\/3nx3cyivj--xfv3mtaujrdvebmy.png\"\/> <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/zf\/zs\/kq\/zfzskqrorhzx8nx3iknpk5ivrjy.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/g1\/ve\/hn\/g1vehnaxqiq9aoebwrmw9qqsk5q.png\"\/><\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u2013 AHBENR \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a SPI2, \u0442\u0430\u043a \u0438 USART1. \u0422\u043e \u0435\u0441\u0442\u044c, \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DMA \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043d\u0435\u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u043e\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043c, \u041a\u041f\u0414 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u0436\u0435 \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u044b\u043c, \u0430 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u0432\u0435\u0434\u044c \u044d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u0439\u043c\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0441\u0445\u043e\u0434\u0443 \u0442\u0430\u043a\u0442\u043e\u0432 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435-\u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e-\u0437\u0430\u043f\u0438\u0441\u044c volatile \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430.<\/p>\n<p>  \u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0432\u0448\u0438\u0441\u044c \u0441 \u0446\u0435\u043b\u044f\u043c\u0438, \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u043e\u0438\u0441\u043a\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u0439.<br \/>  \u2003  <\/p>\n<h2>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b<\/h2>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0442\u0438\u043f\u043e\u0432\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438\u0441\u044c \u0438, \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430, \u0412\u044b \u0438\u0445 \u0442\u0430\u043a\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u0438\/\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435. \u041e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0445, \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u044b\u0445 \u043d\u0430 C, \u0434\u043e fold expression \u0438\u0437 C++17. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043f\u0440\u0438\u0441\u0443\u0449\u0438\u0435 \u0438\u043c \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e, \u0442\u043e \u044d\u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a <a href=\"#next\">\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443<\/a>.<\/p>\n<h3>\u041f\u0440\u044f\u043c\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b<\/h3>\n<p>  \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u00ab\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb \u0438 \u0434\u043b\u044f \u0421 \u0438 \u0434\u043b\u044f C++. \u0412\u0435\u043d\u0434\u043e\u0440, \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0434\u0435\u0444\u0430\u0439\u043d\u0435\u043d\u044b \u0432\u0441\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0438 \u0438\u0445 \u0431\u0438\u0442\u044b, \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0435\u0439:<\/p>\n<pre><code class=\"cpp\">int main(){   RCC-&gt;AHBENR  |= RCC_AHBENR_DMA1EN;   RCC-&gt;APB2ENR |= RCC_APB2ENR_IOPAEN                |  RCC_APB2ENR_IOPBEN                |  RCC_APB2ENR_USART1EN;   RCC-&gt;APB2ENR |= RCC_APB1ENR_SPI2EN; \u2026 } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041b\u0438\u0441\u0442\u0438\u043d\u0433<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">    \/\/ AHBENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DMA1)   ldr     r3, .L3   ldr     r2, [r3, #20]   orr     r2, r2, #1   str     r2, [r3, #20]     \/\/ APB2ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOA, GPIOB, USART1)   ldr     r2, [r3, #24]   orr     r2, r2, #16384   orr     r2, r2, #12   str     r2, [r3, #24]     \/\/ APB1ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2)   ldr     r2, [r3, #28]   orr     r2, r2, #16384   str     r2, [r3, #28] <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u0430: 36 \u0431\u0430\u0439\u0442. <a href=\"https:\/\/godbolt.org\/z\/v9E4nc\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/a><\/p>\n<p>  <b>\u041f\u043b\u044e\u0441\u044b:<\/b><\/p>\n<ul>\n<li>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/li>\n<li>\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 <\/li>\n<\/ul>\n<p>  <b>\u041c\u0438\u043d\u0443\u0441\u044b:<\/b><\/p>\n<ul>\n<li>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0442\u043e\u0432, \u043b\u0438\u0431\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043c\u0430\u043d\u0443\u0430\u043b\u0443<\/li>\n<li>\u041b\u0435\u0433\u043a\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u043a\u043e\u0434\u0435. \u0427\u0438\u0442\u0430\u0442\u0435\u043b\u044c, \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430, \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e SPI2 \u0431\u044b\u043b \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d USART1 <\/li>\n<li>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0439\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, GPIO \u0438 DMA \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 <\/li>\n<li>\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0442\u0435\u0440\u044f\u0435\u0442 \u0441\u043c\u044b\u0441\u043b<\/li>\n<\/ul>\n<p>  \u041f\u0440\u0438 \u0432\u0441\u0435\u0445 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u0445, \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0441\u044c\u043c\u0430 \u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043d\u044b\u043c, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u00ab\u043f\u043e\u0449\u0443\u043f\u0430\u0442\u044c\u00bb \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, <s>\u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u00abHello, World!\u00bb<\/s> \u043c\u0438\u0433\u043d\u0443\u0432 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u043c. <\/p>\n<h3>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/h3>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u043f\u0440\u044f\u0442\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u043c\u0438 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0418 \u0432 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u0430\u044f C-\u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">void UART1_Init(){  RCC-&gt;AHBENR  |= RCC_AHBENR_DMA1EN;  RCC-&gt;APB2ENR |= RCC_APB2ENR_IOPAEN               |  RCC_APB2ENR_USART1EN;   \/\/ \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f }  void SPI2_Init(){  RCC-&gt;AHBENR  |= RCC_AHBENR_DMA1EN;  RCC-&gt;APB2ENR |= RCC_APB2ENR_IOPBEN;  RCC-&gt;APB1ENR |= RCC_APB1ENR_SPI2EN;   \/\/ \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f }  int main(){   UART1_Init();   SPI2_Init(); \u2026 } <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u0430: 72 \u0431\u0430\u0439\u0442\u0430. <a href=\"https:\/\/godbolt.org\/z\/K5vqa8\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/a><\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041b\u0438\u0441\u0442\u0438\u043d\u0433<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">UART1_Init():     \/\/ AHBENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DMA1)   ldr     r2, .L2   ldr     r3, [r2, #20]   orr     r3, r3, #1   str     r3, [r2, #20]     \/\/ APB2ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOA, USART1)   ldr     r3, [r2, #24]   orr     r3, r3, #16384   orr     r3, r3, #4   str     r3, [r2, #24]   bx      lr SPI2_Init():     \/\/\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e (!) AHBENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DMA1)   ldr     r3, .L5   ldr     r2, [r3, #20]   orr     r2, r2, #1   str     r2, [r3, #20]     \/\/\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e (!) APB2ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOB)   ldr     r2, [r3, #24]   orr     r2, r2, #8   str     r2, [r3, #24]     \/\/\u0417\u0430\u043f\u0438\u0441\u044c \u0432 APB1ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2)   ldr     r2, [r3, #28]   orr     r2, r2, #16384   str     r2, [r3, #28]   bx      lr main:    push    {r3, lr}    bl      UART1_Init()    bl      SPI2_Init() <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <b>\u041f\u043b\u044e\u0441\u044b:<\/b><\/p>\n<ul>\n<li>\u041c\u043e\u0436\u043d\u043e \u043d\u0435 \u0437\u0430\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u0442\u044c \u0432 \u043c\u0430\u043d\u0443\u0430\u043b \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443<\/li>\n<li>\u041e\u0448\u0438\u0431\u043a\u0438 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438<\/li>\n<li>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434 \u043b\u0435\u0433\u043a\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c<\/li>\n<\/ul>\n<p>  <b>\u041c\u0438\u043d\u0443\u0441\u044b:<\/b><\/p>\n<ul>\n<li>\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432\u043e\u0437\u0440\u043e\u0441\u043b\u043e \u043a\u0440\u0430\u0442\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 <\/li>\n<li>\u041e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u2014 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430 UART \u0438 SPI \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u0435\u043d<\/li>\n<\/ul>\n<p>  \u0425\u043e\u0442\u044c \u043c\u044b \u0438 \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u0442 \u043f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u043a\u043e\u0434\u0435, \u043d\u043e \u043a\u0430\u043a\u043e\u0439 \u0446\u0435\u043d\u043e\u0439? \u0422\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u0438\u0441\u044c \u0432 2 \u0440\u0430\u0437\u0430 \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442 \u0440\u0430\u0441\u0442\u0438, \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438. <\/p>\n<h3>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>  \u041e\u0431\u0435\u0440\u043d\u0435\u043c \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u043d\u0438\u0437\u0438\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u044d\u0442\u0438\u043c, \u0432\u0432\u0435\u0434\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440-\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u2013 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">void PowerEnable(uint32_t ahb, uint32_t apb2, uint32_t apb1){     RCC-&gt;AHBENR  |= ahb;     RCC-&gt;APB2ENR |= apb2;     RCC-&gt;APB1ENR |= apb1; }  void UART_Init(int identifier){     uint32_t ahb = RCC_AHBENR_DMA1EN, apb1 = 0U, apb2 = 0U;     if (identifier == 1){       apb2 = RCC_APB2ENR_IOPAEN | RCC_APB2ENR_USART1EN;     }      else if (identifier == 2){\u2026}     PowerEnable(ahb, apb2, apb1);   \/\/ \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f }  void SPI_Init(int identifier){     uint32_t ahb = RCC_AHBENR_DMA1EN, apb1 = 0U, apb2 = 0U;     if (identifier == 1){\u2026}      else if (identifier == 2){       apb2 = RCC_APB2ENR_IOPBEN;       apb1 = RCC_APB1ENR_SPI2EN;     }     PowerEnable(ahb, apb2, apb1);   \/\/ \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f }  int main(){   UART_Init(1);   SPI_Init(2); \u2026 } <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u0430: 92 \u0431\u0430\u0439\u0442\u0430. <a href=\"https:\/\/godbolt.org\/z\/Gnahz4\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/a><\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041b\u0438\u0441\u0442\u0438\u043d\u0433<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">PowerEnable(unsigned long, unsigned long, unsigned long):   push    {r4}   ldr     r3, .L3   ldr     r4, [r3, #20]   orrs    r4, r4, r0   str     r4, [r3, #20]   ldr     r0, [r3, #24]   orrs    r0, r0, r1   str     r0, [r3, #24]   ldr     r1, [r3, #28]   orrs    r1, r1, r2   str     r1, [r3, #28]   pop     {r4}   bx      lr UART_Init(int):   push    {r3, lr}   cmp     r0, #1   mov     r2, #0   movw    r1, #16388   it      ne   movne   r1, r2   movs    r0, #1   bl      PowerEnable(unsigned long, unsigned long, unsigned long)   pop     {r3, pc} SPI_Init(int):   push    {r3, lr}   cmp     r0, #2   ittee   eq   moveq   r1, #8   moveq   r1, #16384   movne   r1, #0   movne   r2, r1   movs    r0, #1   bl      PowerEnable(unsigned long, unsigned long, unsigned long)   pop     {r3, pc} main:    push    {r3, lr}    movs    r0, #1    bl      UART_Init(int)    movs    r0, #2    bl      SPI_Init(int) <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <b>\u041f\u043b\u044e\u0441\u044b:<\/b>  <\/p>\n<ul>\n<li>\u0423\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u0434 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430<\/li>\n<li>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u043e\u0441\u044c*<\/li>\n<\/ul>\n<p>  <b>\u041c\u0438\u043d\u0443\u0441\u044b:<\/b><\/p>\n<ul>\n<li>\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/li>\n<\/ul>\n<p>  *\u0414\u0430, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432\u043e\u0437\u0440\u043e\u0441, \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c, \u043d\u043e \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0438\u0432\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u043e 2 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438. <\/p>\n<p>  \u0422.\u043a. \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0442\u043e \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0435\u043a\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e \u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435, \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e <s>\u043d\u0430\u0448\u0438 \u043f\u043e\u043b\u043d\u043e\u043c\u043e\u0447\u0438\u044f \u0432\u0441\u0435<\/s> \u0441\u0442\u043e\u0438\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a <i>\u043f\u043b\u044e\u0441\u0430\u043c<\/i>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u0447\u0438\u0441\u0442\u043e\u043c C \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432. \u041d\u043e \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u0442\u0430\u043a\u0436\u0435 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u0435\u043d \u0438 \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d \u0441 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u043a\u043e\u0434\u0435. <br \/>  \u2003  <\/p>\n<h3>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b<\/h3>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043f\u043b\u044e\u0441\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u0442.\u043a. \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u0441\u0442\u0438\u043b\u0435 C. <\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043d\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b, \u0442\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441\u043e \u0441\u0442\u0435\u043a\u043e\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c, \u0430 \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u043d\u0430\u0434\u0435\u043b\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 <i>(value trait)<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432.<\/p>\n<pre><code class=\"cpp\">struct Power{ template&lt; uint32_t valueAHBENR, uint32_t valueAPB2ENR, uint32_t valueAPB1ENR&gt;     static void Enable(){ \/\/ \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 = 0, \u0442\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u043a\u043e\u0434\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442         if constexpr (valueAHBENR)             RCC-&gt;AHBENR |= valueAHBENR;         if constexpr (valueAPB2ENR)             RCC-&gt;APB2ENR |= valueAPB2ENR;         if constexpr (valueAPB1ENR)             RCC-&gt;APB1ENR |= valueAPB1ENR;     };  };  template&lt;auto identifier&gt; struct UART{ \/\/ \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e identifier \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438   static constexpr auto valueAHBENR = RCC_AHBENR_DMA1EN;   static constexpr auto valueAPB1ENR = identifier == 1 ? 0U : RCC_APB1ENR_USART2EN;   static constexpr auto valueAPB2ENR = RCC_APB2ENR_IOPAEN                                     |  (identifier == 1 ? RCC_APB2ENR_USART1EN : 0U);     \/\/ \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f };  template&lt;auto identifier&gt; struct SPI{   static constexpr auto valueAHBENR = RCC_AHBENR_DMA1EN;   static constexpr auto valueAPB1ENR = identifier == 1 ? 0U : RCC_APB1ENR_SPI2EN;   static constexpr auto valueAPB2ENR = RCC_APB2ENR_IOPBEN                                     |  (identifier == 1 ? RCC_APB2ENR_SPI1EN : 0U);     \/\/ \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f };  int main(){     \/\/ \u041d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438   using uart = UART&lt;1&gt;;   using spi = SPI&lt;2&gt;;    Power::Enable&lt;                 uart::valueAHBENR  | spi::valueAHBENR,                 uart::valueAPB2ENR | spi::valueAPB2ENR,                 uart::valueAPB1ENR | spi::valueAPB1ENR                 &gt;(); \u2026 } <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u0430: 36 \u0431\u0430\u0439\u0442. <a href=\"https:\/\/godbolt.org\/z\/a56are\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/a><\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041b\u0438\u0441\u0442\u0438\u043d\u0433<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">main:     \/\/ AHBENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DMA1)   ldr     r3, .L3   ldr     r2, [r3, #20]   orr     r2, r2, #1   str     r2, [r3, #20]     \/\/ APB2ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOA, GPIOB, USART1)   ldr     r2, [r3, #24]   orr     r2, r2, #16384   orr     r2, r2, #12   str     r2, [r3, #24]     \/\/ APB1ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2)   ldr     r2, [r3, #28]   orr     r2, r2, #16384   str     r2, [r3, #28] <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <b>\u041f\u043b\u044e\u0441\u044b:<\/b><\/p>\n<ul>\n<li>\u0420\u0430\u0437\u043c\u0435\u0440 \u0438 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0442\u0430\u043a\u0438\u043c\u0438 \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0441 \u043f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b <\/li>\n<li>\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u2013 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <s>\u0432\u043e\u0434\u044b <\/s> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438<\/li>\n<\/ul>\n<p>  <b>\u041c\u0438\u043d\u0443\u0441\u044b:<\/b><\/p>\n<ul>\n<li>\u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0432 \u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/li>\n<li> \u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u2013 \u0441\u0442\u0440\u0430\u0434\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u043e\u0441\u0442\u044c<\/li>\n<li>\u00ab\u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u00bb \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <\/li>\n<\/ul>\n<p>  \u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044c, \u043d\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u043b\u0438 \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f? \u0414\u0443\u043c\u0430\u044e \u2014 \u043d\u0435\u0442, \u0432\u0435\u0434\u044c \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<h3> \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u2026 \u043f\u043e\u0447\u0442\u0438<\/h3>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f parameter pack, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0431\u0435\u0440\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u043a\u043e\u0434\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">struct Power{ template&lt;typename... Peripherals&gt;   static void Enable(){       \/\/ \u0414\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0430\u043a\u0435\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f |        \/\/ \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 value = uart::valueAHBENR | spi::valueAHBENR \u0438 \u0442.\u0434.     if constexpr (constexpr auto value = (Peripherals::valueAHBENR | ... ); value)       RCC-&gt;AHBENR |= value;     if constexpr (constexpr auto value = (Peripherals::valueAPB2ENR | ... ); value)       RCC-&gt;APB2ENR |= value;     if constexpr (constexpr auto value = (Peripherals::valueAPB1ENR | ... ); value)       RCC-&gt;APB1ENR |= value;   }; };     \u2026 int main(){     \/\/ \u041d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438   using uart = UART&lt;1&gt;;   using spi = SPI&lt;2&gt;;    Power::Enable&lt;uart, spi&gt;(); \u2026 } <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u0430: 36 \u0431\u0430\u0439\u0442. <a href=\"https:\/\/godbolt.org\/z\/9dx98M\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/a><\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041b\u0438\u0441\u0442\u0438\u043d\u0433<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">main:     \/\/ AHBENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DMA1)   ldr     r3, .L3   ldr     r2, [r3, #20]   orr     r2, r2, #1   str     r2, [r3, #20]     \/\/ APB2ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOA, GPIOB, USART1)   ldr     r2, [r3, #24]   orr     r2, r2, #16384   orr     r2, r2, #12   str     r2, [r3, #24]     \/\/ APB1ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2)   ldr     r2, [r3, #28]   orr     r2, r2, #16384   str     r2, [r3, #28] <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0432\u044b\u0441\u0438\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u0442\u0430\u043b\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430, \u0430 \u0440\u0430\u0441\u0445\u043e\u0434 \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u043d\u0430 \u0442\u043e\u043c \u0436\u0435 \u0443\u0440\u043e\u0432\u043d\u0435.<\/p>\n<p>  \u0418, \u0432\u0440\u043e\u0434\u0435 \u0431\u044b, \u043c\u043e\u0436\u043d\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f, \u043d\u043e\u2026<br \/>  \u2003<br \/>  <a name=\"next\"><\/a>  <\/p>\n<h2>\u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b<\/h2>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439:  <\/p>\n<blockquote><p>\u041f\u043e\u043c\u0438\u043c\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b <\/p><\/blockquote>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u0430\u043b\u043e\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u044e\u0449\u0438\u043c, \u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432\u0441\u044e \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u044d\u043d\u0435\u0440\u0433\u043e\u0441\u0431\u0435\u0440\u0435\u0433\u0430\u044e\u0449\u0435\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430.<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u043e\u0437\u0432\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 USART1, \u0430 SPI2 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0435\u043c\u0443 \u043f\u043e\u0440\u0442 GPIOB \u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043e\u0431\u0449\u0438\u0438\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 DMA1 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c.<\/p>\n<p>  \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u043b\u044e\u0431\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430, \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e, \u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0443\u0447\u043d\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432. <br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431:<\/p>\n<pre><code class=\"cpp\">int main(){   using uart = UART&lt;1&gt;;   using spi = SPI&lt;2&gt;; \u2026     \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c USART, SPI, DMA, GPIOA, GPIOB   Power::Enable&lt;uart, spi&gt;();      \/\/ Some code      \/\/ \u0412\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u043c SPI \u0438 GPIOB \u0432\u043c\u0435\u0441\u0442\u0435 (!) \u0441 DMA   Power::Disable&lt;spi&gt;();          \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e DMA \u0432\u043c\u0435\u0441\u0442\u0435(!) \u0441 USART \u0438 GPIOA   Power::Enable&lt;uart&gt;();          \/\/ Sleep();      \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c SPI \u0438 GPIOB \u0432\u043c\u0435\u0441\u0442\u0435(!) \u0441 DMA   Power::Enable&lt;spi&gt;(); \u2026 } <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u0430: 100 \u0431\u0430\u0439\u0442. <a href=\"https:\/\/godbolt.org\/z\/rbodGE\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/a><\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041b\u0438\u0441\u0442\u0438\u043d\u0433<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">main:         \/\/ AHBENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DMA1)         ldr     r3, .L3         ldr     r2, [r3, #20]         orr     r2, r2, #1         str     r2, [r3, #20]        \/\/ APB2ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOA, GPIOB, USART1)         ldr     r2, [r3, #24]         orr     r2, r2, #16384         orr     r2, r2, #12         str     r2, [r3, #24]        \/\/ APB1ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2)         ldr     r2, [r3, #28]         orr     r2, r2, #16384         str     r2, [r3, #28]         \/\/ \u0412\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2        \/\/ AHBENR(\u0412\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DMA1)         ldr     r2, [r3, #20]         bic     r2, r2, #1         str     r2, [r3, #20]        \/\/ APB2ENR(\u0412\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOB)         ldr     r2, [r3, #24]         bic     r2, r2, #8         str     r2, [r3, #24]        \/\/ APB1ENR(\u0412\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2)         ldr     r2, [r3, #28]         bic     r2, r2, #16384         str     r2, [r3, #28]         \/\/ \u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 (!) \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 USART1         \/\/ AHBENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DMA1)         ldr     r2, [r3, #20]         orr     r2, r2, #1         str     r2, [r3, #20]        \/\/ APB2ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOA, USART1)         ldr     r2, [r3, #24]         orr     r2, r2, #16384         orr     r2, r2, #4         str     r2, [r3, #24]         \/\/ Sleep();         \/\/ AHBENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DMA1)         ldr     r2, [r3, #20]         orr     r2, r2, #1         str     r2, [r3, #20]        \/\/ APB2ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOB)         ldr     r2, [r3, #24]         orr     r2, r2, #8         str     r2, [r3, #24]        \/\/ APB1ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2)         ldr     r2, [r3, #28]         orr     r2, r2, #16384         str     r2, [r3, #28]  <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0412 \u044d\u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445 \u0437\u0430\u043d\u044f\u043b 68 \u0431\u0430\u0439\u0442. <a href=\"https:\/\/godbolt.org\/z\/PsfqGn\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/a><\/p>\n<p>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u043a\u0430\u043c\u043d\u0435\u043c \u043f\u0440\u0435\u0442\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u0443\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a DMA. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0441\u0442\u0430\u043d\u0443\u0442 \u043d\u0435\u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u043c\u0438 \u0438, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u0430\u0432\u0430\u0440\u0438\u0439\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u2026<\/p>\n<h2>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h2>\n<p>  \u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u2014 \u0438\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u0430\u043a\u043e\u0439 \u043c\u044b \u0435\u0435 \u0445\u043e\u0442\u0438\u043c \u0432\u0438\u0434\u0435\u0442\u044c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xh\/wi\/8g\/xhwi8gnq8hjxiajczumohxt_qy4.png\"\/><\/p>\n<p>  \u041e\u043d\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432\u0441\u0435\u0433\u043e \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0431\u043b\u043e\u043a\u043e\u0432:<\/p>\n<p>  \u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435:<\/p>\n<ul>\n<li> <b>IPower<\/b> \u2013 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b<\/li>\n<li> <b>Hardware<\/b>\u2013 \u0437\u0430\u043f\u0438\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430<\/li>\n<\/ul>\n<p>  \u0410\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435:  <\/p>\n<ul>\n<li> <b> Peripherals<\/b> \u2013 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443, \u043a\u0430\u043a\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0430\u0434\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u043b\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c <\/li>\n<li> <b>Adapter<\/b> \u2013 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 Hardware, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u0432 \u043a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0438\u0445 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c <\/li>\n<\/ul>\n<p>\u2003  <\/p>\n<h3>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IPower<\/h3>\n<p>  \u0421 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u0441\u0435\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435:<\/p>\n<pre><code class=\"cpp\">template&lt;typename\u2026 Peripherals&gt; Enable();  template&lt;typename EnableList, typename ExceptList&gt; EnableExcept();  template&lt;typename EnableList, typename DisableList&gt; Keep(); <\/code><\/pre>\n<p>  <b>Enable<\/b> \u2014 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430.<\/p>\n<p>  <b>EnableExcept<\/b> \u2013 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 EnableList, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0439, \u0447\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u0430 \u0432 ExceptList.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/b>                         <\/p>\n<div class=\"spoiler_text\">\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u0438  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<th>\u0411\u0438\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/th>\n<th>\u0411\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/th>\n<th>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/th>\n<th>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<tr>\n<td align=\"center\">0<\/td>\n<td align=\"center\">0<\/td>\n<td align=\"center\">0<\/td>\n<td align=\"center\">0<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">0<\/td>\n<td align=\"center\">1<\/td>\n<td align=\"center\">0<\/td>\n<td align=\"center\">0<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">1<\/td>\n<td align=\"center\">0<\/td>\n<td align=\"center\"><b>1<\/b><\/td>\n<td align=\"center\">0<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">1<\/td>\n<td align=\"center\">1<\/td>\n<td align=\"center\">0<\/td>\n<td align=\"center\">0<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0437\u043e\u0432:  <\/p>\n<pre><code class=\"cpp\">EnableExcept&lt;spi, uart&gt;(); <\/code><\/pre>\n<p>  \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0442 SPI2EN \u0438 \u0431\u0438\u0442 IOPBEN. \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u0430\u043a \u043e\u0431\u0449\u0438\u0439 DMA1EN, \u0430 \u0442\u0430\u043a\u0436\u0435 USART1EN \u0438 IOPAEN \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. <\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"cpp\">resultEnable = (enable ^ except) & enable <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041a \u043d\u0438\u043c \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u0436\u0435 \u0438\u0434\u0443\u0442 \u043a\u043e\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b <b>Disable<\/b>, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>  <b>Keep<\/b> \u2013 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u0438\u0437 EnableList, \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u0438\u0437 DisableList, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044f \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043f\u0438\u0441\u043a\u0430\u0445, \u0442\u043e \u043e\u043d\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/b>                         <\/p>\n<div class=\"spoiler_text\">\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u0438  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<th>\u0411\u0438\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/th>\n<th>\u0411\u0438\u0442 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/th>\n<th>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/th>\n<th>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<tr>\n<td align=\"center\">0<\/td>\n<td align=\"center\">0<\/td>\n<td align=\"center\">0<\/td>\n<td align=\"center\">0<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">0<\/td>\n<td align=\"center\">1<\/td>\n<td align=\"center\">0<\/td>\n<td align=\"center\">1<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">1<\/td>\n<td align=\"center\">0<\/td>\n<td align=\"center\">1<\/td>\n<td align=\"center\">0<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">1<\/td>\n<td align=\"center\">1<\/td>\n<td align=\"center\"><b>0<\/b><\/td>\n<td align=\"center\"><b>0<\/b><\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435:  <\/p>\n<pre><code class=\"cpp\">Keep&lt;spi, uart&gt;(); <\/code><\/pre>\n<p>  \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f SPI2EN \u0438 IOPBEN, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c USART1EN \u0438 IOPAEN \u0441\u0431\u0440\u043e\u0441\u044f\u0442\u0441\u044f, \u0430 DMA1EN \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"cpp\">resultEnable = (enable ^ disable) & enable resultDisable = (enable ^ disable) & disable <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041c\u0435\u0442\u043e\u0434\u044b \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\/\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e fold expression, \u043d\u043e \u043a\u0430\u043a \u0431\u044b\u0442\u044c \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438?<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c 2 \u0432\u0438\u0434\u043e\u0432 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0438, \u0442\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442. \u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0439\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2013 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u044f\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e parameter pack, \u0442.\u043a. \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0433\u0434\u0435 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432\u0442\u043e\u0440\u043e\u0439:<\/p>\n<pre><code class=\"cpp\">template&lt;typename\u2026 EnableList, typename\u2026 ExceptList&gt; EnableExcept(){\u2026};   \/\/ \u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0433\u0434\u0435 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f EnableList \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f ExceptList EnableExcept&lt;spi2, pin3, uart1, pin1, i2c3&gt;(); <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441-\u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0434\u043b\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">template&lt;typename\u2026 Peripherals&gt; PowerWrap{   static constexpr auto valueAHBENR = (Peripherals::valueAHBENR | \u2026);   static constexpr auto valueAPB1ENR = (Peripherals:: valueAPB1ENR | \u2026);   static constexpr auto valueAPB2ENR = (Peripherals:: valueAPB2ENR | \u2026); };  using EnableList = PowerWrap&lt;spi2, uart1&gt;; using ExceptList = PowerWrap&lt;pin1, i2c1&gt;;  EnableExcept&lt;EnableList, ExceptList&gt;(); <\/code><\/pre>\n<p>  \u041d\u043e \u0438 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u0442\u0430\u043d\u0435\u0442 \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0432\u044f\u0437\u0430\u043d \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 \u0431\u0435\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0441\u043b\u043e\u0438.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044f \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0442\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<br \/>  \u2003  <\/p>\n<h4>\u041c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>  \u0418\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u0435\u0436\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0435 \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438, \u0430 \u0441 \u0438\u0445 \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438, \u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0434\u0432\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u043e\u0432\u044b\u043c\u0438 \u0438 \u043d\u0435\u0442\u0438\u043f\u043e\u0432\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n<pre><code class=\"cpp\">template&lt;typename... Types&gt; struct Typelist{};  template&lt;auto... Values&gt; struct Valuelist{}; \u2026 using listT = Typelist&lt;char, int&gt; ;\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0438\u043f\u043e\u0432 char \u0438 int \u2026 using listV = Valuelist&lt;8,9,5,11&gt; ;\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0438\u0437 4 \u043d\u0435\u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u0441 \u044d\u0442\u0438\u043c\u0438 \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438, \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u0430\u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>  1. \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">front<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">  \/\/ \u041f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 template&lt;typename List&gt; struct front;    \/\/ \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0442\u0438\u043f\u043e\u0432   \/\/ \u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0430 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0438 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f template&lt;typename Head, typename... Tail&gt; struct front&lt;Typelist&lt;Head, Tail...&gt;&gt;{      \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430   using type = Head;  };   \/\/ \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0435\u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 template&lt;auto Head, auto... Tail&gt; struct front&lt;Valuelist&lt;Head, Tail...&gt;&gt; {   \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f   static constexpr auto value = Head; };    \/\/ \u041f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f template&lt;typename List&gt; using front_t = typename front&lt;List&gt;::type;  template&lt;typename List&gt; static constexpr auto front_v = front&lt;List&gt;::value;    \/\/ \u041f\u0440\u0438\u043c\u0435\u0440\u044b using listT = Typelist&lt;char, bool, int&gt;; using type = front_t&lt;listT&gt;; \/\/ type = char  using listV = Valuelist&lt;9,8,7&gt;; constexpr auto value = front_v&lt;listV&gt;; \/\/value = 9 <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  2. \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">pop_front<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;typename List&gt; struct pop_front;    \/\/ \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0442\u0438\u043f\u043e\u0432   \/\/ \u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0430 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0438 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f template&lt;typename Head, typename... Tail&gt; struct pop_front&lt;Typelist&lt;Head, Tail...&gt;&gt; {   \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0442\u0438\u043f\u044b   using type = Typelist&lt;Tail...&gt;; };  template&lt;auto Head, auto... Tail&gt; struct pop_front&lt;Valuelist&lt;Head, Tail...&gt;&gt; {   using type = Valuelist&lt;Tail...&gt;; };  template&lt;typename List&gt; using pop_front_t = typename pop_front&lt;List&gt;::type;   \/\/ \u041f\u0440\u0438\u043c\u0435\u0440\u044b using listT = Typelist&lt;char, bool, int&gt;; using typeT = pop_front_t&lt;listT&gt;; \/\/ type = Typelist&lt;bool, int&gt;  using listV = Valuelist&lt;9,8,7&gt;; using typeV = pop_front_t&lt;listV&gt;; \/\/ type = Valuelist&lt;8,7&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  3. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u043f\u0438\u0441\u043a\u0430  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">push_front<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;typename List, typename NewElement&gt; struct push_front;  template&lt;typename... List, typename NewElement&gt; struct push_front&lt;Typelist&lt;List...&gt;, NewElement&gt; {   using type = Typelist&lt;NewElement, List...&gt;; };  template&lt;typename List, typename NewElement&gt; using push_front_t = typename push_front&lt;List, NewElement&gt;::type;    \/\/ \u041f\u0440\u0438\u043c\u0435\u0440 using listT = Typelist&lt;char, bool, int&gt;; using typeT = push_front_t&lt;listT, long &gt;; \/\/ type = Typelist&lt;long, char, bool, int&gt;  <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  4. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u0442\u0438\u043f\u043e\u0432\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432 \u043a\u043e\u043d\u0435\u0446 \u0441\u043f\u0438\u0441\u043a\u0430<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">push_back_value<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;typename List, auto NewElement&gt; struct push_back;  template&lt;auto... List, auto NewElement&gt; struct push_back&lt;Valuelist&lt;List...&gt;, NewElement&gt;{   using type = Valuelist&lt;List..., NewElement&gt;; };  template&lt;typename List, auto NewElement&gt; using push_back_t = typename push_back&lt;List, NewElement&gt;::type;    \/\/ \u041f\u0440\u0438\u043c\u0435\u0440 using listV = Valuelist&lt;9,8,7&gt;; using typeV = push_back_t&lt;listV, 6&gt;; \/\/ typeV = Valuelist&lt;9,8,7,6&gt;  <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  5. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u043f\u0443\u0441\u0442\u043e\u0442\u0443<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">is_empty<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;typename List&gt; struct is_empty{     static constexpr auto value = false; };   \/\/ \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f, \u043a\u043e\u0433\u0434\u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0443\u0441\u0442 template&lt;&gt; struct is_empty&lt;Typelist&lt;&gt;&gt;{     static constexpr auto value = true; };  template&lt;typename List&gt; static constexpr auto is_empty_v = is_empty&lt;List&gt;::value;   \/\/ \u041f\u0440\u0438\u043c\u0435\u0440 using listT = Typelist&lt;char, bool, int&gt;; constexpr auto value = is_empty_v&lt;listT&gt;; \/\/ value = false <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  6. \u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">size_of_list<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">  \/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430,   \/\/ \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044f \u0441\u0447\u0435\u0442\u0447\u0438\u043a count, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0434\u043e\u0439\u0434\u0435\u0442 \u0434\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 2 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 template&lt;typename List, std::size_t count = 0&gt; struct size_of_list : public size_of_list&lt;pop_front_t&lt;List&gt;, count + 1&gt;{};    \/\/ \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0434\u043b\u044f \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0442\u0438\u043f\u043e\u0432 template&lt;std::size_t count&gt; struct size_of_list&lt;Typelist&lt;&gt;, count&gt;{   static constexpr std::size_t value = count; };    \/\/ \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0434\u043b\u044f \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0435\u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432  template&lt;std::size_t count&gt; struct size_of_list&lt;Valuelist&lt;&gt;, count&gt;{   static constexpr std::size_t value = count; };  template&lt;typename List&gt; static constexpr std::size_t size_of_list_v = size_of_list&lt;List&gt;::value;    \/\/ \u041f\u0440\u0438\u043c\u0435\u0440 using listT = Typelist&lt;char, bool, int&gt;; constexpr auto value = size_of_list_v &lt;listT&gt;; \/\/ value = 3 <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432\u0441\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043c\u0435\u0442\u0430\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439: <b>or<\/b>, <b>and<\/b>, <b>xor<\/b>, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u0438 \u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b, \u0442\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430. <\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0430\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0430\u0434 \u0441\u043f\u0438\u0441\u043a\u043e\u043c<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">lists_operation<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;template&lt;typename first, typename second&gt; class operation,          typename Lists, bool isEnd = size_of_list_v&lt;Lists&gt; == 1&gt; class lists_operation{    using first = front_t&lt;Lists&gt;; \/\/ (3)   using second = front_t&lt;pop_front_t&lt;Lists&gt;&gt;; \/\/ (4)   using next = pop_front_t&lt;pop_front_t&lt;Lists&gt;&gt;; \/\/ (5)   using result = operation&lt;first, second&gt;; \/\/ (6)  public:    using type = typename        lists_operation&lt;operation, push_front_t&lt;next, result&gt;&gt;::type; \/\/ (7)  };  template&lt;template&lt;typename first, typename second&gt; class operation, typename List&gt; class lists_operation&lt;operation, List, true&gt;{ \/\/ (1) public:   using type = front_t&lt;List&gt;; \/\/ (2) }; <\/code><\/pre>\n<p>  <b>Lists<\/b> \u2013 \u0441\u043f\u0438\u0441\u043e\u043a, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u0442\u0438\u043f\u043e\u0432 \u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<br \/>  <b>operation<\/b> \u2013 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 2 \u043f\u0435\u0440\u0432\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 Lists \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0442\u0438\u043f \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<br \/>  <b>isEnd<\/b> \u2013 \u0433\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043c\u0435\u0442\u0430\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0438\u043f\u043e\u0432 \u0432 Lists.<\/p>\n<p>  \u0412 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 (1) Lists \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 1 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0442\u0430\u043d\u0435\u0442 \u0435\u0433\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435(2).<\/p>\n<p>  \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u2013 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 (3) \u0438 \u0432\u0442\u043e\u0440\u043e\u0439 (4) \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 Lists, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f <i>\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f<\/i> (6). \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430 (7) \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u0430\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043d\u043e\u0432\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0442\u0438\u043f\u043e\u0432, \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0442\u043e\u0438\u0442 (6), \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0442\u0438\u043f\u044b (5) \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e Lists. \u041e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0432\u044b\u0437\u043e\u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (1).   <\/div>\n<\/p><\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043c\u0435\u0442\u0430\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0447\u043b\u0435\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0434 \u043d\u0435\u0442\u0438\u043f\u043e\u0432\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">valuelists_operation<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;template &lt;auto value1, auto value2&gt; typename operation,           typename List1, typename List2, typename Result = Valuelist&lt;&gt;&gt; struct operation_2_termwise_valuelists{   constexpr static auto newValue =        operation&lt;front_v&lt;List1&gt;, front_v&lt;List2&gt;&gt;::value; \/\/ (2)      using nextList1 = pop_front_t&lt;List1&gt;;   using nextList2 = pop_front_t&lt;List2&gt;;        using result = push_back_value_t&lt;Result, newValue&gt;; \/\/ (3)   using type = typename        operation_2_termwise_valuelists &lt;operation, nextList1, nextList2, result&gt;::type; \/\/ (4) };  template&lt;template &lt;auto value1, auto value2&gt; typename operation, typename Result&gt; struct operation_2_termwise_valuelists &lt;operation, Valuelist&lt;&gt;, Valuelist&lt;&gt;, Result&gt;{ \/\/ (1)   using type = Result; }; <\/code><\/pre>\n<p>  <b>List1<\/b> \u0438 <b>List2<\/b> \u2013 \u0441\u043f\u0438\u0441\u043a\u0438 \u043d\u0435\u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<br \/>  <b>operation<\/b> \u2013 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u0430\u044f \u043d\u0430\u0434 \u043d\u0435\u0442\u0438\u043f\u043e\u0432\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.<br \/>  <b>Result<\/b> \u2013 \u0442\u0438\u043f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. <\/p>\n<p>  \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 (1), \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u0443\u0441\u0442\u044b, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Result.<\/p>\n<p>  \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (2) \u0438 \u0437\u0430\u043d\u0435\u0441\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a Result (3). \u0414\u0430\u043b\u0435\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u0430\u0444\u0443\u043d\u043a\u0446\u0438\u044f (4) \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u043a\u0430 \u043e\u0431\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0435 \u0441\u0442\u0430\u043d\u0443\u0442 \u043f\u0443\u0441\u0442\u044b\u043c\u0438.   <\/div>\n<\/p><\/div>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">bitwise_operation<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;auto value1, auto value2&gt; struct and_operation{ static constexpr auto value = value1 & value2;};  template&lt;auto value1, auto value2&gt; struct or_operation{ static constexpr auto value = value1 | value2;};  template&lt;auto value1, auto value2&gt; struct xor_operation{ static constexpr auto value = value1 ^ value2;}; <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">  \/\/ \u041f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b \u0434\u043b\u044f \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u0447\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 2 \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438 template&lt;typename List1, typename List2&gt; using operation_and_termwise_t = typename            operation_2_termwise_valuelists&lt;and_operation, List1, List2&gt;::type;  template&lt;typename List1, typename List2&gt; using operation_or_termwise_t = typename            operation_2_termwise_valuelists&lt;or_operation, List1, List2&gt;::type;  template&lt;typename List1, typename List2&gt; using operation_xor_termwise_t = typename            operation_2_termwise_valuelists&lt;xor_operation, List1, List2&gt;::type;    \/\/ \u041f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b \u043f\u043e\u0447\u043b\u0435\u043d\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 template&lt;typename... Lists&gt; using lists_termwise_and_t = typename            lists_operation&lt;operation_and_termwise_t, Typelist&lt;Lists...&gt;&gt;::type;  template&lt;typename... Lists&gt; using lists_termwise_or_t= typename            lists_operation&lt;operation_or_termwise_t, Typelist&lt;Lists...&gt;&gt;::type;  template&lt;typename... Lists&gt; using lists_termwise_xor_t = typename            lists_operation&lt;operation_xor_termwise_t, Typelist&lt;Lists...&gt;&gt;::type; <\/code><\/pre>\n<p>  <a href=\"https:\/\/godbolt.org\/z\/9nYjqT\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/a> (\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 \u043e\u0448\u0438\u0431\u043e\u043a).  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h4>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430<\/h4>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044f, \u0442\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u2014 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c \u0441 \u0438\u0434\u0438\u043e\u043c\u043e\u0439 <abbr title=\"Curiously recurring template pattern\"><a href=\"https:\/\/en.wikipedia.org\/wiki\/Curiously_recurring_template_pattern\">CRTP<\/a><\/abbr>. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441-\u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<pre><code class=\"cpp\">template&lt;typename adapter&gt;   struct IPower{    template&lt;typename... Peripherals&gt;   static void Enable(){             \/\/ \u0420\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u2018power\u2019       \/\/ \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c     using tEnableList = lists_termwise_or_t&lt;typename Peripherals::power...&gt;;        \/\/ \u041f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c Valuelist&lt;\u2026&gt;, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0442\u043e\u043b\u044c\u043a\u043e 0,        \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432     using tDisableList = typename adapter::template fromValues&lt;&gt;::power;           \/\/ \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\/\u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0443    adapter:: template _Set&lt;tEnableList , tDisableList&gt;();   }    template&lt;typename EnableList, typename ExceptList&gt;   static void EnableExcept(){      using tXORedList = lists_termwise_xor_t &lt;         typename EnableList::power, typename ExceptList::power&gt;;      using tEnableList = lists_termwise_and_t &lt;         typename EnableList::power, tXORedList&gt;;      using tDisableList = typename adapter::template fromValues&lt;&gt;::power;      adapter:: template _Set&lt;tEnableList , tDisableList&gt;();   }    template&lt;typename EnableList, typename DisableList&gt;     static void Keep(){      using tXORedList = lists_termwise_xor_t &lt;         typename EnableList::power, typename DisableList::power&gt;;      using tEnableList = lists_termwise_and_t &lt;         typename EnableList::power, tXORedList&gt;;      using tDisableList = lists_termwise_and_t &lt;         typename DisableList::power, tXORedList&gt;;      adapter:: template _Set&lt;tEnableList , tDisableList&gt;();   }    template&lt;typename... PeripheralsList&gt;   struct fromPeripherals{     using power = lists_termwise_or_t&lt;typename PeripheralsList::power...&gt;;   };  }; <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <b>fromPeripherals<\/b>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044e \u0432 \u043e\u0434\u0438\u043d \u0441\u043f\u0438\u0441\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0437\u0430\u0442\u0435\u043c, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445:<\/p>\n<pre><code class=\"cpp\">  using listPower = Power::fromPeripherals&lt;spi, uart&gt;;    Power::Enable&lt;listPower&gt;(); <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434\u044b <b>Disable <\/b> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e.<\/p>\n<h3>\u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430<\/h3>\n<p>  \u0412 \u043a\u043b\u0430\u0441\u0441\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043d\u0438\u0445, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043b\u0430\u0441\u0441\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u0438\u043b\u0438 \u0441\u0431\u0440\u043e\u0441\u0438\u0442 \u0431\u0438\u0442\u044b \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432.<\/p>\n<pre><code class=\"cpp\">struct Power: public IPower&lt;Power&gt;{    static constexpr uint32_t      _addressAHBENR  = 0x40021014,     _addressAPB2ENR = 0x40021018,     _addressAPB1ENR = 0x4002101C;      using AddressesList = Valuelist&lt;       _addressAHBENR, _addressAPB1ENR, _addressAPB2ENR&gt;;    template&lt;typename EnableList, typename DisableList&gt;   static void _Set(){     \/\/ \u0412\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b     HPower:: template ModifyRegisters&lt;EnableList, DisableList, AddressesList&gt;();   }        template&lt;uint32_t valueAHBENR = 0, uint32_t valueAPB1ENR = 0, uint32_t valueAPB2ENR = 0&gt;   struct fromValues{     using power = Valuelist&lt;valueAHBENR, valueAPB1ENR, valueAPB2ENR&gt;;   };  }; <\/code><\/pre>\n<p>\u2003  <\/p>\n<h3>\u041f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044f<\/h3>\n<p>  \u041d\u0430\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c <i>power<\/i>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <i>fromValues<\/i> \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">template&lt;int identifier&gt; struct SPI{   \/\/ \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e identifier \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0442\u044b \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438   using power = Power::fromValues&lt;       RCC_AHBENR_DMA1EN, \/\/ \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432,       RCC_APB1ENR_SPI2EN, \/\/ \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0432 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0435       RCC_APB2ENR_IOPBEN&gt;::power; };  template&lt;int identifier&gt; struct UART{   using power = Power::fromValues&lt;       RCC_AHBENR_DMA1EN,       0U,        RCC_APB2ENR_USART1EN | RCC_APB2ENR_IOPAEN&gt;::power; }; <\/code><\/pre>\n<p>\u2003  <\/p>\n<h3>\u0417\u0430\u043f\u0438\u0441\u044c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b<\/h3>\n<p>  \u041a\u043b\u0430\u0441\u0441 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, \u0437\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0437\u0430\u043f\u0438\u0441\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u043c.<\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 3 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0435\u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 <i>Valuelist&lt;\u2026&gt;<\/i>:<\/p>\n<ul>\n<li><b>SetList <\/b> \u0438 <b>ResetList <\/b> \u2013 \u0441\u043f\u0438\u0441\u043a\u0438 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0431\u0438\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\/\u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435<\/li>\n<li><b>AddressesList <\/b>\u2013 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"cpp\">struct HPower{    template&lt;typename SetList, typename ResetList, typename AddressesList&gt;     static void ModifyRegisters(){     if constexpr (!is_empty_v&lt;SetList&gt; && !is_empty_v&lt;ResetList&gt; &&  \t\t  !is_empty_v&lt;AddressesList&gt;){          \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u0432       constexpr auto valueSet = front_v&lt;SetList&gt;;       constexpr auto valueReset = front_v&lt;ResetList&gt;;        if constexpr(valueSet || valueReset){          constexpr auto address = front_v&lt;AddressesList&gt;;         using pRegister_t = volatile std::remove_const_t&lt;decltype(address)&gt;* const;         auto& reg = *reinterpret_cast&lt;pRegister_t&gt;(address);          \/\/ (!)\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433         reg = (reg &(~valueReset)) | valueSet;       }          \/\/ \u0423\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0432\u0441\u0435\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432                   using tRestSet = pop_front_t&lt;SetList&gt;;       using tRestReset = pop_front_t&lt;ResetList&gt;;       using tRestAddress = pop_front_t&lt;AddressesList&gt;;                \/\/ \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0438 \u043d\u0435 \u0441\u0442\u0430\u043d\u0443\u0442 \u043f\u0443\u0441\u0442\u044b\u043c\u0438       ModifyRegisters&lt;tRestSet, tRestReset, tRestAddress&gt;();     }   };  }; <\/code><\/pre>\n<p>  \u0412 \u043a\u043b\u0430\u0441\u0441\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0431\u043b\u043e\u043a\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0433\u043e\u0442\u043e\u0432\u044b, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e.<br \/>  \u2003  <\/p>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434<\/h2>\n<p>  \u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li> \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2 \u0438 USART1 <\/li>\n<li> \u0412\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2 \u043f\u0435\u0440\u0435\u0434 \u0432\u0445\u043e\u0434\u043e\u043c \u0432 \u00ab\u0440\u0435\u0436\u0438\u043c \u044d\u043d\u0435\u0440\u0433\u043e\u0441\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u0438\u044f\u00bb<\/li>\n<li> \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u00ab\u0440\u0435\u0436\u0438\u043c\u0430 \u044d\u043d\u0435\u0440\u0433\u043e\u0441\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u0438\u044f\u00bb<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"cpp\">\/\/ \u041d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b \u0434\u043b\u044f \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 using spi = SPI&lt;2&gt;; using uart = UART&lt;1&gt;;  \/\/ \u0417\u0430\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c (\u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430) using listPowerInit = Power::fromPeripherals&lt;spi, uart&gt;; using listPowerDown = Power::fromPeripherals&lt;spi&gt;; using listPowerWake = Power::fromPeripherals&lt;uart&gt;;  int main() {     \/\/ \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2, UASRT1, DMA1, GPIOA, GPIOB     Power::Enable&lt;listPowerInit&gt;();      \/\/ Some code          \/\/ \u0412\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e SPI2 \u0438 GPIOB     Power::DisableExcept&lt;listPowerDown, listPowerWake&gt;();      \/\/Sleep();      \/\/ \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e SPI2 \u0438 GPIOB     Power::EnableExcept&lt;listPowerDown, listPowerWake&gt;(); \u2026 }  <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u0430: 68 \u0431\u0430\u0439\u0442*, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041b\u0438\u0441\u0442\u0438\u043d\u0433<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">main:   \/\/ AHBENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 DMA1)   ldr     r3, .L3   ldr     r2, [r3, #20]   orr     r2, r2, #1   str     r2, [r3, #20]   \/\/ APB1ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2   ldr     r2, [r3, #28]   orr     r2, r2, #16384   str     r2, [r3, #28]   \/\/ APB2ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOA, GPIOB, USART1)   ldr     r2, [r3, #24]   orr     r2, r2, #16384   orr     r2, r2, #12   str     r2, [r3, #24]   \/\/ APB1ENR(\u0412\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2)   ldr     r2, [r3, #28]   bic     r2, r2, #16384   str     r2, [r3, #28]   \/\/ APB2ENR(\u0412\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOB)   ldr     r2, [r3, #24]   bic     r2, r2, #8   str     r2, [r3, #24]   \/\/ APB1ENR(\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SPI2   ldr     r2, [r3, #28]   orr     r2, r2, #16384   str     r2, [r3, #28]   \/\/ APB2ENR(\u0412\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 GPIOB)   ldr     r2, [r3, #24]   orr     r2, r2, #8   str     r2, [r3, #24] <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  *\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <b>GCC 9.2.1<\/b> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 8 \u0431\u0430\u0439\u0442 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 <b>GCC 10.1.1<\/b>. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 <a href=\"https:\/\/godbolt.org\/z\/q54eeE\">\u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430<\/a> \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0435\u0434 \u0447\u0442\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 (<b>ldr<\/b>) \u0435\u0441\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f (<b>adds<\/b>), \u0445\u043e\u0442\u044f \u044d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0441\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c. \u041d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c <a href=\"https:\/\/godbolt.org\/z\/Eae5z7\">clang<\/a> \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0438.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>  \u041f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0446\u0435\u043b\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044b \u2013 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u043a\u043e\u0434\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0430 \u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0443.<\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u0431\u044a\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u043c\u0438, \u043e\u0434\u043d\u0430\u043a\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u0430\u043a\u043e\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439, \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043a \u043d\u043e\u0432\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0443 \u0437\u0430\u0439\u043c\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0443\u0441\u0438\u043b\u0438\u0439: 30 \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 + \u043f\u043e 5 \u0441\u0442\u0440\u043e\u043a \u043d\u0430 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u0431\u043b\u043e\u043a. <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">type_traits_custom.hpp<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _TYPE_TRAITS_CUSTOM_HPP #define _TYPE_TRAITS_CUSTOM_HPP  #include &lt;type_traits&gt;  \/*!   @file   @brief Traits for metaprogramming *\/  \/*!   @brief Namespace for utils. *\/ namespace utils{  \/*-----------------------------------Basic----------------------------------------*\/  \/*!   @brief Basic list of types   @tparam Types parameter pack *\/ template&lt;typename... Types&gt; struct Typelist{};  \/*!   @brief Basic list of values   @tparam Values parameter pack *\/ template&lt;auto... Values&gt; struct Valuelist{};  \/*------------------------------End of Basic--------------------------------------*\/  \/*----------------------------------Front-------------------------------------------   Description:  Pop front type or value from list    using listOfTypes = Typelist&lt;int, short, bool, unsigned&gt;;   using listOfValues = Valuelist&lt;1,2,3,4,5,6,1&gt;;    |-----------------|--------------------|----------|   |      Trait      |    Parameters      |  Result  |   |-----------------|--------------------|----------|   |     front_t     |   &lt;listOfTypes&gt;    |    int   |   |-----------------|--------------------|----------|   |     front_v     |   &lt;listOfValues&gt;   |     1    |   |-----------------|--------------------|----------| *\/  namespace{  template&lt;typename List&gt; struct front;  template&lt;typename Head, typename... Tail&gt; struct front&lt;Typelist&lt;Head, Tail...&gt;&gt;{    using type = Head;  };  template&lt;auto Head, auto... Tail&gt; struct front&lt;Valuelist&lt;Head, Tail...&gt;&gt; {   static constexpr auto value = Head; };  }  template&lt;typename List&gt; using front_t = typename front&lt;List&gt;::type;  template&lt;typename List&gt; static constexpr auto front_v = front&lt;List&gt;::value;  \/*----------------------------------End of Front----------------------------------*\/  \/*----------------------------------Pop_Front---------------------------------------   Description:  Pop front type or value from list and return rest of the list    using listOfTypes = Typelist&lt;int, short, bool&gt;;   using listOfValues = Valuelist&lt;1,2,3,4,5,6,1&gt;;    |-----------------|--------------------|------------------------|   |      Trait      |    Parameters      |         Result         |   |-----------------|--------------------|------------------------|   |   pop_front_t   |    &lt;listOfTypes&gt;   | Typelist&lt;short, bool&gt;  |   |-----------------|--------------------|------------------------|   |   pop_front_t   |   &lt;listOfValues&gt;   | Valuelist&lt;2,3,4,5,6,1&gt; |   |-----------------|--------------------|------------------------| *\/  namespace{  template&lt;typename List&gt; struct pop_front;  template&lt;typename Head, typename... Tail&gt; struct pop_front&lt;Typelist&lt;Head, Tail...&gt;&gt; {   using type = Typelist&lt;Tail...&gt;; };  template&lt;auto Head, auto... Tail&gt; struct pop_front&lt;Valuelist&lt;Head, Tail...&gt;&gt; {   using type = Valuelist&lt;Tail...&gt;; };  }  template&lt;typename List&gt; using pop_front_t = typename pop_front&lt;List&gt;::type;  \/*------------------------------End of Pop_Front----------------------------------*\/  \/*----------------------------------Push_Front--------------------------------------   Description:  Push new element to front of the list    using listOfTypes = Typelist&lt;short, bool&gt;;    |-----------------------|--------------------------|-------------------------------|   |      Trait            |        Parameters        |             Result            |   |-----------------------|--------------------------|-------------------------------|   |      push_front_t     |   &lt;listOfTypes, float&gt;   | Typelist&lt;float, short, bool&gt;  |   |-----------------------|--------------------------|-------------------------------| *\/  namespace{  template&lt;typename List, typename NewElement&gt; struct push_front;  template&lt;typename... List, typename NewElement&gt; struct push_front&lt;Typelist&lt;List...&gt;, NewElement&gt; {   using type = Typelist&lt;NewElement, List...&gt;; };  }  template&lt;typename List, typename NewElement&gt; using push_front_t = typename push_front&lt;List, NewElement&gt;::type;  \/*------------------------------End of Push_Front---------------------------------*\/  \/*----------------------------------Push_Back---------------------------------------   Description:  Push new value to back of the list    using listOfValues = Valuelist&lt;1,2,3,4,5,6&gt;;    |-----------------------|--------------------------|-------------------------------|   |      Trait            |        Parameters        |             Result            |   |-----------------------|--------------------------|-------------------------------|   |   push_back_value_t   |     &lt;listOfValues, 0&gt;    |    Valuelist&lt;1,2,3,4,5,6,0&gt;   |   |-----------------------|--------------------------|-------------------------------| *\/  namespace{  template&lt;typename List, auto NewElement&gt; struct push_back_value;  template&lt;auto... List, auto NewElement&gt; struct push_back_value&lt;Valuelist&lt;List...&gt;, NewElement&gt;{   using type = Valuelist&lt;List..., NewElement&gt;; };  }  template&lt;typename List, auto NewElement&gt; using push_back_value_t = typename push_back_value&lt;List, NewElement&gt;::type;  \/*----------------------------------End of Push_Back------------------------------*\/  \/*-----------------------------------Is_Empty---------------------------------------   Description:  Check parameters list for empty and return bool value    using listOfTypes = Typelist&lt;int, short, bool, unsigned&gt;;   using listOfValues = Valuelist&lt;&gt;;    |-------------------------|--------------------|----------|   |          Trait          |     Parameters     |  Result  |   |-------------------------|--------------------|----------|   |        is_empty_v       |    &lt;listOfTypes&gt;   |  false   |   |-------------------------|--------------------|----------|   |        is_empty_v       |   &lt;listOfValues&gt;   |   true   |   |-------------------------|--------------------|----------| *\/  namespace{ \/*!   @brief Check the emptiness of the types in parameters.   \\n      E.g.: is_empty&lt;int, short, bool&gt;::value; *\/  template&lt;typename List&gt; struct is_empty{     static constexpr auto value = false; };  \/*!   @brief Check the emptiness of the types in parameter. Specializatio for empty parameters   \\n      E.g.: is_empty&lt;&gt;::value; *\/  template&lt;&gt; struct is_empty&lt;Typelist&lt;&gt;&gt;{     static constexpr auto value = true; };  template&lt;&gt; struct is_empty&lt;Valuelist&lt;&gt;&gt;{     static constexpr auto value = true; };  }  \/*!   @brief Check the emptiness of the types-list in parameter.   \\n      E.g.: using list = Typelist&lt;int, short, bool&gt;; is_empty_v&lt;list&gt;; *\/  template&lt;typename List&gt; static constexpr auto is_empty_v = is_empty&lt;List&gt;::value;  \/*--------------------------------End of Is_Empty---------------------------------*\/  \/*---------------------------------Size_Of_List-------------------------------------   Description:  Return number of elements in list    using listOfTypes = Typelist&lt;int, float, double, bool&gt;;    |------------------|--------------------|----------|   |       Trait      |     Parameters     |  Result  |   |------------------|--------------------|----------|   |  size_of_list_v  |     listOfTypes    |    4     |   |------------------|--------------------|----------| *\/  namespace{  template&lt;typename List, std::size_t count = 0U&gt; struct size_of_list : public size_of_list&lt;pop_front_t&lt;List&gt;, count + 1&gt;{};  template&lt;std::size_t count&gt; struct size_of_list&lt;Typelist&lt;&gt;, count&gt;{   static constexpr std::size_t value = count; };  template&lt;std::size_t count&gt; struct size_of_list&lt;Valuelist&lt;&gt;, count&gt;{   static constexpr std::size_t value = count; };  }  template&lt;typename List&gt; static constexpr std::size_t size_of_list_v = size_of_list&lt;List&gt;::value;  \/*-------------------------------End Size_Of_List---------------------------------*\/  \/*---------------------------------Lists Operation--------------------------------*\/    \/*Description: Operations with lists of values    using list1 = Valuelist&lt;1, 4, 8, 16&gt;;   using list2 = Valuelist&lt;1, 5, 96, 17&gt;;    |------------------------------|-------------------|---------------------------|   |               Trait          |    Parameters     |           Result          |   |------------------------------|-------------------|---------------------------|   |     lists_termwise_and_t     |  &lt;list1, list2&gt;   |  Valuelist&lt;1, 4, 0, 16&gt;   |   |------------------------------|-------------------|---------------------------|   |     lists_termwise_or_t      |  &lt;list1, list2&gt;   |  Valuelist&lt;1, 5, 104, 17&gt; |   |---------------------------- -|-------------------|---------------------------|   |     lists_termwise_xor_t     |  &lt;list1, list2&gt;   |  Valuelist&lt;0, 1, 104, 1&gt;  |   |------------------------------|-------------------|---------------------------| *\/  namespace{  template&lt;template &lt;auto value1, auto value2&gt; typename operation,           typename List1, typename List2, typename Result = Valuelist&lt;&gt;&gt; struct operation_2_termwise_valuelists{   constexpr static auto newValue = operation&lt;front_v&lt;List1&gt;, front_v&lt;List2&gt;&gt;::value;   using nextList1 = pop_front_t&lt;List1&gt;;   using nextList2 = pop_front_t&lt;List2&gt;;        using result = push_back_value_t&lt;Result, newValue&gt;;   using type = typename        operation_2_termwise_valuelists&lt;operation, nextList1, nextList2, result&gt;::type; };  template&lt;template &lt;auto value1, auto value2&gt; typename operation, typename Result&gt; struct operation_2_termwise_valuelists&lt;operation, Valuelist&lt;&gt;, Valuelist&lt;&gt;, Result&gt;{   using type = Result; };  template&lt;template &lt;auto value1, auto value2&gt; typename operation,           typename List2, typename Result&gt; struct operation_2_termwise_valuelists&lt;operation, Valuelist&lt;&gt;, List2, Result&gt;{   using type = typename        operation_2_termwise_valuelists&lt;operation, Valuelist&lt;0&gt;, List2, Result&gt;::type; };  template&lt;template &lt;auto value1, auto value2&gt; typename operation,           typename List1, typename Result&gt; struct operation_2_termwise_valuelists&lt;operation, List1, Valuelist&lt;&gt;, Result&gt;{   using type = typename        operation_2_termwise_valuelists&lt;operation, List1, Valuelist&lt;0&gt;, Result&gt;::type; };  template&lt;template&lt;typename first, typename second&gt; class operation,          typename Lists, bool isEnd = size_of_list_v&lt;Lists&gt; == 1&gt; class lists_operation{    using first = front_t&lt;Lists&gt;;   using second = front_t&lt;pop_front_t&lt;Lists&gt;&gt;;   using next = pop_front_t&lt;pop_front_t&lt;Lists&gt;&gt;;   using result = operation&lt;first, second&gt;;  public:    using type = typename lists_operation&lt;operation, push_front_t&lt;next, result&gt;&gt;::type;  };  template&lt;template&lt;typename first, typename second&gt; class operation,          typename Lists&gt; class lists_operation&lt;operation, Lists, true&gt;{ public:   using type = front_t&lt;Lists&gt;; };  template&lt;auto value1, auto value2&gt; struct and_operation{ static constexpr auto value = value1 & value2;};  template&lt;auto value1, auto value2&gt; struct or_operation{ static constexpr auto value = value1 | value2;};  template&lt;auto value1, auto value2&gt; struct xor_operation{ static constexpr auto value = value1 ^ value2;};  template&lt;typename List1, typename List2&gt; using operation_and_termwise_t = typename      operation_2_termwise_valuelists&lt;and_operation, List1, List2&gt;::type;  template&lt;typename List1, typename List2&gt; using operation_or_termwise_t = typename      operation_2_termwise_valuelists&lt;or_operation, List1, List2&gt;::type;  template&lt;typename List1, typename List2&gt; using operation_xor_termwise_t = typename      operation_2_termwise_valuelists&lt;xor_operation, List1, List2&gt;::type;  }  template&lt;typename... Lists&gt; using lists_termwise_and_t =      typename lists_operation&lt;operation_and_termwise_t, Typelist&lt;Lists...&gt;&gt;::type;  template&lt;typename... Lists&gt; using lists_termwise_or_t = typename      lists_operation&lt;operation_or_termwise_t, Typelist&lt;Lists...&gt;&gt;::type;  template&lt;typename... Lists&gt; using lists_termwise_xor_t = typename      lists_operation&lt;operation_xor_termwise_t, Typelist&lt;Lists...&gt;&gt;::type;  \/*--------------------------------End of Lists Operation----------------------------*\/  } \/\/ !namespace utils  #endif \/\/!_TYPE_TRAITS_CUSTOM_HPP  <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">IPower.hpp<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _IPOWER_HPP #define _IPOWER_HPP  #include &quot;type_traits_custom.hpp&quot;  #define __FORCE_INLINE __attribute__((always_inline)) inline  \/*!   @brief Controller's peripherals interfaces *\/ namespace controller::interfaces{  \/*!   @brief Interface for Power(Clock control). Static class. CRT pattern   @tparam &lt;adapter&gt; class of specific controller *\/ template&lt;typename adapter&gt;   class IPower{    IPower() = delete;  public:    \/*!     @brief Enables peripherals Power(Clock)     @tparam &lt;Peripherals&gt; list of peripherals with trait 'power'   *\/   template&lt;typename... Peripherals&gt;   __FORCE_INLINE static void Enable(){     using tEnableList = utils::lists_termwise_or_t&lt;typename Peripherals::power...&gt;;     using tDisableList = typename adapter::template fromValues&lt;&gt;::power;    adapter:: template _Set&lt;tEnableList, tDisableList&gt;();   }    \/*!     @brief Enables Power(Clock) except listed peripherals in 'ExceptList'.        If Enable = Exception = 1, then Enable = 0, otherwise depends on Enable.     @tparam &lt;EnableList&gt; list to enable, with trait 'power'     @tparam &lt;ExceptList&gt; list of exception, with trait 'power'   *\/   template&lt;typename EnableList, typename ExceptList&gt;   __FORCE_INLINE static void EnableExcept(){     using tXORedList = utils::lists_termwise_xor_t&lt;typename EnableList::power, typename ExceptList::power&gt;;     using tEnableList = utils::lists_termwise_and_t&lt;typename EnableList::power, tXORedList&gt;;     using tDisableList = typename adapter::template fromValues&lt;&gt;::power;     adapter:: template _Set&lt;tEnableList, tDisableList&gt;();   }    \/*!     @brief Disables peripherals Power(Clock)     @tparam &lt;Peripherals&gt; list of peripherals with trait 'power'   *\/   template&lt;typename... Peripherals&gt;   __FORCE_INLINE static void Disable(){     using tDisableList = utils::lists_termwise_or_t&lt;typename Peripherals::power...&gt;;     using tEnableList = typename adapter::template fromValues&lt;&gt;::power;     adapter:: template _Set&lt;tEnableList, tDisableList&gt;();   }    \/*!     @brief Disables Power(Clock) except listed peripherals in 'ExceptList'.        If Disable = Exception = 1, then Disable = 0, otherwise depends on Disable.     @tparam &lt;DisableList&gt; list to disable, with trait 'power'     @tparam &lt;ExceptList&gt; list of exception, with trait 'power'   *\/   template&lt;typename DisableList, typename ExceptList&gt;   __FORCE_INLINE static void DisableExcept(){     using tXORedList = utils::lists_termwise_xor_t&lt;typename DisableList::power, typename ExceptList::power&gt;;     using tDisableList = utils::lists_termwise_and_t&lt;typename DisableList::power, tXORedList&gt;;     using tEnableList = typename adapter::template fromValues&lt;&gt;::power;     adapter:: template _Set&lt;tEnableList, tDisableList&gt;();   }    \/*!     @brief Disable and Enables Power(Clock) depends on values.        If Enable = Disable = 1, then Enable = Disable = 0, otherwise depends on values     @tparam &lt;EnableList&gt; list to enable, with trait 'power'     @tparam &lt;DisableList&gt; list to disable, with trait 'power'   *\/   template&lt;typename EnableList, typename DisableList&gt;   __FORCE_INLINE static void Keep(){     using tXORedList = utils::lists_termwise_xor_t&lt;typename EnableList::power, typename DisableList::power&gt;;     using tEnableList = utils::lists_termwise_and_t&lt;typename EnableList::power, tXORedList&gt;;     using tDisableList = utils::lists_termwise_and_t&lt;typename DisableList::power, tXORedList&gt;;     adapter:: template _Set&lt;tEnableList, tDisableList&gt;();   }    \/*!     @brief Creates custom 'power' list from peripherals. Peripheral driver should implement 'power' trait.       E.g.: using power = Power::makeFromValues&lt;1, 512, 8&gt;::power;      @tparam &lt;PeripheralsList&gt; list of peripherals with trait 'power'   *\/  template&lt;typename... PeripheralsList&gt;   class fromPeripherals{     fromPeripherals() = delete;     using power = utils::lists_termwise_or_t&lt;typename PeripheralsList::power...&gt;;     friend class IPower&lt;adapter&gt;;   };  };  } \/\/ !namespace controller::interfaces  #undef   __FORCE_INLINE  #endif \/\/ !_IPOWER_HPP  <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">HPower.hpp<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _HPOWER_HPP #define _HPOWER_HPP  #include &quot;type_traits_custom.hpp&quot;  #define __FORCE_INLINE __attribute__((always_inline)) inline  \/*!   @brief Hardware operations *\/ namespace controller::hardware{  \/*!   @brief Implements hardware operations with Power(Clock) registers *\/ class HPower{    HPower() = delete;  protected:  \/*!   @brief Set or Reset bits in the registers   @tparam &lt;SetList&gt; list of values to set    @tparam &lt;ResetList&gt; list of values to reset   @tparam &lt;AddressesList&gt; list of registers addresses to operate *\/   template&lt;typename SetList, typename ResetList, typename AddressesList&gt;   __FORCE_INLINE static void ModifyRegisters(){     using namespace utils;      if constexpr (!is_empty_v&lt;SetList&gt; && !is_empty_v&lt;ResetList&gt; &&  \t\t  !is_empty_v&lt;AddressesList&gt;){        constexpr auto valueSet = front_v&lt;SetList&gt;;       constexpr auto valueReset = front_v&lt;ResetList&gt;;        if constexpr(valueSet || valueReset){         constexpr auto address = front_v&lt;AddressesList&gt;;                    using pRegister_t = volatile std::remove_const_t&lt;decltype(address)&gt;* const;         auto& reg = *reinterpret_cast&lt;pRegister_t&gt;(address);          reg = (reg &(~valueReset)) | valueSet;       }                using tRestSet = pop_front_t&lt;SetList&gt;;       using tRestReset = pop_front_t&lt;ResetList&gt;;       using tRestAddress = pop_front_t&lt;AddressesList&gt;;              ModifyRegisters&lt;tRestSet, tRestReset, tRestAddress&gt;();     }   };  };  } \/\/ !namespace controller::hardware  #undef __FORCE_INLINE  #endif \/\/ !_HPOWER_HPP  <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">stm32f1_Power.hpp<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _STM32F1_POWER_HPP #define _STM32F1_POWER_HPP  #include &lt;cstdint&gt; #include &quot;IPower.hpp&quot; #include &quot;HPower.hpp&quot; #include &quot;type_traits_custom.hpp&quot;  #define __FORCE_INLINE __attribute__((always_inline)) inline  \/*!   @brief Controller's peripherals *\/ namespace controller{  \/*!   @brief Power managment for controller *\/ class Power: public interfaces::IPower&lt;Power&gt;, public hardware::HPower{    Power() = delete;  public:    \/*!     @brief Creates custom 'power' list from values. Peripheral driver should implement 'power' trait.       E.g.: using power = Power::fromValues&lt;1, 512, 8&gt;::power;      @tparam &lt;valueAHB=0&gt; value for AHBENR register     @tparam &lt;valueAPB1=0&gt; value for APB1ENR register     @tparam &lt;valueAPB2=0&gt; value for APB1ENR register   *\/   template&lt;uint32_t valueAHBENR = 0, uint32_t valueAPB1ENR = 0, uint32_t valueAPB2ENR = 0&gt;   struct fromValues{     fromValues() = delete;     using power = utils::Valuelist&lt;valueAHBENR, valueAPB1ENR, valueAPB2ENR&gt;;   };  private:     static constexpr uint32_t      _addressAHBENR  = 0x40021014,     _addressAPB2ENR = 0x40021018,     _addressAPB1ENR = 0x4002101C;      using AddressesList = utils::Valuelist&lt;_addressAHBENR, _addressAPB1ENR, _addressAPB2ENR&gt;;    template&lt;typename EnableList, typename DisableList&gt;   __FORCE_INLINE static void _Set(){     HPower:: template ModifyRegisters&lt;EnableList, DisableList, AddressesList&gt;();   }    friend class IPower&lt;Power&gt;;  };  } \/\/ !namespace controller  #undef __FORCE_INLINE  #endif \/\/ !_STM32F1_POWER_HPP  <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">stm32f1_SPI.hpp<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _STM32F1_SPI_HPP #define _STM32F1_SPI_HPP  #include &quot;stm32f1_Power.hpp&quot;  namespace controller{  template&lt;auto baseAddress&gt; class SPI{    static const uint32_t RCC_AHBENR_DMA1EN = 1;   static const uint32_t RCC_APB2ENR_IOPBEN = 8;   static const uint32_t RCC_APB1ENR_SPI2EN = 0x4000;    \/*!     @brief Trait for using in Power class. Consists of Valueslist with       values for AHBENR, APB1ENR, APB2ENR registers    *\/   using power = Power::fromValues&lt;            RCC_AHBENR_DMA1EN,            RCC_APB1ENR_SPI2EN,             RCC_APB2ENR_IOPBEN&gt;::power;    template&lt;typename&gt;   friend class interfaces::IPower; };  }  #endif \/\/ !_STM32F1_SPI_HPP  <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">stm32f1_UART.hpp<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _STM32F1_UART_HPP #define _STM32F1_UART_HPP  #include &quot;stm32f1_Power.hpp&quot;  namespace controller{  template&lt;auto baseAddress&gt; class UART{    static const uint32_t RCC_AHBENR_DMA1EN = 1;   static const uint32_t RCC_APB2ENR_IOPAEN = 4;   static const uint32_t RCC_APB2ENR_USART1EN = 0x4000;    \/*!     @brief Trait for using in Power class. Consists of Valueslist with       values for AHBENR, APB1ENR, APB2ENR registers    *\/   using power = Power::fromValues&lt;            RCC_AHBENR_DMA1EN,            0U,             RCC_APB2ENR_USART1EN | RCC_APB2ENR_IOPAEN&gt;::power;    template&lt;typename&gt;   friend class interfaces::IPower; };  }  #endif \/\/ !_STM32F1_UART_HPP  <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">main.cpp<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;stm32f1_Power.hpp&quot; #include &quot;stm32f1_UART.hpp&quot; #include &quot;stm32f1_SPI.hpp&quot;  using namespace controller;  using spi = SPI&lt;2&gt;; using uart = UART&lt;1&gt;;  using listPowerInit = Power::fromPeripherals&lt;spi, uart&gt;; using listPowerDown = Power::fromPeripherals&lt;spi&gt;; using listPowerWake = Power::fromPeripherals&lt;uart&gt;;  int main(){    Power::Enable&lt;listPowerInit&gt;();    \/\/Some code    Power::DisableExcept&lt;listPowerDown, listPowerWake&gt;();    \/\/Sleep();    Power::EnableExcept&lt;listPowerDown, listPowerWake&gt;();    while(1);   return 1; };  <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <a href=\"https:\/\/github.com\/7bnx\/Articles\/tree\/master\/uC%20Metaprogramming%20Power\">Github<\/a><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/528194\/\"> https:\/\/habr.com\/ru\/post\/528194\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/m6\/5v\/6n\/m65v6nk2ktzzuhm0wofwz8bff4o.png\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e, \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u043a\u043e\u0433\u0434\u0430 \u0431\u0430\u0439\u0442\u0438\u043a\u0438 \u043d\u0435 \u0431\u0435\u0433\u0430\u044e\u0442 \u043f\u043e UART, \u0432\u044b \u0432\u043e\u0441\u043a\u043b\u0438\u0446\u0430\u0435\u0442\u0435: \u00ab\u0410\u0430\u0430, \u0442\u043e\u0447\u043d\u043e! \u041d\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435!\u00bb. \u0418\u043b\u0438, \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u043d\u043e\u0436\u043a\u0438 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430, \u0437\u0430\u0431\u044b\u0432\u0430\u043b\u0438 \u00ab\u043f\u043e\u0434\u0430\u0442\u044c \u043f\u0438\u0442\u0430\u043d\u0438\u0435\u00bb \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0440\u0442? \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e. \u042f, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u2014 \u0443\u0436 \u0442\u043e\u0447\u043d\u043e. <\/p>\n<p>  \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e: \u0437\u0430\u043f\u0438\u0441\u0430\u043b 1 \u2014 \u0432\u043a\u043b\u044e\u0447\u0438\u043b, 0 \u2014 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u043b. <\/p>\n<p>  \u041d\u043e \u00ab\u043f\u0440\u043e\u0441\u0442\u043e\u00bb, \u2014 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u2026  <\/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-313194","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/313194","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=313194"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/313194\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}