\doxysubsubsection{SPI Tools }
\hypertarget{group___m_y___l_i_b_s___s_p_i}{}\label{group___m_y___l_i_b_s___s_p_i}\index{SPI Tools@{SPI Tools}}


Функции и макросы для удобной работы с SPI.  


Collaboration diagram for SPI Tools\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=334pt]{group___m_y___l_i_b_s___s_p_i}
\end{center}
\end{figure}
\doxysubsubsubsubsection*{Topics}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group___s_p_i___i_n_i_t}{Init defines}}
\begin{DoxyCompactList}\small\item\em Настройка SPI. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsubsubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \mbox{\hyperlink{struct_s_p_i___settings_type_def}{SPI\+\_\+\+Settings\+Type\+Def}}
\begin{DoxyCompactList}\small\item\em Структура настроек SPI. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
HAL\+\_\+\+Status\+Type\+Def \mbox{\hyperlink{group___m_y___l_i_b_s___s_p_i_ga0e177e3c57a8fcdc73b5602e72ec66ba}{SPI\+\_\+\+Base\+\_\+\+Init}} (\mbox{\hyperlink{struct_s_p_i___settings_type_def}{SPI\+\_\+\+Settings\+Type\+Def}} \texorpdfstring{$\ast$}{*}sspi)
\begin{DoxyCompactList}\small\item\em Инициализация SPI с помощью структуры \doxylink{struct_s_p_i___settings_type_def}{SPI\+\_\+\+Settings\+Type\+Def}. \end{DoxyCompactList}\item 
HAL\+\_\+\+Status\+Type\+Def \mbox{\hyperlink{group___m_y___l_i_b_s___s_p_i_ga333dd251bc878931086d48aa932b1a5f}{SPI\+\_\+\+Check\+\_\+\+Init\+\_\+\+Struct}} (\mbox{\hyperlink{struct_s_p_i___settings_type_def}{SPI\+\_\+\+Settings\+Type\+Def}} \texorpdfstring{$\ast$}{*}sspi)
\begin{DoxyCompactList}\small\item\em Проверка корректности структуры инициализации SPI. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group___m_y___l_i_b_s___s_p_i_gab9f13318daf02bc5b5f302ae392dccac}{SPI\+\_\+\+Msp\+Init}} (SPI\+\_\+\+Handle\+Type\+Def \texorpdfstring{$\ast$}{*}hspi)
\begin{DoxyCompactList}\small\item\em Настройка тактирования и прерываний SPI. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group___m_y___l_i_b_s___s_p_i_gac279cc3eaa35541edfe330a1844a85e4}{SPI\+\_\+\+Msp\+De\+Init}} (SPI\+\_\+\+Handle\+Type\+Def \texorpdfstring{$\ast$}{*}hspi)
\begin{DoxyCompactList}\small\item\em Деинициализация тактирования и прерываний SPI. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsubsubsection{Detailed Description}
Функции и макросы для удобной работы с SPI. 

Модуль предоставляет функции для базовой инициализации SPI

\begin{DoxyParagraph}{Пример использования\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{comment}{//\ Структура\ настроек\ SPI}}
\DoxyCodeLine{\mbox{\hyperlink{struct_s_p_i___settings_type_def}{SPI\_SettingsTypeDef}}\ spi1Settings;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{void}\ SPI1\_Init(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Настройка\ SPI1\ как\ Master,\ 8\ бит,\ полный\ дуплекс}}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_ad203d8b8d67e4f477d002d15b03ba422}{hspi}}.Instance\ =\ SPI1;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_ad203d8b8d67e4f477d002d15b03ba422}{hspi}}.Init.Mode\ =\ SPI\_MODE\_MASTER;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_ad203d8b8d67e4f477d002d15b03ba422}{hspi}}.Init.Direction\ =\ SPI\_DIRECTION\_2LINES;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_ad203d8b8d67e4f477d002d15b03ba422}{hspi}}.Init.DataSize\ =\ SPI\_DATASIZE\_8BIT;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_ad203d8b8d67e4f477d002d15b03ba422}{hspi}}.Init.CLKPolarity\ =\ SPI\_POLARITY\_LOW;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_ad203d8b8d67e4f477d002d15b03ba422}{hspi}}.Init.CLKPhase\ =\ SPI\_PHASE\_1EDGE;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_ad203d8b8d67e4f477d002d15b03ba422}{hspi}}.Init.NSS\ =\ SPI\_NSS\_SOFT;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_ad203d8b8d67e4f477d002d15b03ba422}{hspi}}.Init.BaudRatePrescaler\ =\ SPI\_BAUDRATEPRESCALER\_16;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_ad203d8b8d67e4f477d002d15b03ba422}{hspi}}.Init.FirstBit\ =\ SPI\_FIRSTBIT\_MSB;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_ad203d8b8d67e4f477d002d15b03ba422}{hspi}}.Init.TIMode\ =\ SPI\_TIMODE\_DISABLE;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_ad203d8b8d67e4f477d002d15b03ba422}{hspi}}.Init.CRCCalculation\ =\ SPI\_CRCCALCULATION\_DISABLE;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Настройка\ GPIO}}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_a6a15d48eccf92959de3a086031fdc979}{CLK\_GPIOx}}\ =\ GPIOA;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_a3bcb1ed12da3544e02e6d36493669bdc}{CLK\_PIN}}\ =\ GPIO\_PIN\_5;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_a3f3748103a0b7861f6700042fd691ba1}{CLK\_GPIO\_AlternageFunc}}\ =\ GPIO\_AF5\_SPI1;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_a0d55a2941854f61934487f3d209cfa95}{MISO\_GPIOx}}\ =\ GPIOA;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_a3366c654d7ec6dd41c6a0b504dc8509a}{MISO\_PIN}}\ =\ GPIO\_PIN\_6;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_aecd7a5c6e205335b8ed229d74cd35d14}{MISO\_GPIO\_AlternageFunc}}\ =\ GPIO\_AF5\_SPI1;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_a0af3bdb273818ff97eb4ff3cff918820}{MOSI\_GPIOx}}\ =\ GPIOA;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_a961208869faf4a7369aaf4edde75f176}{MOSI\_PIN}}\ =\ GPIO\_PIN\_7;}
\DoxyCodeLine{\ \ \ \ spi1Settings.\mbox{\hyperlink{struct_s_p_i___settings_type_def_afbe75a1c36650a4a9b41fa706a4c7eab}{MOSI\_GPIO\_AlternageFunc}}\ =\ GPIO\_AF5\_SPI1;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ Инициализация\ SPI}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}(\mbox{\hyperlink{group___m_y___l_i_b_s___s_p_i_ga0e177e3c57a8fcdc73b5602e72ec66ba}{SPI\_Base\_Init}}(\&spi1Settings)\ !=\ HAL\_OK)}
\DoxyCodeLine{\ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{comment}{//\ Обработка\ ошибки}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ Error\_Handler();}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\}}

\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyNote}{Note}
Требуется подключение модуля SPI в библиотеке HAL 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ HAL\_SPI\_MODULE\_ENABLED}}

\end{DoxyCode}
 
\end{DoxyNote}


\label{doc-func-members}
\Hypertarget{group___m_y___l_i_b_s___s_p_i_doc-func-members}
\doxysubsubsubsection{Function Documentation}
\Hypertarget{group___m_y___l_i_b_s___s_p_i_ga0e177e3c57a8fcdc73b5602e72ec66ba}\index{SPI Tools@{SPI Tools}!SPI\_Base\_Init@{SPI\_Base\_Init}}
\index{SPI\_Base\_Init@{SPI\_Base\_Init}!SPI Tools@{SPI Tools}}
\doxysubsubsubsubsection{\texorpdfstring{SPI\_Base\_Init()}{SPI\_Base\_Init()}}
{\footnotesize\ttfamily \label{group___m_y___l_i_b_s___s_p_i_ga0e177e3c57a8fcdc73b5602e72ec66ba} 
HAL\+\_\+\+Status\+Type\+Def SPI\+\_\+\+Base\+\_\+\+Init (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_s_p_i___settings_type_def}{SPI\+\_\+\+Settings\+Type\+Def}} \texorpdfstring{$\ast$}{*}}]{sspi}{}\end{DoxyParamCaption})}



Инициализация SPI с помощью структуры \doxylink{struct_s_p_i___settings_type_def}{SPI\+\_\+\+Settings\+Type\+Def}. 


\begin{DoxyParams}{Parameters}
{\em sspi} & Указатель на структуру с настройками SPI. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
HAL status.
\end{DoxyReturn}
~\newline
 Инициализирует SPI и его GPIO. Настройка аналогична HAL\+\_\+\+SPI\+\_\+\+Init 
\begin{DoxyCode}{0}
\DoxyCodeLine{suart.hspi.Init...}

\end{DoxyCode}
 но дополнительно надо прописать пины CLK/\+MISO/\+MOSI \doxylink{struct_s_p_i___settings_type_def}{SPI\+\_\+\+Settings\+Type\+Def} 

Definition at line \mbox{\hyperlink{general__spi_8c_source_l00028}{28}} of file \mbox{\hyperlink{general__spi_8c_source}{general\+\_\+spi.\+c}}.

\Hypertarget{group___m_y___l_i_b_s___s_p_i_ga333dd251bc878931086d48aa932b1a5f}\index{SPI Tools@{SPI Tools}!SPI\_Check\_Init\_Struct@{SPI\_Check\_Init\_Struct}}
\index{SPI\_Check\_Init\_Struct@{SPI\_Check\_Init\_Struct}!SPI Tools@{SPI Tools}}
\doxysubsubsubsubsection{\texorpdfstring{SPI\_Check\_Init\_Struct()}{SPI\_Check\_Init\_Struct()}}
{\footnotesize\ttfamily \label{group___m_y___l_i_b_s___s_p_i_ga333dd251bc878931086d48aa932b1a5f} 
HAL\+\_\+\+Status\+Type\+Def SPI\+\_\+\+Check\+\_\+\+Init\+\_\+\+Struct (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_s_p_i___settings_type_def}{SPI\+\_\+\+Settings\+Type\+Def}} \texorpdfstring{$\ast$}{*}}]{sspi}{}\end{DoxyParamCaption})}



Проверка корректности структуры инициализации SPI. 


\begin{DoxyParams}{Parameters}
{\em sspi} & Указатель на структуру с настройками SPI. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
HAL status. 
\end{DoxyReturn}


Definition at line \mbox{\hyperlink{general__spi_8c_source_l00246}{246}} of file \mbox{\hyperlink{general__spi_8c_source}{general\+\_\+spi.\+c}}.

\Hypertarget{group___m_y___l_i_b_s___s_p_i_gab9f13318daf02bc5b5f302ae392dccac}\index{SPI Tools@{SPI Tools}!SPI\_MspInit@{SPI\_MspInit}}
\index{SPI\_MspInit@{SPI\_MspInit}!SPI Tools@{SPI Tools}}
\doxysubsubsubsubsection{\texorpdfstring{SPI\_MspInit()}{SPI\_MspInit()}}
{\footnotesize\ttfamily \label{group___m_y___l_i_b_s___s_p_i_gab9f13318daf02bc5b5f302ae392dccac} 
void SPI\+\_\+\+Msp\+Init (\begin{DoxyParamCaption}\item[{SPI\+\_\+\+Handle\+Type\+Def \texorpdfstring{$\ast$}{*}}]{hspi}{}\end{DoxyParamCaption})}



Настройка тактирования и прерываний SPI. 


\begin{DoxyParams}{Parameters}
{\em hspi} & Указатель на хендл SPI. \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
Чтобы не генерировать функцию с иницилизацией неиспользуемых SPI, дефайнами \doxylink{group___s_p_i___i_n_i_t}{Init defines} в \doxylink{general__spi_8h}{general\+\_\+spi.\+h} определяются используемые SPI. 
\end{DoxyNote}


Definition at line \mbox{\hyperlink{general__spi_8c_source_l00127}{127}} of file \mbox{\hyperlink{general__spi_8c_source}{general\+\_\+spi.\+c}}.

\Hypertarget{group___m_y___l_i_b_s___s_p_i_gac279cc3eaa35541edfe330a1844a85e4}\index{SPI Tools@{SPI Tools}!SPI\_MspDeInit@{SPI\_MspDeInit}}
\index{SPI\_MspDeInit@{SPI\_MspDeInit}!SPI Tools@{SPI Tools}}
\doxysubsubsubsubsection{\texorpdfstring{SPI\_MspDeInit()}{SPI\_MspDeInit()}}
{\footnotesize\ttfamily \label{group___m_y___l_i_b_s___s_p_i_gac279cc3eaa35541edfe330a1844a85e4} 
void SPI\+\_\+\+Msp\+De\+Init (\begin{DoxyParamCaption}\item[{SPI\+\_\+\+Handle\+Type\+Def \texorpdfstring{$\ast$}{*}}]{hspi}{}\end{DoxyParamCaption})}



Деинициализация тактирования и прерываний SPI. 


\begin{DoxyParams}{Parameters}
{\em hspi} & Указатель на хендл SPI. \\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
Чтобы не генерировать функцию с иницилизацией неиспользуемых SPI, дефайнами \doxylink{group___s_p_i___i_n_i_t}{Init defines} в \doxylink{general__spi_8h}{general\+\_\+spi.\+h} определяются используемые SPI. 
\end{DoxyNote}


Definition at line \mbox{\hyperlink{general__spi_8c_source_l00191}{191}} of file \mbox{\hyperlink{general__spi_8c_source}{general\+\_\+spi.\+c}}.

\input{group___s_p_i___i_n_i_t}
