\chapter{My\+Libs } \hypertarget{index}{}\label{index}\index{MyLibs@{MyLibs}} \hypertarget{index_overview}{}\doxysection{\texorpdfstring{Обзор}{Обзор}}\label{index_overview} My\+Libs -\/ это набор библиотек для удобной работы с периферией микроконтроллеров STM32.\hypertarget{index_features}{}\doxysubsection{\texorpdfstring{Основные возможности}{Основные возможности}}\label{index_features} \hypertarget{index_utils_module}{}\doxysubsubsection{\texorpdfstring{Общие утилиты \protect\doxylink{group___m_y_l_i_b_s___d_e_f_i_n_e_s}{General Defines}}{Общие утилиты {General Defines}}}\label{index_utils_module} \begin{DoxyItemize} \item Битовый доступ к регистрам через union \item Трекеры для статистики и отладки \item Макросы для задержек и утилит \item Поддержка Free\+RTOS \end{DoxyItemize}\hypertarget{index_trace_module}{}\doxysubsubsection{\texorpdfstring{Трассировка \protect\doxylink{group___t_r_a_c_e}{Trace defines}}{Трассировка {Trace defines}}}\label{index_trace_module} \begin{DoxyItemize} \item Serial трассировка через SWO и RTT \item GPIO трассировка для отладки \item Сохранение логов в Flash память \item Обработка Hard\+Fault с сохранением контекста \end{DoxyItemize}\hypertarget{index_gpio_module}{}\doxysubsubsection{\texorpdfstring{Модуль GPIO \protect\doxylink{group___m_y___l_i_b_s___g_p_i_o}{GPIO Tools}}{Модуль GPIO {GPIO Tools}}}\label{index_gpio_module} \begin{DoxyItemize} \item Управление светодиодами (включение/выключение, моргание, плавное затухание) \item Работа с кнопками (чтение состояния, фильтрация дребезга) \item Инициализация портов и тактирования \item Поддержка альтернативных функций \end{DoxyItemize}\hypertarget{index_tim_module}{}\doxysubsubsection{\texorpdfstring{Модуль таймеров \protect\doxylink{group___m_y___l_i_b_s___t_i_m}{TIM Tools}}{Модуль таймеров {TIM Tools}}}\label{index_tim_module} \begin{DoxyItemize} \item Базовая инициализация таймеров \item Режимы прерываний \item Формирование задержек (блокирующие и неблокирующие) \item Работа с энкодерами (чтение положения, обработка кнопок) \item Настройка ШИМ и Output Compare \end{DoxyItemize}\hypertarget{index_structure}{}\doxysubsection{\texorpdfstring{Структура проекта}{Структура проекта}}\label{index_structure} \begin{DoxyCode}{0} \DoxyCodeLine{├──\ inc/\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \#\ Заголовочные\ файлы} \DoxyCodeLine{│\ \ \ ├──\ mylibs\_include.h\ \ \ \ \ \#\ Главный\ include\ файл} \DoxyCodeLine{│\ \ \ ├──\ mylibs\_config.h\ \ \ \ \ \ \#\ Конфигурация\ библиотек} \DoxyCodeLine{│\ \ \ ├──\ mylibs\_defs.h\ \ \ \ \ \ \ \ \#\ Общие\ определения\ и\ макросы} \DoxyCodeLine{│\ \ \ ├──\ bit\_access.h\ \ \ \ \ \ \ \ \ \#\ Битовый\ доступ\ к\ регистрам} \DoxyCodeLine{│\ \ \ ├──\ trackers.h\ \ \ \ \ \ \ \ \ \ \ \#\ Трекеры\ для\ отладки} \DoxyCodeLine{│\ \ \ ├──\ trace.h\ \ \ \ \ \ \ \ \ \ \ \ \ \ \#\ Трассировка\ и\ логирование} \DoxyCodeLine{│\ \ \ ├──\ general\_gpio.h\ \ \ \ \ \ \ \#\ Работа\ с\ GPIO} \DoxyCodeLine{│\ \ \ └──\ general\_tim.h\ \ \ \ \ \ \ \ \#\ Работа\ с\ таймерами} \DoxyCodeLine{└──\ src/\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \#\ Исходные\ файлы} \DoxyCodeLine{\ \ \ \ ├──\ general\_gpio.c\ \ \ \ \ \ \ \#\ Реализация\ GPIO} \DoxyCodeLine{\ \ \ \ └──\ general\_tim.c\ \ \ \ \ \ \ \ \#\ Реализация\ TIM} \end{DoxyCode} \hypertarget{index_usage_basic}{}\doxysubsection{\texorpdfstring{Использование}{Использование}}\label{index_usage_basic} Инструкция по подключению\+: \begin{DoxyEnumerate} \item Настройте конфигурацию \doxylink{group___m_y_l_i_b_s___c_o_n_f_i_g}{Configs} в \doxylink{mylibs__config_8h}{mylibs\+\_\+config.\+h} \item Подключите главный заголовочный файл\+: \begin{DoxyCode}{0} \DoxyCodeLine{\textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{mylibs__include_8h}{mylibs\_include.h}}"{}}} \end{DoxyCode} \item Используйте нужные модули в своем коде \end{DoxyEnumerate}\hypertarget{index_gpio_example}{}\doxysubsubsection{\texorpdfstring{Пример работы с GPIO}{Пример работы с GPIO}}\label{index_gpio_example} \begin{DoxyCode}{0} \DoxyCodeLine{\textcolor{comment}{//\ Инициализация\ светодиода}} \DoxyCodeLine{MX\_GPIO\_Init();} \DoxyCodeLine{\mbox{\hyperlink{struct_g_p_i_o___l_e_d_type_def}{GPIO\_LEDTypeDef}}\ led;} \DoxyCodeLine{\mbox{\hyperlink{group___m_y_l_i_b_s___g_p_i_o___l_e_d_s_gac936453c7a0841c0b17bcfdae4958084}{GPIO\_LED\_Init}}(\&led,\ GPIOA,\ GPIO\_PIN\_5,\ 1);} \DoxyCodeLine{} \DoxyCodeLine{\textcolor{comment}{//\ Включение\ светодиода}} \DoxyCodeLine{\mbox{\hyperlink{group___m_y_l_i_b_s___g_p_i_o___l_e_d_s_ga4b9572949326b050694cd55d0a7e5f6c}{GPIO\_LED\_On}}(\&led);} \DoxyCodeLine{} \DoxyCodeLine{\textcolor{comment}{//\ Запуск\ моргания}} \DoxyCodeLine{\mbox{\hyperlink{group___m_y_l_i_b_s___g_p_i_o___l_e_d_s_gaf22f44ecaf6a1932b47edc5a845b03a9}{GPIO\_LED\_Blink\_Start}}(\&led,\ 500);\ \textcolor{comment}{//\ Период\ 500\ мс}} \DoxyCodeLine{} \DoxyCodeLine{\textcolor{comment}{//\ В\ основном\ цикле}} \DoxyCodeLine{\textcolor{keywordflow}{while}\ (1)\ \{} \DoxyCodeLine{\mbox{\hyperlink{group___m_y_l_i_b_s___g_p_i_o___l_e_d_s_gad6e6189824406c4d472b6340c7f19bb2}{GPIO\_LED\_Dynamic\_Handle}}(\&led);} \DoxyCodeLine{\}} \end{DoxyCode} \hypertarget{index_tim_example}{}\doxysubsubsection{\texorpdfstring{Пример работы с таймером}{Пример работы с таймером}}\label{index_tim_example} \begin{DoxyCode}{0} \DoxyCodeLine{\textcolor{comment}{//\ Настройка\ таймера}} \DoxyCodeLine{\mbox{\hyperlink{struct_t_i_m___settings_type_def}{TIM\_SettingsTypeDef}}\ tim\_settings\ =\ \{0\};} \DoxyCodeLine{tim\_settings.\mbox{\hyperlink{struct_t_i_m___settings_type_def_ada49efdbd35a8e442c3cff630d42f34c}{htim}}.Instance\ =\ TIM2;} \DoxyCodeLine{tim\_settings.\mbox{\hyperlink{struct_t_i_m___settings_type_def_a7073358fd3a722687eb85238ab570014}{sTimAHBFreqMHz}}\ =\ SystemCoreClock;} \DoxyCodeLine{tim\_settings.\mbox{\hyperlink{struct_t_i_m___settings_type_def_a58da1b4c0f6d12d7d9fb2f170b9b9e6e}{sTickBaseUS}}\ =\ \mbox{\hyperlink{group___m_y_l_i_b_s___t_i_m___g_e_n_e_r_a_l_ggaa0a51c870325217ac099881f09dd0800a6a66c5ed1d966c9e30f0219b664d2b25}{TIM\_TickBase\_1MS}};} \DoxyCodeLine{tim\_settings.\mbox{\hyperlink{struct_t_i_m___settings_type_def_af6057ff3f60f5e01b41d4a347b79a5e4}{sTimFreqHz}}\ =\ 1000;\ \textcolor{comment}{//\ 1\ кГц}} \DoxyCodeLine{tim\_settings.\mbox{\hyperlink{struct_t_i_m___settings_type_def_ab90e370c3edda88e76583293c250d2b0}{sTimMode}}\ =\ TIM\_IT\_CONF;} \DoxyCodeLine{} \DoxyCodeLine{\mbox{\hyperlink{group___m_y_l_i_b_s___t_i_m___g_e_n_e_r_a_l_ga7044214f24a9868ba7e1650b55e639ec}{TIM\_Base\_Init}}(\&tim\_settings);} \DoxyCodeLine{HAL\_TIM\_Base\_Start(\&tim\_settings.\mbox{\hyperlink{struct_t_i_m___settings_type_def_ada49efdbd35a8e442c3cff630d42f34c}{htim}});} \end{DoxyCode} \hypertarget{index_dependencies}{}\doxysubsection{\texorpdfstring{Зависимости}{Зависимости}}\label{index_dependencies} \begin{DoxyItemize} \item HAL библиотека STM32 \item SEGGER RTT (опционально, для RTT трассировки) \item Free\+RTOS (опционально, для Free\+RTOS задержек) \end{DoxyItemize}