\doxysection{E\+:/.WORK/\+STM32/\+Diod\+\_\+\+Test/diode\+\_\+tester/\+Core/\+Modbus/\+Src/rs\+\_\+message.c File Reference} \hypertarget{rs__message_8c}{}\label{rs__message_8c}\index{E:/.WORK/STM32/Diod\_Test/diode\_tester/Core/Modbus/Src/rs\_message.c@{E:/.WORK/STM32/Diod\_Test/diode\_tester/Core/Modbus/Src/rs\_message.c}} Реализация протоколов обмена по RS/\+UART. {\ttfamily \#include "{}rs\+\_\+message.\+h"{}}\newline {\ttfamily \#include "{}modbus\+\_\+diag.\+h"{}}\newline Include dependency graph for rs\+\_\+message.\+c\+:\nopagebreak \begin{figure}[H] \begin{center} \leavevmode \includegraphics[width=350pt]{rs__message_8c__incl} \end{center} \end{figure} \doxysubsubsection*{Functions} \begin{DoxyCompactItemize} \item \Hypertarget{rs__message_8c_a7aef1f003a519a1ab1cc2b299dfbae8e}\label{rs__message_8c_a7aef1f003a519a1ab1cc2b299dfbae8e} void {\bfseries RS\+\_\+\+UART\+\_\+\+Init} (void) \item \Hypertarget{rs__message_8c_ad17df6584058c63f612a9b5b2de73086}\label{rs__message_8c_ad17df6584058c63f612a9b5b2de73086} void {\bfseries RS\+\_\+\+UART\+\_\+\+De\+Init} (UART\+\_\+\+Handle\+Type\+Def \texorpdfstring{$\ast$}{*}huart) \item \Hypertarget{rs__message_8c_a1d002578a8cb8aa681a229a9c80f7d62}\label{rs__message_8c_a1d002578a8cb8aa681a229a9c80f7d62} void {\bfseries RS\+\_\+\+TIM\+\_\+\+Init} (void) \item \Hypertarget{rs__message_8c_aa11084c6fef53422474ef910c38e7732}\label{rs__message_8c_aa11084c6fef53422474ef910c38e7732} void {\bfseries RS\+\_\+\+TIM\+\_\+\+De\+Init} (TIM\+\_\+\+Handle\+Type\+Def \texorpdfstring{$\ast$}{*}htim) \item \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga1b59697f4b7fad81f9d5fd9fffebac2f}{RS\+\_\+\+Receive\+\_\+\+IT}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}RS\+\_\+msg) \begin{DoxyCompactList}\small\item\em Начать прием по прерываниям. \end{DoxyCompactList}\item \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga2e69a97a8b6e0b5855116d88c0e17cb9}{RS\+\_\+\+Transmit\+\_\+\+IT}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}RS\+\_\+msg) \begin{DoxyCompactList}\small\item\em Начать передачу по прерываниям. \end{DoxyCompactList}\item \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_gaa261bb0d37e7f18f04fb4353aa0f5c45}{RS\+\_\+\+Init}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS, UART\+\_\+\+Handle\+Type\+Def \texorpdfstring{$\ast$}{*}huart, TIM\+\_\+\+Handle\+Type\+Def \texorpdfstring{$\ast$}{*}htim, uint8\+\_\+t \texorpdfstring{$\ast$}{*}p\+RS\+\_\+\+Buffer\+Ptr) \begin{DoxyCompactList}\small\item\em Инициалазация структуры \doxylink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}. \end{DoxyCompactList}\item \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga1ffe808b3640f253b1783295d6990962}{RS\+\_\+\+Abort}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS, \mbox{\hyperlink{group___r_s___t_o_o_l_s_gab7c55bd8bb15b0eecc8c525019d4a1cc}{RS\+\_\+\+Abort\+Type\+Def}} Abort\+Mode) \begin{DoxyCompactList}\small\item\em Отменить прием/передачу RS/\+UART. \end{DoxyCompactList}\item \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_gab43a3b93c85adee5e3c561922d7ea2ef}{RS\+\_\+\+Handle\+\_\+\+Receive\+\_\+\+Start}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}RS\+\_\+msg) \begin{DoxyCompactList}\small\item\em Обработчик для начала приема. \end{DoxyCompactList}\item \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga330f6cfcdaab1f239054c0d91be3c5bc}{RS\+\_\+\+Handle\+\_\+\+Transmit\+\_\+\+Start}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}RS\+\_\+msg) \begin{DoxyCompactList}\small\item\em Обработчик для начала передачи. \end{DoxyCompactList}\item \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga7180b913ba795c07637680982d7f45ac}{RS\+\_\+\+UART\+\_\+\+Tx\+Cplt\+Callback}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS) \begin{DoxyCompactList}\small\item\em UART TX Callback\+: коллбек после окончания передачи. \end{DoxyCompactList}\item void \mbox{\hyperlink{group___r_s___t_o_o_l_s_gab27567456df0329130c7fe4fc43c6ee1}{RS\+\_\+\+UART\+\_\+\+Handler}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS) \begin{DoxyCompactList}\small\item\em Обработчик прерывания UART. \end{DoxyCompactList}\item void \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga2d356b2a0b4af43460bb2cacb81779ce}{RS\+\_\+\+TIM\+\_\+\+Handler}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS) \begin{DoxyCompactList}\small\item\em Обработчик прерывания TIM. \end{DoxyCompactList}\item \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_gac3a7bbc060a4250c160d51f0a0ca6cf8}{RS\+\_\+\+Timeout\+\_\+\+Start}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS) \begin{DoxyCompactList}\small\item\em Запуск таймаута приема. \end{DoxyCompactList}\item \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga1de0a597d043b64d0a19bc393cc1b3fd}{RS\+\_\+\+Timeout\+\_\+\+Stop}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS) \begin{DoxyCompactList}\small\item\em Остановка таймаута приема. \end{DoxyCompactList}\item \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_gad3d2e8fb9c2879e1ddb967cff6124521}{RS\+\_\+\+Timeout\+\_\+\+Update}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS) \begin{DoxyCompactList}\small\item\em Обновление (сброс) таймаута приема. \end{DoxyCompactList}\item \+\_\+\+\_\+weak \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga8b7bcc84cb8192a58fe87b662fbd9690}{RS\+\_\+\+Response}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}RS\+\_\+msg) \begin{DoxyCompactList}\small\item\em Пользовательская функция для ответа на запрос по UART. \end{DoxyCompactList}\item \+\_\+\+\_\+weak \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga1cd98c55f6f359e3ab93d0f9cf912ab5}{RS\+\_\+\+Collect\+\_\+\+Message}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}RS\+\_\+msg, uint8\+\_\+t \texorpdfstring{$\ast$}{*}msg\+\_\+uart\+\_\+buff) \begin{DoxyCompactList}\small\item\em Пользовательская функция для сбора сообщения в буфер UART. \end{DoxyCompactList}\item \+\_\+\+\_\+weak \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga727154b368397b4796aa892de12a2289}{RS\+\_\+\+Status\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_ga3500b3fa91d05a94cf8da5cc5ce338f5}{RS\+\_\+\+Parse\+\_\+\+Message}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}h\+RS, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}RS\+\_\+msg, uint8\+\_\+t \texorpdfstring{$\ast$}{*}msg\+\_\+uart\+\_\+buff) \begin{DoxyCompactList}\small\item\em Пользовательская функция для парса сообщения из буфера UART. \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsubsection*{Variables} \begin{DoxyCompactItemize} \item uint8\+\_\+t \mbox{\hyperlink{rs__message_8c_ac20049ae5804e70b5aadeed2819be007}{RS\+\_\+\+Buffer}} \mbox{[}\mbox{\hyperlink{group___m_o_d_b_u_s___m_e_s_s_a_g_e___d_e_f_i_n_e_s_ga7d1e9e8bb8f40ce788836da0739f897c}{MSG\+\_\+\+SIZE\+\_\+\+MAX}}\mbox{]} \end{DoxyCompactItemize} \doxysubsection{Detailed Description} Реализация протоколов обмена по RS/\+UART. Модуль реализует асинхронный обмен сообщениями через UART с использованием\+: \begin{DoxyItemize} \item Прерываний по приему/передаче \item Детектирования конца фрейма по IDLE линии \item Таймаутов через таймер \item Двухстадийного приема (заголовок + данные) \end{DoxyItemize}\hypertarget{rs__message_8c_arch}{}\doxysubsection{\texorpdfstring{Архитектура\+:}{Архитектура\+:}}\label{rs__message_8c_arch} В режиме слейв\+: \begin{DoxyItemize} \item Инициализация приема с сообщения с максимальным размером MSG\+\_\+\+SIZE\+\_\+\+MAX \item При срабатывании прерывания IDLE -\/ обработка полученного сообщения В режиме мастер (пока не реализовано)\+: \item Отправка запроса и переход в режим приема сообщения с максимальным размером MSG\+\_\+\+SIZE\+\_\+\+MAX \item При срабатывании прерывания IDLE -\/ обработка полученного ответа \end{DoxyItemize}\hypertarget{rs__message_8c_ithandler}{}\doxysubsection{\texorpdfstring{Необходимые обработчики\+:}{Необходимые обработчики\+:}}\label{rs__message_8c_ithandler} \begin{DoxyItemize} \item \doxylink{group___r_s___t_o_o_l_s_gab27567456df0329130c7fe4fc43c6ee1}{RS\+\_\+\+UART\+\_\+\+Handler()} в UARTx\+\_\+\+IRQHandler вместо HAL\+\_\+\+UART\+\_\+\+IRQHandler() \item \doxylink{group___r_s___t_o_o_l_s_ga2d356b2a0b4af43460bb2cacb81779ce}{RS\+\_\+\+TIM\+\_\+\+Handler()} в TIMx\+\_\+\+IRQHandler вместо HAL\+\_\+\+TIM\+\_\+\+IRQHandler() \end{DoxyItemize} Definition in file \mbox{\hyperlink{rs__message_8c_source}{rs\+\_\+message.\+c}}. \label{doc-var-members} \Hypertarget{rs__message_8c_doc-var-members} \doxysubsection{Variable Documentation} \Hypertarget{rs__message_8c_ac20049ae5804e70b5aadeed2819be007}\index{rs\_message.c@{rs\_message.c}!RS\_Buffer@{RS\_Buffer}} \index{RS\_Buffer@{RS\_Buffer}!rs\_message.c@{rs\_message.c}} \doxysubsubsection{\texorpdfstring{RS\_Buffer}{RS\_Buffer}} {\footnotesize\ttfamily \label{rs__message_8c_ac20049ae5804e70b5aadeed2819be007} uint8\+\_\+t RS\+\_\+\+Buffer\mbox{[}\mbox{\hyperlink{group___m_o_d_b_u_s___m_e_s_s_a_g_e___d_e_f_i_n_e_s_ga7d1e9e8bb8f40ce788836da0739f897c}{MSG\+\_\+\+SIZE\+\_\+\+MAX}}\mbox{]}} Definition at line \mbox{\hyperlink{rs__message_8c_source_l00028}{28}} of file \mbox{\hyperlink{rs__message_8c_source}{rs\+\_\+message.\+c}}.