\doxysection{bench\+\_\+time.\+h} \hypertarget{bench__time_8h_source}{}\label{bench__time_8h_source}\index{E:/.WORK/STM32/STM\_Libs/STM32\_ExtendedLibs/MyLibs/Inc/bench\_time.h@{E:/.WORK/STM32/STM\_Libs/STM32\_ExtendedLibs/MyLibs/Inc/bench\_time.h}} \mbox{\hyperlink{bench__time_8h}{Go to the documentation of this file.}} \begin{DoxyCode}{0} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00001}00001\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00002}00002\ \textcolor{comment}{******************************************************************************}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00003}00003\ \textcolor{comment}{*\ @file\ bench\_time.h}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00004}00004\ \textcolor{comment}{*\ @brief\ Заголовочный\ файл\ для\ измерения\ времени\ между\ событиями}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00005}00005\ \textcolor{comment}{******************************************************************************}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00006}00006\ \textcolor{comment}{*\ @addtogroup\ BENCH\_TIME\ \ \ \ Time\ measurement}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00007}00007\ \textcolor{comment}{*\ @brief\ \ \ \ \ \ Библиотека\ для\ измерения\ времени/тиков\ между\ событиями}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00008}00008\ \textcolor{comment}{*\ @details}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00009}00009\ \textcolor{comment}{Поддерживает:}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00010}00010\ \textcolor{comment}{-\/\ Многоканальные\ измерения\ (несколько\ независимых\ таймеров)}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00011}00011\ \textcolor{comment}{-\/\ Платформонезависимый\ интерфейс}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00012}00012\ \textcolor{comment}{-\/\ Измерение\ в\ тиках\ или\ временных\ единицах}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00013}00013\ \textcolor{comment}{-\/\ Статистику\ измерений\ (мин/макс/среднее)}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00014}00014\ \textcolor{comment}{-\/\ Настраиваемый\ размер\ тиков\ для\ каждого\ канала}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00015}00015\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00016}00016\ \textcolor{comment}{Параметры\ для\ конфигурации:}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00017}00017\ \textcolor{comment}{-\/\ @ref\ BENCH\_TIME\_ENABLE\ -\/\ Включить\ бенч\ времени}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00018}00018\ \textcolor{comment}{-\/\ @ref\ BENCH\_TIME\_MAX\_CHANNELS\ -\/\ Максимальное\ количество\ каналов\ измерения\ (по\ умолчанию\ 8)}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00019}00019\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00020}00020\ \textcolor{comment}{@par\ Пример\ использования:}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00021}00021\ \textcolor{comment}{@code}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00022}00022\ \textcolor{comment}{\#include\ "{}bench\_time.h"{}}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00023}00023\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00024}00024\ \textcolor{comment}{//\ Инициализация}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00025}00025\ \textcolor{comment}{BenchTime\_Init();}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00026}00026\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00027}00027\ \textcolor{comment}{//\ Измерение\ с\ SysTick}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00028}00028\ \textcolor{comment}{BenchTime\_Start(0,\ HAL\_GetTick,\ 0xFFFFFFFF);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00029}00029\ \textcolor{comment}{some\_function();}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00030}00030\ \textcolor{comment}{uint32\_t\ time\ =\ BenchTime\_End(0,\ HAL\_GetTick);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00031}00031\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00032}00032\ \textcolor{comment}{//\ Измерение\ с\ TIM2\ (16-\/бит)}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00033}00033\ \textcolor{comment}{BenchTime\_Start(1,\ TIM2-\/>CNT,\ 0xFFFF);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00034}00034\ \textcolor{comment}{fast\_function();\ }} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00035}00035\ \textcolor{comment}{uint32\_t\ time2\ =\ BenchTime\_End(1,\ TIM2-\/>CNT);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00036}00036\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00037}00037\ \textcolor{comment}{//\ Измерение\ с\ DWT\ цикловым\ счетчиком}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00038}00038\ \textcolor{comment}{BenchTime\_Start(2,\ DWT-\/>CYCCNT,\ 0xFFFFFFFF);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00039}00039\ \textcolor{comment}{critical\_function();}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00040}00040\ \textcolor{comment}{uint32\_t\ cycles\ =\ BenchTime\_End(2,\ DWT-\/>CYCCNT);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00041}00041\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00042}00042\ \textcolor{comment}{//\ Многоканальное\ измерение}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00043}00043\ \textcolor{comment}{BenchTime\_Start(0,\ HAL\_GetTick,\ 1000);\ \ \ \ \ \ \ \ //\ общее\ время}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00044}00044\ \textcolor{comment}{BenchTime\_Start(1,\ TIM3-\/>CNT,\ 500);\ \ \ \ \ \ \ \ \ \ \ //\ часть\ 1}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00045}00045\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00046}00046\ \textcolor{comment}{//\ ...\ код\ 1}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00047}00047\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00048}00048\ \textcolor{comment}{uint32\_t\ part1\ =\ BenchTime\_End(1,\ TIM3-\/>CNT);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00049}00049\ \textcolor{comment}{BenchTime\_Start(2,\ TIM4-\/>CNT,\ 200);\ \ \ \ \ \ \ \ \ \ \ //\ часть\ 2\ \ }} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00050}00050\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00051}00051\ \textcolor{comment}{//\ ...\ код\ 2}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00052}00052\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00053}00053\ \textcolor{comment}{uint32\_t\ part2\ =\ BenchTime\_End(2,\ TIM4-\/>CNT);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00054}00054\ \textcolor{comment}{uint32\_t\ total\ =\ BenchTime\_End(0,\ HAL\_GetTick);\ //\ общее\ время}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00055}00055\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00056}00056\ \textcolor{comment}{//\ Статистика}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00057}00057\ \textcolor{comment}{uint32\_t\ min\_time\ =\ BenchTime\_GetMin(0);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00058}00058\ \textcolor{comment}{uint32\_t\ max\_time\ =\ BenchTime\_GetMax(0);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00059}00059\ \textcolor{comment}{uint32\_t\ avg\_time\ =\ BenchTime\_GetAverage(0);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00060}00060\ \textcolor{comment}{uint32\_t\ count\ =\ BenchTime\_GetCount(0);}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00061}00061\ \textcolor{comment}{@endcode}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00062}00062\ \textcolor{comment}{*\ @\{\ \ }} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00063}00063\ \textcolor{comment}{*****************************************************************************/}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00064}00064\ \textcolor{preprocessor}{\#ifndef\ \_\_BENCH\_TIME\_H\_}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00065}00065\ \textcolor{preprocessor}{\#define\ \_\_BENCH\_TIME\_H\_}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00066}00066\ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00067}00067\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{mylibs__defs_8h}{mylibs\_defs.h}}"{}}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00068}00068\ \textcolor{preprocessor}{\#include\ }} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00069}00069\ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00070}00070\ \textcolor{preprocessor}{\#ifdef\ BENCH\_TIME\_ENABLE}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00071}00071\ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00072}00072\ \textcolor{comment}{//\ Конфигурация\ библиотеки}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00073}00073\ \textcolor{preprocessor}{\#ifndef\ BENCH\_TIME\_MAX\_CHANNELS}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00074}00074\ \textcolor{preprocessor}{\#define\ BENCH\_TIME\_MAX\_CHANNELS\ \ 8\ \ \ \ }\textcolor{comment}{///<\ Максимальное\ количество\ каналов\ измерения}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00075}00075\ \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00076}00076\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00077}00077\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00078}00078\ \textcolor{comment}{\ \ *\ @brief\ Структура\ статистики\ измерений}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00079}00079\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00080}00080\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00081}00081\ \ \ uint32\_t\ min\_ticks;\ \ \ \ \ \ \textcolor{comment}{///<\ Минимальное\ время\ в\ тиках}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00082}00082\ \ \ uint32\_t\ max\_ticks;\ \ \ \ \ \ \textcolor{comment}{///<\ Максимальное\ время\ в\ тиках\ \ }} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00083}00083\ \ \ uint32\_t\ total\_ticks;\ \ \ \ \textcolor{comment}{///<\ Суммарное\ время\ в\ тиках}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00084}00084\ \ \ uint32\_t\ count;\ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Количество\ измерений}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00085}00085\ \ \ uint32\_t\ last\_ticks;\ \ \ \ \ \textcolor{comment}{///<\ Последнее\ измеренное\ время}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00086}00086\ \}\ BenchTimeStats\_t;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00087}00087\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00088}00088\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00089}00089\ \textcolor{comment}{\ \ *\ @brief\ Структура\ канала\ измерения}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00090}00090\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00091}00091\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00092}00092\ \ \ uint32\_t\ start\_tick;\ \ \ \ \ \textcolor{comment}{///<\ Время\ старта\ в\ тиках}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00093}00093\ \ \ uint32\_t\ tick\_period;\ \ \ \ \textcolor{comment}{///<\ Период\ тиков\ для\ переполнения}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00094}00094\ \ \ uint32\_t\ is\_running;\ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Флаг\ активного\ измерения}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00095}00095\ \ \ BenchTimeStats\_t\ stats;\ \ \textcolor{comment}{///<\ Статистика\ измерений}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00096}00096\ \}\ BenchTimeChannel\_t;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00097}00097\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00098}00098\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00099}00099\ \textcolor{comment}{\ \ *\ @brief\ Основная\ структура\ менеджера\ измерений}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00100}00100\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00101}00101\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00102}00102\ \ \ BenchTimeChannel\_t\ channels[\mbox{\hyperlink{group___g_e_n___c_o_n_f_i_g_ga74fdf777ceefa5e7d67120fbda4cde52}{BENCH\_TIME\_MAX\_CHANNELS}}];\ \textcolor{comment}{///<\ Каналы\ измерения}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00103}00103\ \}\ BenchTime\_t;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00104}00104\ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00105}00105\ \textcolor{keyword}{static}\ BenchTime\_t\ hbt\ =\ \{0\};\ \textcolor{comment}{///<\ Внутренний\ экземпляр}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00106}00106\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00107}00107\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00108}00108\ \textcolor{comment}{\ \ *\ @brief\ Инициализация\ системы\ измерения\ времени}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00109}00109\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00110}00110\ \textcolor{keyword}{static}\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ BenchTime\_Init(\textcolor{keywordtype}{void})\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00111}00111\ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ \mbox{\hyperlink{group___g_e_n___c_o_n_f_i_g_ga74fdf777ceefa5e7d67120fbda4cde52}{BENCH\_TIME\_MAX\_CHANNELS}};\ i++)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00112}00112\ \ \ \ \ hbt.channels[i].start\_tick\ =\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00113}00113\ \ \ \ \ hbt.channels[i].tick\_period\ =\ 0xFFFFFFFF;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00114}00114\ \ \ \ \ hbt.channels[i].is\_running\ =\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00115}00115\ \ \ \ \ hbt.channels[i].stats.min\_ticks\ =\ 0xFFFFFFFF;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00116}00116\ \ \ \ \ hbt.channels[i].stats.max\_ticks\ =\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00117}00117\ \ \ \ \ hbt.channels[i].stats.total\_ticks\ =\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00118}00118\ \ \ \ \ hbt.channels[i].stats.count\ =\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00119}00119\ \ \ \ \ hbt.channels[i].stats.last\_ticks\ =\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00120}00120\ \ \ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00121}00121\ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00122}00122\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00123}00123\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00124}00124\ \textcolor{comment}{\ \ *\ @brief\ Начало\ измерения\ на\ указанном\ канале}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00125}00125\ \textcolor{comment}{\ \ *\ @param\ channel\ Номер\ канала\ (0..BENCH\_TIME\_MAX\_CHANNELS-\/1)}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00126}00126\ \textcolor{comment}{\ \ *\ @param\ ticks\ Источник\ тиков\ (например:\ HAL\_GetTick(),\ TIM2-\/>CNT,\ DWT-\/>CYCCNT)}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00127}00127\ \textcolor{comment}{\ \ *\ @param\ tick\_period\ Период\ тиков\ для\ переполнения}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00128}00128\ \textcolor{comment}{\ \ *\ @return\ 1\ -\/\ успех,\ 0\ -\/\ ошибка}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00129}00129\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00130}00130\ \textcolor{keyword}{static}\ \textcolor{keyword}{inline}\ uint32\_t\ BenchTime\_Start(uint8\_t\ channel,\ uint32\_t\ ticks,\ uint32\_t\ tick\_period)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00131}00131\ \ \ \textcolor{keywordflow}{if}\ (channel\ >=\ \mbox{\hyperlink{group___g_e_n___c_o_n_f_i_g_ga74fdf777ceefa5e7d67120fbda4cde52}{BENCH\_TIME\_MAX\_CHANNELS}})\ \textcolor{keywordflow}{return}\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00132}00132\ \ \ \textcolor{keywordflow}{if}\ (hbt.channels[channel].is\_running)\ \textcolor{keywordflow}{return}\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00133}00133\ \ \ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00134}00134\ \ \ hbt.channels[channel].start\_tick\ =\ ticks;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00135}00135\ \ \ hbt.channels[channel].tick\_period\ =\ tick\_period;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00136}00136\ \ \ hbt.channels[channel].is\_running\ =\ 1;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00137}00137\ \ \ \textcolor{keywordflow}{return}\ 1;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00138}00138\ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00139}00139\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00140}00140\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00141}00141\ \textcolor{comment}{\ \ *\ @brief\ Окончание\ измерения\ на\ указанном\ канале}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00142}00142\ \textcolor{comment}{\ \ *\ @param\ channel\ Номер\ канала\ (0..BENCH\_TIME\_MAX\_CHANNELS-\/1)}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00143}00143\ \textcolor{comment}{\ \ *\ @param\ ticks\ Источник\ тиков\ (должен\ быть\ тот\ же\ что\ в\ Start)}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00144}00144\ \textcolor{comment}{\ \ *\ @return\ Измеренное\ время\ в\ тиках,\ 0\ -\/\ в\ случае\ ошибки}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00145}00145\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00146}00146\ \textcolor{keyword}{static}\ \textcolor{keyword}{inline}\ uint32\_t\ BenchTime\_End(uint8\_t\ channel,\ uint32\_t\ ticks)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00147}00147\ \ \ \textcolor{keywordflow}{if}\ (channel\ >=\ \mbox{\hyperlink{group___g_e_n___c_o_n_f_i_g_ga74fdf777ceefa5e7d67120fbda4cde52}{BENCH\_TIME\_MAX\_CHANNELS}})\ \textcolor{keywordflow}{return}\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00148}00148\ \ \ \textcolor{keywordflow}{if}\ (!hbt.channels[channel].is\_running)\ \textcolor{keywordflow}{return}\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00149}00149\ \ \ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00150}00150\ \ \ uint32\_t\ end\_tick\ =\ ticks;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00151}00151\ \ \ uint32\_t\ start\_tick\ =\ hbt.channels[channel].start\_tick;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00152}00152\ \ \ uint32\_t\ tick\_period\ =\ hbt.channels[channel].tick\_period;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00153}00153\ \ \ uint32\_t\ elapsed\_ticks;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00154}00154\ \ \ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00155}00155\ \ \ \textcolor{keywordflow}{if}\ (end\_tick\ >=\ start\_tick)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00156}00156\ \ \ \ \ elapsed\_ticks\ =\ end\_tick\ -\/\ start\_tick;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00157}00157\ \ \ \}\ \textcolor{keywordflow}{else}\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00158}00158\ \ \ \ \ elapsed\_ticks\ =\ (tick\_period\ -\/\ start\_tick)\ +\ end\_tick\ +\ 1;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00159}00159\ \ \ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00160}00160\ \ \ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00161}00161\ \ \ \textcolor{keywordflow}{if}\ (elapsed\_ticks\ >\ tick\_period)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00162}00162\ \ \ \ \ elapsed\_ticks\ =\ tick\_period;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00163}00163\ \ \ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00164}00164\ \ \ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00165}00165\ \ \ hbt.channels[channel].is\_running\ =\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00166}00166\ \ \ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00167}00167\ \ \ \textcolor{comment}{//\ Обновление\ статистики}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00168}00168\ \ \ BenchTimeStats\_t*\ stats\ =\ \&hbt.channels[channel].stats;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00169}00169\ \ \ stats-\/>last\_ticks\ =\ elapsed\_ticks;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00170}00170\ \ \ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00171}00171\ \ \ \textcolor{keywordflow}{if}\ (elapsed\_ticks\ <\ stats-\/>min\_ticks)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00172}00172\ \ \ \ \ stats-\/>min\_ticks\ =\ elapsed\_ticks;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00173}00173\ \ \ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00174}00174\ \ \ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00175}00175\ \ \ \textcolor{keywordflow}{if}\ (elapsed\_ticks\ >\ stats-\/>max\_ticks)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00176}00176\ \ \ \ \ stats-\/>max\_ticks\ =\ elapsed\_ticks;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00177}00177\ \ \ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00178}00178\ \ \ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00179}00179\ \ \ stats-\/>total\_ticks\ +=\ elapsed\_ticks;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00180}00180\ \ \ stats-\/>count++;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00181}00181\ \ \ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00182}00182\ \ \ \textcolor{keywordflow}{return}\ elapsed\_ticks;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00183}00183\ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00184}00184\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00185}00185\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00186}00186\ \textcolor{comment}{\ \ *\ @brief\ Получение\ минимального\ времени\ измерения}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00187}00187\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00188}00188\ \textcolor{keyword}{static}\ \textcolor{keyword}{inline}\ uint32\_t\ BenchTime\_GetMin(uint8\_t\ channel)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00189}00189\ \ \ \textcolor{keywordflow}{if}\ (channel\ >=\ \mbox{\hyperlink{group___g_e_n___c_o_n_f_i_g_ga74fdf777ceefa5e7d67120fbda4cde52}{BENCH\_TIME\_MAX\_CHANNELS}})\ \textcolor{keywordflow}{return}\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00190}00190\ \ \ \textcolor{keywordflow}{return}\ hbt.channels[channel].stats.min\_ticks;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00191}00191\ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00192}00192\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00193}00193\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00194}00194\ \textcolor{comment}{\ \ *\ @brief\ Получение\ максимального\ времени\ измерения}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00195}00195\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00196}00196\ \textcolor{keyword}{static}\ \textcolor{keyword}{inline}\ uint32\_t\ BenchTime\_GetMax(uint8\_t\ channel)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00197}00197\ \ \ \textcolor{keywordflow}{if}\ (channel\ >=\ \mbox{\hyperlink{group___g_e_n___c_o_n_f_i_g_ga74fdf777ceefa5e7d67120fbda4cde52}{BENCH\_TIME\_MAX\_CHANNELS}})\ \textcolor{keywordflow}{return}\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00198}00198\ \ \ \textcolor{keywordflow}{return}\ hbt.channels[channel].stats.max\_ticks;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00199}00199\ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00200}00200\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00201}00201\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00202}00202\ \textcolor{comment}{\ \ *\ @brief\ Получение\ среднего\ времени\ измерения}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00203}00203\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00204}00204\ \textcolor{keyword}{static}\ \textcolor{keyword}{inline}\ uint32\_t\ BenchTime\_GetAverage(uint8\_t\ channel)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00205}00205\ \ \ \textcolor{keywordflow}{if}\ (channel\ >=\ \mbox{\hyperlink{group___g_e_n___c_o_n_f_i_g_ga74fdf777ceefa5e7d67120fbda4cde52}{BENCH\_TIME\_MAX\_CHANNELS}})\ \textcolor{keywordflow}{return}\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00206}00206\ \ \ BenchTimeStats\_t*\ stats\ =\ \&hbt.channels[channel].stats;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00207}00207\ \ \ \textcolor{keywordflow}{if}\ (stats-\/>count\ ==\ 0)\ \textcolor{keywordflow}{return}\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00208}00208\ \ \ \textcolor{keywordflow}{return}\ stats-\/>total\_ticks\ /\ stats-\/>count;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00209}00209\ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00210}00210\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00211}00211\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00212}00212\ \textcolor{comment}{\ \ *\ @brief\ Получение\ количества\ измерений}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00213}00213\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00214}00214\ \textcolor{keyword}{static}\ \textcolor{keyword}{inline}\ uint32\_t\ BenchTime\_GetCount(uint8\_t\ channel)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00215}00215\ \ \ \textcolor{keywordflow}{if}\ (channel\ >=\ \mbox{\hyperlink{group___g_e_n___c_o_n_f_i_g_ga74fdf777ceefa5e7d67120fbda4cde52}{BENCH\_TIME\_MAX\_CHANNELS}})\ \textcolor{keywordflow}{return}\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00216}00216\ \ \ \textcolor{keywordflow}{return}\ hbt.channels[channel].stats.count;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00217}00217\ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00218}00218\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00219}00219\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00220}00220\ \textcolor{comment}{\ \ *\ @brief\ Получение\ последнего\ измеренного\ времени}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00221}00221\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00222}00222\ \textcolor{keyword}{static}\ \textcolor{keyword}{inline}\ uint32\_t\ BenchTime\_GetLast(uint8\_t\ channel)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00223}00223\ \ \ \textcolor{keywordflow}{if}\ (channel\ >=\ \mbox{\hyperlink{group___g_e_n___c_o_n_f_i_g_ga74fdf777ceefa5e7d67120fbda4cde52}{BENCH\_TIME\_MAX\_CHANNELS}})\ \textcolor{keywordflow}{return}\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00224}00224\ \ \ \textcolor{keywordflow}{return}\ hbt.channels[channel].stats.last\_ticks;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00225}00225\ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00226}00226\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00227}00227\ \textcolor{comment}{/**}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00228}00228\ \textcolor{comment}{\ \ *\ @brief\ Сброс\ статистики\ для\ канала}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00229}00229\ \textcolor{comment}{\ \ */}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00230}00230\ \textcolor{keyword}{static}\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ BenchTime\_ResetStats(uint8\_t\ channel)\ \{} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00231}00231\ \ \ \textcolor{keywordflow}{if}\ (channel\ >=\ \mbox{\hyperlink{group___g_e_n___c_o_n_f_i_g_ga74fdf777ceefa5e7d67120fbda4cde52}{BENCH\_TIME\_MAX\_CHANNELS}})\ \textcolor{keywordflow}{return};} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00232}00232\ \ \ BenchTimeStats\_t*\ stats\ =\ \&hbt.channels[channel].stats;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00233}00233\ \ \ stats-\/>min\_ticks\ =\ 0xFFFFFFFF;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00234}00234\ \ \ stats-\/>max\_ticks\ =\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00235}00235\ \ \ stats-\/>total\_ticks\ =\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00236}00236\ \ \ stats-\/>count\ =\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00237}00237\ \ \ stats-\/>last\_ticks\ =\ 0;} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00238}00238\ \}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00239}00239\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//BENCH\_TIME\_ENABLE}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00240}00240\ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00241}00241\ \textcolor{preprocessor}{\#define\ BenchTime\_Init()}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00242}00242\ \textcolor{preprocessor}{\#define\ BenchTime\_Start(channel,\ ticks,\ tick\_period)\ \ 0}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00243}00243\ \textcolor{preprocessor}{\#define\ BenchTime\_End(channel,\ ticks)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00244}00244\ \textcolor{preprocessor}{\#define\ BenchTime\_GetMin(channel)\ \ \ \ \ \ \ 0}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00245}00245\ \textcolor{preprocessor}{\#define\ BenchTime\_GetMax(channel)\ \ \ \ \ \ \ 0}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00246}00246\ \textcolor{preprocessor}{\#define\ BenchTime\_GetAverage(channel)\ \ \ 0}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00247}00247\ \textcolor{preprocessor}{\#define\ BenchTime\_GetCount(channel)\ \ \ \ \ 0}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00248}00248\ \textcolor{preprocessor}{\#define\ BenchTime\_GetLast(channel)\ \ \ \ \ \ 0}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00249}00249\ \textcolor{preprocessor}{\#define\ BenchTime\_ResetStats(channel)}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00250}00250\ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00251}00251\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//BENCH\_TIME\_ENABLE}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00252}00252\ } \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00253}00253\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ \_\_BENCH\_TIME\_H\_}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00254}00254\ \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00255}00255\ \textcolor{comment}{/**\ BENCH\_TIME}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00256}00256\ \textcolor{comment}{\ \ *\ @\}}} \DoxyCodeLine{\Hypertarget{bench__time_8h_source_l00257}00257\ \textcolor{comment}{\ \ */}} \end{DoxyCode}