\doxysection{E\+:/.WORK/\+STM32/\+Diod\+\_\+\+Test/diode\+\_\+tester/\+Core/\+Modbus/\+Src/modbus.c File Reference}
\hypertarget{modbus_8c}{}\label{modbus_8c}\index{E:/.WORK/STM32/Diod\_Test/diode\_tester/Core/Modbus/Src/modbus.c@{E:/.WORK/STM32/Diod\_Test/diode\_tester/Core/Modbus/Src/modbus.c}}


Модуль для реализации MODBUS.  


{\ttfamily \#include "{}modbus.\+h"{}}\newline
Include dependency graph for modbus.\+c\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{modbus_8c__incl}
\end{center}
\end{figure}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static void \mbox{\hyperlink{modbus_8c_ae7c4bdaeae2e9deb8422ae0a0fc64cb4}{MB\+\_\+\+Default\+Callback}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}hmodbus, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}modbus\+\_\+msg)
\begin{DoxyCompactList}\small\item\em Coils \& Registers. \end{DoxyCompactList}\item 
HAL\+\_\+\+Status\+Type\+Def \mbox{\hyperlink{group___m_o_d_b_u_s___f_u_n_c_t_i_o_n_s_ga9e787c3454aab3293dec6e6795f687f5}{MODBUS\+\_\+\+First\+Init}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}hmodbus, UART\+\_\+\+Handle\+Type\+Def \texorpdfstring{$\ast$}{*}huart, TIM\+\_\+\+Handle\+Type\+Def \texorpdfstring{$\ast$}{*}htim)
\begin{DoxyCompactList}\small\item\em Инициализация периферии модбас. \end{DoxyCompactList}\item 
HAL\+\_\+\+Status\+Type\+Def \mbox{\hyperlink{group___m_o_d_b_u_s___f_u_n_c_t_i_o_n_s_ga460466907693a256487d31f09b16edfe}{MODBUS\+\_\+\+Config}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}hmodbus, uint8\+\_\+t ID, uint16\+\_\+t Timeout, uint8\+\_\+t master)
\begin{DoxyCompactList}\small\item\em Программная конфигурация модбас. \end{DoxyCompactList}\item 
HAL\+\_\+\+Status\+Type\+Def \mbox{\hyperlink{group___m_o_d_b_u_s___f_u_n_c_t_i_o_n_s_ga9a17402983188566254b7096342ba69e}{MODBUS\+\_\+\+Slave\+Start}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}hmodbus, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}modbus\+\_\+msg)
\begin{DoxyCompactList}\small\item\em Запуск слейв модбас. \end{DoxyCompactList}\item 
HAL\+\_\+\+Status\+Type\+Def \mbox{\hyperlink{group___m_o_d_b_u_s___f_u_n_c_t_i_o_n_s_ga19090cabfba2345391e37398125a2f55}{MODBUS\+\_\+\+Master\+Request}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}hmodbus, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}modbus\+\_\+msg, void(\texorpdfstring{$\ast$}{*}p\+Clbk)(\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}))
\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_ga8b7bcc84cb8192a58fe87b662fbd9690}{RS\+\_\+\+Response}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}hmodbus, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}modbus\+\_\+msg)
\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_ga1cd98c55f6f359e3ab93d0f9cf912ab5}{RS\+\_\+\+Collect\+\_\+\+Message}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}hmodbus, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}modbus\+\_\+msg, uint8\+\_\+t \texorpdfstring{$\ast$}{*}modbus\+\_\+uart\+\_\+buff)
\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_ga3500b3fa91d05a94cf8da5cc5ce338f5}{RS\+\_\+\+Parse\+\_\+\+Message}} (\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}hmodbus, \mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}modbus\+\_\+msg, uint8\+\_\+t \texorpdfstring{$\ast$}{*}modbus\+\_\+uart\+\_\+buff)
\end{DoxyCompactItemize}
\doxysubsubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \mbox{\hyperlink{group___r_s___t_o_o_l_s_gadaef5cb7e494d0fd139199f5b6cbeb86}{hmodbus1}}
\begin{DoxyCompactList}\small\item\em Default Handle for Modbus. \end{DoxyCompactList}\item 
\mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \mbox{\hyperlink{group___m_o_d_b_u_s___m_e_s_s_a_g_e___d_e_f_i_n_e_s_ga679c526f339999281b97010876e7a295}{MODBUS\+\_\+\+MSG}}
\begin{DoxyCompactList}\small\item\em Default Message Struct for Modbus. \end{DoxyCompactList}\item 
\mbox{\hyperlink{struct_m_b___data_structure_type_def}{MB\+\_\+\+Data\+Structure\+Type\+Def}} \mbox{\hyperlink{modbus_8c_a4eb1dbed7cecbafeb1980809fbda7de7}{MB\+\_\+\+DATA}} = \{0\}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Модуль для реализации MODBUS. 

Файл содержит реализацию функций работы с Modbus.\hypertarget{modbus_8c_mbapi}{}\doxysubsection{\texorpdfstring{Функции и макросы}{Функции и макросы}}\label{modbus_8c_mbapi}
\hypertarget{modbus_8c_инициализация}{}\doxysubsubsubsection{\texorpdfstring{Инициализация\+:}{Инициализация\+:}}\label{modbus_8c_инициализация}

\begin{DoxyItemize}
\item \doxylink{group___m_o_d_b_u_s___f_u_n_c_t_i_o_n_s_ga9e787c3454aab3293dec6e6795f687f5}{MODBUS\+\_\+\+First\+Init()} — Инициализация Modbus (подключение UART, TIM)
\item \doxylink{group___m_o_d_b_u_s___f_u_n_c_t_i_o_n_s_ga460466907693a256487d31f09b16edfe}{MODBUS\+\_\+\+Config()} — Конфигурацмя Modbus (ID, Timeout).
\item \doxylink{group___m_o_d_b_u_s___f_u_n_c_t_i_o_n_s_ga9a17402983188566254b7096342ba69e}{MODBUS\+\_\+\+Slave\+Start()} — Запуск Modbus как Slave.
\item \doxylink{group___m_o_d_b_u_s___f_u_n_c_t_i_o_n_s_ga19090cabfba2345391e37398125a2f55}{MODBUS\+\_\+\+Master\+Request()} — Отправить запрос в MODBUS как Master.
\end{DoxyItemize}\hypertarget{modbus_8c_функции-для-работы-с-rs-uart}{}\doxysubsubsubsection{\texorpdfstring{Функции для работы с RS (UART)\+:}{Функции для работы с RS (UART)\+:}}\label{modbus_8c_функции-для-работы-с-rs-uart}

\begin{DoxyItemize}
\item RS\+\_\+\+Parse\+\_\+\+Message() / RS\+\_\+\+Collect\+\_\+\+Message() — Парсинг и сборка сообщения.
\item RS\+\_\+\+Response() — Отправка ответа. 
\end{DoxyItemize}

Definition in file \mbox{\hyperlink{modbus_8c_source}{modbus.\+c}}.



\label{doc-func-members}
\Hypertarget{modbus_8c_doc-func-members}
\doxysubsection{Function Documentation}
\Hypertarget{modbus_8c_ae7c4bdaeae2e9deb8422ae0a0fc64cb4}\index{modbus.c@{modbus.c}!MB\_DefaultCallback@{MB\_DefaultCallback}}
\index{MB\_DefaultCallback@{MB\_DefaultCallback}!modbus.c@{modbus.c}}
\doxysubsubsection{\texorpdfstring{MB\_DefaultCallback()}{MB\_DefaultCallback()}}
{\footnotesize\ttfamily \label{modbus_8c_ae7c4bdaeae2e9deb8422ae0a0fc64cb4} 
void MB\+\_\+\+Default\+Callback (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_r_s___handle_type_def}{RS\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}}]{hmodbus}{, }\item[{\mbox{\hyperlink{struct_r_s___msg_type_def}{RS\+\_\+\+Msg\+Type\+Def}} \texorpdfstring{$\ast$}{*}}]{modbus\+\_\+msg}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Coils \& Registers. 

Дефолтный коллбек для мастера.


\begin{DoxyParams}{Parameters}
{\em hmodbus} & Указатель на хендлер RS \\
\hline
{\em modbus\+\_\+msg} & Указатель на структуру сообщения\\
\hline
\end{DoxyParams}
В этот коллбек попадут все запросы, с NULL-\/коллбеком 

Definition at line \mbox{\hyperlink{modbus_8c_source_l00176}{176}} of file \mbox{\hyperlink{modbus_8c_source}{modbus.\+c}}.



\label{doc-var-members}
\Hypertarget{modbus_8c_doc-var-members}
\doxysubsection{Variable Documentation}
\Hypertarget{modbus_8c_a4eb1dbed7cecbafeb1980809fbda7de7}\index{modbus.c@{modbus.c}!MB\_DATA@{MB\_DATA}}
\index{MB\_DATA@{MB\_DATA}!modbus.c@{modbus.c}}
\doxysubsubsection{\texorpdfstring{MB\_DATA}{MB\_DATA}}
{\footnotesize\ttfamily \label{modbus_8c_a4eb1dbed7cecbafeb1980809fbda7de7} 
\mbox{\hyperlink{struct_m_b___data_structure_type_def}{MB\+\_\+\+Data\+Structure\+Type\+Def}} MB\+\_\+\+DATA = \{0\}}



Definition at line \mbox{\hyperlink{modbus_8c_source_l00028}{28}} of file \mbox{\hyperlink{modbus_8c_source}{modbus.\+c}}.

