From 37843e4bef628500b9a463fd420c7ab4180d496d Mon Sep 17 00:00:00 2001 From: Razvalyaev Date: Mon, 20 Oct 2025 08:48:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B5=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D0=BC=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20.h=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE?= =?UTF-8?q?=D1=82=D0=B5=D0=BA=20=D0=BE=D1=82=20=D1=82=D0=B0=D1=80=D0=B3?= =?UTF-8?q?=D0=B5=D1=82=D0=B0=20=D0=B8=20HAL=20(=D0=BD=D0=B0=D1=81=D0=BA?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE?= =?UTF-8?q?=D0=B6=D0=BD=D0=BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Doc/html/doxygen_crawl.html | 6 +- Doc/html/evolve__optimizer_8h.html | 10 +- Doc/html/evolve__optimizer_8h.js | 5 +- Doc/html/evolve__optimizer_8h_source.html | 503 +++---- Doc/html/functions.html | 1 + Doc/html/functions_vars.html | 1 + Doc/html/globals.html | 5 +- Doc/html/globals_defs.html | 1 + Doc/html/globals_func.html | 4 +- ...oup___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html | 82 +- ...group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.js | 8 +- Doc/html/group___t_r_a_c_e___g_p_i_o.html | 4 +- ...group___t_r_a_c_e___h_a_r_d_f_a_u_l_t.html | 30 +- ...group___t_r_a_c_e___r_t_t___f_l_a_s_h.html | 17 +- Doc/html/group___t_r_a_c_e___s_e_r_i_a_l.html | 17 +- Doc/html/group___t_r_a_c_k_e_r_s.html | 54 +- Doc/html/mylibs__include_8h_source.html | 2 +- Doc/html/navtreedata.js | 2 +- Doc/html/navtreeindex0.js | 10 +- Doc/html/navtreeindex1.js | 2 + Doc/html/search/all_4.js | 4 +- Doc/html/search/all_9.js | 9 +- Doc/html/search/all_f.js | 37 +- Doc/html/search/functions_0.js | 4 +- Doc/html/search/variables_a.js | 27 +- .../struct_evolve_optimizer__t-members.html | 1 + Doc/html/struct_evolve_optimizer__t.html | 36 +- Doc/html/struct_evolve_optimizer__t.js | 3 +- Doc/html/struct_h_f___stack_frame__t.html | 18 +- Doc/html/struct_r_t_t___flash_header__t.html | 8 +- Doc/html/trace_8h_source.html | 1150 +++++++++-------- Doc/html/trackers_8h_source.html | 291 ++--- Doc/latex/evolve__optimizer_8h.tex | 8 +- Doc/latex/evolve__optimizer_8h_source.tex | 468 ++++--- ...roup___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.tex | 73 +- Doc/latex/group___t_r_a_c_e___g_p_i_o.tex | 4 +- .../group___t_r_a_c_e___h_a_r_d_f_a_u_l_t.tex | 22 +- .../group___t_r_a_c_e___r_t_t___f_l_a_s_h.tex | 19 +- Doc/latex/group___t_r_a_c_e___s_e_r_i_a_l.tex | 15 +- Doc/latex/group___t_r_a_c_k_e_r_s.tex | 45 +- Doc/latex/struct_evolve_optimizer__t.tex | 34 +- Doc/latex/struct_h_f___stack_frame__t.tex | 18 +- Doc/latex/struct_r_t_t___flash_header__t.tex | 8 +- Doc/latex/trace_8h_source.tex | 1090 ++++++++-------- Doc/latex/trackers_8h_source.tex | 289 ++--- MyLibsGeneral/Inc/evolve_optimizer.h | 51 +- MyLibsGeneral/Inc/trace.h | 32 +- MyLibsGeneral/Inc/trackers.h | 7 +- 48 files changed, 2457 insertions(+), 2078 deletions(-) diff --git a/Doc/html/doxygen_crawl.html b/Doc/html/doxygen_crawl.html index 41c0090..e209206 100644 --- a/Doc/html/doxygen_crawl.html +++ b/Doc/html/doxygen_crawl.html @@ -64,9 +64,10 @@ - - + + + @@ -229,6 +230,7 @@ + diff --git a/Doc/html/evolve__optimizer_8h.html b/Doc/html/evolve__optimizer_8h.html index 42c96c5..4e74b63 100644 --- a/Doc/html/evolve__optimizer_8h.html +++ b/Doc/html/evolve__optimizer_8h.html @@ -150,13 +150,15 @@ Macros  Линейное масштабирование x из диапазона [min_val, max_val] в Q16.16 [0, 65536)
#define 
PARAM_UNSCALE_Q16(q16_val, min_val, max_val)  Обратное линейное масштабирование Q16.16 значения в диапазон [min_val, max_val].
+#define local_time() + Локальное время
- - - - + + + +

Functions

__STATIC_INLINE void EvolveOptimizer_Init (EvolveOptimizer_t *opt, uint16_t n_params, uint16_t n_cand, uint16_t n_best, uint16_t iq_mutation, int32_t *start_params)
 Инициализация эволюционного оптимизатора.
__STATIC_INLINE void EvolveOptimizer_Step (EvolveOptimizer_t *opt, int32_t *params, int32_t loss)
 Один шаг эволюционного оптимизатора.
__STATIC_INLINE int EvolveOptimizer_Init (EvolveOptimizer_t *opt, uint16_t n_params, uint16_t n_cand, uint16_t n_best, uint16_t iq_mutation, int32_t *start_params)
 Инициализация эволюционного оптимизатора.
__STATIC_INLINE int EvolveOptimizer_Step (EvolveOptimizer_t *opt, int32_t *params, int32_t loss)
 Один шаг эволюционного оптимизатора.

Detailed Description

Заголовочный файл для адаптивного подбора параметров

diff --git a/Doc/html/evolve__optimizer_8h.js b/Doc/html/evolve__optimizer_8h.js index 46d46b4..30c542c 100644 --- a/Doc/html/evolve__optimizer_8h.js +++ b/Doc/html/evolve__optimizer_8h.js @@ -2,6 +2,7 @@ var evolve__optimizer_8h = [ [ "PARAM_SCALE_Q16", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gaff223481fcffea77394a331afde29fdc", null ], [ "PARAM_UNSCALE_Q16", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga71a0c240c667e976d9caef391ab767ba", null ], - [ "EvolveOptimizer_Init", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gac21587fe68fe3635525358ac3f4059d9", null ], - [ "EvolveOptimizer_Step", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga1ba2fa963c9ae12625be1b7c20718563", null ] + [ "local_time", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga9c853b02c22f26023c34d1d404b6d653", null ], + [ "EvolveOptimizer_Init", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gadaf3a90724197e1737d5c70c7bcc75e1", null ], + [ "EvolveOptimizer_Step", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga75acd71c85d4e60dc0eb31bc5780086a", null ] ]; \ No newline at end of file diff --git a/Doc/html/evolve__optimizer_8h_source.html b/Doc/html/evolve__optimizer_8h_source.html index 70acfe3..7bdfeb3 100644 --- a/Doc/html/evolve__optimizer_8h_source.html +++ b/Doc/html/evolve__optimizer_8h_source.html @@ -115,233 +115,302 @@ $(function(){initNavTree('evolve__optimizer_8h_source.html','',''); });
13- Мутацию для поиска оптимальных параметров
14- Несколько независимых оптимизаторов в одной программе
15
-
16Если библиотека отключена @ref ENABLE_EVOLVE_OPTIMIZATION, то вставляются
-
17заглушки, никак не влияющие на параметры и остальную программу
-
18
-
19@par Пример использования:
-
20@code
-
21#include "evolve_optimizer.h"
-
22#define N_PARAMS 4
-
23#define N_CANDIDATES 100
-
24#define N_BEST 10
-
25#define IQ_MUTATION 655
-
26int32_t params[N_PARAMS];
-
27EvolveOptimizer_t optimizer;
-
28
-
29// Формирование параметров
-
30uint16_t param_u16 = 800;
-
31float param_f = 0.01f;
-
32uint8_t param_u8 = 40;
-
33int16_t param_i16 = 1600;
-
34params[0] = PARAM_SCALE_Q16(param_u16, 0, 1000);
-
35params[1] = PARAM_SCALE_Q16(param_f, 0.001f, 0.1f);
-
36params[2] = PARAM_SCALE_Q16(param_u8, 10, 100);
-
37params[3] = PARAM_SCALE_Q16(param_i16, 500, 5000);
-
38
-
39// Инициалиазция
-
40EvolveOptimizer_Init(&optimizer, N_PARAMS, N_CANDIDATES, N_BEST, IQ_MUTATION, params);
-
41
-
42// Шаг эволюции
-
43int32_t loss = calc_iq_loss(); // расчет эффективности параметров
-
44EvolveOptimizer_Step(&optimizer, params, loss);
-
45
-
46// Взятие следующих для эволюции параметров
-
47param_u16 = PARAM_UNSCALE_Q16(params[0], 0, 1000);
-
48param_f = PARAM_UNSCALE_Q16(params[1], 0.001f, 0.1f);
-
49param_u8 = PARAM_UNSCALE_Q16(params[2], 10, 100);
-
50param_i16 = PARAM_UNSCALE_Q16(params[3], 500, 5000);
-
51@endcode
-
52* @{
-
53*****************************************************************************/
-
54#ifndef __EVOLVE_OPTIMIZER_H_
-
55#define __EVOLVE_OPTIMIZER_H_
-
56
-
57#include "mylibs_defs.h"
-
58#include <stdint.h>
-
59#include <stdlib.h>
-
60
-
61#ifdef ENABLE_EVOLVE_OPTIMIZATION
+
16
+
17Параметры для конфигурации:
+
18- @ref ENABLE_EVOLVE_OPTIMIZATION - Включить оптимизацию параметров
+
19 Если библиотека отключена @ref ENABLE_EVOLVE_OPTIMIZATION, то вставляются
+
20 заглушки, никак не влияющие на параметры и остальную программу
+
21- @ref EVOLVE_MAX_PARAMS - Максимальное количество параметров
+
22- @ref EVOLVE_MAX_CANDIDATES - Максимальное количество кандидатов для обучения
+
23
+
24
+
25@par Пример использования:
+
26@code
+
27#include "evolve_optimizer.h"
+
28#define N_PARAMS 4
+
29#define N_CANDIDATES 100
+
30#define N_BEST 10
+
31#define IQ_MUTATION (PARAM_SCALE_Q16(0.1, 0, 1))
+
32int32_t params[N_PARAMS];
+
33EvolveOptimizer_t optimizer;
+
34
+
35// Формирование параметров
+
36uint16_t param_u16 = 800;
+
37float param_f = 0.01f;
+
38uint8_t param_u8 = 40;
+
39int16_t param_i16 = 1600;
+
40params[0] = PARAM_SCALE_Q16(param_u16, 0, 1000);
+
41params[1] = PARAM_SCALE_Q16(param_f, 0.001f, 0.1f);
+
42params[2] = PARAM_SCALE_Q16(param_u8, 10, 100);
+
43params[3] = PARAM_SCALE_Q16(param_i16, 500, 5000);
+
44
+
45// Инициалиазция
+
46EvolveOptimizer_Init(&optimizer, N_PARAMS, N_CANDIDATES, N_BEST, IQ_MUTATION, params);
+
47
+
48// Шаг эволюции
+
49int32_t loss = calc_iq_loss(); // расчет эффективности параметров
+
50EvolveOptimizer_Step(&optimizer, params, loss);
+
51
+
52// Взятие следующих для эволюции параметров
+
53param_u16 = PARAM_UNSCALE_Q16(params[0], 0, 1000);
+
54param_f = PARAM_UNSCALE_Q16(params[1], 0.001f, 0.1f);
+
55param_u8 = PARAM_UNSCALE_Q16(params[2], 10, 100);
+
56param_i16 = PARAM_UNSCALE_Q16(params[3], 500, 5000);
+
57@endcode
+
58* @{
+
59*****************************************************************************/
+
60#ifndef __EVOLVE_OPTIMIZER_H_
+
61#define __EVOLVE_OPTIMIZER_H_
62
-
63#define Q16_MUL(a,b) ((int32_t)(((int64_t)(a) * (int64_t)(b)) >> 16))
-
64
-
65/**
-
66 * @brief Линейное масштабирование x из диапазона [min_val, max_val] в Q16.16 [0, 65536)
-
67 */
-
-
68#define PARAM_SCALE_Q16(x, min_val, max_val) \
-
69((int32_t)((((float)(x) - (float)(min_val)) / ((float)(max_val) - (float)(min_val))) * 65536.0f))
+
63#include "mylibs_defs.h"
+
64#include <stdint.h>
+
65#include <stdlib.h>
+
66
+
67#ifdef ENABLE_EVOLVE_OPTIMIZATION
+
68/**
+
69 * @brief Линейное масштабирование x из диапазона [min_val, max_val] в Q16.16 [0, 65536)
+
70 */
+
+
71#define PARAM_SCALE_Q16(x, min_val, max_val) \
+
72((int32_t)((((float)(x) - (float)(min_val)) / ((float)(max_val) - (float)(min_val))) * 65536.0f))
-
70
-
71/**
-
72 * @brief Обратное линейное масштабирование Q16.16 значения в диапазон [min_val, max_val]
-
73 */
-
-
74#define PARAM_UNSCALE_Q16(q16_val, min_val, max_val) \
-
75(((float)(q16_val) / 65536.0f) * ((float)(max_val) - (float)(min_val)) + (float)(min_val))
+
73
+
74/**
+
75 * @brief Обратное линейное масштабирование Q16.16 значения в диапазон [min_val, max_val]
+
76 */
+
+
77#define PARAM_UNSCALE_Q16(q16_val, min_val, max_val) \
+
78(((float)(q16_val) / 65536.0f) * ((float)(max_val) - (float)(min_val)) + (float)(min_val))
-
76
-
77
-
78/**
-
79 * @brief Структура эволюционного оптимизатора
-
80 */
-
-
81typedef struct {
-
82 uint16_t n_params; ///< Количество параметров
-
83 uint16_t n_cand; ///< Количество кандидатов
-
84 uint16_t n_best; ///< Количество лучших, усредняемых
-
85 uint16_t iq_mutation; ///< Амплитуда мутации в Q16.16
-
86 uint16_t cand_index; ///< Индекс кандидата для обработки
-
87 int32_t loss[EVOLVE_MAX_CANDIDATES]; ///< Loss для каждого кандидата
-
88 int32_t candidates[EVOLVE_MAX_CANDIDATES][EVOLVE_MAX_PARAMS]; ///< Параметры кандидатов
- +
79
+
80#ifndef local_time
+
81#define local_time() HAL_GetTick() ///< Локальное время
+
82#endif
+
83
+
84/**
+
85 * @brief Структура эволюционного оптимизатора
+
86 */
+
+
87typedef struct {
+
88 uint16_t n_params; ///< Количество параметров
+
89 uint16_t n_cand; ///< Количество кандидатов
+
90 uint16_t n_best; ///< Количество лучших, усредняемых
+
91 uint16_t iq_mutation; ///< Амплитуда мутации в Q16.16
+
92 uint16_t cand_index; ///< Индекс кандидата для обработки
+
93 int32_t loss[EVOLVE_MAX_CANDIDATES]; ///< Loss для каждого кандидата
+
94 int32_t candidates[EVOLVE_MAX_CANDIDATES][EVOLVE_MAX_PARAMS]; ///< Параметры кандидатов
+
95 uint16_t sorted_idx[EVOLVE_MAX_CANDIDATES]; ///< Индексы отсортированных кандидатов
+
-
90
-
91
-
92/**
-
93 * @brief Инициализация эволюционного оптимизатора.
-
94 * @param opt Указатель на структуру оптимизатора
-
95 * @param n_params Количество параметров в одном кандидате
-
96 * @param n_cand Количество кандидатов
-
97 * @param n_best Количество лучших, усредняемых
-
98 * @param iq_mutation Амплитуда мутации в Q16.16
-
99 * @param start_params Начальные параметры (Q16.16)
-
100 */
-
-
101__STATIC_INLINE void EvolveOptimizer_Init(EvolveOptimizer_t* opt,
-
102 uint16_t n_params,
-
103 uint16_t n_cand,
-
104 uint16_t n_best,
-
105 uint16_t iq_mutation,
-
106 int32_t* start_params)
-
107{
-
108 if(check_null_ptr_2(opt, start_params))
-
109 return;
-
110
-
111 opt->n_params = n_params;
-
112 opt->n_cand = n_cand;
-
113 opt->n_best = n_best;
-
114 opt->iq_mutation = iq_mutation;
-
115
-
116 for (uint16_t i = 0; i < n_cand; i++) {
-
117 for (uint16_t j = 0; j < n_params; j++) {
-
118 opt->candidates[i][j] = start_params[j];
-
119 }
-
120 opt->loss[i] = 0;
-
121 }
-
122}
+
97
+
98
+
99
+
100/**
+
101 * @cond EVOLVE_INTERNAL
+
102 */
+
103#define Q16_MUL(a,b) ((int32_t)(((int64_t)(a) * (int64_t)(b)) >> 16))
+
104
+
105// Вспомогательный указатель для сортировки
+
106static EvolveOptimizer_t *g_sort_opt; // глобальный указатель на текущий оптимизатор
+
107
+
108static int cmp_idx(const void *a, const void *b) {
+
109 if (g_sort_opt->loss[*(const uint16_t*)a] < g_sort_opt->loss[*(const uint16_t*)b])
+
110 return -1;
+
111 if (g_sort_opt->loss[*(const uint16_t*)a] > g_sort_opt->loss[*(const uint16_t*)b])
+
112 return 1;
+
113 return 0;
+
114}
+
115/** @endcond */
+
116
+
117
+
118
+
119
+
120
+
121/**
+
122 * @brief Инициализация эволюционного оптимизатора.
+
123 * @param opt Указатель на структуру оптимизатора
+
124 * @param n_params Количество параметров в одном кандидате
+
125 * @param n_cand Количество кандидатов
+
126 * @param n_best Количество лучших, усредняемых
+
127 * @param iq_mutation Амплитуда мутации в Q16.16
+
128 * @param start_params Начальные параметры (Q16.16)
+
129 * @return 0 — если окей,
+
130 * -1 — если ошибка
+
131 */
+
+ +
133 uint16_t n_params,
+
134 uint16_t n_cand,
+
135 uint16_t n_best,
+
136 uint16_t iq_mutation,
+
137 int32_t* start_params)
+
138{
+
139 if((opt = NULL) || (start_params == NULL))
+
140 return -1;
+
141
+
142 if(n_params > EVOLVE_MAX_PARAMS)
+
143 return -1;
+
144 opt->n_params = n_params;
+
145
+
146 if(n_cand > EVOLVE_MAX_CANDIDATES)
+
147 return -1;
+
148 opt->n_cand = n_cand;
+
149
+
150 if(n_best > EVOLVE_MAX_CANDIDATES/2)
+
151 return -1;
+
152 opt->n_best = n_best;
+
153
+
154 if(iq_mutation > 32768)
+
155 return -1;
+
156 opt->iq_mutation = iq_mutation;
+
157
+
158 for (uint16_t i = 0; i < n_cand; i++) {
+
159 for (uint16_t j = 0; j < n_params; j++) {
+
160 opt->candidates[i][j] = start_params[j];
+
161 }
+
162 opt->loss[i] = 0;
+
163 }
+
164 uint32_t seed = local_time() + (ADC1->DR & 0xFF);
+
165 srand(seed);
+
166
+
167 return 0;
+
168}
-
123
-
124
-
125/**
-
126 * @brief Один шаг эволюционного оптимизатора.
-
127 * @param opt Указатель на структуру оптимизатора
-
128 * @param params Массив параметров, которые будут обновлены (на выходе — новые параметры)
-
129 * @param loss Loss текущего кандидата (Q16.16)
-
130 * @details
-
131 * Сохраняет loss текущего кандидата и формирует параметры следующего кандидата.
-
132 * Если накоплено n_cand кандидатов, генерируется новое поколение.
-
133 * Новое поколение формируется случайным выбором из n_best лучших с добавлением мутации.
-
134 *
-
135 * На выходе params содержит параметры следующего кандидата для измерений.
-
136 */
-
-
137__STATIC_INLINE void EvolveOptimizer_Step(EvolveOptimizer_t* opt,
-
138 int32_t* params,
-
139 int32_t loss)
-
140{
-
141 if(check_null_ptr_2(opt, params))
-
142 return;
-
143
-
144 uint16_t n_params = opt->n_params;
-
145 uint16_t n_cand = opt->n_cand;
-
146 uint16_t n_best = opt->n_best;
-
147 uint16_t mut = opt->iq_mutation;
-
148
-
149 // 1. Сохраняем loss текущего кандидата
-
150 opt->loss[opt->cand_index] = loss;
-
151
-
152 opt->cand_index++;
-
153
-
154 if (opt->cand_index >= n_cand) {
-
155 // 2. Сортируем текущее поколение по loss
-
156 for (uint16_t i = 0; i < n_cand - 1; i++) {
-
157 for (uint16_t j = i + 1; j < n_cand; j++) {
-
158 if (opt->loss[j] < opt->loss[i]) {
-
159 int32_t tmp_loss = opt->loss[i];
-
160 opt->loss[i] = opt->loss[j];
-
161 opt->loss[j] = tmp_loss;
-
162
-
163 for (uint16_t k = 0; k < n_params; k++) {
-
164 int32_t tmp = opt->candidates[i][k];
-
165 opt->candidates[i][k] = opt->candidates[j][k];
-
166 opt->candidates[j][k] = tmp;
-
167 }
-
168 }
-
169 }
-
170 }
-
171
-
172 // 3. Генерируем новое поколение: каждый кандидат берется случайно из лучших с мутацией
-
173 uint16_t n_elite = 2; // количество элитных кандидатов, которые сохраняем без изменений
-
174 for (uint16_t c = 0; c < n_cand; c++) {
-
175 if (c < n_elite) {
-
176 // Копируем лучших кандидатов напрямую без мутации
-
177 for (uint16_t i = 0; i < n_params; i++) {
-
178 opt->candidates[c][i] = opt->candidates[c][i]; // просто сохраняем параметры
-
179 }
-
180 opt->loss[c] = 0;
-
181 } else {
-
182 // Остальные кандидаты формируются с кроссовером и мутацией
-
183 for (uint16_t i = 0; i < n_params; i++) {
-
184 int32_t noise = (rand() % (2 * mut)) - mut;
-
185 uint16_t parent = rand() % n_best; // каждый параметр из случайного лучшего
-
186 opt->candidates[c][i] = opt->candidates[parent][i] + noise;
-
187 }
-
188 opt->loss[c] = 0;
-
189 }
-
190 }
-
191 opt->cand_index = 0;
-
192 }
+
169
+
170
+
171/**
+
172 * @brief Один шаг эволюционного оптимизатора.
+
173 * @param opt Указатель на структуру оптимизатора
+
174 * @param params Массив параметров, которые будут обновлены (на выходе — новые параметры)
+
175 * @param loss Loss текущего кандидата (Q16.16)
+
176 * @return 0 — если окей,
+
177 * -1 — если ошибка
+
178 * @details
+
179 * Сохраняет loss текущего кандидата и формирует параметры следующего кандидата.
+
180 * Если накоплено n_cand кандидатов, генерируется новое поколение.
+
181 * Новое поколение формируется случайным выбором из n_best лучших с добавлением мутации.
+
182 *
+
183 * На выходе params содержит параметры следующего кандидата для измерений.
+
184 * @note Функция использует глобальную внутреннюю переменную для сортировки.
+
185 * Надо убедится что только один экземпляр функции запущен в момент времени
+
186 */
+
+ +
188 int32_t* params,
+
189 int32_t loss)
+
190{
+
191 if((opt = NULL) || (params == NULL))
+
192 return -1;
193
-
194 // 4. Возвращаем параметры следующего кандидата
-
195 for (uint16_t i = 0; i < opt->n_params; i++)
-
196 params[i] = opt->candidates[opt->cand_index][i];
-
197}
-
-
198#else // ENABLE_EVOLVE_OPTIMIZATION
-
199//заглушки
-
200typedef struct {
-
201 uint16_t n_params;
-
202 uint16_t n_cand;
-
203 uint16_t n_best;
-
204 uint16_t iq_mutation;
-
205 int32_t loss[0];
-
206 int32_t candidates[0][0];
- -
208#define EvolveOptimizer_Init(opt, n_params, n_cand, n_best, iq_mutation, start_params)
-
209#define EvolveOptimizer_Step(opt, params, LossFunc)
-
210#define PARAM_SCALE_Q16(x, min_val, max_val) (x)
-
211#define PARAM_UNSCALE_Q16(q16_val, min_val, max_val) (q16_val) (q16_val)
-
212#endif // ENABLE_EVOLVE_OPTIMIZATION
+
194 uint16_t n_params = opt->n_params;
+
195 if(n_params > EVOLVE_MAX_PARAMS)
+
196 return -1;
+
197
+
198 uint16_t n_cand = opt->n_cand;
+
199 if(n_cand > EVOLVE_MAX_CANDIDATES)
+
200 return -1;
+
201
+
202 uint16_t n_best = opt->n_best;
+
203 if(n_best > EVOLVE_MAX_CANDIDATES/2)
+
204 return -1;
+
205
+
206 uint16_t mut = opt->iq_mutation;
+
207 if(mut > 32768)
+
208 return -1;
+
209
+
210 // 1. Сохраняем loss текущего кандидата
+
211 opt->loss[opt->cand_index] = loss;
+
212 opt->cand_index++;
213
-
214#endif // __EVOLVE_OPTIMIZER_H_
-
215
-
216/** EVOLVE_OPTIMIZER
-
217 * @}
-
218 */
-
#define check_null_ptr_2(p1, p2)
Проверить два указателя на NULL.
Definition mylibs_defs.h:41
+
214 if (opt->cand_index >= n_cand) {
+
215 // 2. Сортируем текущее поколение по loss
+
216 for(uint16_t i = 0; i < opt->n_cand; i++)
+
217 opt->sorted_idx[i] = i;
+
218
+
219 g_sort_opt = opt;
+
220 qsort(opt->sorted_idx, opt->n_cand, sizeof(uint16_t), cmp_idx);
+
221 g_sort_opt = NULL;
+
222// for (uint16_t i = 0; i < n_cand - 1; i++) {
+
223// for (uint16_t j = i + 1; j < n_cand; j++) {
+
224// if (opt->loss[j] < opt->loss[i]) {
+
225// int32_t tmp_loss = opt->loss[i];
+
226// opt->loss[i] = opt->loss[j];
+
227// opt->loss[j] = tmp_loss;
+
228
+
229// for (uint16_t k = 0; k < n_params; k++) {
+
230// int32_t tmp = opt->candidates[i][k];
+
231// opt->candidates[i][k] = opt->candidates[j][k];
+
232// opt->candidates[j][k] = tmp;
+
233// }
+
234// }
+
235// }
+
236// }
+
237
+
238 // 3. Генерируем новое поколение: каждый кандидат берется случайно из лучших с мутацией
+
239 uint16_t n_elite = 2; // количество элитных кандидатов, которые сохраняем без изменений
+
240 for (uint16_t c = 0; c < n_cand; c++) {
+
241 if (c < n_elite) {
+
242 // Копируем лучших кандидатов напрямую без мутации
+
243 for (uint16_t i = 0; i < n_params; i++) {
+
244 opt->candidates[c][i] = opt->candidates[opt->sorted_idx[c]][i]; // просто сохраняем параметры
+
245 }
+
246 opt->loss[c] = 0;
+
247 } else {
+
248 // Остальные кандидаты формируются с кроссовером и мутацией
+
249 for (uint16_t i = 0; i < n_params; i++) {
+
250 int32_t noise = (rand() % (2 * mut)) - mut;
+
251 uint16_t parent = opt->sorted_idx[rand() % opt->n_best]; // каждый параметр из случайного лучшего
+
252 opt->candidates[c][i] = opt->candidates[parent][i] + noise;
+
253 }
+
254 opt->loss[c] = 0;
+
255 }
+
256 }
+
257 opt->cand_index = 0;
+
258 }
+
259
+
260 // 4. Возвращаем параметры следующего кандидата
+
261 for (uint16_t i = 0; i < opt->n_params; i++)
+
262 params[i] = opt->candidates[opt->cand_index][i];
+
263
+
264 return 0;
+
265}
+
+
266#else // ENABLE_EVOLVE_OPTIMIZATION
+
267//заглушки
+
268typedef struct {
+
269 uint16_t n_params;
+
270 uint16_t n_cand;
+
271 uint16_t n_best;
+
272 uint16_t iq_mutation;
+
273 int32_t loss[0];
+
274 int32_t candidates[0][0];
+ +
276#define EvolveOptimizer_Init(opt, n_params, n_cand, n_best, iq_mutation, start_params)
+
277#define EvolveOptimizer_Step(opt, params, LossFunc)
+
278#define PARAM_SCALE_Q16(x, min_val, max_val) (x)
+
279#define PARAM_UNSCALE_Q16(q16_val, min_val, max_val) (q16_val)
+
280#endif // ENABLE_EVOLVE_OPTIMIZATION
+
281
+
282#endif // __EVOLVE_OPTIMIZER_H_
+
283
+
284/** EVOLVE_OPTIMIZER
+
285 * @}
+
286 */
#define EVOLVE_MAX_CANDIDATES
Максимальное количество кандидатов для обучения
#define EVOLVE_MAX_PARAMS
Максимальное количество параметров
-
__STATIC_INLINE void EvolveOptimizer_Step(EvolveOptimizer_t *opt, int32_t *params, int32_t loss)
Один шаг эволюционного оптимизатора.
-
__STATIC_INLINE void EvolveOptimizer_Init(EvolveOptimizer_t *opt, uint16_t n_params, uint16_t n_cand, uint16_t n_best, uint16_t iq_mutation, int32_t *start_params)
Инициализация эволюционного оптимизатора.
+
__STATIC_INLINE int EvolveOptimizer_Step(EvolveOptimizer_t *opt, int32_t *params, int32_t loss)
Один шаг эволюционного оптимизатора.
+
#define local_time()
Локальное время
+
__STATIC_INLINE int EvolveOptimizer_Init(EvolveOptimizer_t *opt, uint16_t n_params, uint16_t n_cand, uint16_t n_best, uint16_t iq_mutation, int32_t *start_params)
Инициализация эволюционного оптимизатора.
Заголочный файл для дефайнов библиотеки MyLibsGeneral.
-
Структура эволюционного оптимизатора
-
uint16_t cand_index
Индекс кандидата для обработки
-
uint16_t n_params
Количество параметров
-
uint16_t iq_mutation
Амплитуда мутации в Q16.16.
-
int32_t candidates[100][20]
Параметры кандидатов
-
uint16_t n_best
Количество лучших, усредняемых
-
uint16_t n_cand
Количество кандидатов
-
int32_t loss[100]
Loss для каждого кандидата
+
Структура эволюционного оптимизатора
+
uint16_t cand_index
Индекс кандидата для обработки
+
uint16_t n_params
Количество параметров
+
uint16_t iq_mutation
Амплитуда мутации в Q16.16.
+
int32_t candidates[100][20]
Параметры кандидатов
+
uint16_t sorted_idx[100]
Индексы отсортированных кандидатов
+
uint16_t n_best
Количество лучших, усредняемых
+
uint16_t n_cand
Количество кандидатов
+
int32_t loss[100]
Loss для каждого кандидата
diff --git a/Doc/html/functions.html b/Doc/html/functions.html index 4793d9d..b94a60a 100644 --- a/Doc/html/functions.html +++ b/Doc/html/functions.html @@ -172,6 +172,7 @@ $(function(){initNavTree('functions.html','',''); });
  • sConfig : TIM_EncoderTypeDef
  • size : RTT_FlashHeader_t
  • sMasterConfig : TIM_SettingsTypeDef
  • +
  • sorted_idx : EvolveOptimizer_t
  • sSlaveConfig : TIM_SettingsTypeDef
  • state : GPIO_LEDTypeDef
  • sTickBasePrescaler : TIM_SettingsTypeDef
  • diff --git a/Doc/html/functions_vars.html b/Doc/html/functions_vars.html index f6e42da..31585ac 100644 --- a/Doc/html/functions_vars.html +++ b/Doc/html/functions_vars.html @@ -172,6 +172,7 @@ $(function(){initNavTree('functions_vars.html','',''); });
  • sConfig : TIM_EncoderTypeDef
  • size : RTT_FlashHeader_t
  • sMasterConfig : TIM_SettingsTypeDef
  • +
  • sorted_idx : EvolveOptimizer_t
  • sSlaveConfig : TIM_SettingsTypeDef
  • state : GPIO_LEDTypeDef
  • sTickBasePrescaler : TIM_SettingsTypeDef
  • diff --git a/Doc/html/globals.html b/Doc/html/globals.html index d7147e1..b470d85 100644 --- a/Doc/html/globals.html +++ b/Doc/html/globals.html @@ -129,8 +129,8 @@ $(function(){initNavTree('globals.html','',''); });
  • ENABLE_EVOLVE_OPTIMIZATION : mylibs_config.h
  • EVOLVE_MAX_CANDIDATES : mylibs_config.h
  • EVOLVE_MAX_PARAMS : mylibs_config.h
  • -
  • EvolveOptimizer_Init() : evolve_optimizer.h
  • -
  • EvolveOptimizer_Step() : evolve_optimizer.h
  • +
  • EvolveOptimizer_Init() : evolve_optimizer.h
  • +
  • EvolveOptimizer_Step() : evolve_optimizer.h
  • @@ -181,6 +181,7 @@ $(function(){initNavTree('globals.html','',''); });
  • LED_OFF : general_gpio.h
  • LED_ON : general_gpio.h
  • LED_PWM_TICKS : general_gpio.h
  • +
  • local_time : evolve_optimizer.h
  • LOG_LEVEL : mylibs_config.h
  • log_printf : trace.h
  • diff --git a/Doc/html/globals_defs.html b/Doc/html/globals_defs.html index 372247d..77ff945 100644 --- a/Doc/html/globals_defs.html +++ b/Doc/html/globals_defs.html @@ -162,6 +162,7 @@ $(function(){initNavTree('globals_defs.html','',''); });
  • LED_OFF : general_gpio.h
  • LED_ON : general_gpio.h
  • LED_PWM_TICKS : general_gpio.h
  • +
  • local_time : evolve_optimizer.h
  • LOG_LEVEL : mylibs_config.h
  • log_printf : trace.h
  • diff --git a/Doc/html/globals_func.html b/Doc/html/globals_func.html index 908c490..1c29fbd 100644 --- a/Doc/html/globals_func.html +++ b/Doc/html/globals_func.html @@ -100,8 +100,8 @@ $(function(){initNavTree('globals_func.html','',''); });
    Here is a list of all documented functions with links to the documentation:

    - e -

    diff --git a/Doc/html/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html b/Doc/html/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html index c418edc..641eb2f 100644 --- a/Doc/html/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html +++ b/Doc/html/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html @@ -125,13 +125,15 @@ Macros  Линейное масштабирование x из диапазона [min_val, max_val] в Q16.16 [0, 65536)
    #define PARAM_UNSCALE_Q16(q16_val, min_val, max_val)  Обратное линейное масштабирование Q16.16 значения в диапазон [min_val, max_val].
    +#define local_time() + Локальное время
    - - - - + + + +

    Functions

    __STATIC_INLINE void EvolveOptimizer_Init (EvolveOptimizer_t *opt, uint16_t n_params, uint16_t n_cand, uint16_t n_best, uint16_t iq_mutation, int32_t *start_params)
     Инициализация эволюционного оптимизатора.
    __STATIC_INLINE void EvolveOptimizer_Step (EvolveOptimizer_t *opt, int32_t *params, int32_t loss)
     Один шаг эволюционного оптимизатора.
    __STATIC_INLINE int EvolveOptimizer_Init (EvolveOptimizer_t *opt, uint16_t n_params, uint16_t n_cand, uint16_t n_best, uint16_t iq_mutation, int32_t *start_params)
     Инициализация эволюционного оптимизатора.
    __STATIC_INLINE int EvolveOptimizer_Step (EvolveOptimizer_t *opt, int32_t *params, int32_t loss)
     Один шаг эволюционного оптимизатора.

    Detailed Description

    Библиотека для эволюционного подбора параметров

    @@ -141,12 +143,16 @@ Functions
  • Мутацию для поиска оптимальных параметров
  • Несколько независимых оптимизаторов в одной программе
  • -

    Если библиотека отключена ENABLE_EVOLVE_OPTIMIZATION, то вставляются заглушки, никак не влияющие на параметры и остальную программу

    +

    Параметры для конфигурации:

    Пример использования:
    #define N_PARAMS 4
    #define N_CANDIDATES 100
    #define N_BEST 10
    -
    #define IQ_MUTATION 655
    +
    #define IQ_MUTATION (PARAM_SCALE_Q16(0.1, 0, 1))
    int32_t params[N_PARAMS];
    @@ -161,11 +167,11 @@ Functions
    params[3] = PARAM_SCALE_Q16(param_i16, 500, 5000);
    // Инициалиазция
    -
    EvolveOptimizer_Init(&optimizer, N_PARAMS, N_CANDIDATES, N_BEST, IQ_MUTATION, params);
    +
    EvolveOptimizer_Init(&optimizer, N_PARAMS, N_CANDIDATES, N_BEST, IQ_MUTATION, params);
    // Шаг эволюции
    int32_t loss = calc_iq_loss(); // расчет эффективности параметров
    -
    EvolveOptimizer_Step(&optimizer, params, loss);
    +
    EvolveOptimizer_Step(&optimizer, params, loss);
    // Взятие следующих для эволюции параметров
    param_u16 = PARAM_UNSCALE_Q16(params[0], 0, 1000);
    @@ -173,11 +179,11 @@ Functions
    param_u8 = PARAM_UNSCALE_Q16(params[2], 10, 100);
    param_i16 = PARAM_UNSCALE_Q16(params[3], 500, 5000);
    Заголовочный файл для адаптивного подбора параметров
    -
    __STATIC_INLINE void EvolveOptimizer_Step(EvolveOptimizer_t *opt, int32_t *params, int32_t loss)
    Один шаг эволюционного оптимизатора.
    -
    #define PARAM_UNSCALE_Q16(q16_val, min_val, max_val)
    Обратное линейное масштабирование Q16.16 значения в диапазон [min_val, max_val].
    -
    __STATIC_INLINE void EvolveOptimizer_Init(EvolveOptimizer_t *opt, uint16_t n_params, uint16_t n_cand, uint16_t n_best, uint16_t iq_mutation, int32_t *start_params)
    Инициализация эволюционного оптимизатора.
    -
    #define PARAM_SCALE_Q16(x, min_val, max_val)
    Линейное масштабирование x из диапазона [min_val, max_val] в Q16.16 [0, 65536)
    -
    Структура эволюционного оптимизатора
    +
    #define PARAM_UNSCALE_Q16(q16_val, min_val, max_val)
    Обратное линейное масштабирование Q16.16 значения в диапазон [min_val, max_val].
    +
    __STATIC_INLINE int EvolveOptimizer_Step(EvolveOptimizer_t *opt, int32_t *params, int32_t loss)
    Один шаг эволюционного оптимизатора.
    +
    __STATIC_INLINE int EvolveOptimizer_Init(EvolveOptimizer_t *opt, uint16_t n_params, uint16_t n_cand, uint16_t n_best, uint16_t iq_mutation, int32_t *start_params)
    Инициализация эволюционного оптимизатора.
    +
    #define PARAM_SCALE_Q16(x, min_val, max_val)
    Линейное масштабирование x из диапазона [min_val, max_val] в Q16.16 [0, 65536)
    +
    Структура эволюционного оптимизатора

    Macro Definition Documentation

    @@ -207,7 +213,7 @@ Functions

    Линейное масштабирование x из диапазона [min_val, max_val] в Q16.16 [0, 65536)

    -

    Definition at line 68 of file evolve_optimizer.h.

    +

    Definition at line 71 of file evolve_optimizer.h.

    @@ -238,19 +244,41 @@ Functions

    Обратное линейное масштабирование Q16.16 значения в диапазон [min_val, max_val].

    -

    Definition at line 74 of file evolve_optimizer.h.

    +

    Definition at line 77 of file evolve_optimizer.h.

    -

    Function Documentation

    - -

    ◆ EvolveOptimizer_Init()

    + +

    ◆ local_time

    - + + + + + +
    __STATIC_INLINE void EvolveOptimizer_Init #define local_time()
    +
    +Value:
    HAL_GetTick()
    +
    +

    Локальное время

    + +

    Definition at line 81 of file evolve_optimizer.h.

    + +
    +
    +

    Function Documentation

    + +

    ◆ EvolveOptimizer_Init()

    + +
    +
    + + + @@ -294,19 +322,20 @@ Functions
    __STATIC_INLINE int EvolveOptimizer_Init ( EvolveOptimizer_t * opt,
    +
    Returns
    0 — если окей, -1 — если ошибка
    -

    Definition at line 101 of file evolve_optimizer.h.

    +

    Definition at line 132 of file evolve_optimizer.h.

    - -

    ◆ EvolveOptimizer_Step()

    + +

    ◆ EvolveOptimizer_Step()

    - + @@ -328,14 +357,15 @@ Functions
    __STATIC_INLINE void EvolveOptimizer_Step __STATIC_INLINE int EvolveOptimizer_Step ( EvolveOptimizer_t * opt,
    - +
    optУказатель на структуру оптимизатора
    paramsМассив параметров, которые будут обновлены (на выходе — новые параметры)
    lossLoss текущего кандидата (Q16.16)
    lossLoss текущего кандидата (Q16.16)
    +
    Returns
    0 — если окей, -1 — если ошибка

    Сохраняет loss текущего кандидата и формирует параметры следующего кандидата. Если накоплено n_cand кандидатов, генерируется новое поколение. Новое поколение формируется случайным выбором из n_best лучших с добавлением мутации.

    -

    На выходе params содержит параметры следующего кандидата для измерений.

    +

    На выходе params содержит параметры следующего кандидата для измерений.

    Note
    Функция использует глобальную внутреннюю переменную для сортировки. Надо убедится что только один экземпляр функции запущен в момент времени
    -

    Definition at line 137 of file evolve_optimizer.h.

    +

    Definition at line 187 of file evolve_optimizer.h.

    diff --git a/Doc/html/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.js b/Doc/html/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.js index 70ed915..701b377 100644 --- a/Doc/html/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.js +++ b/Doc/html/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.js @@ -7,10 +7,12 @@ var group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r = [ "iq_mutation", "struct_evolve_optimizer__t.html#a5391277564b54e2271856a2466033df5", null ], [ "cand_index", "struct_evolve_optimizer__t.html#a0ae0e63ba351335d4445d927991c64ae", null ], [ "loss", "struct_evolve_optimizer__t.html#ac723b265a3d43b754489f14310314f0d", null ], - [ "candidates", "struct_evolve_optimizer__t.html#a61bd0c8ae322a79936ba1f2ae22e0e0d", null ] + [ "candidates", "struct_evolve_optimizer__t.html#a61bd0c8ae322a79936ba1f2ae22e0e0d", null ], + [ "sorted_idx", "struct_evolve_optimizer__t.html#a74b81df1c298c99162310f3f7d91735a", null ] ] ], [ "PARAM_SCALE_Q16", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gaff223481fcffea77394a331afde29fdc", null ], [ "PARAM_UNSCALE_Q16", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga71a0c240c667e976d9caef391ab767ba", null ], - [ "EvolveOptimizer_Init", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gac21587fe68fe3635525358ac3f4059d9", null ], - [ "EvolveOptimizer_Step", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga1ba2fa963c9ae12625be1b7c20718563", null ] + [ "local_time", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga9c853b02c22f26023c34d1d404b6d653", null ], + [ "EvolveOptimizer_Init", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gadaf3a90724197e1737d5c70c7bcc75e1", null ], + [ "EvolveOptimizer_Step", "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga75acd71c85d4e60dc0eb31bc5780086a", null ] ]; \ No newline at end of file diff --git a/Doc/html/group___t_r_a_c_e___g_p_i_o.html b/Doc/html/group___t_r_a_c_e___g_p_i_o.html index 750167e..8c0129f 100644 --- a/Doc/html/group___t_r_a_c_e___g_p_i_o.html +++ b/Doc/html/group___t_r_a_c_e___g_p_i_o.html @@ -162,7 +162,7 @@ Macros
  • GPIO_TRACE_ENABLE определён - устанавливает бит сброса через BSRR ((pin)<<16)
  • -

    Definition at line 138 of file trace.h.

    +

    Definition at line 142 of file trace.h.

    @@ -199,7 +199,7 @@ Macros
  • GPIO_TRACE_ENABLE определён - устанавливает бит установки через BSRR (pin)
  • -

    Definition at line 137 of file trace.h.

    +

    Definition at line 141 of file trace.h.

    diff --git a/Doc/html/group___t_r_a_c_e___h_a_r_d_f_a_u_l_t.html b/Doc/html/group___t_r_a_c_e___h_a_r_d_f_a_u_l_t.html index 4a44208..3a31782 100644 --- a/Doc/html/group___t_r_a_c_e___h_a_r_d_f_a_u_l_t.html +++ b/Doc/html/group___t_r_a_c_e___h_a_r_d_f_a_u_l_t.html @@ -140,7 +140,19 @@ Functions
  • Для восстановления последнего HardFault используется HF_CheckRecovered(), который:
    1. Читает запись во Flash по базовому тегу.
    2. Выводит сохранённый RTT буфер и контекст регистров.
    3. -
    4. Опционально стирает Flash после восстановления.
      void Hardfault()
      +
    5. Опционально стирает Flash после восстановления.
    6. +
    +
  • + +

    Параметры:

    +
    void Hardfault()
    {
    NVIC_SystemReset();
    @@ -154,14 +166,10 @@ Functions
    RTT_EraseFlash(); // erase rtt flash after message readed
    }
    }
    -
    __STATIC_FORCEINLINE int HF_CheckRecovered(int erase)
    Проверка и вывод последнего HardFault-трейса из Flash.
    Definition trace.h:464
    -
    __STATIC_FORCEINLINE void HF_HandleFault(void)
    Обработчик HardFault.
    Definition trace.h:505
    -
    __STATIC_FORCEINLINE int RTT_EraseFlash(void)
    Стирание сектора Flash с RTT-буфером
    Definition trace.h:363
    -
    - - - -

    Function Documentation

    +
    __STATIC_FORCEINLINE int HF_CheckRecovered(int erase)
    Проверка и вывод последнего HardFault-трейса из Flash.
    Definition trace.h:486
    +
    __STATIC_FORCEINLINE void HF_HandleFault(void)
    Обработчик HardFault.
    Definition trace.h:527
    +
    __STATIC_FORCEINLINE int RTT_EraseFlash(void)
    Стирание сектора Flash с RTT-буфером
    Definition trace.h:375
    +

    Function Documentation

    ◆ HF_CheckRecovered()

    @@ -186,7 +194,7 @@ Functions
    Note
    Вызов рекомендуется при инициализации приложения для анализа предыдущего сбоя.
    -

    Definition at line 464 of file trace.h.

    +

    Definition at line 486 of file trace.h.

    @@ -216,7 +224,7 @@ Functions
    Note
    Функция защищена, так как вызывается в контексте сбоя — минимизирует использование вызовов HAL.
    -

    Definition at line 505 of file trace.h.

    +

    Definition at line 527 of file trace.h.

    diff --git a/Doc/html/group___t_r_a_c_e___r_t_t___f_l_a_s_h.html b/Doc/html/group___t_r_a_c_e___r_t_t___f_l_a_s_h.html index 8cbfe53..07f8f9d 100644 --- a/Doc/html/group___t_r_a_c_e___r_t_t___f_l_a_s_h.html +++ b/Doc/html/group___t_r_a_c_e___r_t_t___f_l_a_s_h.html @@ -142,7 +142,14 @@ Functions если слот с таким тегом уже занят, запись не выполняется.
  • Автоинкремент позволяет хранить несколько последовательных записей в пределах одного базового тега,
    - без необходимости вручную отслеживать адреса Flash или позиции буферов.
  • + без необходимости вручную отслеживать адреса Flash или позиции буферов.
    + + +

    Параметры:

    Function Documentation

    @@ -163,7 +170,7 @@ Functions

    Подготовка Flash к записи

    Сбрасывает ошибки Flash и ожидает готовности перед записью

    -

    Definition at line 179 of file trace.h.

    +

    Definition at line 190 of file trace.h.

    @@ -201,7 +208,7 @@ Functions
  • Если конкретный (младший байт != 0) — запись выполняется только с этим тегом, иначе ошибка.
  • -

    Definition at line 202 of file trace.h.

    +

    Definition at line 214 of file trace.h.

    @@ -250,7 +257,7 @@ Functions
  • Если конкретный (младший байт != 0) — прочитывается именно эта запись.
  • -

    Definition at line 299 of file trace.h.

    +

    Definition at line 311 of file trace.h.

    @@ -271,7 +278,7 @@ Functions

    Стирание сектора Flash с RTT-буфером

    -

    Definition at line 363 of file trace.h.

    +

    Definition at line 375 of file trace.h.

    diff --git a/Doc/html/group___t_r_a_c_e___s_e_r_i_a_l.html b/Doc/html/group___t_r_a_c_e___s_e_r_i_a_l.html index 136bbf1..77f3ffd 100644 --- a/Doc/html/group___t_r_a_c_e___s_e_r_i_a_l.html +++ b/Doc/html/group___t_r_a_c_e___s_e_r_i_a_l.html @@ -123,9 +123,10 @@ Macros

    Detailed Description

    Дефайны для работы с serial трассировкой (SWO, RTT)

    -

    Определяется дефайн my_printf() и log_printf() для работы с serial трассировкой:

    Macro Definition Documentation

    @@ -165,7 +164,7 @@ Macros
  • NO_TRACE - пустой макрос
  • -

    Definition at line 67 of file trace.h.

    +

    Definition at line 71 of file trace.h.

    @@ -194,7 +193,7 @@ Macros
    Value:
    my_printf("\n[%lu] [%s] " fmt, \
    (unsigned long)uwTick, TAG, ##__VA_ARGS__)
    -
    #define my_printf(...)
    Универсальный макрос для вывода трассировки
    Definition trace.h:67
    +
    #define my_printf(...)
    Универсальный макрос для вывода трассировки
    Definition trace.h:71

    Макрос логирования с поддержкой уровней LOG_LEVEL.

    Parameters
    @@ -210,7 +209,7 @@ Macros
  • LOG_LEVEL >= 2 - выводится время, TAG, имя файла и номер строки
  • -

    Definition at line 92 of file trace.h.

    +

    Definition at line 96 of file trace.h.

    diff --git a/Doc/html/group___t_r_a_c_k_e_r_s.html b/Doc/html/group___t_r_a_c_k_e_r_s.html index 70836c7..66db708 100644 --- a/Doc/html/group___t_r_a_c_k_e_r_s.html +++ b/Doc/html/group___t_r_a_c_k_e_r_s.html @@ -167,8 +167,10 @@ Macros
  • user[num_user_vars]
    Также есть ряд функций (дефайнов) для обращения к элементам этой структуры.
  • -

    Если трекеры TRACKERS_ENABLE отключены, то все дефайны определяются как ничего и на производительность кода не влияют
    -

    +

    Параметры для конфигурации:

    Пример:

    Определяем typedef трекера измерений Measure_TrackerTypeDef

      typedef TrackerTypeDef(MEASURE_USER_VARS_NUMB) Measure_TrackerTypeDef;
    @@ -232,7 +234,7 @@ Macros
     

    Содержит счетчик для успешных событый (cnt_ok), счетчик для ошибок (cnt_err), счетчик для предупреждений (cnt_warn).

    Также есть возможность объявить пользовательские переменные в количестве <num_user_vars> штук.

    -

    Definition at line 69 of file trackers.h.

    +

    Definition at line 70 of file trackers.h.

    @@ -254,7 +256,7 @@ Macros

    Получить количетство пользовательских переменных

    -

    Definition at line 79 of file trackers.h.

    +

    Definition at line 80 of file trackers.h.

    @@ -277,11 +279,11 @@ Macros
    Value:
    ((_uservarnumb_) < num_of_usercnts((_cntstruct_).user))
    -
    #define num_of_usercnts(_user_)
    Получить количетство пользовательских переменных
    Definition trackers.h:79
    +
    #define num_of_usercnts(_user_)
    Получить количетство пользовательских переменных
    Definition trackers.h:80

    Проверка существует ли указанная пользовательская переменная

    -

    Definition at line 81 of file trackers.h.

    +

    Definition at line 82 of file trackers.h.

    @@ -304,11 +306,11 @@ Macros
    Value:
    if(assert_usertracker(_cntstruct_, _uservarnumb_))
    -
    #define assert_usertracker(_cntstruct_, _uservarnumb_)
    Проверка существует ли указанная пользовательская переменная
    Definition trackers.h:81
    +
    #define assert_usertracker(_cntstruct_, _uservarnumb_)
    Проверка существует ли указанная пользовательская переменная
    Definition trackers.h:82

    Условие для проверки существует ли указанная пользовательская переменная

    -

    Definition at line 83 of file trackers.h.

    +

    Definition at line 84 of file trackers.h.

    @@ -334,7 +336,7 @@ Macros

    Тернарный оператор для проверки существует ли указанная пользовательская переменная

    -

    Definition at line 85 of file trackers.h.

    +

    Definition at line 86 of file trackers.h.

    @@ -356,7 +358,7 @@ Macros

    Считать счетчик успешных событий

    -

    Definition at line 89 of file trackers.h.

    +

    Definition at line 90 of file trackers.h.

    @@ -378,7 +380,7 @@ Macros

    Считать счетчик ошибок

    -

    Definition at line 91 of file trackers.h.

    +

    Definition at line 92 of file trackers.h.

    @@ -400,7 +402,7 @@ Macros

    Считать счетчик предупреждений

    -

    Definition at line 93 of file trackers.h.

    +

    Definition at line 94 of file trackers.h.

    @@ -423,7 +425,7 @@ Macros
    Value:
    (_cntstruct_).user[tern_assert_usertracker(_cntstruct_, _uservarnumb_)]
    -
    #define tern_assert_usertracker(_cntstruct_, _uservarnumb_)
    Тернарный оператор для проверки существует ли указанная пользовательская переменная
    Definition trackers.h:85
    +
    #define tern_assert_usertracker(_cntstruct_, _uservarnumb_)
    Тернарный оператор для проверки существует ли указанная пользовательская переменная
    Definition trackers.h:86

    Считать пользовательскую переменную

    Note
    Здесь нет проверки - существует ли пользовательская переменная! Есть возможность выйти за границы структуры!!! Чтобы этого избежать можно использовать дефайн #ref assert_usertracker()
      if(assert_usertracker(struct, 0)) {
    @@ -431,7 +433,7 @@ Macros
       }
     
    -

    Definition at line 105 of file trackers.h.

    +

    Definition at line 106 of file trackers.h.

    @@ -453,7 +455,7 @@ Macros

    Инкрементирование счетчика успешных событий

    -

    Definition at line 110 of file trackers.h.

    +

    Definition at line 111 of file trackers.h.

    @@ -475,7 +477,7 @@ Macros

    Инкрементирование счетчика ошибок

    -

    Definition at line 112 of file trackers.h.

    +

    Definition at line 113 of file trackers.h.

    @@ -497,7 +499,7 @@ Macros

    Инкрементирование счетчика предупреждений

    -

    Definition at line 114 of file trackers.h.

    +

    Definition at line 115 of file trackers.h.

    @@ -520,11 +522,11 @@ Macros
    Value:
    if_assert_usertracker(_cntstruct_, _uservarnumb_) (_cntstruct_).user[_uservarnumb_]++;
    -
    #define if_assert_usertracker(_cntstruct_, _uservarnumb_)
    Условие для проверки существует ли указанная пользовательская переменная
    Definition trackers.h:83
    +
    #define if_assert_usertracker(_cntstruct_, _uservarnumb_)
    Условие для проверки существует ли указанная пользовательская переменная
    Definition trackers.h:84

    Инкрементирование пользовательской переменной

    -

    Definition at line 116 of file trackers.h.

    +

    Definition at line 117 of file trackers.h.

    @@ -555,7 +557,7 @@ Macros

    Запись числа в пользовательскую переменную

    -

    Definition at line 118 of file trackers.h.

    +

    Definition at line 119 of file trackers.h.

    @@ -577,7 +579,7 @@ Macros

    Очистка всей структуры

    -

    Definition at line 121 of file trackers.h.

    +

    Definition at line 122 of file trackers.h.

    @@ -599,7 +601,7 @@ Macros

    Очистка счетчика успешных событий

    -

    Definition at line 123 of file trackers.h.

    +

    Definition at line 124 of file trackers.h.

    @@ -621,7 +623,7 @@ Macros

    Очистка счетчика ошибок

    -

    Definition at line 125 of file trackers.h.

    +

    Definition at line 126 of file trackers.h.

    @@ -643,7 +645,7 @@ Macros

    Очистка счетчика предупреждений

    -

    Definition at line 127 of file trackers.h.

    +

    Definition at line 128 of file trackers.h.

    @@ -669,7 +671,7 @@ Macros

    Очистка пользовательской переменной

    -

    Definition at line 129 of file trackers.h.

    +

    Definition at line 130 of file trackers.h.

    @@ -691,7 +693,7 @@ Macros

    Очистка всех пользовательских переменных

    -

    Definition at line 131 of file trackers.h.

    +

    Definition at line 132 of file trackers.h.

    diff --git a/Doc/html/mylibs__include_8h_source.html b/Doc/html/mylibs__include_8h_source.html index 4b13774..fb84a65 100644 --- a/Doc/html/mylibs__include_8h_source.html +++ b/Doc/html/mylibs__include_8h_source.html @@ -230,7 +230,7 @@ $(function(){initNavTree('mylibs__include_8h_source.html','',''); });
    Заголовочный файл для модуля инициализации портов и работы с ними.
    Заголовочный файл для модуля инициализации таймеров и работы с ними.
    Заголочный файл для дефайнов библиотеки MyLibsGeneral.
    -
    Структура эволюционного оптимизатора
    +
    Структура эволюционного оптимизатора
    Заголочный файл для работы с трассировкой.
    Заголочный файл для работы с трекерами Trackers defines.
    diff --git a/Doc/html/navtreedata.js b/Doc/html/navtreedata.js index 2fdddcb..ea6eff0 100644 --- a/Doc/html/navtreedata.js +++ b/Doc/html/navtreedata.js @@ -64,7 +64,7 @@ var NAVTREE = var NAVTREEINDEX = [ "____general__flash_8c_source.html", -"struct_t_i_m___encoder_type_def.html#a4fc05ef011205a6702cb3d006bab677e" +"struct_t_i_m___encoder_type_def.html#a021f0c585e9e62d68a4b09f630d8b6e5" ]; var SYNCONMSG = 'click to disable panel synchronization'; diff --git a/Doc/html/navtreeindex0.js b/Doc/html/navtreeindex0.js index e45e5a6..cdd7a2d 100644 --- a/Doc/html/navtreeindex0.js +++ b/Doc/html/navtreeindex0.js @@ -53,9 +53,10 @@ var NAVTREEINDEX0 = "group___e_v_o_l_v_e___c_o_n_f_i_g.html#ga7c1396e5c95c766afccdb45cbfcf5971":[1,0,0,1,2], "group___e_v_o_l_v_e___c_o_n_f_i_g.html#ga80d6162495fc3776d8902610657d4fee":[1,0,0,1,1], "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html":[1,0,1,1], -"group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga1ba2fa963c9ae12625be1b7c20718563":[1,0,1,1,4], "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga71a0c240c667e976d9caef391ab767ba":[1,0,1,1,2], -"group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gac21587fe68fe3635525358ac3f4059d9":[1,0,1,1,3], +"group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga75acd71c85d4e60dc0eb31bc5780086a":[1,0,1,1,5], +"group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga9c853b02c22f26023c34d1d404b6d653":[1,0,1,1,3], +"group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gadaf3a90724197e1737d5c70c7bcc75e1":[1,0,1,1,4], "group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gaff223481fcffea77394a331afde29fdc":[1,0,1,1,1], "group___g_p_i_o___i_n_i_t.html":[1,0,2,0,0,0], "group___g_p_i_o___i_n_i_t.html#ga19d9e3aced311179a2914e0c9b13d0f9":[1,0,2,0,0,0,3], @@ -218,6 +219,7 @@ var NAVTREEINDEX0 = "struct_evolve_optimizer__t.html#a1c270fce82e0c97e6c88fd0971c1eed8":[1,0,1,1,0,0], "struct_evolve_optimizer__t.html#a5391277564b54e2271856a2466033df5":[1,0,1,1,0,3], "struct_evolve_optimizer__t.html#a61bd0c8ae322a79936ba1f2ae22e0e0d":[1,0,1,1,0,6], +"struct_evolve_optimizer__t.html#a74b81df1c298c99162310f3f7d91735a":[1,0,1,1,0,7], "struct_evolve_optimizer__t.html#a950cd70cb6bff33b78ad35ee58c729a6":[1,0,1,1,0,2], "struct_evolve_optimizer__t.html#ac35c7ca8cede4ab9c53a2845a91cd1b1":[1,0,1,1,0,1], "struct_evolve_optimizer__t.html#ac723b265a3d43b754489f14310314f0d":[1,0,1,1,0,5], @@ -247,7 +249,5 @@ var NAVTREEINDEX0 = "struct_r_t_t___flash_header__t.html#ae7276198385c8d6f6508f433d042d52a":[1,0,1,5,2,0,2], "struct_r_t_t___flash_header__t.html#afd1a5c51af6f97d170c2ccbbe3e34699":[1,0,1,5,2,0,1], "struct_s_p_i___settings_type_def.html":[2,0,5], -"struct_t_i_m___encoder_type_def.html":[1,0,2,1,1,0], -"struct_t_i_m___encoder_type_def.html#a021f0c585e9e62d68a4b09f630d8b6e5":[1,0,2,1,1,0,3], -"struct_t_i_m___encoder_type_def.html#a0dacce3dde7df3122583869d96a372a2":[1,0,2,1,1,0,1] +"struct_t_i_m___encoder_type_def.html":[1,0,2,1,1,0] }; diff --git a/Doc/html/navtreeindex1.js b/Doc/html/navtreeindex1.js index b781f2a..09a6155 100644 --- a/Doc/html/navtreeindex1.js +++ b/Doc/html/navtreeindex1.js @@ -1,5 +1,7 @@ var NAVTREEINDEX1 = { +"struct_t_i_m___encoder_type_def.html#a021f0c585e9e62d68a4b09f630d8b6e5":[1,0,2,1,1,0,3], +"struct_t_i_m___encoder_type_def.html#a0dacce3dde7df3122583869d96a372a2":[1,0,2,1,1,0,1], "struct_t_i_m___encoder_type_def.html#a4fc05ef011205a6702cb3d006bab677e":[1,0,2,1,1,0,5], "struct_t_i_m___encoder_type_def.html#a67ad037b92162546763fc9c425b5e3c5":[1,0,2,1,1,0,6], "struct_t_i_m___encoder_type_def.html#a6973108a83d2a3ea4fc3e0e8a501af80":[1,0,2,1,1,0,7], diff --git a/Doc/html/search/all_4.js b/Doc/html/search/all_4.js index ac3a9dc..004dfd2 100644 --- a/Doc/html/search/all_4.js +++ b/Doc/html/search/all_4.js @@ -10,7 +10,7 @@ var searchData= ['evolve_5fmax_5fcandidates_7',['EVOLVE_MAX_CANDIDATES',['../group___e_v_o_l_v_e___c_o_n_f_i_g.html#ga7c1396e5c95c766afccdb45cbfcf5971',1,'mylibs_config.h']]], ['evolve_5fmax_5fparams_8',['EVOLVE_MAX_PARAMS',['../group___e_v_o_l_v_e___c_o_n_f_i_g.html#ga80d6162495fc3776d8902610657d4fee',1,'mylibs_config.h']]], ['evolve_5foptimizer_2eh_9',['evolve_optimizer.h',['../evolve__optimizer_8h.html',1,'']]], - ['evolveoptimizer_5finit_10',['EvolveOptimizer_Init',['../group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gac21587fe68fe3635525358ac3f4059d9',1,'evolve_optimizer.h']]], - ['evolveoptimizer_5fstep_11',['EvolveOptimizer_Step',['../group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga1ba2fa963c9ae12625be1b7c20718563',1,'evolve_optimizer.h']]], + ['evolveoptimizer_5finit_10',['EvolveOptimizer_Init',['../group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gadaf3a90724197e1737d5c70c7bcc75e1',1,'evolve_optimizer.h']]], + ['evolveoptimizer_5fstep_11',['EvolveOptimizer_Step',['../group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga75acd71c85d4e60dc0eb31bc5780086a',1,'evolve_optimizer.h']]], ['evolveoptimizer_5ft_12',['EvolveOptimizer_t',['../struct_evolve_optimizer__t.html',1,'']]] ]; diff --git a/Doc/html/search/all_9.js b/Doc/html/search/all_9.js index c3193f7..d707ae3 100644 --- a/Doc/html/search/all_9.js +++ b/Doc/html/search/all_9.js @@ -14,8 +14,9 @@ var searchData= ['led_5fpwm_5fticks_11',['LED_PWM_TICKS',['../group___g_p_i_o___i_n_i_t.html#ga1d42e219765ec526d99e306638ac0023',1,'general_gpio.h']]], ['libraries_20configs_12',['Libraries configs',['../group___l_i_b_s___c_o_n_f_i_g.html',1,'']]], ['libs_13',['My Libs',['../group___m_y_l_i_b_s___a_l_l.html',1,'']]], - ['log_5flevel_14',['LOG_LEVEL',['../group___t_r_a_c_e___c_o_n_f_i_g.html#ga0b87e0d3bf5853bcbb0b66a7c48fdc05',1,'mylibs_config.h']]], - ['log_5fprintf_15',['log_printf',['../group___t_r_a_c_e___s_e_r_i_a_l.html#ga730fb7b8d0bbb348dca73c15bd0e0b26',1,'trace.h']]], - ['loss_16',['loss',['../struct_evolve_optimizer__t.html#ac723b265a3d43b754489f14310314f0d',1,'EvolveOptimizer_t']]], - ['lr_17',['lr',['../struct_h_f___stack_frame__t.html#a6e51904297f7725e96d5b5fb291ef577',1,'HF_StackFrame_t']]] + ['local_5ftime_14',['local_time',['../group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga9c853b02c22f26023c34d1d404b6d653',1,'evolve_optimizer.h']]], + ['log_5flevel_15',['LOG_LEVEL',['../group___t_r_a_c_e___c_o_n_f_i_g.html#ga0b87e0d3bf5853bcbb0b66a7c48fdc05',1,'mylibs_config.h']]], + ['log_5fprintf_16',['log_printf',['../group___t_r_a_c_e___s_e_r_i_a_l.html#ga730fb7b8d0bbb348dca73c15bd0e0b26',1,'trace.h']]], + ['loss_17',['loss',['../struct_evolve_optimizer__t.html#ac723b265a3d43b754489f14310314f0d',1,'EvolveOptimizer_t']]], + ['lr_18',['lr',['../struct_h_f___stack_frame__t.html#a6e51904297f7725e96d5b5fb291ef577',1,'HF_StackFrame_t']]] ]; diff --git a/Doc/html/search/all_f.js b/Doc/html/search/all_f.js index 8a01509..9761998 100644 --- a/Doc/html/search/all_f.js +++ b/Doc/html/search/all_f.js @@ -7,22 +7,23 @@ var searchData= ['serial_5ftrace_5fenable_4',['SERIAL_TRACE_ENABLE',['../group___t_r_a_c_e___c_o_n_f_i_g.html#ga76936505ca200d2e61226b7ba68f27c6',1,'mylibs_config.h']]], ['size_5',['size',['../struct_r_t_t___flash_header__t.html#afd1a5c51af6f97d170c2ccbbe3e34699',1,'RTT_FlashHeader_t']]], ['smasterconfig_6',['sMasterConfig',['../struct_t_i_m___settings_type_def.html#a2d9d277dd395424b964445ec1bc65b21',1,'TIM_SettingsTypeDef']]], - ['spi_5fsettingstypedef_7',['SPI_SettingsTypeDef',['../struct_s_p_i___settings_type_def.html',1,'']]], - ['sslaveconfig_8',['sSlaveConfig',['../struct_t_i_m___settings_type_def.html#a9694cf0910a69d48ff94f8aeac106969',1,'TIM_SettingsTypeDef']]], - ['state_9',['state',['../struct_g_p_i_o___l_e_d_type_def.html#ad28d93023a00e3c5669bd3deda122435',1,'GPIO_LEDTypeDef']]], - ['stickbaseprescaler_10',['sTickBasePrescaler',['../struct_t_i_m___settings_type_def.html#a11151fe125960cb8e61328ffd06b7718',1,'TIM_SettingsTypeDef']]], - ['stickbaseus_11',['sTickBaseUS',['../struct_t_i_m___settings_type_def.html#a58da1b4c0f6d12d7d9fb2f170b9b9e6e',1,'TIM_SettingsTypeDef']]], - ['stimahbfreqmhz_12',['sTimAHBFreqMHz',['../struct_t_i_m___settings_type_def.html#a7073358fd3a722687eb85238ab570014',1,'TIM_SettingsTypeDef']]], - ['stimfreqhz_13',['sTimFreqHz',['../struct_t_i_m___settings_type_def.html#af6057ff3f60f5e01b41d4a347b79a5e4',1,'TIM_SettingsTypeDef']]], - ['stimmode_14',['sTimMode',['../struct_t_i_m___settings_type_def.html#ab90e370c3edda88e76583293c250d2b0',1,'TIM_SettingsTypeDef']]], - ['sw_15',['Sw',['../struct_t_i_m___encoder_type_def.html#a99295760ff8b27d1e6f1710f29383a45',1,'TIM_EncoderTypeDef']]], - ['sw_5factivelvl_16',['Sw_ActiveLvl',['../struct_g_p_i_o___switch_type_def.html#a4fadf5ead3ebccad521a52c064eeb405',1,'GPIO_SwitchTypeDef']]], - ['sw_5ffilterdelay_17',['Sw_FilterDelay',['../struct_g_p_i_o___switch_type_def.html#a2600e599a961af2e280c721894df4c06',1,'GPIO_SwitchTypeDef']]], - ['sw_5foff_18',['SW_OFF',['../group___g_p_i_o___i_n_i_t.html#gacd8900c9ec0efde1da3253b718574067',1,'general_gpio.h']]], - ['sw_5fon_19',['SW_ON',['../group___g_p_i_o___i_n_i_t.html#ga19d9e3aced311179a2914e0c9b13d0f9',1,'general_gpio.h']]], - ['sw_5fpin_20',['Sw_Pin',['../struct_g_p_i_o___switch_type_def.html#a63d58d9cba49a5823175585ef2996032',1,'GPIO_SwitchTypeDef']]], - ['sw_5fport_21',['Sw_Port',['../struct_g_p_i_o___switch_type_def.html#afb369df75a6065fd89ac4ba97d98ab1a',1,'GPIO_SwitchTypeDef']]], - ['sw_5fprevstate_22',['Sw_PrevState',['../struct_g_p_i_o___switch_type_def.html#a245f1dc811279ce5d4598582db979a89',1,'GPIO_SwitchTypeDef']]], - ['switch_20tools_23',['Switch tools',['../group___m_y_l_i_b_s___g_p_i_o___s_w_i_t_c_h.html',1,'']]], - ['swo_5ftrace_5fenable_24',['SWO_TRACE_ENABLE',['../group___t_r_a_c_e___c_o_n_f_i_g.html#gab8db9704b5d11858aa879689b9d36336',1,'mylibs_config.h']]] + ['sorted_5fidx_7',['sorted_idx',['../struct_evolve_optimizer__t.html#a74b81df1c298c99162310f3f7d91735a',1,'EvolveOptimizer_t']]], + ['spi_5fsettingstypedef_8',['SPI_SettingsTypeDef',['../struct_s_p_i___settings_type_def.html',1,'']]], + ['sslaveconfig_9',['sSlaveConfig',['../struct_t_i_m___settings_type_def.html#a9694cf0910a69d48ff94f8aeac106969',1,'TIM_SettingsTypeDef']]], + ['state_10',['state',['../struct_g_p_i_o___l_e_d_type_def.html#ad28d93023a00e3c5669bd3deda122435',1,'GPIO_LEDTypeDef']]], + ['stickbaseprescaler_11',['sTickBasePrescaler',['../struct_t_i_m___settings_type_def.html#a11151fe125960cb8e61328ffd06b7718',1,'TIM_SettingsTypeDef']]], + ['stickbaseus_12',['sTickBaseUS',['../struct_t_i_m___settings_type_def.html#a58da1b4c0f6d12d7d9fb2f170b9b9e6e',1,'TIM_SettingsTypeDef']]], + ['stimahbfreqmhz_13',['sTimAHBFreqMHz',['../struct_t_i_m___settings_type_def.html#a7073358fd3a722687eb85238ab570014',1,'TIM_SettingsTypeDef']]], + ['stimfreqhz_14',['sTimFreqHz',['../struct_t_i_m___settings_type_def.html#af6057ff3f60f5e01b41d4a347b79a5e4',1,'TIM_SettingsTypeDef']]], + ['stimmode_15',['sTimMode',['../struct_t_i_m___settings_type_def.html#ab90e370c3edda88e76583293c250d2b0',1,'TIM_SettingsTypeDef']]], + ['sw_16',['Sw',['../struct_t_i_m___encoder_type_def.html#a99295760ff8b27d1e6f1710f29383a45',1,'TIM_EncoderTypeDef']]], + ['sw_5factivelvl_17',['Sw_ActiveLvl',['../struct_g_p_i_o___switch_type_def.html#a4fadf5ead3ebccad521a52c064eeb405',1,'GPIO_SwitchTypeDef']]], + ['sw_5ffilterdelay_18',['Sw_FilterDelay',['../struct_g_p_i_o___switch_type_def.html#a2600e599a961af2e280c721894df4c06',1,'GPIO_SwitchTypeDef']]], + ['sw_5foff_19',['SW_OFF',['../group___g_p_i_o___i_n_i_t.html#gacd8900c9ec0efde1da3253b718574067',1,'general_gpio.h']]], + ['sw_5fon_20',['SW_ON',['../group___g_p_i_o___i_n_i_t.html#ga19d9e3aced311179a2914e0c9b13d0f9',1,'general_gpio.h']]], + ['sw_5fpin_21',['Sw_Pin',['../struct_g_p_i_o___switch_type_def.html#a63d58d9cba49a5823175585ef2996032',1,'GPIO_SwitchTypeDef']]], + ['sw_5fport_22',['Sw_Port',['../struct_g_p_i_o___switch_type_def.html#afb369df75a6065fd89ac4ba97d98ab1a',1,'GPIO_SwitchTypeDef']]], + ['sw_5fprevstate_23',['Sw_PrevState',['../struct_g_p_i_o___switch_type_def.html#a245f1dc811279ce5d4598582db979a89',1,'GPIO_SwitchTypeDef']]], + ['switch_20tools_24',['Switch tools',['../group___m_y_l_i_b_s___g_p_i_o___s_w_i_t_c_h.html',1,'']]], + ['swo_5ftrace_5fenable_25',['SWO_TRACE_ENABLE',['../group___t_r_a_c_e___c_o_n_f_i_g.html#gab8db9704b5d11858aa879689b9d36336',1,'mylibs_config.h']]] ]; diff --git a/Doc/html/search/functions_0.js b/Doc/html/search/functions_0.js index a560c32..ede5d0f 100644 --- a/Doc/html/search/functions_0.js +++ b/Doc/html/search/functions_0.js @@ -1,5 +1,5 @@ var searchData= [ - ['evolveoptimizer_5finit_0',['EvolveOptimizer_Init',['../group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gac21587fe68fe3635525358ac3f4059d9',1,'evolve_optimizer.h']]], - ['evolveoptimizer_5fstep_1',['EvolveOptimizer_Step',['../group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga1ba2fa963c9ae12625be1b7c20718563',1,'evolve_optimizer.h']]] + ['evolveoptimizer_5finit_0',['EvolveOptimizer_Init',['../group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#gadaf3a90724197e1737d5c70c7bcc75e1',1,'evolve_optimizer.h']]], + ['evolveoptimizer_5fstep_1',['EvolveOptimizer_Step',['../group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.html#ga75acd71c85d4e60dc0eb31bc5780086a',1,'evolve_optimizer.h']]] ]; diff --git a/Doc/html/search/variables_a.js b/Doc/html/search/variables_a.js index 4853f37..188fe02 100644 --- a/Doc/html/search/variables_a.js +++ b/Doc/html/search/variables_a.js @@ -5,17 +5,18 @@ var searchData= ['sconfig_2',['sConfig',['../struct_t_i_m___encoder_type_def.html#a021f0c585e9e62d68a4b09f630d8b6e5',1,'TIM_EncoderTypeDef']]], ['size_3',['size',['../struct_r_t_t___flash_header__t.html#afd1a5c51af6f97d170c2ccbbe3e34699',1,'RTT_FlashHeader_t']]], ['smasterconfig_4',['sMasterConfig',['../struct_t_i_m___settings_type_def.html#a2d9d277dd395424b964445ec1bc65b21',1,'TIM_SettingsTypeDef']]], - ['sslaveconfig_5',['sSlaveConfig',['../struct_t_i_m___settings_type_def.html#a9694cf0910a69d48ff94f8aeac106969',1,'TIM_SettingsTypeDef']]], - ['state_6',['state',['../struct_g_p_i_o___l_e_d_type_def.html#ad28d93023a00e3c5669bd3deda122435',1,'GPIO_LEDTypeDef']]], - ['stickbaseprescaler_7',['sTickBasePrescaler',['../struct_t_i_m___settings_type_def.html#a11151fe125960cb8e61328ffd06b7718',1,'TIM_SettingsTypeDef']]], - ['stickbaseus_8',['sTickBaseUS',['../struct_t_i_m___settings_type_def.html#a58da1b4c0f6d12d7d9fb2f170b9b9e6e',1,'TIM_SettingsTypeDef']]], - ['stimahbfreqmhz_9',['sTimAHBFreqMHz',['../struct_t_i_m___settings_type_def.html#a7073358fd3a722687eb85238ab570014',1,'TIM_SettingsTypeDef']]], - ['stimfreqhz_10',['sTimFreqHz',['../struct_t_i_m___settings_type_def.html#af6057ff3f60f5e01b41d4a347b79a5e4',1,'TIM_SettingsTypeDef']]], - ['stimmode_11',['sTimMode',['../struct_t_i_m___settings_type_def.html#ab90e370c3edda88e76583293c250d2b0',1,'TIM_SettingsTypeDef']]], - ['sw_12',['Sw',['../struct_t_i_m___encoder_type_def.html#a99295760ff8b27d1e6f1710f29383a45',1,'TIM_EncoderTypeDef']]], - ['sw_5factivelvl_13',['Sw_ActiveLvl',['../struct_g_p_i_o___switch_type_def.html#a4fadf5ead3ebccad521a52c064eeb405',1,'GPIO_SwitchTypeDef']]], - ['sw_5ffilterdelay_14',['Sw_FilterDelay',['../struct_g_p_i_o___switch_type_def.html#a2600e599a961af2e280c721894df4c06',1,'GPIO_SwitchTypeDef']]], - ['sw_5fpin_15',['Sw_Pin',['../struct_g_p_i_o___switch_type_def.html#a63d58d9cba49a5823175585ef2996032',1,'GPIO_SwitchTypeDef']]], - ['sw_5fport_16',['Sw_Port',['../struct_g_p_i_o___switch_type_def.html#afb369df75a6065fd89ac4ba97d98ab1a',1,'GPIO_SwitchTypeDef']]], - ['sw_5fprevstate_17',['Sw_PrevState',['../struct_g_p_i_o___switch_type_def.html#a245f1dc811279ce5d4598582db979a89',1,'GPIO_SwitchTypeDef']]] + ['sorted_5fidx_5',['sorted_idx',['../struct_evolve_optimizer__t.html#a74b81df1c298c99162310f3f7d91735a',1,'EvolveOptimizer_t']]], + ['sslaveconfig_6',['sSlaveConfig',['../struct_t_i_m___settings_type_def.html#a9694cf0910a69d48ff94f8aeac106969',1,'TIM_SettingsTypeDef']]], + ['state_7',['state',['../struct_g_p_i_o___l_e_d_type_def.html#ad28d93023a00e3c5669bd3deda122435',1,'GPIO_LEDTypeDef']]], + ['stickbaseprescaler_8',['sTickBasePrescaler',['../struct_t_i_m___settings_type_def.html#a11151fe125960cb8e61328ffd06b7718',1,'TIM_SettingsTypeDef']]], + ['stickbaseus_9',['sTickBaseUS',['../struct_t_i_m___settings_type_def.html#a58da1b4c0f6d12d7d9fb2f170b9b9e6e',1,'TIM_SettingsTypeDef']]], + ['stimahbfreqmhz_10',['sTimAHBFreqMHz',['../struct_t_i_m___settings_type_def.html#a7073358fd3a722687eb85238ab570014',1,'TIM_SettingsTypeDef']]], + ['stimfreqhz_11',['sTimFreqHz',['../struct_t_i_m___settings_type_def.html#af6057ff3f60f5e01b41d4a347b79a5e4',1,'TIM_SettingsTypeDef']]], + ['stimmode_12',['sTimMode',['../struct_t_i_m___settings_type_def.html#ab90e370c3edda88e76583293c250d2b0',1,'TIM_SettingsTypeDef']]], + ['sw_13',['Sw',['../struct_t_i_m___encoder_type_def.html#a99295760ff8b27d1e6f1710f29383a45',1,'TIM_EncoderTypeDef']]], + ['sw_5factivelvl_14',['Sw_ActiveLvl',['../struct_g_p_i_o___switch_type_def.html#a4fadf5ead3ebccad521a52c064eeb405',1,'GPIO_SwitchTypeDef']]], + ['sw_5ffilterdelay_15',['Sw_FilterDelay',['../struct_g_p_i_o___switch_type_def.html#a2600e599a961af2e280c721894df4c06',1,'GPIO_SwitchTypeDef']]], + ['sw_5fpin_16',['Sw_Pin',['../struct_g_p_i_o___switch_type_def.html#a63d58d9cba49a5823175585ef2996032',1,'GPIO_SwitchTypeDef']]], + ['sw_5fport_17',['Sw_Port',['../struct_g_p_i_o___switch_type_def.html#afb369df75a6065fd89ac4ba97d98ab1a',1,'GPIO_SwitchTypeDef']]], + ['sw_5fprevstate_18',['Sw_PrevState',['../struct_g_p_i_o___switch_type_def.html#a245f1dc811279ce5d4598582db979a89',1,'GPIO_SwitchTypeDef']]] ]; diff --git a/Doc/html/struct_evolve_optimizer__t-members.html b/Doc/html/struct_evolve_optimizer__t-members.html index 681531b..8578c3c 100644 --- a/Doc/html/struct_evolve_optimizer__t-members.html +++ b/Doc/html/struct_evolve_optimizer__t-members.html @@ -110,6 +110,7 @@ $(function(){initNavTree('struct_evolve_optimizer__t.html','',''); }); n_bestEvolveOptimizer_t n_candEvolveOptimizer_t n_paramsEvolveOptimizer_t + sorted_idxEvolveOptimizer_t diff --git a/Doc/html/struct_evolve_optimizer__t.html b/Doc/html/struct_evolve_optimizer__t.html index 9263f29..d7f47e8 100644 --- a/Doc/html/struct_evolve_optimizer__t.html +++ b/Doc/html/struct_evolve_optimizer__t.html @@ -122,11 +122,13 @@ Public Attributes  Loss для каждого кандидата
    int32_t candidates [100][20]  Параметры кандидатов
    +uint16_t sorted_idx [100] + Индексы отсортированных кандидатов

    Detailed Description

    Структура эволюционного оптимизатора

    -

    Definition at line 81 of file evolve_optimizer.h.

    +

    Definition at line 87 of file evolve_optimizer.h.

    Member Data Documentation

    ◆ n_params

    @@ -142,7 +144,7 @@ Public Attributes

    Количество параметров

    -

    Definition at line 82 of file evolve_optimizer.h.

    +

    Definition at line 88 of file evolve_optimizer.h.

    @@ -160,7 +162,7 @@ Public Attributes

    Количество кандидатов

    -

    Definition at line 83 of file evolve_optimizer.h.

    +

    Definition at line 89 of file evolve_optimizer.h.

    @@ -178,7 +180,7 @@ Public Attributes

    Количество лучших, усредняемых

    -

    Definition at line 84 of file evolve_optimizer.h.

    +

    Definition at line 90 of file evolve_optimizer.h.

    @@ -196,7 +198,7 @@ Public Attributes

    Амплитуда мутации в Q16.16.

    -

    Definition at line 85 of file evolve_optimizer.h.

    +

    Definition at line 91 of file evolve_optimizer.h.

    @@ -214,7 +216,7 @@ Public Attributes

    Индекс кандидата для обработки

    -

    Definition at line 86 of file evolve_optimizer.h.

    +

    Definition at line 92 of file evolve_optimizer.h.

    @@ -232,7 +234,7 @@ Public Attributes

    Loss для каждого кандидата

    -

    Definition at line 87 of file evolve_optimizer.h.

    +

    Definition at line 93 of file evolve_optimizer.h.

    @@ -250,7 +252,25 @@ Public Attributes

    Параметры кандидатов

    -

    Definition at line 88 of file evolve_optimizer.h.

    +

    Definition at line 94 of file evolve_optimizer.h.

    + + + + +

    ◆ sorted_idx

    + +
    +
    + + + + +
    uint16_t EvolveOptimizer_t::sorted_idx[100]
    +
    + +

    Индексы отсортированных кандидатов

    + +

    Definition at line 95 of file evolve_optimizer.h.

    diff --git a/Doc/html/struct_evolve_optimizer__t.js b/Doc/html/struct_evolve_optimizer__t.js index 9f66374..86e701f 100644 --- a/Doc/html/struct_evolve_optimizer__t.js +++ b/Doc/html/struct_evolve_optimizer__t.js @@ -6,5 +6,6 @@ var struct_evolve_optimizer__t = [ "iq_mutation", "struct_evolve_optimizer__t.html#a5391277564b54e2271856a2466033df5", null ], [ "cand_index", "struct_evolve_optimizer__t.html#a0ae0e63ba351335d4445d927991c64ae", null ], [ "loss", "struct_evolve_optimizer__t.html#ac723b265a3d43b754489f14310314f0d", null ], - [ "candidates", "struct_evolve_optimizer__t.html#a61bd0c8ae322a79936ba1f2ae22e0e0d", null ] + [ "candidates", "struct_evolve_optimizer__t.html#a61bd0c8ae322a79936ba1f2ae22e0e0d", null ], + [ "sorted_idx", "struct_evolve_optimizer__t.html#a74b81df1c298c99162310f3f7d91735a", null ] ]; \ No newline at end of file diff --git a/Doc/html/struct_h_f___stack_frame__t.html b/Doc/html/struct_h_f___stack_frame__t.html index 520e7a8..e7069f8 100644 --- a/Doc/html/struct_h_f___stack_frame__t.html +++ b/Doc/html/struct_h_f___stack_frame__t.html @@ -129,7 +129,7 @@ Public Attributes

    Контекст стек-фрейма процессора при HardFault.

    Сохраняет регистры R0-R3, R12, LR, PC, PSR для последующего анализа.

    -

    Definition at line 441 of file trace.h.

    +

    Definition at line 463 of file trace.h.

    Member Data Documentation

    ◆ r0

    @@ -145,7 +145,7 @@ Public Attributes

    Регистр R0.

    -

    Definition at line 442 of file trace.h.

    +

    Definition at line 464 of file trace.h.

    @@ -163,7 +163,7 @@ Public Attributes

    Регистр R1.

    -

    Definition at line 443 of file trace.h.

    +

    Definition at line 465 of file trace.h.

    @@ -181,7 +181,7 @@ Public Attributes

    Регистр R2.

    -

    Definition at line 444 of file trace.h.

    +

    Definition at line 466 of file trace.h.

    @@ -199,7 +199,7 @@ Public Attributes

    Регистр R3.

    -

    Definition at line 445 of file trace.h.

    +

    Definition at line 467 of file trace.h.

    @@ -217,7 +217,7 @@ Public Attributes

    Регистр R12.

    -

    Definition at line 446 of file trace.h.

    +

    Definition at line 468 of file trace.h.

    @@ -235,7 +235,7 @@ Public Attributes

    Link Register.

    -

    Definition at line 447 of file trace.h.

    +

    Definition at line 469 of file trace.h.

    @@ -253,7 +253,7 @@ Public Attributes

    Program Counter.

    -

    Definition at line 448 of file trace.h.

    +

    Definition at line 470 of file trace.h.

    @@ -271,7 +271,7 @@ Public Attributes

    Program Status Register.

    -

    Definition at line 449 of file trace.h.

    +

    Definition at line 471 of file trace.h.

    diff --git a/Doc/html/struct_r_t_t___flash_header__t.html b/Doc/html/struct_r_t_t___flash_header__t.html index 1abfede..6a18e98 100644 --- a/Doc/html/struct_r_t_t___flash_header__t.html +++ b/Doc/html/struct_r_t_t___flash_header__t.html @@ -118,7 +118,7 @@ Public Attributes

    Detailed Description

    Структура RTT, которая будет положена в Flash.

    -

    Definition at line 169 of file trace.h.

    +

    Definition at line 180 of file trace.h.

    Member Data Documentation

    ◆ tag

    @@ -134,7 +134,7 @@ Public Attributes

    Уникальный идентификатор буфера

    -

    Definition at line 170 of file trace.h.

    +

    Definition at line 181 of file trace.h.

    @@ -152,7 +152,7 @@ Public Attributes

    Размер данных

    -

    Definition at line 171 of file trace.h.

    +

    Definition at line 182 of file trace.h.

    @@ -170,7 +170,7 @@ Public Attributes

    Буфер RTT.

    -

    Definition at line 172 of file trace.h.

    +

    Definition at line 183 of file trace.h.

    diff --git a/Doc/html/trace_8h_source.html b/Doc/html/trace_8h_source.html index 66448f3..668e926 100644 --- a/Doc/html/trace_8h_source.html +++ b/Doc/html/trace_8h_source.html @@ -118,562 +118,584 @@ $(function(){initNavTree('trace_8h_source.html','',''); });
    16 * @addtogroup TRACE_SERIAL Serial trace defines
    17 * @ingroup TRACE
    18 * @brief Дефайны для работы с serial трассировкой (SWO, RTT)
    -
    19 * @details Определяется дефайн @ref my_printf() и @ref log_printf() для работы с serial трассировкой:
    -
    20 - для RTT это будет вызов функции SEGGER_RTT_printf(), с подключением библиотеки SEGGER_RTT.h
    -
    21 - для SWO это будет просто printf()
    -
    22
    -
    23 Но библиотеку STDOUT надо подключить самостоятельно:
    -
    24
    -
    25 @verbatim
    -
    26 Manage Run-Time Environment -> Compiler -> I/O -> STDOUT
    -
    27 @endverbatim
    -
    28
    -
    29 Для SWO также надо включить трассировку:
    -
    30
    -
    31 @verbatim
    -
    32 Options For Target -> Debug -> Debugger Settings
    -
    33 @endverbatim
    -
    34
    -
    35 В вкладке Debug:
    -
    36 - Port = SW
    -
    37 В вкладке Trace:
    -
    38 - Указать Core Clock
    -
    39 - Выставить Trace Port = SWO
    -
    40 - ITM - выбрать нужный порт (для Keil нулевой порт)
    -
    41
    -
    42 - Если трассировка @ref SERIAL_TRACE_ENABLE отключена, то все дефайны определяются как 'ничего'
    -
    43 и на производительность кода не влияют
    -
    44 * @{
    -
    45 *
    -
    46 * @def my_printf(...)
    -
    47 * @brief Универсальный макрос для вывода трассировки
    -
    48 * @details Варианты реализации:
    -
    49 * - RTT_TRACE_ENABLE `SEGGER_RTT_printf(0, ...)`
    -
    50 * - SWO_TRACE_ENABLE - `printf(...)`
    -
    51 * - NO_TRACE - пустой макрос
    -
    52 *
    -
    53 * @def log_printf(TAG, fmt, ...)
    -
    54 * @brief Макрос логирования с поддержкой уровней LOG_LEVEL
    -
    55 * @param TAG Тэг лога
    -
    56 * @param fmt, ... Форматируемая строка
    -
    57 * @details Варианты реализации:
    -
    58 * - LOG_LEVEL == 0 - логирование отключено (макрос пустой)
    -
    59 * - LOG_LEVEL == 1 - выводится время и TAG
    -
    60 * - LOG_LEVEL >= 2 - выводится время, TAG, имя файла и номер строки
    -
    61 */
    -
    62#ifdef SERIAL_TRACE_ENABLE
    -
    63
    -
    64 #if defined(RTT_TRACE_ENABLE)
    -
    65 #undef SWO_TRACE_ENABLE
    -
    66 #include "SEGGER_RTT.h"
    -
    67 #define my_printf(...) SEGGER_RTT_printf(0, __VA_ARGS__)
    -
    68 #elif defined(SWO_TRACE_ENABLE)
    -
    69 #undef RTT_TRACE_ENABLE
    -
    70 #define my_printf(...) printf(__VA_ARGS__)
    -
    71 #else // NO_TRACE
    -
    72 #define my_printf(...)
    -
    73 #warning No trace is selected. Serial debug wont work.
    -
    74 #endif // RTT_TRACE_ENABLE/SWO_TRACE_ENABLE/NO_TRACE
    -
    75#else //SERIAL_TRACE_ENABLE
    -
    76
    -
    77 #define my_printf(...)
    -
    78 #undef RTT_TRACE_ENABLE
    -
    79 #undef SWO_TRACE_ENABLE
    -
    80
    -
    81#endif //SERIAL_TRACE_ENABLE
    -
    82
    -
    83
    -
    84#ifndef LOG_LEVEL
    -
    85#define LOG_LEVEL 1 ///< @brief Уровень логирования (по умолчанию == 1)
    -
    86#endif
    +
    19 * @details В зависимости от настроек определяется дефайн @ref my_printf() и @ref log_printf() для работы с трассировкой:
    +
    20 - @ref SERIAL_TRACE_ENABLE - Если трассировка отключена, то все дефайны определяются как 'ничего'
    +
    21 и на производительность кода не влияют
    +
    22
    +
    23 - @ref RTT_TRACE_ENABLE - для RTT это будет вызов функции SEGGER_RTT_printf(), с подключением библиотеки SEGGER_RTT.h
    +
    24 Предварительно надо подключить библиотеку SEGGER RTT и вызвать функцию SEGGER_RTT_Init()
    +
    25
    +
    26 - @ref SWO_TRACE_ENABLE для SWO это будет просто printf()
    +
    27
    +
    28 Но библиотеку STDOUT надо подключить самостоятельно:
    +
    29
    +
    30 @verbatim
    +
    31 Manage Run-Time Environment -> Compiler -> I/O -> STDOUT
    +
    32 @endverbatim
    +
    33
    +
    34 Для SWO также надо включить трассировку:
    +
    35
    +
    36 @verbatim
    +
    37 Options For Target -> Debug -> Debugger Settings
    +
    38 @endverbatim
    +
    39
    +
    40 В вкладке Debug:
    +
    41 - Port = SW
    +
    42 В вкладке Trace:
    +
    43 - Указать Core Clock
    +
    44 - Выставить Trace Port = SWO
    +
    45 - ITM - выбрать нужный порт (для Keil нулевой порт)
    +
    46
    +
    47
    +
    48 * @{
    +
    49 *
    +
    50 * @def my_printf(...)
    +
    51 * @brief Универсальный макрос для вывода трассировки
    +
    52 * @details Варианты реализации:
    +
    53 * - RTT_TRACE_ENABLE `SEGGER_RTT_printf(0, ...)`
    +
    54 * - SWO_TRACE_ENABLE - `printf(...)`
    +
    55 * - NO_TRACE - пустой макрос
    +
    56 *
    +
    57 * @def log_printf(TAG, fmt, ...)
    +
    58 * @brief Макрос логирования с поддержкой уровней LOG_LEVEL
    +
    59 * @param TAG Тэг лога
    +
    60 * @param fmt, ... Форматируемая строка
    +
    61 * @details Варианты реализации:
    +
    62 * - LOG_LEVEL == 0 - логирование отключено (макрос пустой)
    +
    63 * - LOG_LEVEL == 1 - выводится время и TAG
    +
    64 * - LOG_LEVEL >= 2 - выводится время, TAG, имя файла и номер строки
    +
    65 */
    +
    66#ifdef SERIAL_TRACE_ENABLE
    +
    67
    +
    68 #if defined(RTT_TRACE_ENABLE)
    +
    69 #undef SWO_TRACE_ENABLE
    +
    70 #include "SEGGER_RTT.h"
    +
    71 #define my_printf(...) SEGGER_RTT_printf(0, __VA_ARGS__)
    +
    72 #elif defined(SWO_TRACE_ENABLE)
    +
    73 #undef RTT_TRACE_ENABLE
    +
    74 #define my_printf(...) printf(__VA_ARGS__)
    +
    75 #else // NO_TRACE
    +
    76 #define my_printf(...)
    +
    77 #warning No trace is selected. Serial debug wont work.
    +
    78 #endif // RTT_TRACE_ENABLE/SWO_TRACE_ENABLE/NO_TRACE
    +
    79#else //SERIAL_TRACE_ENABLE
    +
    80
    +
    81 #define my_printf(...)
    +
    82 #undef RTT_TRACE_ENABLE
    +
    83 #undef SWO_TRACE_ENABLE
    +
    84
    +
    85#endif //SERIAL_TRACE_ENABLE
    +
    86
    87
    -
    88#if LOG_LEVEL == 0 // лог отключен
    -
    89 #define \
    -
    90log_printf(TAG, fmt, ...)
    -
    91#elif LOG_LEVEL == 1 // только тэг
    -
    -
    92 #define log_printf(TAG, fmt, ...) \
    -
    93my_printf("\n[%lu] [%s] " fmt, \
    -
    94(unsigned long)uwTick, TAG, ##__VA_ARGS__)
    +
    88#ifndef LOG_LEVEL
    +
    89#define LOG_LEVEL 1 ///< @brief Уровень логирования (по умолчанию == 1)
    +
    90#endif
    +
    91
    +
    92#if LOG_LEVEL == 0 // лог отключен
    +
    93 #define \
    +
    94log_printf(TAG, fmt, ...)
    +
    95#elif LOG_LEVEL == 1 // только тэг
    +
    +
    96 #define log_printf(TAG, fmt, ...) \
    +
    97my_printf("\n[%lu] [%s] " fmt, \
    +
    98(unsigned long)uwTick, TAG, ##__VA_ARGS__)
    -
    95#elif LOG_LEVEL >= 2 // всё
    -
    96 #define log_printf(TAG, fmt, ...) \
    -
    97my_printf("\n[%lu] [%s] (%s:%d) " fmt, \
    -
    98(unsigned long)uwTick, TAG, __FILE__, __LINE__, ##__VA_ARGS__)
    -
    99#endif
    -
    100
    -
    101/** TRACE_SERIAL
    -
    102 * @}
    -
    103 */
    -
    104
    -
    105/**
    -
    106 * @addtogroup TRACE_GPIO GPIO trace defines
    -
    107 * @ingroup TRACE
    -
    108 * @brief Дефайны для работы с GPIO трассировкой
    -
    109 * @details Определяется дефайны для работы с GPIO трассировкой:
    -
    110 - TRACE_GPIO_RESET() - для сброса ножки GPIO (через BSRR)
    -
    111 - TRACE_GPIO_SET() - для выставления ножки GPIO (через BSRR)
    -
    112
    -
    113 - Если трассировка @ref GPIO_TRACE_ENABLE отключена, то все дефайны определяются как 'ничего'
    -
    114 и на производительность кода не влияют
    -
    115 * @{
    -
    116 *
    -
    117 * @def TRACE_GPIO_RESET(_gpio_, _pin_)
    -
    118 * @brief Сбросить указанную ножку GPIO
    -
    119 * @param _gpio_ Указатель на структуру GPIO (напр. GPIOA)
    -
    120 * @param _pin_ Номер ножки (напр. GPIO_PIN_0)
    -
    121 * @details Варианты реализации:
    -
    122 * - GPIO_TRACE_ENABLE не определён - макрос пустой
    -
    123 * - GPIO_TRACE_ENABLE определён - устанавливает бит сброса через BSRR ((_pin_)<<16)
    -
    124 *
    -
    125 * @def TRACE_GPIO_SET(_gpio_, _pin_)
    -
    126 * @brief Установить указанную ножку GPIO
    -
    127 * @param _gpio_ Указатель на структуру GPIO (например GPIOA)
    -
    128 * @param _pin_ Номер ножки (напр. GPIO_PIN_0)
    -
    129 * @details Варианты реализации:
    -
    130 * - GPIO_TRACE_ENABLE не определён - макрос пустой
    -
    131 * - GPIO_TRACE_ENABLE определён - устанавливает бит установки через BSRR (_pin_)
    -
    132 */
    -
    133#ifndef GPIO_TRACE_ENABLE
    -
    134 #define TRACE_GPIO_SET(_gpio_,_pin_)
    -
    135 #define TRACE_GPIO_RESET(_gpio_,_pin_)
    -
    136#else
    -
    137 #define TRACE_GPIO_SET(_gpio_,_pin_) (_gpio_)->BSRR = (((_pin_)))
    -
    138 #define TRACE_GPIO_RESET(_gpio_,_pin_) (_gpio_)->BSRR = ((_pin_)<<16)
    -
    139#endif //GPIO_TRACE_ENABLE
    -
    140
    -
    141
    -
    142/** TRACE_GPIO
    -
    143 * @}
    -
    144 */
    -
    145
    -
    146
    -
    147
    -
    148#if defined(HAL_MODULE_ENABLED) && defined(RTT_TRACE_ENABLE)
    -
    149
    -
    150/**
    -
    151 * @addtogroup TRACE_RTT_FLASH Flash RTT Buffer
    -
    152 * @ingroup TRACE
    -
    153 * @brief Макросы и функции для сохранения/чтения RTT буфера в Flash
    -
    154 * @details Модуль позволяет сохранять данные RTT буфера во Flash и читать их обратно по тегам.
    -
    155 * Теги работают следующим образом:
    -
    156 * - Базовый тег (младший байт = 0): модуль сам выбирает первый свободный слот во Flash;
    -
    157 * новые записи получают автоинкрементированный младший байт тега (от 0x00 до 0xFF).
    -
    158 * - Конкретный тег (младший байт != 0): запись или чтение происходит строго с указанным тегом;
    -
    159 * если слот с таким тегом уже занят, запись не выполняется.
    -
    160 * - Автоинкремент позволяет хранить несколько последовательных записей в пределах одного базового тега,
    -
    161 * без необходимости вручную отслеживать адреса Flash или позиции буферов.
    -
    162 * @{
    -
    163 */
    -
    164
    -
    165
    -
    166/**
    -
    167 * @brief Структура RTT, которая будет положена в Flash
    -
    168 */
    -
    -
    169typedef struct {
    -
    170 uint32_t tag; ///< Уникальный идентификатор буфера
    -
    171 uint32_t size; ///< Размер данных
    -
    172 char data[RTT_FLASH_BUFFER_SIZE]; ///< Буфер RTT
    - +
    99#elif LOG_LEVEL >= 2 // всё
    +
    100 #define log_printf(TAG, fmt, ...) \
    +
    101my_printf("\n[%lu] [%s] (%s:%d) " fmt, \
    +
    102(unsigned long)uwTick, TAG, __FILE__, __LINE__, ##__VA_ARGS__)
    +
    103#endif
    +
    104
    +
    105/** TRACE_SERIAL
    +
    106 * @}
    +
    107 */
    +
    108
    +
    109/**
    +
    110 * @addtogroup TRACE_GPIO GPIO trace defines
    +
    111 * @ingroup TRACE
    +
    112 * @brief Дефайны для работы с GPIO трассировкой
    +
    113 * @details Определяется дефайны для работы с GPIO трассировкой:
    +
    114 - TRACE_GPIO_RESET() - для сброса ножки GPIO (через BSRR)
    +
    115 - TRACE_GPIO_SET() - для выставления ножки GPIO (через BSRR)
    +
    116
    +
    117 - Если трассировка @ref GPIO_TRACE_ENABLE отключена, то все дефайны определяются как 'ничего'
    +
    118 и на производительность кода не влияют
    +
    119 * @{
    +
    120 *
    +
    121 * @def TRACE_GPIO_RESET(_gpio_, _pin_)
    +
    122 * @brief Сбросить указанную ножку GPIO
    +
    123 * @param _gpio_ Указатель на структуру GPIO (напр. GPIOA)
    +
    124 * @param _pin_ Номер ножки (напр. GPIO_PIN_0)
    +
    125 * @details Варианты реализации:
    +
    126 * - GPIO_TRACE_ENABLE не определён - макрос пустой
    +
    127 * - GPIO_TRACE_ENABLE определён - устанавливает бит сброса через BSRR ((_pin_)<<16)
    +
    128 *
    +
    129 * @def TRACE_GPIO_SET(_gpio_, _pin_)
    +
    130 * @brief Установить указанную ножку GPIO
    +
    131 * @param _gpio_ Указатель на структуру GPIO (например GPIOA)
    +
    132 * @param _pin_ Номер ножки (напр. GPIO_PIN_0)
    +
    133 * @details Варианты реализации:
    +
    134 * - GPIO_TRACE_ENABLE не определён - макрос пустой
    +
    135 * - GPIO_TRACE_ENABLE определён - устанавливает бит установки через BSRR (_pin_)
    +
    136 */
    +
    137#ifndef GPIO_TRACE_ENABLE
    +
    138 #define TRACE_GPIO_SET(_gpio_,_pin_)
    +
    139 #define TRACE_GPIO_RESET(_gpio_,_pin_)
    +
    140#else
    +
    141 #define TRACE_GPIO_SET(_gpio_,_pin_) (_gpio_)->BSRR = (((_pin_)))
    +
    142 #define TRACE_GPIO_RESET(_gpio_,_pin_) (_gpio_)->BSRR = ((_pin_)<<16)
    +
    143#endif //GPIO_TRACE_ENABLE
    +
    144
    +
    145
    +
    146/** TRACE_GPIO
    +
    147 * @}
    +
    148 */
    +
    149
    +
    150
    +
    151
    +
    152#if defined(HAL_MODULE_ENABLED) && defined(RTT_TRACE_ENABLE)
    +
    153
    +
    154/**
    +
    155 * @addtogroup TRACE_RTT_FLASH Flash RTT Buffer
    +
    156 * @ingroup TRACE
    +
    157 * @brief Макросы и функции для сохранения/чтения RTT буфера в Flash
    +
    158 * @details Модуль позволяет сохранять данные RTT буфера во Flash и читать их обратно по тегам.
    +
    159 * Теги работают следующим образом:
    +
    160 * - Базовый тег (младший байт = 0): модуль сам выбирает первый свободный слот во Flash;
    +
    161 * новые записи получают автоинкрементированный младший байт тега (от 0x00 до 0xFF).
    +
    162 * - Конкретный тег (младший байт != 0): запись или чтение происходит строго с указанным тегом;
    +
    163 * если слот с таким тегом уже занят, запись не выполняется.
    +
    164 * - Автоинкремент позволяет хранить несколько последовательных записей в пределах одного базового тега,
    +
    165 * без необходимости вручную отслеживать адреса Flash или позиции буферов.
    +
    166 *
    +
    167 * Параметры:
    +
    168 * - @ref RTT_FLASH_BUFFER_SIZE - Размер буфера RTT в Flash
    +
    169 * - @ref RTT_FLASH_SECTOR - Сектор FLASH куда положится RTT буфер
    +
    170 * - @ref RTT_FLASH_SECTOR_START - Начало сектора RTT_FLASH_SECTOR
    +
    171 * - @ref RTT_FLASH_SECTOR_END - Конец сектора RTT_FLASH_SECTOR
    +
    172 *
    +
    173 * @{
    +
    174 */
    +
    175
    +
    176
    +
    177/**
    +
    178 * @brief Структура RTT, которая будет положена в Flash
    +
    179 */
    +
    +
    180typedef struct {
    +
    181 uint32_t tag; ///< Уникальный идентификатор буфера
    +
    182 uint32_t size; ///< Размер данных
    +
    183 char data[RTT_FLASH_BUFFER_SIZE]; ///< Буфер RTT
    +
    -
    174
    -
    175/**
    -
    176 * @brief Подготовка Flash к записи
    -
    177 * @details Сбрасывает ошибки Flash и ожидает готовности перед записью
    -
    178 */
    -
    -
    179__STATIC_FORCEINLINE void RTT_FlashPrepare(void)
    -
    180{
    -
    181 HAL_FLASH_Unlock();
    -
    182 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGSERR | FLASH_FLAG_WRPERR | FLASH_FLAG_OPERR);
    -
    183 while (__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY)) {
    -
    184 __NOP();
    -
    185 }
    -
    186}
    +
    185
    +
    186/**
    +
    187 * @brief Подготовка Flash к записи
    +
    188 * @details Сбрасывает ошибки Flash и ожидает готовности перед записью
    +
    189 */
    +
    +
    190__STATIC_FORCEINLINE void RTT_FlashPrepare(void)
    +
    191{
    +
    192 HAL_FLASH_Unlock();
    +
    193 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGSERR | FLASH_FLAG_WRPERR | FLASH_FLAG_OPERR);
    +
    194 while (__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY)) {
    +
    195 __NOP();
    +
    196 }
    +
    197}
    -
    187
    -
    188/**
    -
    189 * @brief Сохраняет последние символы RTT-буфера в Flash по тегу
    -
    190 * @param tag Базовый или конкретный идентификатор буфера.
    -
    191 * @param tail_size Количество последних символов RTT для копирования
    -
    192 * @param buf_num Указатель на переменную в которую запишется номер буфера для конкретного тега
    -
    193 * @return >=0 — номер буфера (тег) для записи, <0 — ошибка (нет места, тег уже занят, ошибка записи в флеш)
    -
    194 *
    -
    195 * @details Автоматически копирует последние tail_size символов из RTT-буфера
    -
    196 * и записывает их во Flash.
    -
    197 * Тег может быть базовым или конкретным:
    -
    198 * - Если базовый (младший байт == 0) — будет выбран первый свободный слот с автоинкрементом.
    -
    199 * Автоинкремент формируется в пределах от 0x1 до 0xFF
    -
    200 * - Если конкретный (младший байт != 0) — запись выполняется только с этим тегом, иначе ошибка.
    -
    201 */
    -
    -
    202__STATIC_FORCEINLINE int RTT_SaveToFlash(uint32_t tag, uint32_t tail_size)
    -
    203{
    -
    204 if (tag == 0xFFFFFFFF)
    -
    205 return -1; // Неверный тег
    -
    206
    -
    207 SEGGER_RTT_BUFFER_UP *up = &_SEGGER_RTT.aUp[0];
    -
    208 unsigned buf_size = up->SizeOfBuffer;
    -
    209 unsigned wr = up->WrOff;
    -
    210
    -
    211 // Ограничиваем по размеру буфера RTT и RTT_FLASH_BUFFER_SIZE
    -
    212 unsigned n = (tail_size > buf_size) ? buf_size : tail_size;
    -
    213 if (n > RTT_FLASH_BUFFER_SIZE)
    - -
    215
    -
    216 uint32_t addr = RTT_FLASH_SECTOR_START;
    -
    217 RTT_FlashHeader_t *flash_hdr = NULL;
    -
    218 uint32_t base_tag = tag & 0xFFFFFF00;
    -
    219 uint32_t next_tag = (tag & 0xFF) == 0 ? tag + 1 : tag;
    -
    220
    -
    221 // Ищем первый свободный слот, параллельно автоинкрементируем тег
    -
    222 while ((addr + sizeof(RTT_FlashHeader_t)) <= RTT_FLASH_SECTOR_END)
    -
    223 {
    -
    224 flash_hdr = (RTT_FlashHeader_t *)addr;
    -
    225
    -
    226 if (flash_hdr->tag == 0xFFFFFFFF)
    -
    227 break; // Нашли свободное место
    -
    228
    -
    229
    -
    230 if((flash_hdr->tag & 0xFFFFFF00) == base_tag) // выбраный тег
    -
    231 {
    -
    232 if ((tag & 0xFF) == 0) // если он базовый - ищем последний
    -
    233 next_tag = flash_hdr->tag + 1; // автоинкремент
    -
    234 else
    -
    235 if(flash_hdr->tag == tag) // если он конкретный и уже существует - то ошибка
    -
    236 return -1; // конкретный тег уже занят
    -
    237 }
    -
    238
    -
    239
    -
    240 if(next_tag - tag > 0xFF)
    -
    241 return -1; // автоинкремент слишком большой
    -
    242
    -
    243 addr += sizeof(RTT_FlashHeader_t);
    -
    244 }
    -
    245
    -
    246 if ((addr + sizeof(RTT_FlashHeader_t)) > RTT_FLASH_SECTOR_END)
    -
    247 return -1; // Нет свободного места
    -
    248
    -
    249 // Копируем последние n символов из RTT
    -
    250 char temp[RTT_FLASH_BUFFER_SIZE];
    -
    251 unsigned valid_count = 0;
    -
    252
    -
    253 for (unsigned i = 0; i < n; i++)
    -
    254 {
    -
    255 unsigned idx = (wr + buf_size - n + i) % buf_size;
    -
    256 char c = up->pBuffer[idx];
    -
    257 if (c != 0)
    -
    258 temp[valid_count++] = c;
    -
    259 }
    +
    198
    +
    199/**
    +
    200 * @brief Сохраняет последние символы RTT-буфера в Flash по тегу
    +
    201 * @param tag Базовый или конкретный идентификатор буфера.
    +
    202 * @param tail_size Количество последних символов RTT для копирования
    +
    203 * @param buf_num Указатель на переменную в которую запишется номер буфера для конкретного тега
    +
    204 * @return >=0 — номер буфера (тег) для записи, <0 — ошибка (нет места, тег уже занят, ошибка записи в флеш)
    +
    205 *
    +
    206 * @details Автоматически копирует последние tail_size символов из RTT-буфера
    +
    207 * и записывает их во Flash.
    +
    208 * Тег может быть базовым или конкретным:
    +
    209 * - Если базовый (младший байт == 0) — будет выбран первый свободный слот с автоинкрементом.
    +
    210 * Автоинкремент формируется в пределах от 0x1 до 0xFF
    +
    211 * - Если конкретный (младший байт != 0) — запись выполняется только с этим тегом, иначе ошибка.
    +
    212 *
    +
    213 */
    +
    +
    214__STATIC_FORCEINLINE int RTT_SaveToFlash(uint32_t tag, uint32_t tail_size)
    +
    215{
    +
    216 if (tag == 0xFFFFFFFF)
    +
    217 return -1; // Неверный тег
    +
    218
    +
    219 SEGGER_RTT_BUFFER_UP *up = &_SEGGER_RTT.aUp[0];
    +
    220 unsigned buf_size = up->SizeOfBuffer;
    +
    221 unsigned wr = up->WrOff;
    +
    222
    +
    223 // Ограничиваем по размеру буфера RTT и RTT_FLASH_BUFFER_SIZE
    +
    224 unsigned n = (tail_size > buf_size) ? buf_size : tail_size;
    +
    225 if (n > RTT_FLASH_BUFFER_SIZE)
    + +
    227
    +
    228 uint32_t addr = RTT_FLASH_SECTOR_START;
    +
    229 RTT_FlashHeader_t *flash_hdr = NULL;
    +
    230 uint32_t base_tag = tag & 0xFFFFFF00;
    +
    231 uint32_t next_tag = (tag & 0xFF) == 0 ? tag + 1 : tag;
    +
    232
    +
    233 // Ищем первый свободный слот, параллельно автоинкрементируем тег
    +
    234 while ((addr + sizeof(RTT_FlashHeader_t)) <= RTT_FLASH_SECTOR_END)
    +
    235 {
    +
    236 flash_hdr = (RTT_FlashHeader_t *)addr;
    +
    237
    +
    238 if (flash_hdr->tag == 0xFFFFFFFF)
    +
    239 break; // Нашли свободное место
    +
    240
    +
    241
    +
    242 if((flash_hdr->tag & 0xFFFFFF00) == base_tag) // выбраный тег
    +
    243 {
    +
    244 if ((tag & 0xFF) == 0) // если он базовый - ищем последний
    +
    245 next_tag = flash_hdr->tag + 1; // автоинкремент
    +
    246 else
    +
    247 if(flash_hdr->tag == tag) // если он конкретный и уже существует - то ошибка
    +
    248 return -1; // конкретный тег уже занят
    +
    249 }
    +
    250
    +
    251
    +
    252 if(next_tag - tag > 0xFF)
    +
    253 return -1; // автоинкремент слишком большой
    +
    254
    +
    255 addr += sizeof(RTT_FlashHeader_t);
    +
    256 }
    +
    257
    +
    258 if ((addr + sizeof(RTT_FlashHeader_t)) > RTT_FLASH_SECTOR_END)
    +
    259 return -1; // Нет свободного места
    260
    - -
    262
    -
    263 // Формируем структуру в RAM
    -
    264 RTT_FlashHeader_t flash_data;
    -
    265 flash_data.tag = next_tag;
    -
    266 flash_data.size = valid_count;
    -
    267 memcpy(flash_data.data, temp, valid_count);
    -
    268
    -
    269 // Записываем структуру во Flash (по 4 байта)
    -
    270 const uint32_t *p = (const uint32_t *)&flash_data;
    -
    271 for (unsigned i = 0; i < sizeof(RTT_FlashHeader_t) / 4; i++)
    -
    272 {
    -
    273 if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, addr + i * 4, p[i]) != HAL_OK)
    -
    274 return -1;
    -
    275 }
    -
    276
    -
    277 HAL_FLASH_Lock();
    -
    278 __DSB();
    -
    279 __ISB();
    -
    280
    -
    281
    -
    282 return (int)(next_tag&0xFF);
    -
    283}
    +
    261 // Копируем последние n символов из RTT
    +
    262 char temp[RTT_FLASH_BUFFER_SIZE];
    +
    263 unsigned valid_count = 0;
    +
    264
    +
    265 for (unsigned i = 0; i < n; i++)
    +
    266 {
    +
    267 unsigned idx = (wr + buf_size - n + i) % buf_size;
    +
    268 char c = up->pBuffer[idx];
    +
    269 if (c != 0)
    +
    270 temp[valid_count++] = c;
    +
    271 }
    +
    272
    + +
    274
    +
    275 // Формируем структуру в RAM
    +
    276 RTT_FlashHeader_t flash_data;
    +
    277 flash_data.tag = next_tag;
    +
    278 flash_data.size = valid_count;
    +
    279 memcpy(flash_data.data, temp, valid_count);
    +
    280
    +
    281 // Записываем структуру во Flash (по 4 байта)
    +
    282 const uint32_t *p = (const uint32_t *)&flash_data;
    +
    283 for (unsigned i = 0; i < sizeof(RTT_FlashHeader_t) / 4; i++)
    +
    284 {
    +
    285 if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, addr + i * 4, p[i]) != HAL_OK)
    +
    286 return -1;
    +
    287 }
    +
    288
    +
    289 HAL_FLASH_Lock();
    +
    290 __DSB();
    +
    291 __ISB();
    +
    292
    +
    293
    +
    294 return (int)(next_tag&0xFF);
    +
    295}
    -
    284
    -
    285
    -
    286/**
    -
    287 * @brief Читает последние символы RTT-буфера из Flash по тегу
    -
    288 * @param tag Базовый или конкретный идентификатор буфера.
    -
    289 * @param Buffer Буфер назначения для копирования данных
    -
    290 * @param tail_size Количество последних символов, которые нужно прочитать
    -
    291 * @param read_size Количество считанных символов
    -
    292 * @return >=0 — номер буфера (тег) для записи, <0 — ошибка (тег не найден или структура повреждена)
    -
    293 *
    -
    294 * @details Копирует последние tail_size символов из найденной записи Flash в Buffer.
    -
    295 * Тег может быть базовым или конкретным:
    -
    296 * - Если базовый (младший байт == 0) — будет прочитана последняя запись из группы.
    -
    297 * - Если конкретный (младший байт != 0) — прочитывается именно эта запись.
    -
    298 */
    -
    -
    299__STATIC_FORCEINLINE int RTT_ReadFromFlash(uint32_t tag, char *Buffer, uint32_t tail_size, uint32_t *read_size)
    -
    300{
    -
    301 if (!Buffer || tail_size == 0)
    -
    302 return -1; // Неверные параметры
    -
    303
    -
    304 if (tag == 0xFFFFFFFF)
    -
    305 return -1; // Недопустимый тег
    -
    306
    -
    307 uint32_t addr = RTT_FLASH_SECTOR_START;
    -
    308 RTT_FlashHeader_t *flash_hdr = NULL;
    -
    309 RTT_FlashHeader_t *target_hdr = NULL;
    -
    310 uint32_t base_tag = tag & 0xFFFFFF00;
    -
    311
    -
    312 // Поиск записи по тегу
    -
    313 while ((addr + sizeof(RTT_FlashHeader_t)) <= RTT_FLASH_SECTOR_END)
    -
    314 {
    -
    315 flash_hdr = (RTT_FlashHeader_t *)addr;
    -
    316
    -
    317 if (flash_hdr->tag == 0xFFFFFFFF)
    -
    318 break; // Достигнут конец записанных структур
    -
    319
    -
    320 // выбраный тег
    -
    321 if((flash_hdr->tag & 0xFFFFFF00) == base_tag)
    -
    322 {
    -
    323 if ((tag & 0xFF) == 0) // если он базовый - ищем последний
    -
    324 target_hdr = flash_hdr; // сохраняем последний в группе
    -
    325 else
    -
    326 if(flash_hdr->tag == tag) // если он конкретный и найден - берем его
    -
    327 {
    -
    328 target_hdr = flash_hdr;
    -
    329 break; // конкретный тег найден
    -
    330 }
    -
    331 }
    -
    332
    -
    333 addr += sizeof(RTT_FlashHeader_t);
    -
    334 }
    -
    335
    -
    336 if (!target_hdr) return -1; // Тег не найден
    -
    337
    -
    338 // Проверка корректности размера
    -
    339 if (target_hdr->size > RTT_FLASH_BUFFER_SIZE)
    -
    340 return -1; // Повреждённая запись
    -
    341
    -
    342 // Определяем количество читаемых символов
    -
    343 uint32_t n = (tail_size > target_hdr->size) ? target_hdr->size : tail_size;
    -
    344 // Начальная позиция для чтения последних tail_size символов
    -
    345 uint32_t start = target_hdr->size - n;
    -
    346 // Копируем данные из Flash в RAM
    -
    347 memcpy(Buffer, &target_hdr->data[start], n);
    -
    348
    -
    349 if(read_size != NULL)
    -
    350 {
    -
    351 *read_size = n;
    -
    352 }
    +
    296
    +
    297
    +
    298/**
    +
    299 * @brief Читает последние символы RTT-буфера из Flash по тегу
    +
    300 * @param tag Базовый или конкретный идентификатор буфера.
    +
    301 * @param Buffer Буфер назначения для копирования данных
    +
    302 * @param tail_size Количество последних символов, которые нужно прочитать
    +
    303 * @param read_size Количество считанных символов
    +
    304 * @return >=0 — номер буфера (тег) для записи, <0 — ошибка (тег не найден или структура повреждена)
    +
    305 *
    +
    306 * @details Копирует последние tail_size символов из найденной записи Flash в Buffer.
    +
    307 * Тег может быть базовым или конкретным:
    +
    308 * - Если базовый (младший байт == 0) — будет прочитана последняя запись из группы.
    +
    309 * - Если конкретный (младший байт != 0) — прочитывается именно эта запись.
    +
    310 */
    +
    +
    311__STATIC_FORCEINLINE int RTT_ReadFromFlash(uint32_t tag, char *Buffer, uint32_t tail_size, uint32_t *read_size)
    +
    312{
    +
    313 if (!Buffer || tail_size == 0)
    +
    314 return -1; // Неверные параметры
    +
    315
    +
    316 if (tag == 0xFFFFFFFF)
    +
    317 return -1; // Недопустимый тег
    +
    318
    +
    319 uint32_t addr = RTT_FLASH_SECTOR_START;
    +
    320 RTT_FlashHeader_t *flash_hdr = NULL;
    +
    321 RTT_FlashHeader_t *target_hdr = NULL;
    +
    322 uint32_t base_tag = tag & 0xFFFFFF00;
    +
    323
    +
    324 // Поиск записи по тегу
    +
    325 while ((addr + sizeof(RTT_FlashHeader_t)) <= RTT_FLASH_SECTOR_END)
    +
    326 {
    +
    327 flash_hdr = (RTT_FlashHeader_t *)addr;
    +
    328
    +
    329 if (flash_hdr->tag == 0xFFFFFFFF)
    +
    330 break; // Достигнут конец записанных структур
    +
    331
    +
    332 // выбраный тег
    +
    333 if((flash_hdr->tag & 0xFFFFFF00) == base_tag)
    +
    334 {
    +
    335 if ((tag & 0xFF) == 0) // если он базовый - ищем последний
    +
    336 target_hdr = flash_hdr; // сохраняем последний в группе
    +
    337 else
    +
    338 if(flash_hdr->tag == tag) // если он конкретный и найден - берем его
    +
    339 {
    +
    340 target_hdr = flash_hdr;
    +
    341 break; // конкретный тег найден
    +
    342 }
    +
    343 }
    +
    344
    +
    345 addr += sizeof(RTT_FlashHeader_t);
    +
    346 }
    +
    347
    +
    348 if (!target_hdr) return -1; // Тег не найден
    +
    349
    +
    350 // Проверка корректности размера
    +
    351 if (target_hdr->size > RTT_FLASH_BUFFER_SIZE)
    +
    352 return -1; // Повреждённая запись
    353
    -
    354 __DSB();
    -
    355 __ISB();
    -
    356
    -
    357 return (int)(target_hdr->tag & 0xFF);
    -
    358}
    +
    354 // Определяем количество читаемых символов
    +
    355 uint32_t n = (tail_size > target_hdr->size) ? target_hdr->size : tail_size;
    +
    356 // Начальная позиция для чтения последних tail_size символов
    +
    357 uint32_t start = target_hdr->size - n;
    +
    358 // Копируем данные из Flash в RAM
    +
    359 memcpy(Buffer, &target_hdr->data[start], n);
    +
    360
    +
    361 if(read_size != NULL)
    +
    362 {
    +
    363 *read_size = n;
    +
    364 }
    +
    365
    +
    366 __DSB();
    +
    367 __ISB();
    +
    368
    +
    369 return (int)(target_hdr->tag & 0xFF);
    +
    370}
    -
    359
    -
    360/**
    -
    361 * @brief Стирание сектора Flash с RTT-буфером
    -
    362 */
    -
    -
    363__STATIC_FORCEINLINE int RTT_EraseFlash(void)
    -
    364{
    -
    365 FLASH_EraseInitTypeDef eraseInit;
    -
    366 uint32_t pageError = 0;
    -
    367
    - -
    369
    -
    370 eraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;
    -
    371 eraseInit.Sector = RTT_FLASH_SECTOR;
    -
    372 eraseInit.NbSectors = 1;
    -
    373
    -
    374 if (HAL_FLASHEx_Erase(&eraseInit, &pageError) != HAL_OK)
    -
    375 {
    -
    376 return -1;
    -
    377 }
    -
    378 return 0;
    -
    379 HAL_FLASH_Lock();
    -
    380}
    -
    -
    381
    -
    382/** TRACE_RTT_FLASH
    -
    383 * @}
    -
    384 */
    +
    371
    +
    372/**
    +
    373 * @brief Стирание сектора Flash с RTT-буфером
    +
    374 */
    +
    +
    375__STATIC_FORCEINLINE int RTT_EraseFlash(void)
    +
    376{
    +
    377 FLASH_EraseInitTypeDef eraseInit;
    +
    378 uint32_t pageError = 0;
    +
    379
    + +
    381
    +
    382 eraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;
    +
    383 eraseInit.Sector = RTT_FLASH_SECTOR;
    +
    384 eraseInit.NbSectors = 1;
    385
    -
    386#else // HAL_MODULE_ENABLED && RTT_TRACE_ENABLE
    -
    387#define RTT_FlashPrepare(...)
    -
    388#define RTT_EraseFlash(...) 0
    -
    389#define RTT_SaveToFlash(...) 0
    -
    390#define RTT_ReadFromFlash(...) 0
    -
    391#endif // HAL_MODULE_ENABLED && RTT_TRACE_ENABLE
    -
    392
    -
    393
    -
    394
    -
    395
    -
    396/**
    -
    397 * @addtogroup TRACE_HARDFAULT Hardfault trace defines
    -
    398 * @ingroup TRACE
    -
    399 * @brief Модуль трассировки HardFault с возможностью сохранения RTT буфера во Flash
    -
    400 * @details
    -
    401 * Этот модуль позволяет сохранять контекст процессора и последние символы RTT буфера при возникновении HardFault.
    -
    402 *
    -
    403 * Механизм работы:
    -
    404 * - При срабатывании HardFault вызывается HF_HandleFault(), который:
    -
    405 * 1. Получает указатель на стек, где произошёл HardFault (MSP или PSP).
    -
    406 * 2. Выводит значения регистров R0-R3, R12, LR, PC, PSR и системных регистров SCB.
    -
    407 * 3. Формирует строку с регистрами и копирует последние символы RTT буфера.
    -
    408 * 4. Сохраняет данные во Flash с базовым тегом HF_RTT_TAG_BASE.
    -
    409 * - Для восстановления последнего HardFault используется HF_CheckRecovered(), который:
    -
    410 * 1. Читает запись во Flash по базовому тегу.
    -
    411 * 2. Выводит сохранённый RTT буфер и контекст регистров.
    -
    412 * 3. Опционально стирает Flash после восстановления.
    -
    413 @code
    -
    414 void Hardfault()
    -
    415 {
    -
    416 HF_HandleFault();
    -
    417 NVIC_SystemReset();
    -
    418 }
    -
    419
    -
    420 int main()
    -
    421 {
    -
    422 if(HF_CheckRecovered(0))
    -
    423 {
    -
    424 //set hardfault error
    -
    425 RTT_EraseFlash(); // erase rtt flash after message readed
    -
    426 }
    -
    427 }
    -
    428 @endcode
    -
    429 * @{
    -
    430 */
    -
    431#if defined(HAL_MODULE_ENABLED) && defined(HARDFAULT_SERIAL_TRACE)
    -
    432
    -
    433#ifndef HF_RTT_TAIL_SIZE
    -
    434#define HF_RTT_TAIL_SIZE RTT_FLASH_BUFFER_SIZE ///< Размер буфера RTT, который сохранится при Hardfault
    -
    435#endif
    -
    436
    -
    437/**
    -
    438 * @brief Контекст стек-фрейма процессора при HardFault
    -
    439 * @details Сохраняет регистры R0-R3, R12, LR, PC, PSR для последующего анализа.
    -
    440 */
    -
    -
    441typedef struct {
    -
    442 uint32_t r0; ///< Регистр R0
    -
    443 uint32_t r1; ///< Регистр R1
    -
    444 uint32_t r2; ///< Регистр R2
    -
    445 uint32_t r3; ///< Регистр R3
    -
    446 uint32_t r12; ///< Регистр R12
    -
    447 uint32_t lr; ///< Link Register
    -
    448 uint32_t pc; ///< Program Counter
    -
    449 uint32_t psr; ///< Program Status Register
    - +
    386 if (HAL_FLASHEx_Erase(&eraseInit, &pageError) != HAL_OK)
    +
    387 {
    +
    388 return -1;
    +
    389 }
    +
    390 return 0;
    +
    391 HAL_FLASH_Lock();
    +
    392}
    -
    451
    -
    452/**
    -
    453 * @brief Проверка и вывод последнего HardFault-трейса из Flash
    -
    454 * @details
    -
    455 * Функция ищет последнюю запись HardFault по базовому тегу HF_RTT_TAG_BASE
    -
    456 * и выводит её содержимое в консоль. После успешного вывода Flash можно опционально очистить.
    -
    457 *
    -
    458 * @return int
    -
    459 * - 1 — данные HardFault найдены и выведены
    -
    460 * - 0 — данные отсутствуют или тег не найден
    -
    461 *
    -
    462 * @note Вызов рекомендуется при инициализации приложения для анализа предыдущего сбоя.
    -
    463 */
    -
    -
    464__STATIC_FORCEINLINE int HF_CheckRecovered(int erase)
    -
    465{
    -
    466 char buffer[RTT_FLASH_BUFFER_SIZE];
    -
    467 uint32_t read_size = 0;
    -
    468 int n_hardfault = RTT_ReadFromFlash(HF_RTT_TAG_BASE, buffer, HF_RTT_TAIL_SIZE, &read_size);
    -
    469 if (n_hardfault > 0)
    -
    470 {
    -
    471 my_printf("\n--- Recovered HardFault RTT buffer #%u ---\n", n_hardfault);
    -
    472 for (int i = 0; i < read_size; i++)
    -
    473 {
    -
    474 char c = buffer[i];
    -
    475 if (c == 0 || c == (char)0xFF) break;
    -
    476 my_printf("%c", c);
    -
    477 }
    -
    478
    -
    479 if(erase)
    - -
    481 my_printf("\n--------- HardFault Dump End ---------\n");
    -
    482 return 1;
    -
    483 }
    -
    484 return 0;
    -
    485}
    +
    393
    +
    394/** TRACE_RTT_FLASH
    +
    395 * @}
    +
    396 */
    +
    397
    +
    398#else // HAL_MODULE_ENABLED && RTT_TRACE_ENABLE
    +
    399#define RTT_FlashPrepare(...)
    +
    400#define RTT_EraseFlash(...) 0
    +
    401#define RTT_SaveToFlash(...) 0
    +
    402#define RTT_ReadFromFlash(...) 0
    +
    403#endif // HAL_MODULE_ENABLED && RTT_TRACE_ENABLE
    +
    404
    +
    405
    +
    406
    +
    407
    +
    408/**
    +
    409 * @addtogroup TRACE_HARDFAULT Hardfault trace defines
    +
    410 * @ingroup TRACE
    +
    411 * @brief Модуль трассировки HardFault с возможностью сохранения RTT буфера во Flash
    +
    412 * @details
    +
    413 * Этот модуль позволяет сохранять контекст процессора и последние символы RTT буфера при возникновении HardFault.
    +
    414 *
    +
    415 * Механизм работы:
    +
    416 * - При срабатывании HardFault вызывается HF_HandleFault(), который:
    +
    417 * 1. Получает указатель на стек, где произошёл HardFault (MSP или PSP).
    +
    418 * 2. Выводит значения регистров R0-R3, R12, LR, PC, PSR и системных регистров SCB.
    +
    419 * 3. Формирует строку с регистрами и копирует последние символы RTT буфера.
    +
    420 * 4. Сохраняет данные во Flash с базовым тегом HF_RTT_TAG_BASE.
    +
    421 * - Для восстановления последнего HardFault используется HF_CheckRecovered(), который:
    +
    422 * 1. Читает запись во Flash по базовому тегу.
    +
    423 * 2. Выводит сохранённый RTT буфер и контекст регистров.
    +
    424 * 3. Опционально стирает Flash после восстановления.
    +
    425 *
    +
    426 * Параметры:
    +
    427 * - @ref HARDFAULT_SERIAL_TRACE - Включить обработку и serial трассировку Hardfault
    +
    428 * Если отключена то вставляются заглушки, никак не влияющие на параметры и остальную программу
    +
    429 * - @ref HF_RTT_TAG_BASE - Базовый тег RTT Flash для HardFault
    +
    430 * - @ref HF_RTT_TAIL_SIZE - Размер буфера RTT, который сохранится при Hardfault
    +
    431 * - @ref HF_STACK_DUMP_WORDS - Сколько слов стека будет проанализировано во время Hardfault
    +
    432 * - @ref HF_FLASH_ADDR - Адрес FLASH куда положится RTT буфер
    +
    433 * - @ref HF_RAM_END - Конец RAM памяти (чтобы во время анализа стека не выйти за пределы)
    +
    434 *
    +
    435 @code
    +
    436 void Hardfault()
    +
    437 {
    +
    438 HF_HandleFault();
    +
    439 NVIC_SystemReset();
    +
    440 }
    +
    441
    +
    442 int main()
    +
    443 {
    +
    444 if(HF_CheckRecovered(0))
    +
    445 {
    +
    446 //set hardfault error
    +
    447 RTT_EraseFlash(); // erase rtt flash after message readed
    +
    448 }
    +
    449 }
    +
    450 @endcode
    +
    451 * @{
    +
    452 */
    +
    453#if defined(HAL_MODULE_ENABLED) && defined(HARDFAULT_SERIAL_TRACE)
    +
    454
    +
    455#ifndef HF_RTT_TAIL_SIZE
    +
    456#define HF_RTT_TAIL_SIZE RTT_FLASH_BUFFER_SIZE ///< Размер буфера RTT, который сохранится при Hardfault
    +
    457#endif
    +
    458
    +
    459/**
    +
    460 * @brief Контекст стек-фрейма процессора при HardFault
    +
    461 * @details Сохраняет регистры R0-R3, R12, LR, PC, PSR для последующего анализа.
    +
    462 */
    +
    +
    463typedef struct {
    +
    464 uint32_t r0; ///< Регистр R0
    +
    465 uint32_t r1; ///< Регистр R1
    +
    466 uint32_t r2; ///< Регистр R2
    +
    467 uint32_t r3; ///< Регистр R3
    +
    468 uint32_t r12; ///< Регистр R12
    +
    469 uint32_t lr; ///< Link Register
    +
    470 uint32_t pc; ///< Program Counter
    +
    471 uint32_t psr; ///< Program Status Register
    +
    -
    486
    -
    487
    -
    488static HF_StackFrame_t *stack_frame;
    -
    489static uint32_t stack_dump[HF_STACK_DUMP_WORDS];
    -
    490static void *ret_adr[10] = {0};
    -
    491/**
    -
    492 * @brief Обработчик HardFault
    -
    493 * @details
    -
    494 * Вызывается из прерывания HardFault или в любом месте где понятно что ошибка критическая.
    -
    495 * Последовательно выполняет:
    -
    496 * 1. Определяет активный стек (MSP или PSP) на момент сбоя.
    -
    497 * 2. Сохраняет значения регистров R0-R3, R12, LR, PC, PSR.
    -
    498 * 3. Выводит системные регистры CFSR, HFSR, DFSR, AFSR, MMFAR, BFAR.
    -
    499 * 4. Формирует stack trace с 3 уровнями возврата.
    -
    500 * 5. Копирует последние символы RTT буфера.
    -
    501 * 6. Сохраняет все данные во Flash через RTT_SaveToFlash с базовым тегом HF_RTT_TAG_BASE.
    -
    502 *
    -
    503 * @note Функция защищена, так как вызывается в контексте сбоя — минимизирует использование вызовов HAL.
    -
    504 */
    -
    -
    505__STATIC_FORCEINLINE void HF_HandleFault(void)
    -
    506{
    -
    507 // Получаем указатель на стек, где произошёл HardFault
    -
    508 __ASM volatile(
    -
    509 "TST lr, #4 \n"
    -
    510 "ITE EQ \n"
    -
    511 "MRSEQ %[ptr], MSP\n"
    -
    512 "MRSNE %[ptr], PSP\n"
    -
    513 : [ptr] "=r"(stack_frame)
    -
    514 );
    -
    515
    -
    516 my_printf("\n===== HardFault occurred! =====\n");
    -
    517 my_printf("R0 = 0x%08X\n", stack_frame->r0);
    -
    518 my_printf("R1 = 0x%08X\n", stack_frame->r1);
    -
    519 my_printf("R2 = 0x%08X\n", stack_frame->r2);
    -
    520 my_printf("R3 = 0x%08X\n", stack_frame->r3);
    -
    521 my_printf("R12 = 0x%08X\n", stack_frame->r12);
    -
    522 my_printf("LR = 0x%08X\n", stack_frame->lr);
    -
    523 my_printf("PC = 0x%08X\n", stack_frame->pc);
    -
    524 my_printf("PSR = 0x%08X\n", stack_frame->psr);
    -
    525
    -
    526 my_printf("CFSR = 0x%08X\n", SCB->CFSR);
    -
    527 my_printf("HFSR = 0x%08X\n", SCB->HFSR);
    -
    528 my_printf("DFSR = 0x%08X\n", SCB->DFSR);
    -
    529 my_printf("AFSR = 0x%08X\n", SCB->AFSR);
    -
    530 my_printf("MMFAR = 0x%08X\n", SCB->MMFAR);
    -
    531 my_printf("BFAR = 0x%08X\n", SCB->BFAR);
    -
    532
    -
    533 // --- Stack trace ---
    -
    534 my_printf("--- Stack trace ---\n");
    -
    535 ret_adr[0] = __builtin_return_address(0);
    -
    536 ret_adr[1] = __builtin_return_address(1);
    -
    537 ret_adr[2] = __builtin_return_address(2);
    -
    538
    -
    539 for (int i = 0; i < 3; i++) // развернуть n уровней
    -
    540 {
    -
    541 if(ret_adr[i])
    -
    542 my_printf(" #%d: 0x%08lX\r\n", i, ret_adr[i]); // -1 для Thumb
    -
    543 }
    - -
    545}
    +
    473
    +
    474/**
    +
    475 * @brief Проверка и вывод последнего HardFault-трейса из Flash
    +
    476 * @details
    +
    477 * Функция ищет последнюю запись HardFault по базовому тегу HF_RTT_TAG_BASE
    +
    478 * и выводит её содержимое в консоль. После успешного вывода Flash можно опционально очистить.
    +
    479 *
    +
    480 * @return int
    +
    481 * - 1 — данные HardFault найдены и выведены
    +
    482 * - 0 — данные отсутствуют или тег не найден
    +
    483 *
    +
    484 * @note Вызов рекомендуется при инициализации приложения для анализа предыдущего сбоя.
    +
    485 */
    +
    +
    486__STATIC_FORCEINLINE int HF_CheckRecovered(int erase)
    +
    487{
    +
    488 char buffer[RTT_FLASH_BUFFER_SIZE];
    +
    489 uint32_t read_size = 0;
    +
    490 int n_hardfault = RTT_ReadFromFlash(HF_RTT_TAG_BASE, buffer, HF_RTT_TAIL_SIZE, &read_size);
    +
    491 if (n_hardfault > 0)
    +
    492 {
    +
    493 my_printf("\n--- Recovered HardFault RTT buffer #%u ---\n", n_hardfault);
    +
    494 for (int i = 0; i < read_size; i++)
    +
    495 {
    +
    496 char c = buffer[i];
    +
    497 if (c == 0 || c == (char)0xFF) break;
    +
    498 my_printf("%c", c);
    +
    499 }
    +
    500
    +
    501 if(erase)
    + +
    503 my_printf("\n--------- HardFault Dump End ---------\n");
    +
    504 return 1;
    +
    505 }
    +
    506 return 0;
    +
    507}
    -
    546#else // HAL_MODULE_ENABLED && HARDFAULT_SERIAL_TRACE
    -
    547#define HF_CheckRecovered(...) 0
    -
    548#define HF_HandleFault(...)
    -
    549#endif // HAL_MODULE_ENABLED && HARDFAULT_SERIAL_TRACE
    -
    550/** TRACE_HARDFAULT
    -
    551 * @}
    -
    552 */
    -
    553
    -
    554
    -
    555
    -
    556#endif //__TRACE_H_
    +
    508
    +
    509
    +
    510static HF_StackFrame_t *stack_frame;
    +
    511static uint32_t stack_dump[HF_STACK_DUMP_WORDS];
    +
    512static void *ret_adr[10] = {0};
    +
    513/**
    +
    514 * @brief Обработчик HardFault
    +
    515 * @details
    +
    516 * Вызывается из прерывания HardFault или в любом месте где понятно что ошибка критическая.
    +
    517 * Последовательно выполняет:
    +
    518 * 1. Определяет активный стек (MSP или PSP) на момент сбоя.
    +
    519 * 2. Сохраняет значения регистров R0-R3, R12, LR, PC, PSR.
    +
    520 * 3. Выводит системные регистры CFSR, HFSR, DFSR, AFSR, MMFAR, BFAR.
    +
    521 * 4. Формирует stack trace с 3 уровнями возврата.
    +
    522 * 5. Копирует последние символы RTT буфера.
    +
    523 * 6. Сохраняет все данные во Flash через RTT_SaveToFlash с базовым тегом HF_RTT_TAG_BASE.
    +
    524 *
    +
    525 * @note Функция защищена, так как вызывается в контексте сбоя — минимизирует использование вызовов HAL.
    +
    526 */
    +
    +
    527__STATIC_FORCEINLINE void HF_HandleFault(void)
    +
    528{
    +
    529 // Получаем указатель на стек, где произошёл HardFault
    +
    530 __ASM volatile(
    +
    531 "TST lr, #4 \n"
    +
    532 "ITE EQ \n"
    +
    533 "MRSEQ %[ptr], MSP\n"
    +
    534 "MRSNE %[ptr], PSP\n"
    +
    535 : [ptr] "=r"(stack_frame)
    +
    536 );
    +
    537
    +
    538 my_printf("\n===== HardFault occurred! =====\n");
    +
    539 my_printf("R0 = 0x%08X\n", stack_frame->r0);
    +
    540 my_printf("R1 = 0x%08X\n", stack_frame->r1);
    +
    541 my_printf("R2 = 0x%08X\n", stack_frame->r2);
    +
    542 my_printf("R3 = 0x%08X\n", stack_frame->r3);
    +
    543 my_printf("R12 = 0x%08X\n", stack_frame->r12);
    +
    544 my_printf("LR = 0x%08X\n", stack_frame->lr);
    +
    545 my_printf("PC = 0x%08X\n", stack_frame->pc);
    +
    546 my_printf("PSR = 0x%08X\n", stack_frame->psr);
    +
    547
    +
    548 my_printf("CFSR = 0x%08X\n", SCB->CFSR);
    +
    549 my_printf("HFSR = 0x%08X\n", SCB->HFSR);
    +
    550 my_printf("DFSR = 0x%08X\n", SCB->DFSR);
    +
    551 my_printf("AFSR = 0x%08X\n", SCB->AFSR);
    +
    552 my_printf("MMFAR = 0x%08X\n", SCB->MMFAR);
    +
    553 my_printf("BFAR = 0x%08X\n", SCB->BFAR);
    +
    554
    +
    555 // --- Stack trace ---
    +
    556 my_printf("--- Stack trace ---\n");
    +
    557 ret_adr[0] = __builtin_return_address(0);
    +
    558 ret_adr[1] = __builtin_return_address(1);
    +
    559 ret_adr[2] = __builtin_return_address(2);
    +
    560
    +
    561 for (int i = 0; i < 3; i++) // развернуть n уровней
    +
    562 {
    +
    563 if(ret_adr[i])
    +
    564 my_printf(" #%d: 0x%08lX\r\n", i, ret_adr[i]); // -1 для Thumb
    +
    565 }
    + +
    567}
    +
    +
    568#else // HAL_MODULE_ENABLED && HARDFAULT_SERIAL_TRACE
    +
    569#define HF_CheckRecovered(...) 0
    +
    570#define HF_HandleFault(...)
    +
    571#endif // HAL_MODULE_ENABLED && HARDFAULT_SERIAL_TRACE
    +
    572/** TRACE_HARDFAULT
    +
    573 * @}
    +
    574 */
    +
    575
    +
    576
    +
    577
    +
    578#endif //__TRACE_H_
    #define RTT_FLASH_SECTOR
    Сектор FLASH куда положится RTT буфер
    #define RTT_FLASH_BUFFER_SIZE
    Размер буфера RTT в Flash.
    #define RTT_FLASH_SECTOR_START
    Начало сектора RTT_FLASH_SECTOR.
    @@ -681,27 +703,27 @@ $(function(){initNavTree('trace_8h_source.html','',''); });
    #define HF_RTT_TAG_BASE
    базовый тег для HardFault
    #define HF_RTT_TAIL_SIZE
    Размер буфера RTT, который сохранится при Hardfault.
    #define RTT_FLASH_SECTOR_END
    Конец сектора RTT_FLASH_SECTOR.
    -
    __STATIC_FORCEINLINE int HF_CheckRecovered(int erase)
    Проверка и вывод последнего HardFault-трейса из Flash.
    Definition trace.h:464
    -
    __STATIC_FORCEINLINE void HF_HandleFault(void)
    Обработчик HardFault.
    Definition trace.h:505
    -
    __STATIC_FORCEINLINE void RTT_FlashPrepare(void)
    Подготовка Flash к записи
    Definition trace.h:179
    -
    __STATIC_FORCEINLINE int RTT_ReadFromFlash(uint32_t tag, char *Buffer, uint32_t tail_size, uint32_t *read_size)
    Читает последние символы RTT-буфера из Flash по тегу
    Definition trace.h:299
    -
    __STATIC_FORCEINLINE int RTT_SaveToFlash(uint32_t tag, uint32_t tail_size)
    Сохраняет последние символы RTT-буфера в Flash по тегу
    Definition trace.h:202
    -
    __STATIC_FORCEINLINE int RTT_EraseFlash(void)
    Стирание сектора Flash с RTT-буфером
    Definition trace.h:363
    -
    #define my_printf(...)
    Универсальный макрос для вывода трассировки
    Definition trace.h:67
    +
    __STATIC_FORCEINLINE int HF_CheckRecovered(int erase)
    Проверка и вывод последнего HardFault-трейса из Flash.
    Definition trace.h:486
    +
    __STATIC_FORCEINLINE void HF_HandleFault(void)
    Обработчик HardFault.
    Definition trace.h:527
    +
    __STATIC_FORCEINLINE void RTT_FlashPrepare(void)
    Подготовка Flash к записи
    Definition trace.h:190
    +
    __STATIC_FORCEINLINE int RTT_ReadFromFlash(uint32_t tag, char *Buffer, uint32_t tail_size, uint32_t *read_size)
    Читает последние символы RTT-буфера из Flash по тегу
    Definition trace.h:311
    +
    __STATIC_FORCEINLINE int RTT_SaveToFlash(uint32_t tag, uint32_t tail_size)
    Сохраняет последние символы RTT-буфера в Flash по тегу
    Definition trace.h:214
    +
    __STATIC_FORCEINLINE int RTT_EraseFlash(void)
    Стирание сектора Flash с RTT-буфером
    Definition trace.h:375
    +
    #define my_printf(...)
    Универсальный макрос для вывода трассировки
    Definition trace.h:71
    Заголочный файл для дефайнов библиотеки MyLibsGeneral.
    -
    Контекст стек-фрейма процессора при HardFault.
    Definition trace.h:441
    -
    uint32_t pc
    Program Counter.
    Definition trace.h:448
    -
    uint32_t r1
    Регистр R1.
    Definition trace.h:443
    -
    uint32_t r0
    Регистр R0.
    Definition trace.h:442
    -
    uint32_t r3
    Регистр R3.
    Definition trace.h:445
    -
    uint32_t r2
    Регистр R2.
    Definition trace.h:444
    -
    uint32_t lr
    Link Register.
    Definition trace.h:447
    -
    uint32_t r12
    Регистр R12.
    Definition trace.h:446
    -
    uint32_t psr
    Program Status Register.
    Definition trace.h:449
    -
    Структура RTT, которая будет положена в Flash.
    Definition trace.h:169
    -
    uint32_t tag
    Уникальный идентификатор буфера
    Definition trace.h:170
    -
    char data[1024]
    Буфер RTT.
    Definition trace.h:172
    -
    uint32_t size
    Размер данных
    Definition trace.h:171
    +
    Контекст стек-фрейма процессора при HardFault.
    Definition trace.h:463
    +
    uint32_t pc
    Program Counter.
    Definition trace.h:470
    +
    uint32_t r1
    Регистр R1.
    Definition trace.h:465
    +
    uint32_t r0
    Регистр R0.
    Definition trace.h:464
    +
    uint32_t r3
    Регистр R3.
    Definition trace.h:467
    +
    uint32_t r2
    Регистр R2.
    Definition trace.h:466
    +
    uint32_t lr
    Link Register.
    Definition trace.h:469
    +
    uint32_t r12
    Регистр R12.
    Definition trace.h:468
    +
    uint32_t psr
    Program Status Register.
    Definition trace.h:471
    +
    Структура RTT, которая будет положена в Flash.
    Definition trace.h:180
    +
    uint32_t tag
    Уникальный идентификатор буфера
    Definition trace.h:181
    +
    char data[1024]
    Буфер RTT.
    Definition trace.h:183
    +
    uint32_t size
    Размер данных
    Definition trace.h:182
    diff --git a/Doc/html/trackers_8h_source.html b/Doc/html/trackers_8h_source.html index 847f6be..f618be6 100644 --- a/Doc/html/trackers_8h_source.html +++ b/Doc/html/trackers_8h_source.html @@ -117,153 +117,154 @@ $(function(){initNavTree('trackers_8h_source.html','',''); });
    15- user[num_user_vars]
    16Также есть ряд функций (дефайнов) для обращения к элементам этой структуры.
    17
    -
    18
    -
    19Если трекеры @ref TRACKERS_ENABLE отключены, то все дефайны определяются как ничего
    -
    20и на производительность кода не влияют
    -
    21
    -
    22@par Пример:
    -
    23
    -
    24Определяем typedef трекера измерений Measure_TrackerTypeDef
    -
    25
    -
    26@verbatim
    -
    27 typedef TrackerTypeDef(MEASURE_USER_VARS_NUMB) Measure_TrackerTypeDef;
    -
    28@endverbatim
    -
    29
    -
    30И через @ref Measure_TrackerTypeDef структура подключается в другие структуры
    -
    31
    -
    32Для работы с структурой можно использовать функции:
    -
    33- Для получения значения:
    -
    34 - TrackerGet_Ok()
    -
    35 - TrackerGet_Err()
    -
    36 - TrackerGet_Warn()
    -
    37 - TrackerGet_User(n)
    -
    38
    -
    39- Для записи значения:
    -
    40 - TrackerCnt_Ok()
    -
    41 - TrackerCnt_Err()
    -
    42 - TrackerCnt_Warn()
    -
    43 - TrackerCnt_User()
    -
    44 - TrackerWrite_User(n)
    -
    45
    -
    46- Для очищения значения:
    -
    47 - TrackerClear_All()
    -
    48 - TrackerClear_Ok()
    -
    49 - TrackerClear_Err()
    -
    50 - TrackerClear_Warn()
    -
    51 - TrackerClear_User(n)
    -
    52 - TrackerClear_UserAll()
    -
    53* @{
    -
    54*************************************************************************/
    -
    55#ifndef __TRACKERS_H_
    -
    56#define __TRACKERS_H_
    -
    57#include "mylibs_defs.h"
    -
    58
    -
    59#ifdef TRACKERS_ENABLE
    -
    60 /**
    -
    61 * @brief Структура для счетчиков отладки
    -
    62 * @param num_user_vars - количество пользовательских переменных
    -
    63 * @details Содержит счетчик для успешных событый (cnt_ok),
    -
    64 * счетчик для ошибок (cnt_err), счетчик для предупреждений (cnt_warn).
    -
    65 *
    -
    66 * Также есть возможность объявить пользовательские переменные в
    -
    67 * количестве <num_user_vars> штук.
    -
    68 */
    -
    -
    69 #define TrackerTypeDef(num_user_vars) \
    -
    70 struct \
    -
    71 { \
    -
    72 uint32_t cnt_ok; \
    -
    73 uint32_t cnt_err; \
    -
    74 uint32_t cnt_warn; \
    -
    75 uint32_t user[num_user_vars]; \
    -
    76 }
    +
    18Параметры для конфигурации:
    +
    19- @ref TRACKERS_ENABLE - Включить трекеры
    +
    20 Если трекеры @ref TRACKERS_ENABLE отключены, то все дефайны определяются как ничего
    +
    21 и на производительность кода не влияют
    +
    22
    +
    23@par Пример:
    +
    24
    +
    25Определяем typedef трекера измерений Measure_TrackerTypeDef
    +
    26
    +
    27@verbatim
    +
    28 typedef TrackerTypeDef(MEASURE_USER_VARS_NUMB) Measure_TrackerTypeDef;
    +
    29@endverbatim
    +
    30
    +
    31И через @ref Measure_TrackerTypeDef структура подключается в другие структуры
    +
    32
    +
    33Для работы с структурой можно использовать функции:
    +
    34- Для получения значения:
    +
    35 - TrackerGet_Ok()
    +
    36 - TrackerGet_Err()
    +
    37 - TrackerGet_Warn()
    +
    38 - TrackerGet_User(n)
    +
    39
    +
    40- Для записи значения:
    +
    41 - TrackerCnt_Ok()
    +
    42 - TrackerCnt_Err()
    +
    43 - TrackerCnt_Warn()
    +
    44 - TrackerCnt_User()
    +
    45 - TrackerWrite_User(n)
    +
    46
    +
    47- Для очищения значения:
    +
    48 - TrackerClear_All()
    +
    49 - TrackerClear_Ok()
    +
    50 - TrackerClear_Err()
    +
    51 - TrackerClear_Warn()
    +
    52 - TrackerClear_User(n)
    +
    53 - TrackerClear_UserAll()
    +
    54* @{
    +
    55*************************************************************************/
    +
    56#ifndef __TRACKERS_H_
    +
    57#define __TRACKERS_H_
    +
    58#include "mylibs_defs.h"
    +
    59
    +
    60#ifdef TRACKERS_ENABLE
    +
    61 /**
    +
    62 * @brief Структура для счетчиков отладки
    +
    63 * @param num_user_vars - количество пользовательских переменных
    +
    64 * @details Содержит счетчик для успешных событый (cnt_ok),
    +
    65 * счетчик для ошибок (cnt_err), счетчик для предупреждений (cnt_warn).
    +
    66 *
    +
    67 * Также есть возможность объявить пользовательские переменные в
    +
    68 * количестве <num_user_vars> штук.
    +
    69 */
    +
    +
    70 #define TrackerTypeDef(num_user_vars) \
    +
    71 struct \
    +
    72 { \
    +
    73 uint32_t cnt_ok; \
    +
    74 uint32_t cnt_err; \
    +
    75 uint32_t cnt_warn; \
    +
    76 uint32_t user[num_user_vars]; \
    +
    77 }
    -
    77
    -
    78 /** @brief Получить количетство пользовательских переменных */
    -
    79 #define num_of_usercnts(_user_) (sizeof(_user_) / sizeof(uint32_t))
    -
    80 /** @brief Проверка существует ли указанная пользовательская переменная */
    -
    81 #define assert_usertracker(_cntstruct_, _uservarnumb_) ((_uservarnumb_) < num_of_usercnts((_cntstruct_).user))
    -
    82 /** @brief Условие для проверки существует ли указанная пользовательская переменная */
    -
    83 #define if_assert_usertracker(_cntstruct_, _uservarnumb_) if(assert_usertracker(_cntstruct_, _uservarnumb_))
    -
    84 /** @brief Тернарный оператор для проверки существует ли указанная пользовательская переменная */
    -
    85 #define tern_assert_usertracker(_cntstruct_, _uservarnumb_) (assert_usertracker(_cntstruct_, _uservarnumb_)) ? _uservarnumb_ : 0
    -
    86
    -
    87
    -
    88 /** @brief Считать счетчик успешных событий */
    -
    89 #define TrackerGet_Ok(_cntstruct_) (_cntstruct_).cnt_ok
    -
    90 /** @brief Считать счетчик ошибок */
    -
    91 #define TrackerGet_Err(_cntstruct_) (_cntstruct_).cnt_err
    -
    92 /** @brief Считать счетчик предупреждений */
    -
    93 #define TrackerGet_Warn(_cntstruct_) (_cntstruct_).cnt_warn
    -
    94 /**
    -
    95 * @brief Считать пользовательскую переменную
    -
    96 * @note Здесь нет проверки - существует ли пользовательская переменная!
    -
    97 * Есть возможность выйти за границы структуры!!!
    -
    98 * Чтобы этого избежать можно использовать дефайн #ref assert_usertracker()
    -
    99 @verbatim
    -
    100 if(assert_usertracker(struct, 0)) {
    -
    101 TrackerGet_User(struct, 0)
    -
    102 }
    -
    103 @endverbatim
    -
    104 */
    -
    105 #define TrackerGet_User(_cntstruct_, _uservarnumb_) (_cntstruct_).user[tern_assert_usertracker(_cntstruct_, _uservarnumb_)]
    -
    106
    +
    78
    +
    79 /** @brief Получить количетство пользовательских переменных */
    +
    80 #define num_of_usercnts(_user_) (sizeof(_user_) / sizeof(uint32_t))
    +
    81 /** @brief Проверка существует ли указанная пользовательская переменная */
    +
    82 #define assert_usertracker(_cntstruct_, _uservarnumb_) ((_uservarnumb_) < num_of_usercnts((_cntstruct_).user))
    +
    83 /** @brief Условие для проверки существует ли указанная пользовательская переменная */
    +
    84 #define if_assert_usertracker(_cntstruct_, _uservarnumb_) if(assert_usertracker(_cntstruct_, _uservarnumb_))
    +
    85 /** @brief Тернарный оператор для проверки существует ли указанная пользовательская переменная */
    +
    86 #define tern_assert_usertracker(_cntstruct_, _uservarnumb_) (assert_usertracker(_cntstruct_, _uservarnumb_)) ? _uservarnumb_ : 0
    +
    87
    +
    88
    +
    89 /** @brief Считать счетчик успешных событий */
    +
    90 #define TrackerGet_Ok(_cntstruct_) (_cntstruct_).cnt_ok
    +
    91 /** @brief Считать счетчик ошибок */
    +
    92 #define TrackerGet_Err(_cntstruct_) (_cntstruct_).cnt_err
    +
    93 /** @brief Считать счетчик предупреждений */
    +
    94 #define TrackerGet_Warn(_cntstruct_) (_cntstruct_).cnt_warn
    +
    95 /**
    +
    96 * @brief Считать пользовательскую переменную
    +
    97 * @note Здесь нет проверки - существует ли пользовательская переменная!
    +
    98 * Есть возможность выйти за границы структуры!!!
    +
    99 * Чтобы этого избежать можно использовать дефайн #ref assert_usertracker()
    +
    100 @verbatim
    +
    101 if(assert_usertracker(struct, 0)) {
    +
    102 TrackerGet_User(struct, 0)
    +
    103 }
    +
    104 @endverbatim
    +
    105 */
    +
    106 #define TrackerGet_User(_cntstruct_, _uservarnumb_) (_cntstruct_).user[tern_assert_usertracker(_cntstruct_, _uservarnumb_)]
    107
    -
    108
    -
    109 /** @brief Инкрементирование счетчика успешных событий */
    -
    110 #define TrackerCnt_Ok(_cntstruct_) (_cntstruct_).cnt_ok++
    -
    111 /** @brief Инкрементирование счетчика ошибок */
    -
    112 #define TrackerCnt_Err(_cntstruct_) (_cntstruct_).cnt_err++
    -
    113 /** @brief Инкрементирование счетчика предупреждений */
    -
    114 #define TrackerCnt_Warn(_cntstruct_) (_cntstruct_).cnt_warn++
    -
    115 /** @brief Инкрементирование пользовательской переменной */
    -
    116 #define TrackerCnt_User(_cntstruct_, _uservarnumb_) if_assert_usertracker(_cntstruct_, _uservarnumb_) (_cntstruct_).user[_uservarnumb_]++;
    -
    117 /** @brief Запись числа в пользовательскую переменную */
    -
    118 #define TrackerWrite_User(_cntstruct_, _uservarnumb_, _val_) if_assert_usertracker(_cntstruct_, _uservarnumb_) (_cntstruct_).user[_uservarnumb_] = (_val_)
    -
    119
    -
    120 /** @brief Очистка всей структуры */
    -
    121 #define TrackerClear_All(_cntstruct_) memset(&(_cntstruct_), 0, sizeof(_cntstruct_))
    -
    122 /** @brief Очистка счетчика успешных событий */
    -
    123 #define TrackerClear_Ok(_cntstruct_) (_cntstruct_).cnt_ok = 0
    -
    124 /** @brief Очистка счетчика ошибок */
    -
    125 #define TrackerClear_Err(_cntstruct_) (_cntstruct_).cnt_err = 0
    -
    126 /** @brief Очистка счетчика предупреждений */
    -
    127 #define TrackerClear_Warn(_cntstruct_) (_cntstruct_).cnt_warn = 0
    -
    128 /** @brief Очистка пользовательской переменной */
    -
    129 #define TrackerClear_User(_cntstruct_, _uservarnumb_) if_assert_usertracker(_cntstruct_, _uservarnumb_) (_cntstruct_).user[_uservarnumb_] = 0;
    -
    130 /** @brief Очистка всех пользовательских переменных */
    -
    131 #define TrackerClear_UserAll(_cntstruct_) memset(&(_cntstruct_).user, 0, sizeof((_cntstruct_).user))
    -
    132
    -
    133#else //TRACKERS_ENABLE
    -
    134
    -
    135 #define TrackerTypeDef(num_user_vars) void *
    -
    136
    -
    137 #define num_of_usercnts(_user_) 0
    -
    138 #define assert_tracecnt(_cntstruct_, _uservarnumb_) 0
    -
    139 #define if_assert_usertracker(_cntstruct_, _uservarnumb_) if(0)
    -
    140 #define tern_assert_usertracker(_cntstruct_, _uservarnumb_) 0
    -
    141
    -
    142 #define TrackerGet_Ok(_cntstruct_) dummy
    -
    143 #define TrackerGet_Err(_cntstruct_) dummy
    -
    144 #define TrackerGet_Warn(_cntstruct_) dummy
    -
    145 #define TrackerGet_User(_cntstruct_, _uservarnumb_) dummy
    -
    146
    -
    147 #define TrackerCnt_Ok(_cntstruct_)
    -
    148 #define TrackerCnt_Err(_cntstruct_)
    -
    149 #define TrackerCnt_Warn(_cntstruct_)
    -
    150 #define TrackerCnt_User(_cntstruct_, _uservarnumb_)
    -
    151 #define TrackerWrite_User(_cntstruct_, _uservarnumb_, _val_)
    -
    152
    -
    153 #define TrackerClear_All(_cntstruct_)
    -
    154 #define TrackerClear_Ok(_cntstruct_)
    -
    155 #define TrackerClear_Err(_cntstruct_)
    -
    156 #define TrackerClear_Warn(_cntstruct_)
    -
    157 #define TrackerClear_User(_cntstruct_)
    -
    158 #define TrackerClear_UserAll(_cntstruct_)
    -
    159
    -
    160#endif //TRACKERS_ENABLE
    -
    161
    -
    162#endif //__TRACKERS_H_
    +
    108
    +
    109
    +
    110 /** @brief Инкрементирование счетчика успешных событий */
    +
    111 #define TrackerCnt_Ok(_cntstruct_) (_cntstruct_).cnt_ok++
    +
    112 /** @brief Инкрементирование счетчика ошибок */
    +
    113 #define TrackerCnt_Err(_cntstruct_) (_cntstruct_).cnt_err++
    +
    114 /** @brief Инкрементирование счетчика предупреждений */
    +
    115 #define TrackerCnt_Warn(_cntstruct_) (_cntstruct_).cnt_warn++
    +
    116 /** @brief Инкрементирование пользовательской переменной */
    +
    117 #define TrackerCnt_User(_cntstruct_, _uservarnumb_) if_assert_usertracker(_cntstruct_, _uservarnumb_) (_cntstruct_).user[_uservarnumb_]++;
    +
    118 /** @brief Запись числа в пользовательскую переменную */
    +
    119 #define TrackerWrite_User(_cntstruct_, _uservarnumb_, _val_) if_assert_usertracker(_cntstruct_, _uservarnumb_) (_cntstruct_).user[_uservarnumb_] = (_val_)
    +
    120
    +
    121 /** @brief Очистка всей структуры */
    +
    122 #define TrackerClear_All(_cntstruct_) memset(&(_cntstruct_), 0, sizeof(_cntstruct_))
    +
    123 /** @brief Очистка счетчика успешных событий */
    +
    124 #define TrackerClear_Ok(_cntstruct_) (_cntstruct_).cnt_ok = 0
    +
    125 /** @brief Очистка счетчика ошибок */
    +
    126 #define TrackerClear_Err(_cntstruct_) (_cntstruct_).cnt_err = 0
    +
    127 /** @brief Очистка счетчика предупреждений */
    +
    128 #define TrackerClear_Warn(_cntstruct_) (_cntstruct_).cnt_warn = 0
    +
    129 /** @brief Очистка пользовательской переменной */
    +
    130 #define TrackerClear_User(_cntstruct_, _uservarnumb_) if_assert_usertracker(_cntstruct_, _uservarnumb_) (_cntstruct_).user[_uservarnumb_] = 0;
    +
    131 /** @brief Очистка всех пользовательских переменных */
    +
    132 #define TrackerClear_UserAll(_cntstruct_) memset(&(_cntstruct_).user, 0, sizeof((_cntstruct_).user))
    +
    133
    +
    134#else //TRACKERS_ENABLE
    +
    135
    +
    136 #define TrackerTypeDef(num_user_vars) void *
    +
    137
    +
    138 #define num_of_usercnts(_user_) 0
    +
    139 #define assert_tracecnt(_cntstruct_, _uservarnumb_) 0
    +
    140 #define if_assert_usertracker(_cntstruct_, _uservarnumb_) if(0)
    +
    141 #define tern_assert_usertracker(_cntstruct_, _uservarnumb_) 0
    +
    142
    +
    143 #define TrackerGet_Ok(_cntstruct_) dummy
    +
    144 #define TrackerGet_Err(_cntstruct_) dummy
    +
    145 #define TrackerGet_Warn(_cntstruct_) dummy
    +
    146 #define TrackerGet_User(_cntstruct_, _uservarnumb_) dummy
    +
    147
    +
    148 #define TrackerCnt_Ok(_cntstruct_)
    +
    149 #define TrackerCnt_Err(_cntstruct_)
    +
    150 #define TrackerCnt_Warn(_cntstruct_)
    +
    151 #define TrackerCnt_User(_cntstruct_, _uservarnumb_)
    +
    152 #define TrackerWrite_User(_cntstruct_, _uservarnumb_, _val_)
    +
    153
    +
    154 #define TrackerClear_All(_cntstruct_)
    +
    155 #define TrackerClear_Ok(_cntstruct_)
    +
    156 #define TrackerClear_Err(_cntstruct_)
    +
    157 #define TrackerClear_Warn(_cntstruct_)
    +
    158 #define TrackerClear_User(_cntstruct_)
    +
    159 #define TrackerClear_UserAll(_cntstruct_)
    +
    160
    +
    161#endif //TRACKERS_ENABLE
    +
    162
    +
    163#endif //__TRACKERS_H_
    Заголочный файл для дефайнов библиотеки MyLibsGeneral.
    diff --git a/Doc/latex/evolve__optimizer_8h.tex b/Doc/latex/evolve__optimizer_8h.tex index f04a5c3..3e7ba54 100644 --- a/Doc/latex/evolve__optimizer_8h.tex +++ b/Doc/latex/evolve__optimizer_8h.tex @@ -33,13 +33,15 @@ struct \mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \#define \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gaff223481fcffea77394a331afde29fdc}{PARAM\+\_\+\+SCALE\+\_\+\+Q16}}(x, min\+\_\+val, max\+\_\+val) \begin{DoxyCompactList}\small\item\em Линейное масштабирование x из диапазона \mbox{[}min\+\_\+val, max\+\_\+val\mbox{]} в Q16.\+16 \mbox{[}0, 65536) \end{DoxyCompactList}\item \#define \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga71a0c240c667e976d9caef391ab767ba}{PARAM\+\_\+\+UNSCALE\+\_\+\+Q16}}(q16\+\_\+val, min\+\_\+val, max\+\_\+val) -\begin{DoxyCompactList}\small\item\em Обратное линейное масштабирование Q16.\+16 значения в диапазон \mbox{[}min\+\_\+val, max\+\_\+val\mbox{]}. \end{DoxyCompactList}\end{DoxyCompactItemize} +\begin{DoxyCompactList}\small\item\em Обратное линейное масштабирование Q16.\+16 значения в диапазон \mbox{[}min\+\_\+val, max\+\_\+val\mbox{]}. \end{DoxyCompactList}\item +\#define \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga9c853b02c22f26023c34d1d404b6d653}{local\+\_\+time}}() +\begin{DoxyCompactList}\small\item\em Локальное время \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsubsection*{Functions} \begin{DoxyCompactItemize} \item -\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE void \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gac21587fe68fe3635525358ac3f4059d9}{Evolve\+Optimizer\+\_\+\+Init}} (\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}opt, uint16\+\_\+t n\+\_\+params, uint16\+\_\+t n\+\_\+cand, uint16\+\_\+t n\+\_\+best, uint16\+\_\+t iq\+\_\+mutation, int32\+\_\+t \texorpdfstring{$\ast$}{*}start\+\_\+params) +\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE int \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gadaf3a90724197e1737d5c70c7bcc75e1}{Evolve\+Optimizer\+\_\+\+Init}} (\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}opt, uint16\+\_\+t n\+\_\+params, uint16\+\_\+t n\+\_\+cand, uint16\+\_\+t n\+\_\+best, uint16\+\_\+t iq\+\_\+mutation, int32\+\_\+t \texorpdfstring{$\ast$}{*}start\+\_\+params) \begin{DoxyCompactList}\small\item\em Инициализация эволюционного оптимизатора. \end{DoxyCompactList}\item -\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE void \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga1ba2fa963c9ae12625be1b7c20718563}{Evolve\+Optimizer\+\_\+\+Step}} (\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}opt, int32\+\_\+t \texorpdfstring{$\ast$}{*}params, int32\+\_\+t loss) +\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE int \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga75acd71c85d4e60dc0eb31bc5780086a}{Evolve\+Optimizer\+\_\+\+Step}} (\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}opt, int32\+\_\+t \texorpdfstring{$\ast$}{*}params, int32\+\_\+t loss) \begin{DoxyCompactList}\small\item\em Один шаг эволюционного оптимизатора. \end{DoxyCompactList}\end{DoxyCompactItemize} diff --git a/Doc/latex/evolve__optimizer_8h_source.tex b/Doc/latex/evolve__optimizer_8h_source.tex index 50733a7..37adfbd 100644 --- a/Doc/latex/evolve__optimizer_8h_source.tex +++ b/Doc/latex/evolve__optimizer_8h_source.tex @@ -17,208 +17,276 @@ \DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00013}00013\ \textcolor{comment}{-\/\ Мутацию\ для\ поиска\ оптимальных\ параметров}} \DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00014}00014\ \textcolor{comment}{-\/\ Несколько\ независимых\ оптимизаторов\ в\ одной\ программе}} \DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00015}00015\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00016}00016\ \textcolor{comment}{Если\ библиотека\ отключена\ @ref\ ENABLE\_EVOLVE\_OPTIMIZATION,\ то\ вставляются\ }} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00017}00017\ \textcolor{comment}{заглушки,\ никак\ не\ влияющие\ на\ параметры\ и\ остальную\ программу}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00018}00018\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00019}00019\ \textcolor{comment}{@par\ Пример\ использования:}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00020}00020\ \textcolor{comment}{@code}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00021}00021\ \textcolor{comment}{\#include\ "{}evolve\_optimizer.h"{}}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00022}00022\ \textcolor{comment}{\#define\ N\_PARAMS\ \ \ \ \ \ \ \ 4}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00023}00023\ \textcolor{comment}{\#define\ N\_CANDIDATES\ \ \ \ 100}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00024}00024\ \textcolor{comment}{\#define\ N\_BEST\ \ \ \ \ \ \ \ \ \ 10}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00025}00025\ \textcolor{comment}{\#define\ IQ\_MUTATION\ \ \ \ \ 655}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00026}00026\ \textcolor{comment}{int32\_t\ params[N\_PARAMS];}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00027}00027\ \textcolor{comment}{EvolveOptimizer\_t\ optimizer;}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00028}00028\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00029}00029\ \textcolor{comment}{//\ Формирование\ параметров}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00030}00030\ \textcolor{comment}{uint16\_t\ \ param\_u16\ =\ 800;}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00031}00031\ \textcolor{comment}{float\ \ \ \ \ param\_f\ \ \ =\ 0.01f;}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00032}00032\ \textcolor{comment}{uint8\_t\ \ \ param\_u8\ \ =\ 40;}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00033}00033\ \textcolor{comment}{int16\_t\ \ \ param\_i16\ =\ 1600;}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00034}00034\ \textcolor{comment}{params[0]\ =\ PARAM\_SCALE\_Q16(param\_u16,\ \ 0,\ \ \ \ \ \ 1000);}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00035}00035\ \textcolor{comment}{params[1]\ =\ PARAM\_SCALE\_Q16(param\_f,\ \ \ \ 0.001f,\ 0.1f);}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00036}00036\ \textcolor{comment}{params[2]\ =\ PARAM\_SCALE\_Q16(param\_u8,\ \ \ 10,\ \ \ \ \ 100);}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00037}00037\ \textcolor{comment}{params[3]\ =\ PARAM\_SCALE\_Q16(param\_i16,\ \ 500,\ \ \ \ 5000);}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00038}00038\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00039}00039\ \textcolor{comment}{//\ Инициалиазция}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00040}00040\ \textcolor{comment}{EvolveOptimizer\_Init(\&optimizer,\ N\_PARAMS,\ N\_CANDIDATES,\ N\_BEST,\ IQ\_MUTATION,\ params);}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00041}00041\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00042}00042\ \textcolor{comment}{//\ Шаг\ эволюции}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00043}00043\ \textcolor{comment}{int32\_t\ loss\ =\ calc\_iq\_loss();\ //\ расчет\ эффективности\ параметров}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00044}00044\ \textcolor{comment}{EvolveOptimizer\_Step(\&optimizer,\ params,\ loss);}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00045}00045\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00046}00046\ \textcolor{comment}{//\ Взятие\ следующих\ для\ эволюции\ параметров}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00047}00047\ \textcolor{comment}{param\_u16\ =\ PARAM\_UNSCALE\_Q16(params[0],\ \ 0,\ \ \ \ \ \ 1000);}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00048}00048\ \textcolor{comment}{param\_f\ \ \ =\ PARAM\_UNSCALE\_Q16(params[1],\ \ 0.001f,\ 0.1f);}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00049}00049\ \textcolor{comment}{param\_u8\ \ =\ PARAM\_UNSCALE\_Q16(params[2],\ \ 10,\ \ \ \ \ 100);}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00050}00050\ \textcolor{comment}{param\_i16\ =\ PARAM\_UNSCALE\_Q16(params[3],\ \ 500,\ \ \ \ 5000);}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00051}00051\ \textcolor{comment}{@endcode}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00052}00052\ \textcolor{comment}{*\ @\{\ \ }} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00053}00053\ \textcolor{comment}{*****************************************************************************/}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00054}00054\ \textcolor{preprocessor}{\#ifndef\ \_\_EVOLVE\_OPTIMIZER\_H\_}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00055}00055\ \textcolor{preprocessor}{\#define\ \_\_EVOLVE\_OPTIMIZER\_H\_}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00056}00056\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00057}00057\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{mylibs__defs_8h}{mylibs\_defs.h}}"{}}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00058}00058\ \textcolor{preprocessor}{\#include\ }} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00059}00059\ \textcolor{preprocessor}{\#include\ }} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00060}00060\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00061}00061\ \textcolor{preprocessor}{\#ifdef\ ENABLE\_EVOLVE\_OPTIMIZATION}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00016}00016\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00017}00017\ \textcolor{comment}{Параметры\ для\ конфигурации:}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00018}00018\ \textcolor{comment}{-\/\ @ref\ ENABLE\_EVOLVE\_OPTIMIZATION\ -\/\ Включить\ оптимизацию\ параметров}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00019}00019\ \textcolor{comment}{\ \ Если\ библиотека\ отключена\ @ref\ ENABLE\_EVOLVE\_OPTIMIZATION,\ то\ вставляются\ }} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00020}00020\ \textcolor{comment}{\ \ заглушки,\ никак\ не\ влияющие\ на\ параметры\ и\ остальную\ программу}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00021}00021\ \textcolor{comment}{-\/\ @ref\ EVOLVE\_MAX\_PARAMS\ \ \ \ \ \ \ \ \ \ -\/\ Максимальное\ количество\ параметров}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00022}00022\ \textcolor{comment}{-\/\ @ref\ EVOLVE\_MAX\_CANDIDATES\ \ \ \ \ \ -\/\ Максимальное\ количество\ кандидатов\ для\ обучения}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00023}00023\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00024}00024\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00025}00025\ \textcolor{comment}{@par\ Пример\ использования:}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00026}00026\ \textcolor{comment}{@code}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00027}00027\ \textcolor{comment}{\#include\ "{}evolve\_optimizer.h"{}}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00028}00028\ \textcolor{comment}{\#define\ N\_PARAMS\ \ \ \ \ \ \ \ 4}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00029}00029\ \textcolor{comment}{\#define\ N\_CANDIDATES\ \ \ \ 100}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00030}00030\ \textcolor{comment}{\#define\ N\_BEST\ \ \ \ \ \ \ \ \ \ 10}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00031}00031\ \textcolor{comment}{\#define\ IQ\_MUTATION\ \ \ \ \ (PARAM\_SCALE\_Q16(0.1,\ 0,\ 1))}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00032}00032\ \textcolor{comment}{int32\_t\ params[N\_PARAMS];}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00033}00033\ \textcolor{comment}{EvolveOptimizer\_t\ optimizer;}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00034}00034\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00035}00035\ \textcolor{comment}{//\ Формирование\ параметров}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00036}00036\ \textcolor{comment}{uint16\_t\ \ param\_u16\ =\ 800;}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00037}00037\ \textcolor{comment}{float\ \ \ \ \ param\_f\ \ \ =\ 0.01f;}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00038}00038\ \textcolor{comment}{uint8\_t\ \ \ param\_u8\ \ =\ 40;}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00039}00039\ \textcolor{comment}{int16\_t\ \ \ param\_i16\ =\ 1600;}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00040}00040\ \textcolor{comment}{params[0]\ =\ PARAM\_SCALE\_Q16(param\_u16,\ \ 0,\ \ \ \ \ \ 1000);}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00041}00041\ \textcolor{comment}{params[1]\ =\ PARAM\_SCALE\_Q16(param\_f,\ \ \ \ 0.001f,\ 0.1f);}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00042}00042\ \textcolor{comment}{params[2]\ =\ PARAM\_SCALE\_Q16(param\_u8,\ \ \ 10,\ \ \ \ \ 100);}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00043}00043\ \textcolor{comment}{params[3]\ =\ PARAM\_SCALE\_Q16(param\_i16,\ \ 500,\ \ \ \ 5000);}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00044}00044\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00045}00045\ \textcolor{comment}{//\ Инициалиазция}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00046}00046\ \textcolor{comment}{EvolveOptimizer\_Init(\&optimizer,\ N\_PARAMS,\ N\_CANDIDATES,\ N\_BEST,\ IQ\_MUTATION,\ params);}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00047}00047\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00048}00048\ \textcolor{comment}{//\ Шаг\ эволюции}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00049}00049\ \textcolor{comment}{int32\_t\ loss\ =\ calc\_iq\_loss();\ //\ расчет\ эффективности\ параметров}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00050}00050\ \textcolor{comment}{EvolveOptimizer\_Step(\&optimizer,\ params,\ loss);}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00051}00051\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00052}00052\ \textcolor{comment}{//\ Взятие\ следующих\ для\ эволюции\ параметров}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00053}00053\ \textcolor{comment}{param\_u16\ =\ PARAM\_UNSCALE\_Q16(params[0],\ \ 0,\ \ \ \ \ \ 1000);}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00054}00054\ \textcolor{comment}{param\_f\ \ \ =\ PARAM\_UNSCALE\_Q16(params[1],\ \ 0.001f,\ 0.1f);}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00055}00055\ \textcolor{comment}{param\_u8\ \ =\ PARAM\_UNSCALE\_Q16(params[2],\ \ 10,\ \ \ \ \ 100);}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00056}00056\ \textcolor{comment}{param\_i16\ =\ PARAM\_UNSCALE\_Q16(params[3],\ \ 500,\ \ \ \ 5000);}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00057}00057\ \textcolor{comment}{@endcode}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00058}00058\ \textcolor{comment}{*\ @\{\ \ }} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00059}00059\ \textcolor{comment}{*****************************************************************************/}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00060}00060\ \textcolor{preprocessor}{\#ifndef\ \_\_EVOLVE\_OPTIMIZER\_H\_}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00061}00061\ \textcolor{preprocessor}{\#define\ \_\_EVOLVE\_OPTIMIZER\_H\_}} \DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00062}00062\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00063}00063\ \textcolor{preprocessor}{\#define\ Q16\_MUL(a,b)\ ((int32\_t)(((int64\_t)(a)\ *\ (int64\_t)(b))\ >>\ 16))}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00064}00064\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00065}00065\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00066}00066\ \textcolor{comment}{\ \ *\ @brief\ Линейное\ масштабирование\ x\ из\ диапазона\ [min\_val,\ max\_val]\ в\ Q16.16\ [0,\ 65536)}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00067}00067\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00068}\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gaff223481fcffea77394a331afde29fdc}{00068}}\ \textcolor{preprocessor}{\#define\ PARAM\_SCALE\_Q16(x,\ min\_val,\ max\_val)\ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00069}00069\ \textcolor{preprocessor}{((int32\_t)((((float)(x)\ -\/\ (float)(min\_val))\ /\ ((float)(max\_val)\ -\/\ (float)(min\_val)))\ *\ 65536.0f))}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00070}00070\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00071}00071\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00072}00072\ \textcolor{comment}{\ \ *\ @brief\ Обратное\ линейное\ масштабирование\ Q16.16\ значения\ в\ диапазон\ [min\_val,\ max\_val]}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00073}00073\ \textcolor{comment}{\ */}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00074}\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga71a0c240c667e976d9caef391ab767ba}{00074}}\ \textcolor{preprocessor}{\#define\ PARAM\_UNSCALE\_Q16(q16\_val,\ min\_val,\ max\_val)\ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00075}00075\ \textcolor{preprocessor}{(((float)(q16\_val)\ /\ 65536.0f)\ *\ ((float)(max\_val)\ -\/\ (float)(min\_val))\ +\ (float)(min\_val))}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00076}00076\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00077}00077\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00078}00078\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00079}00079\ \textcolor{comment}{\ \ *\ @brief\ Структура\ эволюционного\ оптимизатора}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00080}00080\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00081}\mbox{\hyperlink{struct_evolve_optimizer__t}{00081}}\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00082}\mbox{\hyperlink{struct_evolve_optimizer__t_a1c270fce82e0c97e6c88fd0971c1eed8}{00082}}\ \ \ uint16\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_a1c270fce82e0c97e6c88fd0971c1eed8}{n\_params}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Количество\ параметров}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00083}\mbox{\hyperlink{struct_evolve_optimizer__t_ac35c7ca8cede4ab9c53a2845a91cd1b1}{00083}}\ \ \ uint16\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_ac35c7ca8cede4ab9c53a2845a91cd1b1}{n\_cand}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Количество\ кандидатов}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00084}\mbox{\hyperlink{struct_evolve_optimizer__t_a950cd70cb6bff33b78ad35ee58c729a6}{00084}}\ \ \ uint16\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_a950cd70cb6bff33b78ad35ee58c729a6}{n\_best}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Количество\ лучших,\ усредняемых}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00085}\mbox{\hyperlink{struct_evolve_optimizer__t_a5391277564b54e2271856a2466033df5}{00085}}\ \ \ uint16\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_a5391277564b54e2271856a2466033df5}{iq\_mutation}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Амплитуда\ мутации\ в\ Q16.16}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00086}\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{00086}}\ \ \ uint16\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Индекс\ кандидата\ для\ обработки}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00087}\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{00087}}\ \ \ int32\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[\mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga7c1396e5c95c766afccdb45cbfcf5971}{EVOLVE\_MAX\_CANDIDATES}}];\ \ \ \ \textcolor{comment}{///<\ Loss\ для\ каждого\ кандидата}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00088}\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{00088}}\ \ \ int32\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[\mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga7c1396e5c95c766afccdb45cbfcf5971}{EVOLVE\_MAX\_CANDIDATES}}][\mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga80d6162495fc3776d8902610657d4fee}{EVOLVE\_MAX\_PARAMS}}];\ \ \ \ \textcolor{comment}{///<\ Параметры\ кандидатов}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00089}00089\ \}\ \mbox{\hyperlink{struct_evolve_optimizer__t}{EvolveOptimizer\_t}};} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00090}00090\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00091}00091\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00092}00092\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00093}00093\ \textcolor{comment}{\ \ *\ @brief\ Инициализация\ эволюционного\ оптимизатора.}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00094}00094\ \textcolor{comment}{\ \ *\ @param\ opt\ \ \ \ \ \ \ \ \ \ Указатель\ на\ структуру\ оптимизатора}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00095}00095\ \textcolor{comment}{\ \ *\ @param\ n\_params\ \ \ \ \ Количество\ параметров\ в\ одном\ кандидате}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00096}00096\ \textcolor{comment}{\ \ *\ @param\ n\_cand\ \ \ \ \ \ \ Количество\ кандидатов}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00097}00097\ \textcolor{comment}{\ \ *\ @param\ n\_best\ \ \ \ \ \ \ Количество\ лучших,\ усредняемых}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00098}00098\ \textcolor{comment}{\ \ *\ @param\ iq\_mutation\ \ Амплитуда\ мутации\ в\ Q16.16}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00099}00099\ \textcolor{comment}{\ \ *\ @param\ start\_params\ Начальные\ параметры\ (Q16.16)}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00100}00100\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00101}\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gac21587fe68fe3635525358ac3f4059d9}{00101}}\ \_\_STATIC\_INLINE\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gac21587fe68fe3635525358ac3f4059d9}{EvolveOptimizer\_Init}}(\mbox{\hyperlink{struct_evolve_optimizer__t}{EvolveOptimizer\_t}}*\ opt,} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00102}00102\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint16\_t\ n\_params,} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00103}00103\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint16\_t\ n\_cand,} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00104}00104\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint16\_t\ n\_best,} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00105}00105\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint16\_t\ iq\_mutation,} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00106}00106\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ int32\_t*\ start\_params)} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00107}00107\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00108}00108\ \ \ \textcolor{keywordflow}{if}(\mbox{\hyperlink{group___e_r_r_o_r___h_a_n_d_l_e_r___d_e_f_i_n_e_s_ga27b363f333cacdccc15f5174e096b5b3}{check\_null\_ptr\_2}}(opt,\ start\_params))} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00109}00109\ \ \ \ \ \textcolor{keywordflow}{return};} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00110}00110\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00111}00111\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a1c270fce82e0c97e6c88fd0971c1eed8}{n\_params}}\ \ \ \ \ =\ n\_params;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00112}00112\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac35c7ca8cede4ab9c53a2845a91cd1b1}{n\_cand}}\ \ \ \ \ \ \ =\ n\_cand;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00113}00113\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a950cd70cb6bff33b78ad35ee58c729a6}{n\_best}}\ \ \ \ \ \ \ =\ n\_best;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00114}00114\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a5391277564b54e2271856a2466033df5}{iq\_mutation}}\ \ =\ iq\_mutation;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00115}00115\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00116}00116\ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ i\ =\ 0;\ i\ <\ n\_cand;\ i++)\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00117}00117\ \ \ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ j\ =\ 0;\ j\ <\ n\_params;\ j++)\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00118}00118\ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[i][j]\ =\ start\_params[j];} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00119}00119\ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00120}00120\ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[i]\ =\ 0;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00121}00121\ \ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00122}00122\ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00123}00123\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00124}00124\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00125}00125\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00126}00126\ \textcolor{comment}{\ \ *\ @brief\ Один\ шаг\ эволюционного\ оптимизатора.}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00127}00127\ \textcolor{comment}{\ \ *\ @param\ opt\ \ \ \ Указатель\ на\ структуру\ оптимизатора}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00128}00128\ \textcolor{comment}{\ \ *\ @param\ params\ Массив\ параметров,\ которые\ будут\ обновлены\ (на\ выходе\ —\ новые\ параметры)}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00129}00129\ \textcolor{comment}{\ \ *\ @param\ loss\ \ \ Loss\ текущего\ кандидата\ (Q16.16)}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00130}00130\ \textcolor{comment}{\ \ *\ @details}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00131}00131\ \textcolor{comment}{\ \ *\ Сохраняет\ loss\ текущего\ кандидата\ и\ формирует\ параметры\ следующего\ кандидата.}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00132}00132\ \textcolor{comment}{\ \ *\ Если\ накоплено\ n\_cand\ кандидатов,\ генерируется\ новое\ поколение.}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00133}00133\ \textcolor{comment}{\ \ *\ Новое\ поколение\ формируется\ случайным\ выбором\ из\ n\_best\ лучших\ с\ добавлением\ мутации.}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00134}00134\ \textcolor{comment}{\ \ *}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00135}00135\ \textcolor{comment}{\ \ *\ На\ выходе\ params\ содержит\ параметры\ следующего\ кандидата\ для\ измерений.}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00136}00136\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00137}\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga1ba2fa963c9ae12625be1b7c20718563}{00137}}\ \_\_STATIC\_INLINE\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga1ba2fa963c9ae12625be1b7c20718563}{EvolveOptimizer\_Step}}(\mbox{\hyperlink{struct_evolve_optimizer__t}{EvolveOptimizer\_t}}*\ opt,} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00138}00138\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ int32\_t*\ params,} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00139}00139\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ int32\_t\ \ \ loss)} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00140}00140\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00141}00141\ \ \ \textcolor{keywordflow}{if}(\mbox{\hyperlink{group___e_r_r_o_r___h_a_n_d_l_e_r___d_e_f_i_n_e_s_ga27b363f333cacdccc15f5174e096b5b3}{check\_null\_ptr\_2}}(opt,\ params))} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00142}00142\ \ \ \ \ \textcolor{keywordflow}{return};} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00143}00143\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00144}00144\ \ \ uint16\_t\ n\_params\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a1c270fce82e0c97e6c88fd0971c1eed8}{n\_params}};\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00145}00145\ \ \ uint16\_t\ n\_cand\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac35c7ca8cede4ab9c53a2845a91cd1b1}{n\_cand}};\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00146}00146\ \ \ uint16\_t\ n\_best\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a950cd70cb6bff33b78ad35ee58c729a6}{n\_best}};\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00147}00147\ \ \ uint16\_t\ mut\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a5391277564b54e2271856a2466033df5}{iq\_mutation}};} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00148}00148\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00149}00149\ \ \ \textcolor{comment}{//\ 1.\ Сохраняем\ loss\ текущего\ кандидата}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00150}00150\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}}]\ =\ loss;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00151}00151\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00152}00152\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}}++;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00153}00153\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00154}00154\ \ \ \textcolor{keywordflow}{if}\ (opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}}\ >=\ n\_cand)\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00155}00155\ \ \ \ \ \textcolor{comment}{//\ 2.\ Сортируем\ текущее\ поколение\ по\ loss}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00156}00156\ \ \ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ i\ =\ 0;\ i\ <\ n\_cand\ -\/\ 1;\ i++)\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00157}00157\ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ j\ =\ i\ +\ 1;\ j\ <\ n\_cand;\ j++)\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00158}00158\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[j]\ <\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[i])\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00159}00159\ \ \ \ \ \ \ \ \ \ \ int32\_t\ tmp\_loss\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[i];} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00160}00160\ \ \ \ \ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[i]\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[j];} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00161}00161\ \ \ \ \ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[j]\ =\ tmp\_loss;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00162}00162\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00163}00163\ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ k\ =\ 0;\ k\ <\ n\_params;\ k++)\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00164}00164\ \ \ \ \ \ \ \ \ \ \ \ \ int32\_t\ tmp\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[i][k];} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00165}00165\ \ \ \ \ \ \ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[i][k]\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[j][k];} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00166}00166\ \ \ \ \ \ \ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[j][k]\ =\ tmp;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00167}00167\ \ \ \ \ \ \ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00168}00168\ \ \ \ \ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00169}00169\ \ \ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00170}00170\ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00171}00171\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00172}00172\ \ \ \ \ \textcolor{comment}{//\ 3.\ Генерируем\ новое\ поколение:\ каждый\ кандидат\ берется\ случайно\ из\ лучших\ с\ мутацией}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00173}00173\ \ \ \ \ uint16\_t\ n\_elite\ =\ 2;\ \textcolor{comment}{//\ количество\ элитных\ кандидатов,\ которые\ сохраняем\ без\ изменений}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00174}00174\ \ \ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ c\ =\ 0;\ c\ <\ n\_cand;\ c++)\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00175}00175\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (c\ <\ n\_elite)\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00176}00176\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Копируем\ лучших\ кандидатов\ напрямую\ без\ мутации}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00177}00177\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ i\ =\ 0;\ i\ <\ n\_params;\ i++)\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00178}00178\ \ \ \ \ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[c][i]\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[c][i];\ \textcolor{comment}{//\ просто\ сохраняем\ параметры}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00179}00179\ \ \ \ \ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00180}00180\ \ \ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[c]\ =\ 0;\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00181}00181\ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00182}00182\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Остальные\ кандидаты\ формируются\ с\ кроссовером\ и\ мутацией}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00183}00183\ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ i\ =\ 0;\ i\ <\ n\_params;\ i++)\ \{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00184}00184\ \ \ \ \ \ \ \ \ int32\_t\ noise\ =\ (rand()\ \%\ (2\ *\ mut))\ -\/\ mut;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00185}00185\ \ \ \ \ \ \ \ \ \ \ uint16\_t\ parent\ =\ rand()\ \%\ n\_best;\ \textcolor{comment}{//\ каждый\ параметр\ из\ случайного\ лучшего}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00186}00186\ \ \ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[c][i]\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[parent][i]\ +\ noise;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00187}00187\ \ \ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00188}00188\ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[c]\ =\ 0;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00189}00189\ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00190}00190\ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00191}00191\ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}}\ =\ 0;} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00192}00192\ \ \ \}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00063}00063\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{mylibs__defs_8h}{mylibs\_defs.h}}"{}}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00064}00064\ \textcolor{preprocessor}{\#include\ }} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00065}00065\ \textcolor{preprocessor}{\#include\ }} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00066}00066\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00067}00067\ \textcolor{preprocessor}{\#ifdef\ ENABLE\_EVOLVE\_OPTIMIZATION}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00068}00068\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00069}00069\ \textcolor{comment}{\ \ *\ @brief\ Линейное\ масштабирование\ x\ из\ диапазона\ [min\_val,\ max\_val]\ в\ Q16.16\ [0,\ 65536)}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00070}00070\ \textcolor{comment}{\ \ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00071}\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gaff223481fcffea77394a331afde29fdc}{00071}}\ \textcolor{preprocessor}{\#define\ PARAM\_SCALE\_Q16(x,\ min\_val,\ max\_val)\ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00072}00072\ \textcolor{preprocessor}{((int32\_t)((((float)(x)\ -\/\ (float)(min\_val))\ /\ ((float)(max\_val)\ -\/\ (float)(min\_val)))\ *\ 65536.0f))}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00073}00073\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00074}00074\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00075}00075\ \textcolor{comment}{\ \ *\ @brief\ Обратное\ линейное\ масштабирование\ Q16.16\ значения\ в\ диапазон\ [min\_val,\ max\_val]}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00076}00076\ \textcolor{comment}{\ */}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00077}\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga71a0c240c667e976d9caef391ab767ba}{00077}}\ \textcolor{preprocessor}{\#define\ PARAM\_UNSCALE\_Q16(q16\_val,\ min\_val,\ max\_val)\ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00078}00078\ \textcolor{preprocessor}{(((float)(q16\_val)\ /\ 65536.0f)\ *\ ((float)(max\_val)\ -\/\ (float)(min\_val))\ +\ (float)(min\_val))}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00079}00079\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00080}00080\ \textcolor{preprocessor}{\#ifndef\ local\_time}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00081}\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga9c853b02c22f26023c34d1d404b6d653}{00081}}\ \textcolor{preprocessor}{\#define\ local\_time()\ \ HAL\_GetTick()\ }\textcolor{comment}{///<\ Локальное\ время}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00082}00082\ \textcolor{preprocessor}{\#endif}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00083}00083\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00084}00084\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00085}00085\ \textcolor{comment}{\ \ *\ @brief\ Структура\ эволюционного\ оптимизатора}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00086}00086\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00087}\mbox{\hyperlink{struct_evolve_optimizer__t}{00087}}\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00088}\mbox{\hyperlink{struct_evolve_optimizer__t_a1c270fce82e0c97e6c88fd0971c1eed8}{00088}}\ \ \ uint16\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_a1c270fce82e0c97e6c88fd0971c1eed8}{n\_params}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Количество\ параметров}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00089}\mbox{\hyperlink{struct_evolve_optimizer__t_ac35c7ca8cede4ab9c53a2845a91cd1b1}{00089}}\ \ \ uint16\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_ac35c7ca8cede4ab9c53a2845a91cd1b1}{n\_cand}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Количество\ кандидатов}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00090}\mbox{\hyperlink{struct_evolve_optimizer__t_a950cd70cb6bff33b78ad35ee58c729a6}{00090}}\ \ \ uint16\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_a950cd70cb6bff33b78ad35ee58c729a6}{n\_best}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Количество\ лучших,\ усредняемых}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00091}\mbox{\hyperlink{struct_evolve_optimizer__t_a5391277564b54e2271856a2466033df5}{00091}}\ \ \ uint16\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_a5391277564b54e2271856a2466033df5}{iq\_mutation}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Амплитуда\ мутации\ в\ Q16.16}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00092}\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{00092}}\ \ \ uint16\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Индекс\ кандидата\ для\ обработки}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00093}\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{00093}}\ \ \ int32\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[\mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga7c1396e5c95c766afccdb45cbfcf5971}{EVOLVE\_MAX\_CANDIDATES}}];\ \ \ \ \textcolor{comment}{///<\ Loss\ для\ каждого\ кандидата}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00094}\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{00094}}\ \ \ int32\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[\mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga7c1396e5c95c766afccdb45cbfcf5971}{EVOLVE\_MAX\_CANDIDATES}}][\mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga80d6162495fc3776d8902610657d4fee}{EVOLVE\_MAX\_PARAMS}}];\ \ \ \ \textcolor{comment}{///<\ Параметры\ кандидатов}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00095}\mbox{\hyperlink{struct_evolve_optimizer__t_a74b81df1c298c99162310f3f7d91735a}{00095}}\ \ \ uint16\_t\ \mbox{\hyperlink{struct_evolve_optimizer__t_a74b81df1c298c99162310f3f7d91735a}{sorted\_idx}}[\mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga7c1396e5c95c766afccdb45cbfcf5971}{EVOLVE\_MAX\_CANDIDATES}}];\ \textcolor{comment}{///<\ Индексы\ отсортированных\ кандидатов}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00096}00096\ \}\ \mbox{\hyperlink{struct_evolve_optimizer__t}{EvolveOptimizer\_t}};} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00097}00097\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00098}00098\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00099}00099\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00100}00100\ \textcolor{comment}{/**\ }} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00101}00101\ \textcolor{comment}{\ *\ @cond\ EVOLVE\_INTERNAL}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00102}00102\ \textcolor{comment}{\ */}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00103}00103\ \textcolor{preprocessor}{\#define\ Q16\_MUL(a,b)\ ((int32\_t)(((int64\_t)(a)\ *\ (int64\_t)(b))\ >>\ 16))}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00104}00104\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00105}00105\ \textcolor{comment}{//\ Вспомогательный\ указатель\ для\ сортировки}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00106}00106\ \textcolor{keyword}{static}\ \mbox{\hyperlink{struct_evolve_optimizer__t}{EvolveOptimizer\_t}}\ *g\_sort\_opt;\ \textcolor{comment}{//\ глобальный\ указатель\ на\ текущий\ оптимизатор}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00107}00107\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00108}00108\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ cmp\_idx(\textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *a,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *b)\ \{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00109}00109\ \ \ \textcolor{keywordflow}{if}\ (g\_sort\_opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[*(\textcolor{keyword}{const}\ uint16\_t*)a]\ <\ g\_sort\_opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[*(\textcolor{keyword}{const}\ uint16\_t*)b])\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00110}00110\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00111}00111\ \ \ \textcolor{keywordflow}{if}\ (g\_sort\_opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[*(\textcolor{keyword}{const}\ uint16\_t*)a]\ >\ g\_sort\_opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[*(\textcolor{keyword}{const}\ uint16\_t*)b])\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00112}00112\ \ \ \ \ \textcolor{keywordflow}{return}\ 1;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00113}00113\ \ \ \textcolor{keywordflow}{return}\ 0;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00114}00114\ \}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00115}00115\ \textcolor{comment}{/**\ @endcond\ */}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00116}00116\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00117}00117\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00118}00118\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00119}00119\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00120}00120\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00121}00121\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00122}00122\ \textcolor{comment}{\ \ *\ @brief\ Инициализация\ эволюционного\ оптимизатора.}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00123}00123\ \textcolor{comment}{\ \ *\ @param\ opt\ \ \ \ \ \ \ \ \ \ Указатель\ на\ структуру\ оптимизатора}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00124}00124\ \textcolor{comment}{\ \ *\ @param\ n\_params\ \ \ \ \ Количество\ параметров\ в\ одном\ кандидате}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00125}00125\ \textcolor{comment}{\ \ *\ @param\ n\_cand\ \ \ \ \ \ \ Количество\ кандидатов}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00126}00126\ \textcolor{comment}{\ \ *\ @param\ n\_best\ \ \ \ \ \ \ Количество\ лучших,\ усредняемых}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00127}00127\ \textcolor{comment}{\ \ *\ @param\ iq\_mutation\ \ Амплитуда\ мутации\ в\ Q16.16}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00128}00128\ \textcolor{comment}{\ \ *\ @param\ start\_params\ Начальные\ параметры\ (Q16.16)}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00129}00129\ \textcolor{comment}{\ \ *\ @return\ 0\ \ \ —\ если\ окей,\ }} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00130}00130\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ -\/1\ \ —\ если\ ошибка}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00131}00131\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00132}\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gadaf3a90724197e1737d5c70c7bcc75e1}{00132}}\ \_\_STATIC\_INLINE\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gadaf3a90724197e1737d5c70c7bcc75e1}{EvolveOptimizer\_Init}}(\mbox{\hyperlink{struct_evolve_optimizer__t}{EvolveOptimizer\_t}}*\ opt,} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00133}00133\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint16\_t\ n\_params,} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00134}00134\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint16\_t\ n\_cand,} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00135}00135\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint16\_t\ n\_best,} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00136}00136\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint16\_t\ iq\_mutation,} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00137}00137\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ int32\_t*\ start\_params)} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00138}00138\ \{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00139}00139\ \ \ \textcolor{keywordflow}{if}((opt\ =\ NULL)\ ||\ (start\_params\ ==\ NULL))} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00140}00140\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00141}00141\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00142}00142\ \ \ \textcolor{keywordflow}{if}(n\_params\ >\ \mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga80d6162495fc3776d8902610657d4fee}{EVOLVE\_MAX\_PARAMS}})} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00143}00143\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00144}00144\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a1c270fce82e0c97e6c88fd0971c1eed8}{n\_params}}\ \ \ \ \ =\ n\_params;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00145}00145\ \ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00146}00146\ \ \ \textcolor{keywordflow}{if}(n\_cand\ >\ \mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga7c1396e5c95c766afccdb45cbfcf5971}{EVOLVE\_MAX\_CANDIDATES}})} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00147}00147\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00148}00148\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac35c7ca8cede4ab9c53a2845a91cd1b1}{n\_cand}}\ \ \ \ \ \ \ =\ n\_cand;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00149}00149\ \ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00150}00150\ \ \ \textcolor{keywordflow}{if}(n\_best\ >\ \mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga7c1396e5c95c766afccdb45cbfcf5971}{EVOLVE\_MAX\_CANDIDATES}}/2)} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00151}00151\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00152}00152\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a950cd70cb6bff33b78ad35ee58c729a6}{n\_best}}\ \ \ \ \ \ \ =\ n\_best;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00153}00153\ \ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00154}00154\ \ \ \textcolor{keywordflow}{if}(iq\_mutation\ >\ 32768)} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00155}00155\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00156}00156\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a5391277564b54e2271856a2466033df5}{iq\_mutation}}\ \ =\ iq\_mutation;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00157}00157\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00158}00158\ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ i\ =\ 0;\ i\ <\ n\_cand;\ i++)\ \{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00159}00159\ \ \ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ j\ =\ 0;\ j\ <\ n\_params;\ j++)\ \{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00160}00160\ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[i][j]\ =\ start\_params[j];} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00161}00161\ \ \ \ \ \}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00162}00162\ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[i]\ =\ 0;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00163}00163\ \ \ \}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00164}00164\ \ \ uint32\_t\ seed\ =\ \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga9c853b02c22f26023c34d1d404b6d653}{local\_time}}()\ +\ (ADC1-\/>DR\ \&\ 0xFF);} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00165}00165\ \ \ srand(seed);} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00166}00166\ \ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00167}00167\ \ \ \textcolor{keywordflow}{return}\ 0;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00168}00168\ \}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00169}00169\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00170}00170\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00171}00171\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00172}00172\ \textcolor{comment}{\ \ *\ @brief\ Один\ шаг\ эволюционного\ оптимизатора.}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00173}00173\ \textcolor{comment}{\ \ *\ @param\ opt\ \ \ \ Указатель\ на\ структуру\ оптимизатора}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00174}00174\ \textcolor{comment}{\ \ *\ @param\ params\ Массив\ параметров,\ которые\ будут\ обновлены\ (на\ выходе\ —\ новые\ параметры)}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00175}00175\ \textcolor{comment}{\ \ *\ @param\ loss\ \ \ Loss\ текущего\ кандидата\ (Q16.16)}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00176}00176\ \textcolor{comment}{\ \ *\ @return\ 0\ \ \ —\ если\ окей,\ }} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00177}00177\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ -\/1\ \ —\ если\ ошибка}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00178}00178\ \textcolor{comment}{\ \ *\ @details}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00179}00179\ \textcolor{comment}{\ \ *\ Сохраняет\ loss\ текущего\ кандидата\ и\ формирует\ параметры\ следующего\ кандидата.}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00180}00180\ \textcolor{comment}{\ \ *\ Если\ накоплено\ n\_cand\ кандидатов,\ генерируется\ новое\ поколение.}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00181}00181\ \textcolor{comment}{\ \ *\ Новое\ поколение\ формируется\ случайным\ выбором\ из\ n\_best\ лучших\ с\ добавлением\ мутации.}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00182}00182\ \textcolor{comment}{\ \ *}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00183}00183\ \textcolor{comment}{\ \ *\ На\ выходе\ params\ содержит\ параметры\ следующего\ кандидата\ для\ измерений.}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00184}00184\ \textcolor{comment}{\ \ *\ @note\ Функция\ использует\ глобальную\ внутреннюю\ переменную\ для\ сортировки.}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00185}00185\ \textcolor{comment}{\ \ *\ Надо\ убедится\ что\ только\ один\ экземпляр\ функции\ запущен\ в\ момент\ времени}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00186}00186\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00187}\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga75acd71c85d4e60dc0eb31bc5780086a}{00187}}\ \_\_STATIC\_INLINE\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga75acd71c85d4e60dc0eb31bc5780086a}{EvolveOptimizer\_Step}}(\mbox{\hyperlink{struct_evolve_optimizer__t}{EvolveOptimizer\_t}}*\ opt,} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00188}00188\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ int32\_t*\ params,} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00189}00189\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ int32\_t\ \ \ loss)} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00190}00190\ \{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00191}00191\ \ \ \textcolor{keywordflow}{if}((opt\ =\ NULL)\ ||\ (params\ ==\ NULL))} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00192}00192\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;} \DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00193}00193\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00194}00194\ \ \ \textcolor{comment}{//\ 4.\ Возвращаем\ параметры\ следующего\ кандидата}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00195}00195\ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ i\ =\ 0;\ i\ <\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a1c270fce82e0c97e6c88fd0971c1eed8}{n\_params}};\ i++)} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00196}00196\ \ \ \ \ params[i]\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}}][i];} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00197}00197\ \}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00198}00198\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//\ ENABLE\_EVOLVE\_OPTIMIZATION}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00199}00199\ \textcolor{comment}{//заглушки}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00200}00200\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\{} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00201}00201\ \ \ uint16\_t\ n\_params;\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00202}00202\ \ \ uint16\_t\ n\_cand;\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00203}00203\ \ \ uint16\_t\ n\_best;\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00204}00204\ \ \ uint16\_t\ iq\_mutation;\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00205}00205\ \ \ int32\_t\ loss[0];\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00206}00206\ \ \ int32\_t\ candidates[0][0];\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00207}00207\ \}\ \mbox{\hyperlink{struct_evolve_optimizer__t}{EvolveOptimizer\_t}};} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00208}00208\ \textcolor{preprocessor}{\#define\ EvolveOptimizer\_Init(opt,\ n\_params,\ n\_cand,\ n\_best,\ iq\_mutation,\ start\_params)}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00209}00209\ \textcolor{preprocessor}{\#define\ EvolveOptimizer\_Step(opt,\ params,\ LossFunc)}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00210}00210\ \textcolor{preprocessor}{\#define\ PARAM\_SCALE\_Q16(x,\ min\_val,\ max\_val)\ \ \ \ \ \ \ \ \ \ \ \ (x)}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00211}00211\ \textcolor{preprocessor}{\#define\ PARAM\_UNSCALE\_Q16(q16\_val,\ min\_val,\ max\_val)\ \ \ \ (q16\_val)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (q16\_val)}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00212}00212\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ ENABLE\_EVOLVE\_OPTIMIZATION}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00194}00194\ \ \ uint16\_t\ n\_params\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a1c270fce82e0c97e6c88fd0971c1eed8}{n\_params}};\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00195}00195\ \ \ \textcolor{keywordflow}{if}(n\_params\ >\ \mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga80d6162495fc3776d8902610657d4fee}{EVOLVE\_MAX\_PARAMS}})} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00196}00196\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00197}00197\ \ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00198}00198\ \ \ uint16\_t\ n\_cand\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac35c7ca8cede4ab9c53a2845a91cd1b1}{n\_cand}};\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00199}00199\ \ \ \textcolor{keywordflow}{if}(n\_cand\ >\ \mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga7c1396e5c95c766afccdb45cbfcf5971}{EVOLVE\_MAX\_CANDIDATES}})} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00200}00200\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00201}00201\ \ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00202}00202\ \ \ uint16\_t\ n\_best\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a950cd70cb6bff33b78ad35ee58c729a6}{n\_best}};\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00203}00203\ \ \ \textcolor{keywordflow}{if}(n\_best\ >\ \mbox{\hyperlink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga7c1396e5c95c766afccdb45cbfcf5971}{EVOLVE\_MAX\_CANDIDATES}}/2)} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00204}00204\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00205}00205\ \ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00206}00206\ \ \ uint16\_t\ mut\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a5391277564b54e2271856a2466033df5}{iq\_mutation}};} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00207}00207\ \ \ \textcolor{keywordflow}{if}(mut\ >\ 32768)} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00208}00208\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00209}00209\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00210}00210\ \ \ \textcolor{comment}{//\ 1.\ Сохраняем\ loss\ текущего\ кандидата}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00211}00211\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}}]\ =\ loss;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00212}00212\ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}}++;} \DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00213}00213\ } -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00214}00214\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ \_\_EVOLVE\_OPTIMIZER\_H\_}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00215}00215\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00216}00216\ \textcolor{comment}{/**\ EVOLVE\_OPTIMIZER}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00217}00217\ \textcolor{comment}{\ \ *\ @\}}} -\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00218}00218\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00214}00214\ \ \ \textcolor{keywordflow}{if}\ (opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}}\ >=\ n\_cand)\ \{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00215}00215\ \ \ \ \ \textcolor{comment}{//\ 2.\ Сортируем\ текущее\ поколение\ по\ loss}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00216}00216\ \ \ \ \ \textcolor{keywordflow}{for}(uint16\_t\ i\ =\ 0;\ i\ <\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac35c7ca8cede4ab9c53a2845a91cd1b1}{n\_cand}};\ i++)} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00217}00217\ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a74b81df1c298c99162310f3f7d91735a}{sorted\_idx}}[i]\ =\ i;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00218}00218\ \ \ \ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00219}00219\ \ \ \ \ g\_sort\_opt\ =\ opt;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00220}00220\ \ \ \ \ qsort(opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a74b81df1c298c99162310f3f7d91735a}{sorted\_idx}},\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac35c7ca8cede4ab9c53a2845a91cd1b1}{n\_cand}},\ \textcolor{keyword}{sizeof}(uint16\_t),\ cmp\_idx);} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00221}00221\ \ \ \ \ g\_sort\_opt\ =\ NULL;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00222}00222\ \textcolor{comment}{//\ \ \ \ for\ (uint16\_t\ i\ =\ 0;\ i\ <\ n\_cand\ -\/\ 1;\ i++)\ \{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00223}00223\ \textcolor{comment}{//\ \ \ \ \ \ for\ (uint16\_t\ j\ =\ i\ +\ 1;\ j\ <\ n\_cand;\ j++)\ \{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00224}00224\ \textcolor{comment}{//\ \ \ \ \ \ \ \ if\ (opt-\/>loss[j]\ <\ opt-\/>loss[i])\ \{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00225}00225\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ int32\_t\ tmp\_loss\ =\ opt-\/>loss[i];}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00226}00226\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ opt-\/>loss[i]\ =\ opt-\/>loss[j];}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00227}00227\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ opt-\/>loss[j]\ =\ tmp\_loss;}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00228}00228\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00229}00229\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ for\ (uint16\_t\ k\ =\ 0;\ k\ <\ n\_params;\ k++)\ \{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00230}00230\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ int32\_t\ tmp\ =\ opt-\/>candidates[i][k];}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00231}00231\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ opt-\/>candidates[i][k]\ =\ opt-\/>candidates[j][k];}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00232}00232\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ opt-\/>candidates[j][k]\ =\ tmp;}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00233}00233\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \}}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00234}00234\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \}}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00235}00235\ \textcolor{comment}{//\ \ \ \ \ \ \}}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00236}00236\ \textcolor{comment}{//\ \ \ \ \}}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00237}00237\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00238}00238\ \ \ \ \ \textcolor{comment}{//\ 3.\ Генерируем\ новое\ поколение:\ каждый\ кандидат\ берется\ случайно\ из\ лучших\ с\ мутацией}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00239}00239\ \ \ \ \ uint16\_t\ n\_elite\ =\ 2;\ \textcolor{comment}{//\ количество\ элитных\ кандидатов,\ которые\ сохраняем\ без\ изменений}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00240}00240\ \ \ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ c\ =\ 0;\ c\ <\ n\_cand;\ c++)\ \{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00241}00241\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (c\ <\ n\_elite)\ \{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00242}00242\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Копируем\ лучших\ кандидатов\ напрямую\ без\ мутации}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00243}00243\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ i\ =\ 0;\ i\ <\ n\_params;\ i++)\ \{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00244}00244\ \ \ \ \ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[c][i]\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a74b81df1c298c99162310f3f7d91735a}{sorted\_idx}}[c]][i];\ \textcolor{comment}{//\ просто\ сохраняем\ параметры}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00245}00245\ \ \ \ \ \ \ \ \ \}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00246}00246\ \ \ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[c]\ =\ 0;\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00247}00247\ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00248}00248\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Остальные\ кандидаты\ формируются\ с\ кроссовером\ и\ мутацией}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00249}00249\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ i\ =\ 0;\ i\ <\ n\_params;\ i++)\ \{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00250}00250\ \ \ \ \ \ \ \ \ \ \ int32\_t\ noise\ =\ (rand()\ \%\ (2\ *\ mut))\ -\/\ mut;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00251}00251\ \ \ \ \ \ \ \ \ \ \ uint16\_t\ parent\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a74b81df1c298c99162310f3f7d91735a}{sorted\_idx}}[rand()\ \%\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a950cd70cb6bff33b78ad35ee58c729a6}{n\_best}}];\ \textcolor{comment}{//\ каждый\ параметр\ из\ случайного\ лучшего}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00252}00252\ \ \ \ \ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[c][i]\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[parent][i]\ +\ noise;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00253}00253\ \ \ \ \ \ \ \ \ \}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00254}00254\ \ \ \ \ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}}[c]\ =\ 0;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00255}00255\ \ \ \ \ \ \ \}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00256}00256\ \ \ \ \ \}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00257}00257\ \ \ \ \ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}}\ =\ 0;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00258}00258\ \ \ \}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00259}00259\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00260}00260\ \ \ \textcolor{comment}{//\ 4.\ Возвращаем\ параметры\ следующего\ кандидата}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00261}00261\ \ \ \textcolor{keywordflow}{for}\ (uint16\_t\ i\ =\ 0;\ i\ <\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a1c270fce82e0c97e6c88fd0971c1eed8}{n\_params}};\ i++)} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00262}00262\ \ \ \ \ params[i]\ =\ opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}}[opt-\/>\mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}{cand\_index}}][i];} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00263}00263\ \ \ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00264}00264\ \ \ \textcolor{keywordflow}{return}\ 0;} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00265}00265\ \}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00266}00266\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//\ ENABLE\_EVOLVE\_OPTIMIZATION}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00267}00267\ \textcolor{comment}{//заглушки}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00268}00268\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\{} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00269}00269\ \ \ uint16\_t\ n\_params;\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00270}00270\ \ \ uint16\_t\ n\_cand;\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00271}00271\ \ \ uint16\_t\ n\_best;\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00272}00272\ \ \ uint16\_t\ iq\_mutation;\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00273}00273\ \ \ int32\_t\ loss[0];\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00274}00274\ \ \ int32\_t\ candidates[0][0];\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00275}00275\ \}\ \mbox{\hyperlink{struct_evolve_optimizer__t}{EvolveOptimizer\_t}};} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00276}00276\ \textcolor{preprocessor}{\#define\ EvolveOptimizer\_Init(opt,\ n\_params,\ n\_cand,\ n\_best,\ iq\_mutation,\ start\_params)}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00277}00277\ \textcolor{preprocessor}{\#define\ EvolveOptimizer\_Step(opt,\ params,\ LossFunc)}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00278}00278\ \textcolor{preprocessor}{\#define\ PARAM\_SCALE\_Q16(x,\ min\_val,\ max\_val)\ \ \ \ \ \ \ \ \ \ \ \ (x)}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00279}00279\ \textcolor{preprocessor}{\#define\ PARAM\_UNSCALE\_Q16(q16\_val,\ min\_val,\ max\_val)\ \ \ \ (q16\_val)}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00280}00280\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ ENABLE\_EVOLVE\_OPTIMIZATION}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00281}00281\ } +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00282}00282\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ \_\_EVOLVE\_OPTIMIZER\_H\_}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00283}00283\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00284}00284\ \textcolor{comment}{/**\ EVOLVE\_OPTIMIZER}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00285}00285\ \textcolor{comment}{\ \ *\ @\}}} +\DoxyCodeLine{\Hypertarget{evolve__optimizer_8h_source_l00286}00286\ \textcolor{comment}{\ \ */}} \end{DoxyCode} diff --git a/Doc/latex/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.tex b/Doc/latex/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.tex index ec03a32..0ca1115 100644 --- a/Doc/latex/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.tex +++ b/Doc/latex/group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r.tex @@ -23,13 +23,15 @@ struct \mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \#define \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gaff223481fcffea77394a331afde29fdc}{PARAM\+\_\+\+SCALE\+\_\+\+Q16}}(x, min\+\_\+val, max\+\_\+val) \begin{DoxyCompactList}\small\item\em Линейное масштабирование x из диапазона \mbox{[}min\+\_\+val, max\+\_\+val\mbox{]} в Q16.\+16 \mbox{[}0, 65536) \end{DoxyCompactList}\item \#define \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga71a0c240c667e976d9caef391ab767ba}{PARAM\+\_\+\+UNSCALE\+\_\+\+Q16}}(q16\+\_\+val, min\+\_\+val, max\+\_\+val) -\begin{DoxyCompactList}\small\item\em Обратное линейное масштабирование Q16.\+16 значения в диапазон \mbox{[}min\+\_\+val, max\+\_\+val\mbox{]}. \end{DoxyCompactList}\end{DoxyCompactItemize} +\begin{DoxyCompactList}\small\item\em Обратное линейное масштабирование Q16.\+16 значения в диапазон \mbox{[}min\+\_\+val, max\+\_\+val\mbox{]}. \end{DoxyCompactList}\item +\#define \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga9c853b02c22f26023c34d1d404b6d653}{local\+\_\+time}}() +\begin{DoxyCompactList}\small\item\em Локальное время \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsubsubsubsection*{Functions} \begin{DoxyCompactItemize} \item -\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE void \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gac21587fe68fe3635525358ac3f4059d9}{Evolve\+Optimizer\+\_\+\+Init}} (\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}opt, uint16\+\_\+t n\+\_\+params, uint16\+\_\+t n\+\_\+cand, uint16\+\_\+t n\+\_\+best, uint16\+\_\+t iq\+\_\+mutation, int32\+\_\+t \texorpdfstring{$\ast$}{*}start\+\_\+params) +\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE int \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gadaf3a90724197e1737d5c70c7bcc75e1}{Evolve\+Optimizer\+\_\+\+Init}} (\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}opt, uint16\+\_\+t n\+\_\+params, uint16\+\_\+t n\+\_\+cand, uint16\+\_\+t n\+\_\+best, uint16\+\_\+t iq\+\_\+mutation, int32\+\_\+t \texorpdfstring{$\ast$}{*}start\+\_\+params) \begin{DoxyCompactList}\small\item\em Инициализация эволюционного оптимизатора. \end{DoxyCompactList}\item -\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE void \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga1ba2fa963c9ae12625be1b7c20718563}{Evolve\+Optimizer\+\_\+\+Step}} (\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}opt, int32\+\_\+t \texorpdfstring{$\ast$}{*}params, int32\+\_\+t loss) +\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE int \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga75acd71c85d4e60dc0eb31bc5780086a}{Evolve\+Optimizer\+\_\+\+Step}} (\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}opt, int32\+\_\+t \texorpdfstring{$\ast$}{*}params, int32\+\_\+t loss) \begin{DoxyCompactList}\small\item\em Один шаг эволюционного оптимизатора. \end{DoxyCompactList}\end{DoxyCompactItemize} @@ -44,7 +46,12 @@ struct \mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \item Несколько независимых оптимизаторов в одной программе \end{DoxyItemize} -Если библиотека отключена \doxylink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga2cac097081444a7a9b040f4b11550e47}{ENABLE\+\_\+\+EVOLVE\+\_\+\+OPTIMIZATION}, то вставляются заглушки, никак не влияющие на параметры и остальную программу +Параметры для конфигурации\+: +\begin{DoxyItemize} +\item \doxylink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga2cac097081444a7a9b040f4b11550e47}{ENABLE\+\_\+\+EVOLVE\+\_\+\+OPTIMIZATION} -\/ Включить оптимизацию параметров Если библиотека отключена \doxylink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga2cac097081444a7a9b040f4b11550e47}{ENABLE\+\_\+\+EVOLVE\+\_\+\+OPTIMIZATION}, то вставляются заглушки, никак не влияющие на параметры и остальную программу +\item \doxylink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga80d6162495fc3776d8902610657d4fee}{EVOLVE\+\_\+\+MAX\+\_\+\+PARAMS} -\/ Максимальное количество параметров +\item \doxylink{group___e_v_o_l_v_e___c_o_n_f_i_g_ga7c1396e5c95c766afccdb45cbfcf5971}{EVOLVE\+\_\+\+MAX\+\_\+\+CANDIDATES} -\/ Максимальное количество кандидатов для обучения +\end{DoxyItemize} \begin{DoxyParagraph}{Пример использования\+:} @@ -53,7 +60,7 @@ struct \mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \DoxyCodeLine{\textcolor{preprocessor}{\#define\ N\_PARAMS\ \ \ \ \ \ \ \ 4}} \DoxyCodeLine{\textcolor{preprocessor}{\#define\ N\_CANDIDATES\ \ \ \ 100}} \DoxyCodeLine{\textcolor{preprocessor}{\#define\ N\_BEST\ \ \ \ \ \ \ \ \ \ 10}} -\DoxyCodeLine{\textcolor{preprocessor}{\#define\ IQ\_MUTATION\ \ \ \ \ 655}} +\DoxyCodeLine{\textcolor{preprocessor}{\#define\ IQ\_MUTATION\ \ \ \ \ (PARAM\_SCALE\_Q16(0.1,\ 0,\ 1))}} \DoxyCodeLine{int32\_t\ params[N\_PARAMS];} \DoxyCodeLine{\mbox{\hyperlink{struct_evolve_optimizer__t}{EvolveOptimizer\_t}}\ optimizer;} \DoxyCodeLine{} @@ -68,11 +75,11 @@ struct \mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \DoxyCodeLine{params[3]\ =\ \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gaff223481fcffea77394a331afde29fdc}{PARAM\_SCALE\_Q16}}(param\_i16,\ \ 500,\ \ \ \ 5000);} \DoxyCodeLine{} \DoxyCodeLine{\textcolor{comment}{//\ Инициалиазция}} -\DoxyCodeLine{\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gac21587fe68fe3635525358ac3f4059d9}{EvolveOptimizer\_Init}}(\&optimizer,\ N\_PARAMS,\ N\_CANDIDATES,\ N\_BEST,\ IQ\_MUTATION,\ params);} +\DoxyCodeLine{\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gadaf3a90724197e1737d5c70c7bcc75e1}{EvolveOptimizer\_Init}}(\&optimizer,\ N\_PARAMS,\ N\_CANDIDATES,\ N\_BEST,\ IQ\_MUTATION,\ params);} \DoxyCodeLine{} \DoxyCodeLine{\textcolor{comment}{//\ Шаг\ эволюции}} \DoxyCodeLine{int32\_t\ loss\ =\ calc\_iq\_loss();\ \textcolor{comment}{//\ расчет\ эффективности\ параметров}} -\DoxyCodeLine{\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga1ba2fa963c9ae12625be1b7c20718563}{EvolveOptimizer\_Step}}(\&optimizer,\ params,\ loss);} +\DoxyCodeLine{\mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga75acd71c85d4e60dc0eb31bc5780086a}{EvolveOptimizer\_Step}}(\&optimizer,\ params,\ loss);} \DoxyCodeLine{} \DoxyCodeLine{\textcolor{comment}{//\ Взятие\ следующих\ для\ эволюции\ параметров}} \DoxyCodeLine{param\_u16\ =\ \mbox{\hyperlink{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga71a0c240c667e976d9caef391ab767ba}{PARAM\_UNSCALE\_Q16}}(params[0],\ \ 0,\ \ \ \ \ \ 1000);} @@ -105,7 +112,7 @@ struct \mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00068}{68}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00071}{71}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. \Hypertarget{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga71a0c240c667e976d9caef391ab767ba}\index{Evolve optimizer@{Evolve optimizer}!PARAM\_UNSCALE\_Q16@{PARAM\_UNSCALE\_Q16}} \index{PARAM\_UNSCALE\_Q16@{PARAM\_UNSCALE\_Q16}!Evolve optimizer@{Evolve optimizer}} @@ -124,18 +131,37 @@ Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00068}{68}} of -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00074}{74}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00077}{77}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. + +\Hypertarget{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga9c853b02c22f26023c34d1d404b6d653}\index{Evolve optimizer@{Evolve optimizer}!local\_time@{local\_time}} +\index{local\_time@{local\_time}!Evolve optimizer@{Evolve optimizer}} +\doxysubsubsubsubsection{\texorpdfstring{local\_time}{local\_time}} +{\footnotesize\ttfamily \label{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga9c853b02c22f26023c34d1d404b6d653} +\#define local\+\_\+time(\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})} + +{\bfseries Value\+:} +\begin{DoxyCode}{0} +\DoxyCodeLine{HAL\_GetTick()} + +\end{DoxyCode} + + +Локальное время + + + +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00081}{81}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. \label{doc-func-members} \Hypertarget{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_doc-func-members} \doxysubsubsubsection{Function Documentation} -\Hypertarget{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gac21587fe68fe3635525358ac3f4059d9}\index{Evolve optimizer@{Evolve optimizer}!EvolveOptimizer\_Init@{EvolveOptimizer\_Init}} +\Hypertarget{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gadaf3a90724197e1737d5c70c7bcc75e1}\index{Evolve optimizer@{Evolve optimizer}!EvolveOptimizer\_Init@{EvolveOptimizer\_Init}} \index{EvolveOptimizer\_Init@{EvolveOptimizer\_Init}!Evolve optimizer@{Evolve optimizer}} \doxysubsubsubsubsection{\texorpdfstring{EvolveOptimizer\_Init()}{EvolveOptimizer\_Init()}} -{\footnotesize\ttfamily \label{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gac21587fe68fe3635525358ac3f4059d9} -\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE void Evolve\+Optimizer\+\_\+\+Init (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}}]{opt}{, }\item[{uint16\+\_\+t}]{n\+\_\+params}{, }\item[{uint16\+\_\+t}]{n\+\_\+cand}{, }\item[{uint16\+\_\+t}]{n\+\_\+best}{, }\item[{uint16\+\_\+t}]{iq\+\_\+mutation}{, }\item[{int32\+\_\+t \texorpdfstring{$\ast$}{*}}]{start\+\_\+params}{}\end{DoxyParamCaption})} +{\footnotesize\ttfamily \label{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_gadaf3a90724197e1737d5c70c7bcc75e1} +\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE int Evolve\+Optimizer\+\_\+\+Init (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}}]{opt}{, }\item[{uint16\+\_\+t}]{n\+\_\+params}{, }\item[{uint16\+\_\+t}]{n\+\_\+cand}{, }\item[{uint16\+\_\+t}]{n\+\_\+best}{, }\item[{uint16\+\_\+t}]{iq\+\_\+mutation}{, }\item[{int32\+\_\+t \texorpdfstring{$\ast$}{*}}]{start\+\_\+params}{}\end{DoxyParamCaption})} @@ -156,15 +182,18 @@ Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00074}{74}} of {\em start\+\_\+params} & Начальные параметры (Q16.\+16) \\ \hline \end{DoxyParams} +\begin{DoxyReturn}{Returns} +0 — если окей, -\/1 — если ошибка +\end{DoxyReturn} -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00101}{101}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00132}{132}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. -\Hypertarget{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga1ba2fa963c9ae12625be1b7c20718563}\index{Evolve optimizer@{Evolve optimizer}!EvolveOptimizer\_Step@{EvolveOptimizer\_Step}} +\Hypertarget{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga75acd71c85d4e60dc0eb31bc5780086a}\index{Evolve optimizer@{Evolve optimizer}!EvolveOptimizer\_Step@{EvolveOptimizer\_Step}} \index{EvolveOptimizer\_Step@{EvolveOptimizer\_Step}!Evolve optimizer@{Evolve optimizer}} \doxysubsubsubsubsection{\texorpdfstring{EvolveOptimizer\_Step()}{EvolveOptimizer\_Step()}} -{\footnotesize\ttfamily \label{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga1ba2fa963c9ae12625be1b7c20718563} -\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE void Evolve\+Optimizer\+\_\+\+Step (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}}]{opt}{, }\item[{int32\+\_\+t \texorpdfstring{$\ast$}{*}}]{params}{, }\item[{int32\+\_\+t}]{loss}{}\end{DoxyParamCaption})} +{\footnotesize\ttfamily \label{group___e_v_o_l_v_e___o_p_t_i_m_i_z_e_r_ga75acd71c85d4e60dc0eb31bc5780086a} +\+\_\+\+\_\+\+STATIC\+\_\+\+INLINE int Evolve\+Optimizer\+\_\+\+Step (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_evolve_optimizer__t}{Evolve\+Optimizer\+\_\+t}} \texorpdfstring{$\ast$}{*}}]{opt}{, }\item[{int32\+\_\+t \texorpdfstring{$\ast$}{*}}]{params}{, }\item[{int32\+\_\+t}]{loss}{}\end{DoxyParamCaption})} @@ -176,12 +205,18 @@ Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00101}{101}} of \hline {\em params} & Массив параметров, которые будут обновлены (на выходе — новые параметры) \\ \hline -{\em loss} & Loss текущего кандидата (Q16.\+16)\\ +{\em loss} & Loss текущего кандидата (Q16.\+16) \\ \hline \end{DoxyParams} +\begin{DoxyReturn}{Returns} +0 — если окей, -\/1 — если ошибка +\end{DoxyReturn} Сохраняет loss текущего кандидата и формирует параметры следующего кандидата. Если накоплено n\+\_\+cand кандидатов, генерируется новое поколение. Новое поколение формируется случайным выбором из n\+\_\+best лучших с добавлением мутации. -На выходе params содержит параметры следующего кандидата для измерений. +На выходе params содержит параметры следующего кандидата для измерений. \begin{DoxyNote}{Note} +Функция использует глобальную внутреннюю переменную для сортировки. Надо убедится что только один экземпляр функции запущен в момент времени +\end{DoxyNote} -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00137}{137}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. + +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00187}{187}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. diff --git a/Doc/latex/group___t_r_a_c_e___g_p_i_o.tex b/Doc/latex/group___t_r_a_c_e___g_p_i_o.tex index 710c717..7672e01 100644 --- a/Doc/latex/group___t_r_a_c_e___g_p_i_o.tex +++ b/Doc/latex/group___t_r_a_c_e___g_p_i_o.tex @@ -62,7 +62,7 @@ Collaboration diagram for GPIO trace defines\+:\nopagebreak \item GPIO\+\_\+\+TRACE\+\_\+\+ENABLE определён -\/ устанавливает бит сброса через BSRR (({\itshape pin})\texorpdfstring{$<$}{<}\texorpdfstring{$<$}{<}16) \end{DoxyItemize} -Definition at line \mbox{\hyperlink{trace_8h_source_l00138}{138}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00142}{142}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{group___t_r_a_c_e___g_p_i_o_ga02a6a7b273766121db8ad4a1371373eb}\index{GPIO trace defines@{GPIO trace defines}!TRACE\_GPIO\_SET@{TRACE\_GPIO\_SET}} \index{TRACE\_GPIO\_SET@{TRACE\_GPIO\_SET}!GPIO trace defines@{GPIO trace defines}} @@ -92,5 +92,5 @@ Definition at line \mbox{\hyperlink{trace_8h_source_l00138}{138}} of file \mbox{ \item GPIO\+\_\+\+TRACE\+\_\+\+ENABLE определён -\/ устанавливает бит установки через BSRR ({\itshape pin}) \end{DoxyItemize} -Definition at line \mbox{\hyperlink{trace_8h_source_l00137}{137}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00141}{141}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. diff --git a/Doc/latex/group___t_r_a_c_e___h_a_r_d_f_a_u_l_t.tex b/Doc/latex/group___t_r_a_c_e___h_a_r_d_f_a_u_l_t.tex index da953dc..768442a 100644 --- a/Doc/latex/group___t_r_a_c_e___h_a_r_d_f_a_u_l_t.tex +++ b/Doc/latex/group___t_r_a_c_e___h_a_r_d_f_a_u_l_t.tex @@ -44,7 +44,21 @@ struct \mbox{\hyperlink{struct_h_f___stack_frame__t}{HF\+\_\+\+Stack\+Frame\+\_\ \begin{DoxyEnumerate} \item Читает запись во Flash по базовому тегу. \item Выводит сохранённый RTT буфер и контекст регистров. -\item Опционально стирает Flash после восстановления. +\item Опционально стирает Flash после восстановления. +\end{DoxyEnumerate} +\end{DoxyItemize} + +Параметры\+: +\begin{DoxyItemize} +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_ga47f454f804b4dbc26cae079e8d8641e6}{HARDFAULT\+\_\+\+SERIAL\+\_\+\+TRACE} -\/ Включить обработку и serial трассировку Hardfault Если отключена то вставляются заглушки, никак не влияющие на параметры и остальную программу +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_gadc960255719c7eff4bdfaa850be9b313}{HF\+\_\+\+RTT\+\_\+\+TAG\+\_\+\+BASE} -\/ Базовый тег RTT Flash для Hard\+Fault +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_gafcc7ea03d4df8f1909e580b519a7f3ca}{HF\+\_\+\+RTT\+\_\+\+TAIL\+\_\+\+SIZE} -\/ Размер буфера RTT, который сохранится при Hardfault +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_gaa31234688b333a505aaa57b8ecdedf5b}{HF\+\_\+\+STACK\+\_\+\+DUMP\+\_\+\+WORDS} -\/ Сколько слов стека будет проанализировано во время Hardfault +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_ga0c602733a4a359bf8c095d71cd4d0f63}{HF\+\_\+\+FLASH\+\_\+\+ADDR} -\/ Адрес FLASH куда положится RTT буфер +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_ga92d0d14732edb7dfa21d483304bdb051}{HF\+\_\+\+RAM\+\_\+\+END} -\/ Конец RAM памяти (чтобы во время анализа стека не выйти за пределы) +\end{DoxyItemize} + + \begin{DoxyCode}{0} \DoxyCodeLine{\textcolor{keywordtype}{void}\ Hardfault()} \DoxyCodeLine{\{} @@ -63,8 +77,6 @@ struct \mbox{\hyperlink{struct_h_f___stack_frame__t}{HF\+\_\+\+Stack\+Frame\+\_\ \end{DoxyCode} -\end{DoxyEnumerate} -\end{DoxyItemize} \label{doc-func-members} \Hypertarget{group___t_r_a_c_e___h_a_r_d_f_a_u_l_t_doc-func-members} @@ -93,7 +105,7 @@ int \end{DoxyNote} -Definition at line \mbox{\hyperlink{trace_8h_source_l00464}{464}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00486}{486}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{group___t_r_a_c_e___h_a_r_d_f_a_u_l_t_gadd8e10e7ec3b0204f7f92062ecd452f7}\index{Hardfault trace defines@{Hardfault trace defines}!HF\_HandleFault@{HF\_HandleFault}} \index{HF\_HandleFault@{HF\_HandleFault}!Hardfault trace defines@{Hardfault trace defines}} @@ -120,5 +132,5 @@ Definition at line \mbox{\hyperlink{trace_8h_source_l00464}{464}} of file \mbox{ \end{DoxyNote} -Definition at line \mbox{\hyperlink{trace_8h_source_l00505}{505}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00527}{527}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. diff --git a/Doc/latex/group___t_r_a_c_e___r_t_t___f_l_a_s_h.tex b/Doc/latex/group___t_r_a_c_e___r_t_t___f_l_a_s_h.tex index 79ed0f9..68a1594 100644 --- a/Doc/latex/group___t_r_a_c_e___r_t_t___f_l_a_s_h.tex +++ b/Doc/latex/group___t_r_a_c_e___r_t_t___f_l_a_s_h.tex @@ -44,7 +44,16 @@ struct \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\+\_\+\+Flash\+Header если слот с таким тегом уже занят, запись не выполняется. ~\newline \item Автоинкремент позволяет хранить несколько последовательных записей в пределах одного базового тега, ~\newline - без необходимости вручную отслеживать адреса Flash или позиции буферов. + без необходимости вручную отслеживать адреса Flash или позиции буферов. ~\newline + +\end{DoxyItemize} + +Параметры\+: +\begin{DoxyItemize} +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\+\_\+\+FLASH\+\_\+\+BUFFER\+\_\+\+SIZE} -\/ Размер буфера RTT в Flash +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_ga3bc1b76864e1d32cbdd174d4caae7724}{RTT\+\_\+\+FLASH\+\_\+\+SECTOR} -\/ Сектор FLASH куда положится RTT буфер +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_ga8e56f75d3ab8a89ddde1404ae23c3297}{RTT\+\_\+\+FLASH\+\_\+\+SECTOR\+\_\+\+START} -\/ Начало сектора RTT\+\_\+\+FLASH\+\_\+\+SECTOR +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_gafeca0be3688dea07ff443f894668003d}{RTT\+\_\+\+FLASH\+\_\+\+SECTOR\+\_\+\+END} -\/ Конец сектора RTT\+\_\+\+FLASH\+\_\+\+SECTOR \end{DoxyItemize} \label{doc-func-members} @@ -62,7 +71,7 @@ struct \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\+\_\+\+Flash\+Header Сбрасывает ошибки Flash и ожидает готовности перед записью -Definition at line \mbox{\hyperlink{trace_8h_source_l00179}{179}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00190}{190}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga79f222c8ab644de4d47f07528d1edd63}\index{Flash RTT Buffer@{Flash RTT Buffer}!RTT\_SaveToFlash@{RTT\_SaveToFlash}} \index{RTT\_SaveToFlash@{RTT\_SaveToFlash}!Flash RTT Buffer@{Flash RTT Buffer}} @@ -92,7 +101,7 @@ Definition at line \mbox{\hyperlink{trace_8h_source_l00179}{179}} of file \mbox{ \item Если конкретный (младший байт != 0) — запись выполняется только с этим тегом, иначе ошибка. \end{DoxyItemize} -Definition at line \mbox{\hyperlink{trace_8h_source_l00202}{202}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00214}{214}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga734b2ebbf0c77699b739013878cfd146}\index{Flash RTT Buffer@{Flash RTT Buffer}!RTT\_ReadFromFlash@{RTT\_ReadFromFlash}} \index{RTT\_ReadFromFlash@{RTT\_ReadFromFlash}!Flash RTT Buffer@{Flash RTT Buffer}} @@ -124,7 +133,7 @@ Definition at line \mbox{\hyperlink{trace_8h_source_l00202}{202}} of file \mbox{ \item Если конкретный (младший байт != 0) — прочитывается именно эта запись. \end{DoxyItemize} -Definition at line \mbox{\hyperlink{trace_8h_source_l00299}{299}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00311}{311}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga8d8c6850e32b42871faefce3352012d1}\index{Flash RTT Buffer@{Flash RTT Buffer}!RTT\_EraseFlash@{RTT\_EraseFlash}} \index{RTT\_EraseFlash@{RTT\_EraseFlash}!Flash RTT Buffer@{Flash RTT Buffer}} @@ -138,5 +147,5 @@ Definition at line \mbox{\hyperlink{trace_8h_source_l00299}{299}} of file \mbox{ -Definition at line \mbox{\hyperlink{trace_8h_source_l00363}{363}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00375}{375}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. diff --git a/Doc/latex/group___t_r_a_c_e___s_e_r_i_a_l.tex b/Doc/latex/group___t_r_a_c_e___s_e_r_i_a_l.tex index 1b175c8..82ada06 100644 --- a/Doc/latex/group___t_r_a_c_e___s_e_r_i_a_l.tex +++ b/Doc/latex/group___t_r_a_c_e___s_e_r_i_a_l.tex @@ -24,10 +24,11 @@ Collaboration diagram for Serial trace defines\+:\nopagebreak \doxysubsubsubsubsection{Detailed Description} Дефайны для работы с serial трассировкой (SWO, RTT) -Определяется дефайн \doxylink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\+\_\+printf()} и \doxylink{group___t_r_a_c_e___s_e_r_i_a_l_ga730fb7b8d0bbb348dca73c15bd0e0b26}{log\+\_\+printf()} для работы с serial трассировкой\+: +В зависимости от настроек определяется дефайн \doxylink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\+\_\+printf()} и \doxylink{group___t_r_a_c_e___s_e_r_i_a_l_ga730fb7b8d0bbb348dca73c15bd0e0b26}{log\+\_\+printf()} для работы с трассировкой\+: \begin{DoxyItemize} -\item для RTT это будет вызов функции SEGGER\+\_\+\+RTT\+\_\+printf(), с подключением библиотеки SEGGER\+\_\+\+RTT.\+h -\item для SWO это будет просто printf() +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_ga76936505ca200d2e61226b7ba68f27c6}{SERIAL\+\_\+\+TRACE\+\_\+\+ENABLE} -\/ Если трассировка отключена, то все дефайны определяются как \textquotesingle{}ничего\textquotesingle{} и на производительность кода не влияют +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_ga00ff2175bdc1fb11c8ec970ea3010dd8}{RTT\+\_\+\+TRACE\+\_\+\+ENABLE} -\/ для RTT это будет вызов функции SEGGER\+\_\+\+RTT\+\_\+printf(), с подключением библиотеки SEGGER\+\_\+\+RTT.\+h Предварительно надо подключить библиотеку SEGGER RTT и вызвать функцию SEGGER\+\_\+\+RTT\+\_\+\+Init() +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_gab8db9704b5d11858aa879689b9d36336}{SWO\+\_\+\+TRACE\+\_\+\+ENABLE} для SWO это будет просто printf() Но библиотеку STDOUT надо подключить самостоятельно\+: @@ -47,10 +48,8 @@ Collaboration diagram for Serial trace defines\+:\nopagebreak \item Port = SW В вкладке Trace\+: \item Указать Core Clock \item Выставить Trace Port = SWO -\item ITM -\/ выбрать нужный порт (для Keil нулевой порт) ~\newline - +\item ITM -\/ выбрать нужный порт (для Keil нулевой порт) \end{DoxyItemize} -\item Если трассировка \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_ga76936505ca200d2e61226b7ba68f27c6}{SERIAL\+\_\+\+TRACE\+\_\+\+ENABLE} отключена, то все дефайны определяются как \textquotesingle{}ничего\textquotesingle{} и на производительность кода не влияют \end{DoxyItemize} \label{doc-define-members} @@ -78,7 +77,7 @@ Collaboration diagram for Serial trace defines\+:\nopagebreak \item NO\+\_\+\+TRACE -\/ пустой макрос \end{DoxyItemize} -Definition at line \mbox{\hyperlink{trace_8h_source_l00067}{67}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00071}{71}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{group___t_r_a_c_e___s_e_r_i_a_l_ga730fb7b8d0bbb348dca73c15bd0e0b26}\index{Serial trace defines@{Serial trace defines}!log\_printf@{log\_printf}} \index{log\_printf@{log\_printf}!Serial trace defines@{Serial trace defines}} @@ -110,5 +109,5 @@ Definition at line \mbox{\hyperlink{trace_8h_source_l00067}{67}} of file \mbox{\ \item LOG\+\_\+\+LEVEL \texorpdfstring{$>$}{>}= 2 -\/ выводится время, TAG, имя файла и номер строки \end{DoxyItemize} -Definition at line \mbox{\hyperlink{trace_8h_source_l00092}{92}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00096}{96}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. diff --git a/Doc/latex/group___t_r_a_c_k_e_r_s.tex b/Doc/latex/group___t_r_a_c_k_e_r_s.tex index bab2a28..9f4c6e3 100644 --- a/Doc/latex/group___t_r_a_c_k_e_r_s.tex +++ b/Doc/latex/group___t_r_a_c_k_e_r_s.tex @@ -70,8 +70,11 @@ Collaboration diagram for Trackers defines\+:\nopagebreak Также есть ряд функций (дефайнов) для обращения к элементам этой структуры. \end{DoxyItemize} -Если трекеры \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_gac9eaedc31ab023ce7d6403999216e496}{TRACKERS\+\_\+\+ENABLE} отключены, то все дефайны определяются как ничего и на производительность кода не влияют ~\newline +Параметры для конфигурации\+: +\begin{DoxyItemize} +\item \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_gac9eaedc31ab023ce7d6403999216e496}{TRACKERS\+\_\+\+ENABLE} -\/ Включить трекеры Если трекеры \doxylink{group___t_r_a_c_e___c_o_n_f_i_g_gac9eaedc31ab023ce7d6403999216e496}{TRACKERS\+\_\+\+ENABLE} отключены, то все дефайны определяются как ничего и на производительность кода не влияют ~\newline +\end{DoxyItemize} \begin{DoxyParagraph}{Пример\+:} @@ -145,7 +148,7 @@ Collaboration diagram for Trackers defines\+:\nopagebreak Также есть возможность объявить пользовательские переменные в количестве $<$num\+\_\+user\+\_\+vars$>$ штук. -Definition at line \mbox{\hyperlink{trackers_8h_source_l00069}{69}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00070}{70}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga72be24629fedb8bf70e830373d151fbc}\index{Trackers defines@{Trackers defines}!num\_of\_usercnts@{num\_of\_usercnts}} \index{num\_of\_usercnts@{num\_of\_usercnts}!Trackers defines@{Trackers defines}} @@ -164,7 +167,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00069}{69}} of file \mbo -Definition at line \mbox{\hyperlink{trackers_8h_source_l00079}{79}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00080}{80}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_gadd7fd2c6e3a4800f1d5ddab35fd4b43e}\index{Trackers defines@{Trackers defines}!assert\_usertracker@{assert\_usertracker}} \index{assert\_usertracker@{assert\_usertracker}!Trackers defines@{Trackers defines}} @@ -183,7 +186,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00079}{79}} of file \mbo -Definition at line \mbox{\hyperlink{trackers_8h_source_l00081}{81}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00082}{82}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_gad91d8ca89074270fc040c0449e57cf07}\index{Trackers defines@{Trackers defines}!if\_assert\_usertracker@{if\_assert\_usertracker}} \index{if\_assert\_usertracker@{if\_assert\_usertracker}!Trackers defines@{Trackers defines}} @@ -202,7 +205,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00081}{81}} of file \mbo -Definition at line \mbox{\hyperlink{trackers_8h_source_l00083}{83}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00084}{84}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga39b6ffbc561f8caac276415e1ad32c30}\index{Trackers defines@{Trackers defines}!tern\_assert\_usertracker@{tern\_assert\_usertracker}} \index{tern\_assert\_usertracker@{tern\_assert\_usertracker}!Trackers defines@{Trackers defines}} @@ -221,7 +224,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00083}{83}} of file \mbo -Definition at line \mbox{\hyperlink{trackers_8h_source_l00085}{85}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00086}{86}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_gab880911066605602a966641682090169}\index{Trackers defines@{Trackers defines}!TrackerGet\_Ok@{TrackerGet\_Ok}} \index{TrackerGet\_Ok@{TrackerGet\_Ok}!Trackers defines@{Trackers defines}} @@ -240,7 +243,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00085}{85}} of file \mbo -Definition at line \mbox{\hyperlink{trackers_8h_source_l00089}{89}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00090}{90}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga9dc91e6b798a081f95f2ccef2c288e5e}\index{Trackers defines@{Trackers defines}!TrackerGet\_Err@{TrackerGet\_Err}} \index{TrackerGet\_Err@{TrackerGet\_Err}!Trackers defines@{Trackers defines}} @@ -259,7 +262,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00089}{89}} of file \mbo -Definition at line \mbox{\hyperlink{trackers_8h_source_l00091}{91}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00092}{92}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga47ac59a406ee74d4cd9fe0fbaf63a758}\index{Trackers defines@{Trackers defines}!TrackerGet\_Warn@{TrackerGet\_Warn}} \index{TrackerGet\_Warn@{TrackerGet\_Warn}!Trackers defines@{Trackers defines}} @@ -278,7 +281,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00091}{91}} of file \mbo -Definition at line \mbox{\hyperlink{trackers_8h_source_l00093}{93}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00094}{94}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga4b08632669043dfdbd219dda03502bdb}\index{Trackers defines@{Trackers defines}!TrackerGet\_User@{TrackerGet\_User}} \index{TrackerGet\_User@{TrackerGet\_User}!Trackers defines@{Trackers defines}} @@ -304,7 +307,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00093}{93}} of file \mbo \end{DoxyNote} -Definition at line \mbox{\hyperlink{trackers_8h_source_l00105}{105}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00106}{106}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga23de0006aa08984cfeddb6aa5e512fa1}\index{Trackers defines@{Trackers defines}!TrackerCnt\_Ok@{TrackerCnt\_Ok}} \index{TrackerCnt\_Ok@{TrackerCnt\_Ok}!Trackers defines@{Trackers defines}} @@ -323,7 +326,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00105}{105}} of file \mb -Definition at line \mbox{\hyperlink{trackers_8h_source_l00110}{110}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00111}{111}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga49af29ab3927cad105c1d2b018a767e9}\index{Trackers defines@{Trackers defines}!TrackerCnt\_Err@{TrackerCnt\_Err}} \index{TrackerCnt\_Err@{TrackerCnt\_Err}!Trackers defines@{Trackers defines}} @@ -342,7 +345,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00110}{110}} of file \mb -Definition at line \mbox{\hyperlink{trackers_8h_source_l00112}{112}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00113}{113}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga8017fb05a56a1b667244f1f786fa9c57}\index{Trackers defines@{Trackers defines}!TrackerCnt\_Warn@{TrackerCnt\_Warn}} \index{TrackerCnt\_Warn@{TrackerCnt\_Warn}!Trackers defines@{Trackers defines}} @@ -361,7 +364,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00112}{112}} of file \mb -Definition at line \mbox{\hyperlink{trackers_8h_source_l00114}{114}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00115}{115}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga1b7549afc4a1760b54a9b93b0f6d105e}\index{Trackers defines@{Trackers defines}!TrackerCnt\_User@{TrackerCnt\_User}} \index{TrackerCnt\_User@{TrackerCnt\_User}!Trackers defines@{Trackers defines}} @@ -380,7 +383,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00114}{114}} of file \mb -Definition at line \mbox{\hyperlink{trackers_8h_source_l00116}{116}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00117}{117}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_gad2f4062a9ac8c2ab062a364f640ebc51}\index{Trackers defines@{Trackers defines}!TrackerWrite\_User@{TrackerWrite\_User}} \index{TrackerWrite\_User@{TrackerWrite\_User}!Trackers defines@{Trackers defines}} @@ -399,7 +402,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00116}{116}} of file \mb -Definition at line \mbox{\hyperlink{trackers_8h_source_l00118}{118}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00119}{119}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga704f7b9f8c65c9bcec48ce7cb77a2d3b}\index{Trackers defines@{Trackers defines}!TrackerClear\_All@{TrackerClear\_All}} \index{TrackerClear\_All@{TrackerClear\_All}!Trackers defines@{Trackers defines}} @@ -418,7 +421,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00118}{118}} of file \mb -Definition at line \mbox{\hyperlink{trackers_8h_source_l00121}{121}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00122}{122}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga5dd8bac8c7ab5832019d55d7a68371b9}\index{Trackers defines@{Trackers defines}!TrackerClear\_Ok@{TrackerClear\_Ok}} \index{TrackerClear\_Ok@{TrackerClear\_Ok}!Trackers defines@{Trackers defines}} @@ -437,7 +440,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00121}{121}} of file \mb -Definition at line \mbox{\hyperlink{trackers_8h_source_l00123}{123}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00124}{124}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_gae860b6947c6e317e14d40bd7b4b8eb74}\index{Trackers defines@{Trackers defines}!TrackerClear\_Err@{TrackerClear\_Err}} \index{TrackerClear\_Err@{TrackerClear\_Err}!Trackers defines@{Trackers defines}} @@ -456,7 +459,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00123}{123}} of file \mb -Definition at line \mbox{\hyperlink{trackers_8h_source_l00125}{125}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00126}{126}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga365a8c60bd13b75154feda649dd21ead}\index{Trackers defines@{Trackers defines}!TrackerClear\_Warn@{TrackerClear\_Warn}} \index{TrackerClear\_Warn@{TrackerClear\_Warn}!Trackers defines@{Trackers defines}} @@ -475,7 +478,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00125}{125}} of file \mb -Definition at line \mbox{\hyperlink{trackers_8h_source_l00127}{127}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00128}{128}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_ga063dab1067005e1600ea32531fdf3f8d}\index{Trackers defines@{Trackers defines}!TrackerClear\_User@{TrackerClear\_User}} \index{TrackerClear\_User@{TrackerClear\_User}!Trackers defines@{Trackers defines}} @@ -494,7 +497,7 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00127}{127}} of file \mb -Definition at line \mbox{\hyperlink{trackers_8h_source_l00129}{129}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00130}{130}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. \Hypertarget{group___t_r_a_c_k_e_r_s_gaaec7ec19977bb26fa1919dfe920b82d5}\index{Trackers defines@{Trackers defines}!TrackerClear\_UserAll@{TrackerClear\_UserAll}} \index{TrackerClear\_UserAll@{TrackerClear\_UserAll}!Trackers defines@{Trackers defines}} @@ -513,5 +516,5 @@ Definition at line \mbox{\hyperlink{trackers_8h_source_l00129}{129}} of file \mb -Definition at line \mbox{\hyperlink{trackers_8h_source_l00131}{131}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. +Definition at line \mbox{\hyperlink{trackers_8h_source_l00132}{132}} of file \mbox{\hyperlink{trackers_8h_source}{trackers.\+h}}. diff --git a/Doc/latex/struct_evolve_optimizer__t.tex b/Doc/latex/struct_evolve_optimizer__t.tex index cd7a322..5f573db 100644 --- a/Doc/latex/struct_evolve_optimizer__t.tex +++ b/Doc/latex/struct_evolve_optimizer__t.tex @@ -25,13 +25,15 @@ uint16\+\_\+t \mbox{\hyperlink{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d int32\+\_\+t \mbox{\hyperlink{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}{loss}} \mbox{[}100\mbox{]} \begin{DoxyCompactList}\small\item\em Loss для каждого кандидата \end{DoxyCompactList}\item int32\+\_\+t \mbox{\hyperlink{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}{candidates}} \mbox{[}100\mbox{]}\mbox{[}20\mbox{]} -\begin{DoxyCompactList}\small\item\em Параметры кандидатов \end{DoxyCompactList}\end{DoxyCompactItemize} +\begin{DoxyCompactList}\small\item\em Параметры кандидатов \end{DoxyCompactList}\item +uint16\+\_\+t \mbox{\hyperlink{struct_evolve_optimizer__t_a74b81df1c298c99162310f3f7d91735a}{sorted\+\_\+idx}} \mbox{[}100\mbox{]} +\begin{DoxyCompactList}\small\item\em Индексы отсортированных кандидатов \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsection{Detailed Description} Структура эволюционного оптимизатора -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00081}{81}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00087}{87}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. @@ -50,7 +52,7 @@ uint16\+\_\+t Evolve\+Optimizer\+\_\+t\+::n\+\_\+params} -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00082}{82}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00088}{88}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. \Hypertarget{struct_evolve_optimizer__t_ac35c7ca8cede4ab9c53a2845a91cd1b1}\index{EvolveOptimizer\_t@{EvolveOptimizer\_t}!n\_cand@{n\_cand}} \index{n\_cand@{n\_cand}!EvolveOptimizer\_t@{EvolveOptimizer\_t}} @@ -64,7 +66,7 @@ uint16\+\_\+t Evolve\+Optimizer\+\_\+t\+::n\+\_\+cand} -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00083}{83}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00089}{89}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. \Hypertarget{struct_evolve_optimizer__t_a950cd70cb6bff33b78ad35ee58c729a6}\index{EvolveOptimizer\_t@{EvolveOptimizer\_t}!n\_best@{n\_best}} \index{n\_best@{n\_best}!EvolveOptimizer\_t@{EvolveOptimizer\_t}} @@ -78,7 +80,7 @@ uint16\+\_\+t Evolve\+Optimizer\+\_\+t\+::n\+\_\+best} -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00084}{84}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00090}{90}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. \Hypertarget{struct_evolve_optimizer__t_a5391277564b54e2271856a2466033df5}\index{EvolveOptimizer\_t@{EvolveOptimizer\_t}!iq\_mutation@{iq\_mutation}} \index{iq\_mutation@{iq\_mutation}!EvolveOptimizer\_t@{EvolveOptimizer\_t}} @@ -92,7 +94,7 @@ uint16\+\_\+t Evolve\+Optimizer\+\_\+t\+::iq\+\_\+mutation} -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00085}{85}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00091}{91}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. \Hypertarget{struct_evolve_optimizer__t_a0ae0e63ba351335d4445d927991c64ae}\index{EvolveOptimizer\_t@{EvolveOptimizer\_t}!cand\_index@{cand\_index}} \index{cand\_index@{cand\_index}!EvolveOptimizer\_t@{EvolveOptimizer\_t}} @@ -106,7 +108,7 @@ uint16\+\_\+t Evolve\+Optimizer\+\_\+t\+::cand\+\_\+index} -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00086}{86}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00092}{92}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. \Hypertarget{struct_evolve_optimizer__t_ac723b265a3d43b754489f14310314f0d}\index{EvolveOptimizer\_t@{EvolveOptimizer\_t}!loss@{loss}} \index{loss@{loss}!EvolveOptimizer\_t@{EvolveOptimizer\_t}} @@ -120,7 +122,7 @@ Loss для каждого кандидата -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00087}{87}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00093}{93}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. \Hypertarget{struct_evolve_optimizer__t_a61bd0c8ae322a79936ba1f2ae22e0e0d}\index{EvolveOptimizer\_t@{EvolveOptimizer\_t}!candidates@{candidates}} \index{candidates@{candidates}!EvolveOptimizer\_t@{EvolveOptimizer\_t}} @@ -134,7 +136,21 @@ int32\+\_\+t Evolve\+Optimizer\+\_\+t\+::candidates\mbox{[}100\mbox{]}\mbox{[}20 -Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00088}{88}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00094}{94}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. + +\Hypertarget{struct_evolve_optimizer__t_a74b81df1c298c99162310f3f7d91735a}\index{EvolveOptimizer\_t@{EvolveOptimizer\_t}!sorted\_idx@{sorted\_idx}} +\index{sorted\_idx@{sorted\_idx}!EvolveOptimizer\_t@{EvolveOptimizer\_t}} +\doxysubsubsection{\texorpdfstring{sorted\_idx}{sorted\_idx}} +{\footnotesize\ttfamily \label{struct_evolve_optimizer__t_a74b81df1c298c99162310f3f7d91735a} +uint16\+\_\+t Evolve\+Optimizer\+\_\+t\+::sorted\+\_\+idx\mbox{[}100\mbox{]}} + + + +Индексы отсортированных кандидатов + + + +Definition at line \mbox{\hyperlink{evolve__optimizer_8h_source_l00095}{95}} of file \mbox{\hyperlink{evolve__optimizer_8h_source}{evolve\+\_\+optimizer.\+h}}. diff --git a/Doc/latex/struct_h_f___stack_frame__t.tex b/Doc/latex/struct_h_f___stack_frame__t.tex index 6fdbabf..4643782 100644 --- a/Doc/latex/struct_h_f___stack_frame__t.tex +++ b/Doc/latex/struct_h_f___stack_frame__t.tex @@ -35,7 +35,7 @@ uint32\+\_\+t \mbox{\hyperlink{struct_h_f___stack_frame__t_ae47cb051ee3c94471bfd Сохраняет регистры R0-\/\+R3, R12, LR, PC, PSR для последующего анализа. -Definition at line \mbox{\hyperlink{trace_8h_source_l00441}{441}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00463}{463}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. @@ -54,7 +54,7 @@ uint32\+\_\+t HF\+\_\+\+Stack\+Frame\+\_\+t\+::r0} -Definition at line \mbox{\hyperlink{trace_8h_source_l00442}{442}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00464}{464}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{struct_h_f___stack_frame__t_a286104d19185714940645a9df814ddea}\index{HF\_StackFrame\_t@{HF\_StackFrame\_t}!r1@{r1}} \index{r1@{r1}!HF\_StackFrame\_t@{HF\_StackFrame\_t}} @@ -68,7 +68,7 @@ uint32\+\_\+t HF\+\_\+\+Stack\+Frame\+\_\+t\+::r1} -Definition at line \mbox{\hyperlink{trace_8h_source_l00443}{443}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00465}{465}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{struct_h_f___stack_frame__t_a5a52e5006dabcf68c0fa4cfb0e03335b}\index{HF\_StackFrame\_t@{HF\_StackFrame\_t}!r2@{r2}} \index{r2@{r2}!HF\_StackFrame\_t@{HF\_StackFrame\_t}} @@ -82,7 +82,7 @@ uint32\+\_\+t HF\+\_\+\+Stack\+Frame\+\_\+t\+::r2} -Definition at line \mbox{\hyperlink{trace_8h_source_l00444}{444}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00466}{466}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{struct_h_f___stack_frame__t_a453c7af42b6928a693af422e17c981d3}\index{HF\_StackFrame\_t@{HF\_StackFrame\_t}!r3@{r3}} \index{r3@{r3}!HF\_StackFrame\_t@{HF\_StackFrame\_t}} @@ -96,7 +96,7 @@ uint32\+\_\+t HF\+\_\+\+Stack\+Frame\+\_\+t\+::r3} -Definition at line \mbox{\hyperlink{trace_8h_source_l00445}{445}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00467}{467}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{struct_h_f___stack_frame__t_a819ee3bc518c460ece1b7c4079f8f80b}\index{HF\_StackFrame\_t@{HF\_StackFrame\_t}!r12@{r12}} \index{r12@{r12}!HF\_StackFrame\_t@{HF\_StackFrame\_t}} @@ -110,7 +110,7 @@ uint32\+\_\+t HF\+\_\+\+Stack\+Frame\+\_\+t\+::r12} -Definition at line \mbox{\hyperlink{trace_8h_source_l00446}{446}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00468}{468}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{struct_h_f___stack_frame__t_a6e51904297f7725e96d5b5fb291ef577}\index{HF\_StackFrame\_t@{HF\_StackFrame\_t}!lr@{lr}} \index{lr@{lr}!HF\_StackFrame\_t@{HF\_StackFrame\_t}} @@ -124,7 +124,7 @@ Link Register. -Definition at line \mbox{\hyperlink{trace_8h_source_l00447}{447}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00469}{469}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{struct_h_f___stack_frame__t_a16563896004751c90e41c81ae4570732}\index{HF\_StackFrame\_t@{HF\_StackFrame\_t}!pc@{pc}} \index{pc@{pc}!HF\_StackFrame\_t@{HF\_StackFrame\_t}} @@ -138,7 +138,7 @@ Program Counter. -Definition at line \mbox{\hyperlink{trace_8h_source_l00448}{448}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00470}{470}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{struct_h_f___stack_frame__t_ae47cb051ee3c94471bfd4fe7e49c55f9}\index{HF\_StackFrame\_t@{HF\_StackFrame\_t}!psr@{psr}} \index{psr@{psr}!HF\_StackFrame\_t@{HF\_StackFrame\_t}} @@ -152,7 +152,7 @@ Program Status Register. -Definition at line \mbox{\hyperlink{trace_8h_source_l00449}{449}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00471}{471}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. diff --git a/Doc/latex/struct_r_t_t___flash_header__t.tex b/Doc/latex/struct_r_t_t___flash_header__t.tex index aa5fa3f..ee0c1c9 100644 --- a/Doc/latex/struct_r_t_t___flash_header__t.tex +++ b/Doc/latex/struct_r_t_t___flash_header__t.tex @@ -23,7 +23,7 @@ char \mbox{\hyperlink{struct_r_t_t___flash_header__t_ae7276198385c8d6f6508f433d0 \doxysubsection{Detailed Description} Структура RTT, которая будет положена в Flash. -Definition at line \mbox{\hyperlink{trace_8h_source_l00169}{169}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00180}{180}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. @@ -42,7 +42,7 @@ uint32\+\_\+t RTT\+\_\+\+Flash\+Header\+\_\+t\+::tag} -Definition at line \mbox{\hyperlink{trace_8h_source_l00170}{170}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00181}{181}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}\index{RTT\_FlashHeader\_t@{RTT\_FlashHeader\_t}!size@{size}} \index{size@{size}!RTT\_FlashHeader\_t@{RTT\_FlashHeader\_t}} @@ -56,7 +56,7 @@ uint32\+\_\+t RTT\+\_\+\+Flash\+Header\+\_\+t\+::size} -Definition at line \mbox{\hyperlink{trace_8h_source_l00171}{171}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00182}{182}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. \Hypertarget{struct_r_t_t___flash_header__t_ae7276198385c8d6f6508f433d042d52a}\index{RTT\_FlashHeader\_t@{RTT\_FlashHeader\_t}!data@{data}} \index{data@{data}!RTT\_FlashHeader\_t@{RTT\_FlashHeader\_t}} @@ -70,7 +70,7 @@ char RTT\+\_\+\+Flash\+Header\+\_\+t\+::data\mbox{[}1024\mbox{]}} -Definition at line \mbox{\hyperlink{trace_8h_source_l00172}{172}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. +Definition at line \mbox{\hyperlink{trace_8h_source_l00183}{183}} of file \mbox{\hyperlink{trace_8h_source}{trace.\+h}}. diff --git a/Doc/latex/trace_8h_source.tex b/Doc/latex/trace_8h_source.tex index bed3664..a1a84b0 100644 --- a/Doc/latex/trace_8h_source.tex +++ b/Doc/latex/trace_8h_source.tex @@ -20,543 +20,565 @@ \DoxyCodeLine{\Hypertarget{trace_8h_source_l00016}00016\ \textcolor{comment}{\ \ *\ @addtogroup\ TRACE\_SERIAL\ \ \ \ Serial\ trace\ defines}} \DoxyCodeLine{\Hypertarget{trace_8h_source_l00017}00017\ \textcolor{comment}{\ \ *\ @ingroup\ \ \ \ TRACE}} \DoxyCodeLine{\Hypertarget{trace_8h_source_l00018}00018\ \textcolor{comment}{\ \ *\ @brief\ \ \ \ \ \ Дефайны\ для\ работы\ с\ serial\ трассировкой\ (SWO,\ RTT)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00019}00019\ \textcolor{comment}{\ \ *\ @details\ \ \ \ Определяется\ дефайн\ @ref\ my\_printf()\ и\ @ref\ log\_printf()\ для\ работы\ с\ serial\ трассировкой:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00020}00020\ \textcolor{comment}{\ \ \ \ -\/\ для\ RTT\ это\ будет\ вызов\ функции\ SEGGER\_RTT\_printf(),\ с\ подключением\ библиотеки\ SEGGER\_RTT.h}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00021}00021\ \textcolor{comment}{\ \ \ \ -\/\ для\ SWO\ это\ будет\ просто\ printf()}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00022}00022\ \textcolor{comment}{\ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00023}00023\ \textcolor{comment}{\ \ \ \ \ \ Но\ библиотеку\ STDOUT\ надо\ подключить\ самостоятельно:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00024}00024\ \textcolor{comment}{\ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00025}00025\ \textcolor{comment}{\ \ \ \ \ \ @verbatim}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00026}00026\ \textcolor{comment}{\ \ \ \ \ \ \ \ Manage\ Run-\/Time\ Environment\ -\/>\ Compiler\ -\/>\ I/O\ -\/>\ STDOUT\ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00027}00027\ \textcolor{comment}{\ \ \ \ \ \ @endverbatim}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00028}00028\ \textcolor{comment}{\ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00029}00029\ \textcolor{comment}{\ \ \ \ \ \ Для\ SWO\ также\ надо\ включить\ трассировку:\ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00030}00030\ \textcolor{comment}{\ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00031}00031\ \textcolor{comment}{\ \ \ \ \ \ @verbatim}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00032}00032\ \textcolor{comment}{\ \ \ \ \ \ \ \ Options\ For\ Target\ -\/>\ Debug\ -\/>\ Debugger\ Settings}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00033}00033\ \textcolor{comment}{\ \ \ \ \ \ @endverbatim}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00034}00034\ \textcolor{comment}{\ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00035}00035\ \textcolor{comment}{\ \ \ \ \ \ В\ вкладке\ Debug:\ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00036}00036\ \textcolor{comment}{\ \ \ \ \ \ \ \ -\/\ Port\ =\ SW}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00037}00037\ \textcolor{comment}{\ \ \ \ \ \ В\ вкладке\ Trace:\ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00038}00038\ \textcolor{comment}{\ \ \ \ \ \ \ \ -\/\ Указать\ Core\ Clock}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00039}00039\ \textcolor{comment}{\ \ \ \ \ \ \ \ -\/\ Выставить\ Trace\ Port\ =\ SWO}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00040}00040\ \textcolor{comment}{\ \ \ \ \ \ \ \ -\/\ ITM\ -\/\ выбрать\ нужный\ порт\ (для\ Keil\ нулевой\ порт)\ \ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00041}00041\ \textcolor{comment}{\ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00042}00042\ \textcolor{comment}{\ \ \ \ -\/\ Если\ трассировка\ @ref\ SERIAL\_TRACE\_ENABLE\ отключена,\ то\ все\ дефайны\ определяются\ как\ 'ничего'\ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00043}00043\ \textcolor{comment}{\ \ \ \ \ \ и\ на\ производительность\ кода\ не\ влияют}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00044}00044\ \textcolor{comment}{\ \ *\ @\{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00045}00045\ \textcolor{comment}{\ \ *}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00046}00046\ \textcolor{comment}{\ \ *\ @def\ my\_printf(...)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00047}00047\ \textcolor{comment}{\ \ *\ @brief\ Универсальный\ макрос\ для\ вывода\ трассировки}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00048}00048\ \textcolor{comment}{\ \ *\ @details\ Варианты\ реализации:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00049}00049\ \textcolor{comment}{\ \ *\ \ -\/\ RTT\_TRACE\_ENABLE\ \ \ \ \`{}SEGGER\_RTT\_printf(0,\ ...)`}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00050}00050\ \textcolor{comment}{\ \ *\ \ -\/\ SWO\_TRACE\_ENABLE\ -\/\ \`{}printf(...)`}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00051}00051\ \textcolor{comment}{\ \ *\ \ -\/\ NO\_TRACE\ -\/\ пустой\ макрос}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00052}00052\ \textcolor{comment}{\ \ *}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00053}00053\ \textcolor{comment}{\ \ *\ @def\ log\_printf(TAG,\ fmt,\ ...)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00054}00054\ \textcolor{comment}{\ \ *\ @brief\ Макрос\ логирования\ с\ поддержкой\ уровней\ LOG\_LEVEL}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00055}00055\ \textcolor{comment}{\ \ *\ @param\ TAG\ \ Тэг\ лога}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00056}00056\ \textcolor{comment}{\ \ *\ @param\ fmt,\ ...\ \ Форматируемая\ строка}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00057}00057\ \textcolor{comment}{\ \ *\ @details\ Варианты\ реализации:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00058}00058\ \textcolor{comment}{\ \ *\ \ -\/\ LOG\_LEVEL\ ==\ 0\ -\/\ логирование\ отключено\ (макрос\ пустой)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00059}00059\ \textcolor{comment}{\ \ *\ \ -\/\ LOG\_LEVEL\ ==\ 1\ -\/\ выводится\ время\ и\ TAG}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00060}00060\ \textcolor{comment}{\ \ *\ \ -\/\ LOG\_LEVEL\ >=\ 2\ -\/\ выводится\ время,\ TAG,\ имя\ файла\ и\ номер\ строки}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00061}00061\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00062}00062\ \textcolor{preprocessor}{\#ifdef\ SERIAL\_TRACE\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00063}00063\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00064}00064\ \textcolor{preprocessor}{\ \ \#if\ defined(RTT\_TRACE\_ENABLE)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00065}00065\ \textcolor{preprocessor}{\ \ \ \ \#undef\ SWO\_TRACE\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00066}00066\ \textcolor{preprocessor}{\ \ \ \ \#include\ "{}SEGGER\_RTT.h"{}}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00067}\mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{00067}}\ \textcolor{preprocessor}{\ \ \ \ \#define\ my\_printf(...)\ \ \ \ \ \ \ \ SEGGER\_RTT\_printf(0,\ \_\_VA\_ARGS\_\_)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00068}00068\ \textcolor{preprocessor}{\ \ \#elif\ defined(SWO\_TRACE\_ENABLE)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00069}00069\ \textcolor{preprocessor}{\ \ \ \ \#undef\ RTT\_TRACE\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00070}00070\ \textcolor{preprocessor}{\ \ \ \ \#define\ my\_printf(...)\ \ \ \ \ \ \ \ printf(\_\_VA\_ARGS\_\_)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00071}00071\ \textcolor{preprocessor}{\ \ \#else\ }\textcolor{comment}{//\ NO\_TRACE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00072}00072\ \textcolor{preprocessor}{\ \ \ \ \#define\ my\_printf(...)\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00073}00073\ \textcolor{preprocessor}{\ \ \ \ \#warning\ No\ trace\ is\ selected.\ Serial\ debug\ wont\ work.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00074}00074\ \textcolor{preprocessor}{\ \ \#endif\ }\textcolor{comment}{//\ RTT\_TRACE\_ENABLE/SWO\_TRACE\_ENABLE/NO\_TRACE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00075}00075\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//SERIAL\_TRACE\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00076}00076\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00077}00077\ \textcolor{preprocessor}{\ \ \#define\ my\_printf(...)\ \ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00078}00078\ \textcolor{preprocessor}{\ \ \#undef\ RTT\_TRACE\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00079}00079\ \textcolor{preprocessor}{\ \ \#undef\ SWO\_TRACE\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00080}00080\ \ \ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00081}00081\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//SERIAL\_TRACE\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00082}00082\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00083}00083\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00084}00084\ \textcolor{preprocessor}{\#ifndef\ LOG\_LEVEL}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00085}00085\ \textcolor{preprocessor}{\#define\ LOG\_LEVEL\ 1\ \ }\textcolor{comment}{///<\ @brief\ Уровень\ логирования\ (по\ умолчанию\ ==\ 1)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00086}00086\ \textcolor{preprocessor}{\#endif}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00019}00019\ \textcolor{comment}{\ \ *\ @details\ \ \ \ В\ зависимости\ от\ настроек\ определяется\ дефайн\ @ref\ my\_printf()\ и\ @ref\ log\_printf()\ для\ работы\ с\ трассировкой:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00020}00020\ \textcolor{comment}{\ \ \ \ -\/\ @ref\ SERIAL\_TRACE\_ENABLE\ -\/\ Если\ трассировка\ \ отключена,\ то\ все\ дефайны\ определяются\ как\ 'ничего'\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00021}00021\ \textcolor{comment}{\ \ \ \ \ \ и\ на\ производительность\ кода\ не\ влияют}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00022}00022\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00023}00023\ \textcolor{comment}{\ \ \ \ -\/\ @ref\ RTT\_TRACE\_ENABLE\ -\/\ для\ RTT\ это\ будет\ вызов\ функции\ SEGGER\_RTT\_printf(),\ с\ подключением\ библиотеки\ SEGGER\_RTT.h}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00024}00024\ \textcolor{comment}{\ \ \ \ \ \ Предварительно\ надо\ подключить\ библиотеку\ SEGGER\ RTT\ и\ вызвать\ функцию\ SEGGER\_RTT\_Init()}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00025}00025\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00026}00026\ \textcolor{comment}{\ \ \ \ -\/\ @ref\ SWO\_TRACE\_ENABLE\ для\ SWO\ это\ будет\ просто\ printf()}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00027}00027\ \textcolor{comment}{\ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00028}00028\ \textcolor{comment}{\ \ \ \ \ \ Но\ библиотеку\ STDOUT\ надо\ подключить\ самостоятельно:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00029}00029\ \textcolor{comment}{\ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00030}00030\ \textcolor{comment}{\ \ \ \ \ \ @verbatim}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00031}00031\ \textcolor{comment}{\ \ \ \ \ \ \ \ Manage\ Run-\/Time\ Environment\ -\/>\ Compiler\ -\/>\ I/O\ -\/>\ STDOUT\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00032}00032\ \textcolor{comment}{\ \ \ \ \ \ @endverbatim}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00033}00033\ \textcolor{comment}{\ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00034}00034\ \textcolor{comment}{\ \ \ \ \ \ Для\ SWO\ также\ надо\ включить\ трассировку:\ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00035}00035\ \textcolor{comment}{\ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00036}00036\ \textcolor{comment}{\ \ \ \ \ \ @verbatim}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00037}00037\ \textcolor{comment}{\ \ \ \ \ \ \ \ Options\ For\ Target\ -\/>\ Debug\ -\/>\ Debugger\ Settings}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00038}00038\ \textcolor{comment}{\ \ \ \ \ \ @endverbatim}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00039}00039\ \textcolor{comment}{\ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00040}00040\ \textcolor{comment}{\ \ \ \ \ \ В\ вкладке\ Debug:\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00041}00041\ \textcolor{comment}{\ \ \ \ \ \ \ \ -\/\ Port\ =\ SW}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00042}00042\ \textcolor{comment}{\ \ \ \ \ \ В\ вкладке\ Trace:\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00043}00043\ \textcolor{comment}{\ \ \ \ \ \ \ \ -\/\ Указать\ Core\ Clock}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00044}00044\ \textcolor{comment}{\ \ \ \ \ \ \ \ -\/\ Выставить\ Trace\ Port\ =\ SWO}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00045}00045\ \textcolor{comment}{\ \ \ \ \ \ \ \ -\/\ ITM\ -\/\ выбрать\ нужный\ порт\ (для\ Keil\ нулевой\ порт)\ \ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00046}00046\ \textcolor{comment}{\ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00047}00047\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00048}00048\ \textcolor{comment}{\ \ *\ @\{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00049}00049\ \textcolor{comment}{\ \ *}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00050}00050\ \textcolor{comment}{\ \ *\ @def\ my\_printf(...)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00051}00051\ \textcolor{comment}{\ \ *\ @brief\ Универсальный\ макрос\ для\ вывода\ трассировки}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00052}00052\ \textcolor{comment}{\ \ *\ @details\ Варианты\ реализации:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00053}00053\ \textcolor{comment}{\ \ *\ \ -\/\ RTT\_TRACE\_ENABLE\ \ \ \ \`{}SEGGER\_RTT\_printf(0,\ ...)`}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00054}00054\ \textcolor{comment}{\ \ *\ \ -\/\ SWO\_TRACE\_ENABLE\ -\/\ \`{}printf(...)`}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00055}00055\ \textcolor{comment}{\ \ *\ \ -\/\ NO\_TRACE\ -\/\ пустой\ макрос}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00056}00056\ \textcolor{comment}{\ \ *}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00057}00057\ \textcolor{comment}{\ \ *\ @def\ log\_printf(TAG,\ fmt,\ ...)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00058}00058\ \textcolor{comment}{\ \ *\ @brief\ Макрос\ логирования\ с\ поддержкой\ уровней\ LOG\_LEVEL}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00059}00059\ \textcolor{comment}{\ \ *\ @param\ TAG\ \ Тэг\ лога}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00060}00060\ \textcolor{comment}{\ \ *\ @param\ fmt,\ ...\ \ Форматируемая\ строка}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00061}00061\ \textcolor{comment}{\ \ *\ @details\ Варианты\ реализации:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00062}00062\ \textcolor{comment}{\ \ *\ \ -\/\ LOG\_LEVEL\ ==\ 0\ -\/\ логирование\ отключено\ (макрос\ пустой)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00063}00063\ \textcolor{comment}{\ \ *\ \ -\/\ LOG\_LEVEL\ ==\ 1\ -\/\ выводится\ время\ и\ TAG}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00064}00064\ \textcolor{comment}{\ \ *\ \ -\/\ LOG\_LEVEL\ >=\ 2\ -\/\ выводится\ время,\ TAG,\ имя\ файла\ и\ номер\ строки}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00065}00065\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00066}00066\ \textcolor{preprocessor}{\#ifdef\ SERIAL\_TRACE\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00067}00067\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00068}00068\ \textcolor{preprocessor}{\ \ \#if\ defined(RTT\_TRACE\_ENABLE)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00069}00069\ \textcolor{preprocessor}{\ \ \ \ \#undef\ SWO\_TRACE\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00070}00070\ \textcolor{preprocessor}{\ \ \ \ \#include\ "{}SEGGER\_RTT.h"{}}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00071}\mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{00071}}\ \textcolor{preprocessor}{\ \ \ \ \#define\ my\_printf(...)\ \ \ \ \ \ \ \ SEGGER\_RTT\_printf(0,\ \_\_VA\_ARGS\_\_)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00072}00072\ \textcolor{preprocessor}{\ \ \#elif\ defined(SWO\_TRACE\_ENABLE)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00073}00073\ \textcolor{preprocessor}{\ \ \ \ \#undef\ RTT\_TRACE\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00074}00074\ \textcolor{preprocessor}{\ \ \ \ \#define\ my\_printf(...)\ \ \ \ \ \ \ \ printf(\_\_VA\_ARGS\_\_)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00075}00075\ \textcolor{preprocessor}{\ \ \#else\ }\textcolor{comment}{//\ NO\_TRACE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00076}00076\ \textcolor{preprocessor}{\ \ \ \ \#define\ my\_printf(...)\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00077}00077\ \textcolor{preprocessor}{\ \ \ \ \#warning\ No\ trace\ is\ selected.\ Serial\ debug\ wont\ work.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00078}00078\ \textcolor{preprocessor}{\ \ \#endif\ }\textcolor{comment}{//\ RTT\_TRACE\_ENABLE/SWO\_TRACE\_ENABLE/NO\_TRACE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00079}00079\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//SERIAL\_TRACE\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00080}00080\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00081}00081\ \textcolor{preprocessor}{\ \ \#define\ my\_printf(...)\ \ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00082}00082\ \textcolor{preprocessor}{\ \ \#undef\ RTT\_TRACE\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00083}00083\ \textcolor{preprocessor}{\ \ \#undef\ SWO\_TRACE\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00084}00084\ \ \ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00085}00085\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//SERIAL\_TRACE\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00086}00086\ } \DoxyCodeLine{\Hypertarget{trace_8h_source_l00087}00087\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00088}00088\ \textcolor{preprocessor}{\#if\ LOG\_LEVEL\ ==\ 0\ }\textcolor{comment}{//\ лог\ отключен}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00089}00089\ \textcolor{preprocessor}{\ \ \ \ \#define\ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00090}00090\ \textcolor{preprocessor}{log\_printf(TAG,\ fmt,\ ...)\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00091}00091\ \textcolor{preprocessor}{\#elif\ LOG\_LEVEL\ ==\ 1\ }\textcolor{comment}{//\ только\ тэг}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00092}\mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_ga730fb7b8d0bbb348dca73c15bd0e0b26}{00092}}\ \textcolor{preprocessor}{\ \ \ \ \#define\ log\_printf(TAG,\ fmt,\ ...)\ \ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00093}00093\ \textcolor{preprocessor}{my\_printf("{}\(\backslash\)n[\%lu]\ [\%s]\ "{}\ fmt,\ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00094}00094\ \textcolor{preprocessor}{(unsigned\ long)uwTick,\ TAG,\ \#\#\_\_VA\_ARGS\_\_)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00095}00095\ \textcolor{preprocessor}{\#elif\ LOG\_LEVEL\ >=\ 2\ }\textcolor{comment}{//\ всё}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00096}00096\ \textcolor{preprocessor}{\ \ \ \ \#define\ log\_printf(TAG,\ fmt,\ ...)\ \ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00097}00097\ \textcolor{preprocessor}{my\_printf("{}\(\backslash\)n[\%lu]\ [\%s]\ (\%s:\%d)\ "{}\ fmt,\ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00098}00098\ \textcolor{preprocessor}{(unsigned\ long)uwTick,\ TAG,\ \_\_FILE\_\_,\ \_\_LINE\_\_,\ \#\#\_\_VA\_ARGS\_\_)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00099}00099\ \textcolor{preprocessor}{\#endif}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00100}00100\ \ \ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00101}00101\ \textcolor{comment}{/**\ TRACE\_SERIAL}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00102}00102\ \textcolor{comment}{\ \ *\ @\}}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00103}00103\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00104}00104\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00105}00105\ \textcolor{comment}{/**\ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00106}00106\ \textcolor{comment}{\ \ *\ @addtogroup\ TRACE\_GPIO\ \ \ \ GPIO\ trace\ defines}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00107}00107\ \textcolor{comment}{\ \ *\ @ingroup\ \ \ \ TRACE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00108}00108\ \textcolor{comment}{\ \ *\ @brief\ \ \ \ \ \ Дефайны\ для\ работы\ с\ GPIO\ трассировкой}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00109}00109\ \textcolor{comment}{\ \ *\ @details\ \ \ \ Определяется\ дефайны\ для\ работы\ с\ GPIO\ трассировкой:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00110}00110\ \textcolor{comment}{\ \ \ \ -\/\ TRACE\_GPIO\_RESET()\ -\/\ для\ сброса\ ножки\ GPIO\ (через\ BSRR)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00111}00111\ \textcolor{comment}{\ \ \ \ -\/\ TRACE\_GPIO\_SET()\ -\/\ для\ выставления\ ножки\ GPIO\ (через\ BSRR)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00112}00112\ \textcolor{comment}{\ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00113}00113\ \textcolor{comment}{\ \ \ \ -\/\ Если\ трассировка\ @ref\ GPIO\_TRACE\_ENABLE\ отключена,\ то\ все\ дефайны\ определяются\ как\ 'ничего'\ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00114}00114\ \textcolor{comment}{\ \ \ \ \ \ и\ на\ производительность\ кода\ не\ влияют}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00115}00115\ \textcolor{comment}{\ \ *\ @\{\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00116}00116\ \textcolor{comment}{\ \ *}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00117}00117\ \textcolor{comment}{\ \ *\ @def\ TRACE\_GPIO\_RESET(\_gpio\_,\ \_pin\_)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00118}00118\ \textcolor{comment}{\ \ *\ @brief\ Сбросить\ указанную\ ножку\ GPIO}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00119}00119\ \textcolor{comment}{\ \ *\ @param\ \_gpio\_\ \ Указатель\ на\ структуру\ GPIO\ (напр.\ \ GPIOA)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00120}00120\ \textcolor{comment}{\ \ *\ @param\ \_pin\_\ \ \ Номер\ ножки\ (напр.\ GPIO\_PIN\_0)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00121}00121\ \textcolor{comment}{\ \ *\ @details\ Варианты\ реализации:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00122}00122\ \textcolor{comment}{\ \ *\ \ -\/\ GPIO\_TRACE\_ENABLE\ не\ определён\ -\/\ макрос\ пустой}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00123}00123\ \textcolor{comment}{\ \ *\ \ -\/\ GPIO\_TRACE\_ENABLE\ определён\ -\/\ устанавливает\ бит\ сброса\ через\ BSRR\ ((\_pin\_)<<16)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00124}00124\ \textcolor{comment}{\ \ *}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00125}00125\ \textcolor{comment}{\ \ *\ @def\ TRACE\_GPIO\_SET(\_gpio\_,\ \_pin\_)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00126}00126\ \textcolor{comment}{\ \ *\ @brief\ Установить\ указанную\ ножку\ GPIO}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00127}00127\ \textcolor{comment}{\ \ *\ @param\ \_gpio\_\ \ Указатель\ на\ структуру\ GPIO\ (например\ GPIOA)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00128}00128\ \textcolor{comment}{\ \ *\ @param\ \_pin\_\ \ \ Номер\ ножки\ (напр.\ GPIO\_PIN\_0)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00129}00129\ \textcolor{comment}{\ \ *\ @details\ Варианты\ реализации:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00130}00130\ \textcolor{comment}{\ \ *\ \ -\/\ GPIO\_TRACE\_ENABLE\ не\ определён\ -\/\ макрос\ пустой}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00131}00131\ \textcolor{comment}{\ \ *\ \ -\/\ GPIO\_TRACE\_ENABLE\ определён\ -\/\ устанавливает\ бит\ установки\ через\ BSRR\ (\_pin\_)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00132}00132\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00133}00133\ \textcolor{preprocessor}{\#ifndef\ GPIO\_TRACE\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00134}00134\ \textcolor{preprocessor}{\ \ \#define\ TRACE\_GPIO\_SET(\_gpio\_,\_pin\_)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00135}00135\ \textcolor{preprocessor}{\ \ \#define\ TRACE\_GPIO\_RESET(\_gpio\_,\_pin\_)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00136}00136\ \textcolor{preprocessor}{\#else}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00137}\mbox{\hyperlink{group___t_r_a_c_e___g_p_i_o_ga02a6a7b273766121db8ad4a1371373eb}{00137}}\ \textcolor{preprocessor}{\ \ \#define\ TRACE\_GPIO\_SET(\_gpio\_,\_pin\_)\ \ \ \ \ \ \ \ \ \ (\_gpio\_)-\/>BSRR\ =\ (((\_pin\_)))}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00138}\mbox{\hyperlink{group___t_r_a_c_e___g_p_i_o_ga69741d88c991112e99fe7a62e025108a}{00138}}\ \textcolor{preprocessor}{\ \ \#define\ TRACE\_GPIO\_RESET(\_gpio\_,\_pin\_)\ \ \ \ \ \ \ \ (\_gpio\_)-\/>BSRR\ =\ ((\_pin\_)<<16)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00139}00139\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//GPIO\_TRACE\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00140}00140\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00141}00141\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00142}00142\ \textcolor{comment}{/**\ TRACE\_GPIO}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00143}00143\ \textcolor{comment}{\ \ *\ @\}}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00144}00144\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00145}00145\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00146}00146\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00147}00147\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00148}00148\ \textcolor{preprocessor}{\#if\ defined(HAL\_MODULE\_ENABLED)\ \&\&\ defined(RTT\_TRACE\_ENABLE)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00149}00149\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00150}00150\ \textcolor{comment}{/**\ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00151}00151\ \textcolor{comment}{\ \ *\ @addtogroup\ TRACE\_RTT\_FLASH\ \ \ \ Flash\ RTT\ Buffer}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00152}00152\ \textcolor{comment}{\ \ *\ @ingroup\ \ \ \ TRACE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00153}00153\ \textcolor{comment}{\ \ *\ @brief\ \ \ \ \ \ Макросы\ и\ функции\ для\ сохранения/чтения\ RTT\ буфера\ в\ Flash}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00154}00154\ \textcolor{comment}{\ \ *\ @details\ \ \ \ Модуль\ позволяет\ сохранять\ данные\ RTT\ буфера\ во\ Flash\ и\ читать\ их\ обратно\ по\ тегам.\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00155}00155\ \textcolor{comment}{\ \ *\ Теги\ работают\ следующим\ образом:\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00156}00156\ \textcolor{comment}{\ \ *\ \ -\/\ Базовый\ тег\ (младший\ байт\ =\ 0):\ модуль\ сам\ выбирает\ первый\ свободный\ слот\ во\ Flash;\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00157}00157\ \textcolor{comment}{\ \ *\ \ \ \ новые\ записи\ получают\ автоинкрементированный\ младший\ байт\ тега\ (от\ 0x00\ до\ 0xFF).\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00158}00158\ \textcolor{comment}{\ \ *\ \ -\/\ Конкретный\ тег\ (младший\ байт\ !=\ 0):\ запись\ или\ чтение\ происходит\ строго\ с\ указанным\ тегом;\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00159}00159\ \textcolor{comment}{\ \ *\ \ \ \ если\ слот\ с\ таким\ тегом\ уже\ занят,\ запись\ не\ выполняется.\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00160}00160\ \textcolor{comment}{\ \ *\ \ -\/\ Автоинкремент\ позволяет\ хранить\ несколько\ последовательных\ записей\ в\ пределах\ одного\ базового\ тега,\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00161}00161\ \textcolor{comment}{\ \ *\ \ \ \ без\ необходимости\ вручную\ отслеживать\ адреса\ Flash\ или\ позиции\ буферов.\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00162}00162\ \textcolor{comment}{\ \ *\ @\{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00163}00163\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00164}00164\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00165}00165\ \ \ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00166}00166\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00167}00167\ \textcolor{comment}{\ \ *\ @brief\ Структура\ RTT,\ которая\ будет\ положена\ в\ Flash}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00168}00168\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00169}\mbox{\hyperlink{struct_r_t_t___flash_header__t}{00169}}\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00170}\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{00170}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Уникальный\ идентификатор\ буфера}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00171}\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{00171}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Размер\ данных}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00172}\mbox{\hyperlink{struct_r_t_t___flash_header__t_ae7276198385c8d6f6508f433d042d52a}{00172}}\ \ \ \textcolor{keywordtype}{char}\ \ \ \ \ \mbox{\hyperlink{struct_r_t_t___flash_header__t_ae7276198385c8d6f6508f433d042d52a}{data}}[\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}}];\ \ \textcolor{comment}{///<\ Буфер\ RTT}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00173}00173\ \}\ \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}};} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00174}00174\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00175}00175\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00176}00176\ \textcolor{comment}{\ \ *\ @brief\ Подготовка\ Flash\ к\ записи}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00177}00177\ \textcolor{comment}{\ \ *\ @details\ Сбрасывает\ ошибки\ Flash\ и\ ожидает\ готовности\ перед\ записью}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00178}00178\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00179}\mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga21353cb4f5af666237739e62ce019cd6}{00179}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga21353cb4f5af666237739e62ce019cd6}{RTT\_FlashPrepare}}(\textcolor{keywordtype}{void})} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00180}00180\ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00181}00181\ \ \ HAL\_FLASH\_Unlock();} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00182}00182\ \ \ \_\_HAL\_FLASH\_CLEAR\_FLAG(FLASH\_FLAG\_PGSERR\ |\ FLASH\_FLAG\_WRPERR\ |\ FLASH\_FLAG\_OPERR);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00183}00183\ \ \ \textcolor{keywordflow}{while}\ (\_\_HAL\_FLASH\_GET\_FLAG(FLASH\_FLAG\_BSY))\ \{\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00184}00184\ \ \ \_\_NOP();\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00185}00185\ \ \ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00186}00186\ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00187}00187\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00188}00188\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00189}00189\ \textcolor{comment}{\ \ *\ @brief\ Сохраняет\ последние\ символы\ RTT-\/буфера\ в\ Flash\ по\ тегу}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00190}00190\ \textcolor{comment}{\ \ *\ @param\ tag\ \ \ \ \ \ \ \ Базовый\ или\ конкретный\ идентификатор\ буфера.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00191}00191\ \textcolor{comment}{\ \ *\ @param\ tail\_size\ \ Количество\ последних\ символов\ RTT\ для\ копирования}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00192}00192\ \textcolor{comment}{\ \ *\ @param\ buf\_num\ \ \ \ Указатель\ на\ переменную\ в\ которую\ запишется\ номер\ буфера\ для\ конкретного\ тега}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00193}00193\ \textcolor{comment}{\ \ *\ @return\ >=0\ —\ номер\ буфера\ (тег)\ для\ записи,\ <0\ —\ ошибка\ (нет\ места,\ тег\ уже\ занят,\ ошибка\ записи\ в\ флеш)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00194}00194\ \textcolor{comment}{\ \ *}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00195}00195\ \textcolor{comment}{\ \ *\ @details\ \ Автоматически\ копирует\ последние\ tail\_size\ символов\ из\ RTT-\/буфера}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00196}00196\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ и\ записывает\ их\ во\ Flash.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00197}00197\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ Тег\ может\ быть\ базовым\ или\ конкретным:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00198}00198\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ Если\ базовый\ (младший\ байт\ ==\ 0)\ —\ будет\ выбран\ первый\ свободный\ слот\ с\ автоинкрементом.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00199}00199\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Автоинкремент\ формируется\ в\ пределах\ от\ 0x1\ до\ 0xFF}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00200}00200\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ Если\ конкретный\ (младший\ байт\ !=\ 0)\ —\ запись\ выполняется\ только\ с\ этим\ тегом,\ иначе\ ошибка.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00201}00201\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00202}\mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga79f222c8ab644de4d47f07528d1edd63}{00202}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga79f222c8ab644de4d47f07528d1edd63}{RTT\_SaveToFlash}}(uint32\_t\ tag,\ uint32\_t\ tail\_size)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00203}00203\ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00204}00204\ \ \ \textcolor{keywordflow}{if}\ (tag\ ==\ 0xFFFFFFFF)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00205}00205\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ Неверный\ тег}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00206}00206\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00207}00207\ \ \ SEGGER\_RTT\_BUFFER\_UP\ *up\ =\ \&\_SEGGER\_RTT.aUp[0];} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00208}00208\ \ \ \textcolor{keywordtype}{unsigned}\ buf\_size\ =\ up-\/>SizeOfBuffer;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00209}00209\ \ \ \textcolor{keywordtype}{unsigned}\ wr\ =\ up-\/>WrOff;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00210}00210\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00211}00211\ \ \ \textcolor{comment}{//\ Ограничиваем\ по\ размеру\ буфера\ RTT\ и\ RTT\_FLASH\_BUFFER\_SIZE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00212}00212\ \ \ \textcolor{keywordtype}{unsigned}\ n\ =\ (tail\_size\ >\ buf\_size)\ ?\ buf\_size\ :\ tail\_size;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00213}00213\ \ \ \textcolor{keywordflow}{if}\ (n\ >\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}})} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00214}00214\ \ \ \ \ n\ =\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}};} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00215}00215\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00216}00216\ \ \ uint32\_t\ addr\ =\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga8e56f75d3ab8a89ddde1404ae23c3297}{RTT\_FLASH\_SECTOR\_START}};} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00217}00217\ \ \ \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ *flash\_hdr\ =\ NULL;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00218}00218\ \ \ uint32\_t\ base\_tag\ =\ tag\ \&\ 0xFFFFFF00;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00219}00219\ \ \ uint32\_t\ next\_tag\ =\ (tag\ \&\ 0xFF)\ ==\ 0\ ?\ tag\ +\ 1\ :\ tag;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00220}00220\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00221}00221\ \ \ \textcolor{comment}{//\ Ищем\ первый\ свободный\ слот,\ параллельно\ автоинкрементируем\ тег}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00222}00222\ \ \ \textcolor{keywordflow}{while}\ ((addr\ +\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}))\ <=\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gafeca0be3688dea07ff443f894668003d}{RTT\_FLASH\_SECTOR\_END}})} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00223}00223\ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00224}00224\ \ \ \ \ flash\_hdr\ =\ (\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ *)addr;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00225}00225\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00226}00226\ \ \ \ \ \textcolor{keywordflow}{if}\ (flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ ==\ 0xFFFFFFFF)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00227}00227\ \ \ \ \ \ \ \textcolor{keywordflow}{break};\ \ \textcolor{comment}{//\ Нашли\ свободное\ место}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00228}00228\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00229}00229\ \ \ \ \ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00230}00230\ \ \ \ \ \textcolor{keywordflow}{if}((flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ \&\ 0xFFFFFF00)\ ==\ base\_tag)\ \textcolor{comment}{//\ выбраный\ тег}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00231}00231\ \ \ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00232}00232\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((tag\ \&\ 0xFF)\ ==\ 0)\ \textcolor{comment}{//\ если\ он\ базовый\ -\/\ ищем\ последний}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00233}00233\ \ \ \ \ \ \ \ \ next\_tag\ =\ flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ +\ 1;\ \ \textcolor{comment}{//\ автоинкремент}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00234}00234\ \ \ \ \ \ \ \textcolor{keywordflow}{else}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00235}00235\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ ==\ tag)\ \textcolor{comment}{//\ если\ он\ конкретный\ и\ уже\ существует\ -\/\ то\ ошибка}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00236}00236\ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ конкретный\ тег\ уже\ занят}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00237}00237\ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00238}00238\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00239}00239\ \ \ \ \ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00240}00240\ \ \ \ \ \textcolor{keywordflow}{if}(next\_tag\ -\/\ tag\ >\ 0xFF)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00241}00241\ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \textcolor{comment}{//\ автоинкремент\ слишком\ большой}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00242}00242\ \ \ \ \ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00243}00243\ \ \ \ \ addr\ +=\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}});} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00244}00244\ \ \ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00245}00245\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00246}00246\ \ \ \textcolor{keywordflow}{if}\ ((addr\ +\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}))\ >\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gafeca0be3688dea07ff443f894668003d}{RTT\_FLASH\_SECTOR\_END}})} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00247}00247\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ Нет\ свободного\ места}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00248}00248\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00249}00249\ \ \ \textcolor{comment}{//\ Копируем\ последние\ n\ символов\ из\ RTT}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00250}00250\ \ \ \textcolor{keywordtype}{char}\ temp[\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}}];} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00251}00251\ \ \ \textcolor{keywordtype}{unsigned}\ valid\_count\ =\ 0;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00252}00252\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00253}00253\ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{unsigned}\ i\ =\ 0;\ i\ <\ n;\ i++)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00254}00254\ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00255}00255\ \ \ \ \ \textcolor{keywordtype}{unsigned}\ idx\ =\ (wr\ +\ buf\_size\ -\/\ n\ +\ i)\ \%\ buf\_size;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00256}00256\ \ \ \ \ \textcolor{keywordtype}{char}\ c\ =\ up-\/>pBuffer[idx];} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00257}00257\ \ \ \ \ \textcolor{keywordflow}{if}\ (c\ !=\ 0)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00258}00258\ \ \ \ \ \ \ temp[valid\_count++]\ =\ c;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00259}00259\ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00088}00088\ \textcolor{preprocessor}{\#ifndef\ LOG\_LEVEL}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00089}00089\ \textcolor{preprocessor}{\#define\ LOG\_LEVEL\ 1\ \ }\textcolor{comment}{///<\ @brief\ Уровень\ логирования\ (по\ умолчанию\ ==\ 1)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00090}00090\ \textcolor{preprocessor}{\#endif}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00091}00091\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00092}00092\ \textcolor{preprocessor}{\#if\ LOG\_LEVEL\ ==\ 0\ }\textcolor{comment}{//\ лог\ отключен}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00093}00093\ \textcolor{preprocessor}{\ \ \ \ \#define\ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00094}00094\ \textcolor{preprocessor}{log\_printf(TAG,\ fmt,\ ...)\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00095}00095\ \textcolor{preprocessor}{\#elif\ LOG\_LEVEL\ ==\ 1\ }\textcolor{comment}{//\ только\ тэг}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00096}\mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_ga730fb7b8d0bbb348dca73c15bd0e0b26}{00096}}\ \textcolor{preprocessor}{\ \ \ \ \#define\ log\_printf(TAG,\ fmt,\ ...)\ \ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00097}00097\ \textcolor{preprocessor}{my\_printf("{}\(\backslash\)n[\%lu]\ [\%s]\ "{}\ fmt,\ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00098}00098\ \textcolor{preprocessor}{(unsigned\ long)uwTick,\ TAG,\ \#\#\_\_VA\_ARGS\_\_)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00099}00099\ \textcolor{preprocessor}{\#elif\ LOG\_LEVEL\ >=\ 2\ }\textcolor{comment}{//\ всё}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00100}00100\ \textcolor{preprocessor}{\ \ \ \ \#define\ log\_printf(TAG,\ fmt,\ ...)\ \ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00101}00101\ \textcolor{preprocessor}{my\_printf("{}\(\backslash\)n[\%lu]\ [\%s]\ (\%s:\%d)\ "{}\ fmt,\ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00102}00102\ \textcolor{preprocessor}{(unsigned\ long)uwTick,\ TAG,\ \_\_FILE\_\_,\ \_\_LINE\_\_,\ \#\#\_\_VA\_ARGS\_\_)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00103}00103\ \textcolor{preprocessor}{\#endif}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00104}00104\ \ \ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00105}00105\ \textcolor{comment}{/**\ TRACE\_SERIAL}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00106}00106\ \textcolor{comment}{\ \ *\ @\}}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00107}00107\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00108}00108\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00109}00109\ \textcolor{comment}{/**\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00110}00110\ \textcolor{comment}{\ \ *\ @addtogroup\ TRACE\_GPIO\ \ \ \ GPIO\ trace\ defines}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00111}00111\ \textcolor{comment}{\ \ *\ @ingroup\ \ \ \ TRACE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00112}00112\ \textcolor{comment}{\ \ *\ @brief\ \ \ \ \ \ Дефайны\ для\ работы\ с\ GPIO\ трассировкой}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00113}00113\ \textcolor{comment}{\ \ *\ @details\ \ \ \ Определяется\ дефайны\ для\ работы\ с\ GPIO\ трассировкой:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00114}00114\ \textcolor{comment}{\ \ \ \ -\/\ TRACE\_GPIO\_RESET()\ -\/\ для\ сброса\ ножки\ GPIO\ (через\ BSRR)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00115}00115\ \textcolor{comment}{\ \ \ \ -\/\ TRACE\_GPIO\_SET()\ -\/\ для\ выставления\ ножки\ GPIO\ (через\ BSRR)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00116}00116\ \textcolor{comment}{\ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00117}00117\ \textcolor{comment}{\ \ \ \ -\/\ Если\ трассировка\ @ref\ GPIO\_TRACE\_ENABLE\ отключена,\ то\ все\ дефайны\ определяются\ как\ 'ничего'\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00118}00118\ \textcolor{comment}{\ \ \ \ \ \ и\ на\ производительность\ кода\ не\ влияют}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00119}00119\ \textcolor{comment}{\ \ *\ @\{\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00120}00120\ \textcolor{comment}{\ \ *}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00121}00121\ \textcolor{comment}{\ \ *\ @def\ TRACE\_GPIO\_RESET(\_gpio\_,\ \_pin\_)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00122}00122\ \textcolor{comment}{\ \ *\ @brief\ Сбросить\ указанную\ ножку\ GPIO}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00123}00123\ \textcolor{comment}{\ \ *\ @param\ \_gpio\_\ \ Указатель\ на\ структуру\ GPIO\ (напр.\ \ GPIOA)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00124}00124\ \textcolor{comment}{\ \ *\ @param\ \_pin\_\ \ \ Номер\ ножки\ (напр.\ GPIO\_PIN\_0)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00125}00125\ \textcolor{comment}{\ \ *\ @details\ Варианты\ реализации:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00126}00126\ \textcolor{comment}{\ \ *\ \ -\/\ GPIO\_TRACE\_ENABLE\ не\ определён\ -\/\ макрос\ пустой}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00127}00127\ \textcolor{comment}{\ \ *\ \ -\/\ GPIO\_TRACE\_ENABLE\ определён\ -\/\ устанавливает\ бит\ сброса\ через\ BSRR\ ((\_pin\_)<<16)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00128}00128\ \textcolor{comment}{\ \ *}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00129}00129\ \textcolor{comment}{\ \ *\ @def\ TRACE\_GPIO\_SET(\_gpio\_,\ \_pin\_)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00130}00130\ \textcolor{comment}{\ \ *\ @brief\ Установить\ указанную\ ножку\ GPIO}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00131}00131\ \textcolor{comment}{\ \ *\ @param\ \_gpio\_\ \ Указатель\ на\ структуру\ GPIO\ (например\ GPIOA)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00132}00132\ \textcolor{comment}{\ \ *\ @param\ \_pin\_\ \ \ Номер\ ножки\ (напр.\ GPIO\_PIN\_0)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00133}00133\ \textcolor{comment}{\ \ *\ @details\ Варианты\ реализации:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00134}00134\ \textcolor{comment}{\ \ *\ \ -\/\ GPIO\_TRACE\_ENABLE\ не\ определён\ -\/\ макрос\ пустой}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00135}00135\ \textcolor{comment}{\ \ *\ \ -\/\ GPIO\_TRACE\_ENABLE\ определён\ -\/\ устанавливает\ бит\ установки\ через\ BSRR\ (\_pin\_)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00136}00136\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00137}00137\ \textcolor{preprocessor}{\#ifndef\ GPIO\_TRACE\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00138}00138\ \textcolor{preprocessor}{\ \ \#define\ TRACE\_GPIO\_SET(\_gpio\_,\_pin\_)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00139}00139\ \textcolor{preprocessor}{\ \ \#define\ TRACE\_GPIO\_RESET(\_gpio\_,\_pin\_)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00140}00140\ \textcolor{preprocessor}{\#else}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00141}\mbox{\hyperlink{group___t_r_a_c_e___g_p_i_o_ga02a6a7b273766121db8ad4a1371373eb}{00141}}\ \textcolor{preprocessor}{\ \ \#define\ TRACE\_GPIO\_SET(\_gpio\_,\_pin\_)\ \ \ \ \ \ \ \ \ \ (\_gpio\_)-\/>BSRR\ =\ (((\_pin\_)))}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00142}\mbox{\hyperlink{group___t_r_a_c_e___g_p_i_o_ga69741d88c991112e99fe7a62e025108a}{00142}}\ \textcolor{preprocessor}{\ \ \#define\ TRACE\_GPIO\_RESET(\_gpio\_,\_pin\_)\ \ \ \ \ \ \ \ (\_gpio\_)-\/>BSRR\ =\ ((\_pin\_)<<16)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00143}00143\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//GPIO\_TRACE\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00144}00144\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00145}00145\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00146}00146\ \textcolor{comment}{/**\ TRACE\_GPIO}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00147}00147\ \textcolor{comment}{\ \ *\ @\}}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00148}00148\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00149}00149\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00150}00150\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00151}00151\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00152}00152\ \textcolor{preprocessor}{\#if\ defined(HAL\_MODULE\_ENABLED)\ \&\&\ defined(RTT\_TRACE\_ENABLE)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00153}00153\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00154}00154\ \textcolor{comment}{/**\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00155}00155\ \textcolor{comment}{\ \ *\ @addtogroup\ TRACE\_RTT\_FLASH\ \ \ \ Flash\ RTT\ Buffer}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00156}00156\ \textcolor{comment}{\ \ *\ @ingroup\ \ \ \ TRACE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00157}00157\ \textcolor{comment}{\ \ *\ @brief\ \ \ \ \ \ Макросы\ и\ функции\ для\ сохранения/чтения\ RTT\ буфера\ в\ Flash}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00158}00158\ \textcolor{comment}{\ \ *\ @details\ \ \ \ Модуль\ позволяет\ сохранять\ данные\ RTT\ буфера\ во\ Flash\ и\ читать\ их\ обратно\ по\ тегам.\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00159}00159\ \textcolor{comment}{\ \ *\ Теги\ работают\ следующим\ образом:\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00160}00160\ \textcolor{comment}{\ \ *\ \ -\/\ Базовый\ тег\ (младший\ байт\ =\ 0):\ модуль\ сам\ выбирает\ первый\ свободный\ слот\ во\ Flash;\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00161}00161\ \textcolor{comment}{\ \ *\ \ \ \ новые\ записи\ получают\ автоинкрементированный\ младший\ байт\ тега\ (от\ 0x00\ до\ 0xFF).\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00162}00162\ \textcolor{comment}{\ \ *\ \ -\/\ Конкретный\ тег\ (младший\ байт\ !=\ 0):\ запись\ или\ чтение\ происходит\ строго\ с\ указанным\ тегом;\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00163}00163\ \textcolor{comment}{\ \ *\ \ \ \ если\ слот\ с\ таким\ тегом\ уже\ занят,\ запись\ не\ выполняется.\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00164}00164\ \textcolor{comment}{\ \ *\ \ -\/\ Автоинкремент\ позволяет\ хранить\ несколько\ последовательных\ записей\ в\ пределах\ одного\ базового\ тега,\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00165}00165\ \textcolor{comment}{\ \ *\ \ \ \ без\ необходимости\ вручную\ отслеживать\ адреса\ Flash\ или\ позиции\ буферов.\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00166}00166\ \textcolor{comment}{\ \ *\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00167}00167\ \textcolor{comment}{\ \ *\ Параметры:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00168}00168\ \textcolor{comment}{\ \ *\ -\/\ @ref\ RTT\_FLASH\_BUFFER\_SIZE\ \ \ \ -\/\ Размер\ буфера\ RTT\ в\ Flash}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00169}00169\ \textcolor{comment}{\ \ *\ -\/\ @ref\ RTT\_FLASH\_SECTOR\ \ \ \ \ \ \ \ \ -\/\ Сектор\ FLASH\ куда\ положится\ RTT\ буфер}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00170}00170\ \textcolor{comment}{\ \ *\ -\/\ @ref\ RTT\_FLASH\_SECTOR\_START\ \ \ -\/\ Начало\ сектора\ RTT\_FLASH\_SECTOR}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00171}00171\ \textcolor{comment}{\ \ *\ -\/\ @ref\ RTT\_FLASH\_SECTOR\_END\ \ \ \ \ -\/\ Конец\ сектора\ RTT\_FLASH\_SECTOR}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00172}00172\ \textcolor{comment}{\ \ *\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00173}00173\ \textcolor{comment}{\ \ *\ @\{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00174}00174\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00175}00175\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00176}00176\ \ \ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00177}00177\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00178}00178\ \textcolor{comment}{\ \ *\ @brief\ Структура\ RTT,\ которая\ будет\ положена\ в\ Flash}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00179}00179\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00180}\mbox{\hyperlink{struct_r_t_t___flash_header__t}{00180}}\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00181}\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{00181}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Уникальный\ идентификатор\ буфера}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00182}\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{00182}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{///<\ Размер\ данных}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00183}\mbox{\hyperlink{struct_r_t_t___flash_header__t_ae7276198385c8d6f6508f433d042d52a}{00183}}\ \ \ \textcolor{keywordtype}{char}\ \ \ \ \ \mbox{\hyperlink{struct_r_t_t___flash_header__t_ae7276198385c8d6f6508f433d042d52a}{data}}[\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}}];\ \ \textcolor{comment}{///<\ Буфер\ RTT}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00184}00184\ \}\ \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}};} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00185}00185\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00186}00186\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00187}00187\ \textcolor{comment}{\ \ *\ @brief\ Подготовка\ Flash\ к\ записи}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00188}00188\ \textcolor{comment}{\ \ *\ @details\ Сбрасывает\ ошибки\ Flash\ и\ ожидает\ готовности\ перед\ записью}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00189}00189\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00190}\mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga21353cb4f5af666237739e62ce019cd6}{00190}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga21353cb4f5af666237739e62ce019cd6}{RTT\_FlashPrepare}}(\textcolor{keywordtype}{void})} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00191}00191\ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00192}00192\ \ \ HAL\_FLASH\_Unlock();} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00193}00193\ \ \ \_\_HAL\_FLASH\_CLEAR\_FLAG(FLASH\_FLAG\_PGSERR\ |\ FLASH\_FLAG\_WRPERR\ |\ FLASH\_FLAG\_OPERR);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00194}00194\ \ \ \textcolor{keywordflow}{while}\ (\_\_HAL\_FLASH\_GET\_FLAG(FLASH\_FLAG\_BSY))\ \{\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00195}00195\ \ \ \_\_NOP();\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00196}00196\ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00197}00197\ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00198}00198\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00199}00199\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00200}00200\ \textcolor{comment}{\ \ *\ @brief\ Сохраняет\ последние\ символы\ RTT-\/буфера\ в\ Flash\ по\ тегу}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00201}00201\ \textcolor{comment}{\ \ *\ @param\ tag\ \ \ \ \ \ \ \ Базовый\ или\ конкретный\ идентификатор\ буфера.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00202}00202\ \textcolor{comment}{\ \ *\ @param\ tail\_size\ \ Количество\ последних\ символов\ RTT\ для\ копирования}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00203}00203\ \textcolor{comment}{\ \ *\ @param\ buf\_num\ \ \ \ Указатель\ на\ переменную\ в\ которую\ запишется\ номер\ буфера\ для\ конкретного\ тега}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00204}00204\ \textcolor{comment}{\ \ *\ @return\ >=0\ —\ номер\ буфера\ (тег)\ для\ записи,\ <0\ —\ ошибка\ (нет\ места,\ тег\ уже\ занят,\ ошибка\ записи\ в\ флеш)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00205}00205\ \textcolor{comment}{\ \ *}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00206}00206\ \textcolor{comment}{\ \ *\ @details\ \ Автоматически\ копирует\ последние\ tail\_size\ символов\ из\ RTT-\/буфера}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00207}00207\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ и\ записывает\ их\ во\ Flash.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00208}00208\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ Тег\ может\ быть\ базовым\ или\ конкретным:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00209}00209\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ Если\ базовый\ (младший\ байт\ ==\ 0)\ —\ будет\ выбран\ первый\ свободный\ слот\ с\ автоинкрементом.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00210}00210\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Автоинкремент\ формируется\ в\ пределах\ от\ 0x1\ до\ 0xFF}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00211}00211\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ Если\ конкретный\ (младший\ байт\ !=\ 0)\ —\ запись\ выполняется\ только\ с\ этим\ тегом,\ иначе\ ошибка.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00212}00212\ \textcolor{comment}{\ \ *\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00213}00213\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00214}\mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga79f222c8ab644de4d47f07528d1edd63}{00214}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga79f222c8ab644de4d47f07528d1edd63}{RTT\_SaveToFlash}}(uint32\_t\ tag,\ uint32\_t\ tail\_size)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00215}00215\ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00216}00216\ \ \ \textcolor{keywordflow}{if}\ (tag\ ==\ 0xFFFFFFFF)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00217}00217\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ Неверный\ тег}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00218}00218\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00219}00219\ \ \ SEGGER\_RTT\_BUFFER\_UP\ *up\ =\ \&\_SEGGER\_RTT.aUp[0];} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00220}00220\ \ \ \textcolor{keywordtype}{unsigned}\ buf\_size\ =\ up-\/>SizeOfBuffer;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00221}00221\ \ \ \textcolor{keywordtype}{unsigned}\ wr\ =\ up-\/>WrOff;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00222}00222\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00223}00223\ \ \ \textcolor{comment}{//\ Ограничиваем\ по\ размеру\ буфера\ RTT\ и\ RTT\_FLASH\_BUFFER\_SIZE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00224}00224\ \ \ \textcolor{keywordtype}{unsigned}\ n\ =\ (tail\_size\ >\ buf\_size)\ ?\ buf\_size\ :\ tail\_size;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00225}00225\ \ \ \textcolor{keywordflow}{if}\ (n\ >\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}})} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00226}00226\ \ \ \ \ n\ =\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}};} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00227}00227\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00228}00228\ \ \ uint32\_t\ addr\ =\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga8e56f75d3ab8a89ddde1404ae23c3297}{RTT\_FLASH\_SECTOR\_START}};} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00229}00229\ \ \ \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ *flash\_hdr\ =\ NULL;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00230}00230\ \ \ uint32\_t\ base\_tag\ =\ tag\ \&\ 0xFFFFFF00;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00231}00231\ \ \ uint32\_t\ next\_tag\ =\ (tag\ \&\ 0xFF)\ ==\ 0\ ?\ tag\ +\ 1\ :\ tag;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00232}00232\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00233}00233\ \ \ \textcolor{comment}{//\ Ищем\ первый\ свободный\ слот,\ параллельно\ автоинкрементируем\ тег}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00234}00234\ \ \ \textcolor{keywordflow}{while}\ ((addr\ +\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}))\ <=\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gafeca0be3688dea07ff443f894668003d}{RTT\_FLASH\_SECTOR\_END}})} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00235}00235\ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00236}00236\ \ \ \ \ flash\_hdr\ =\ (\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ *)addr;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00237}00237\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00238}00238\ \ \ \ \ \textcolor{keywordflow}{if}\ (flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ ==\ 0xFFFFFFFF)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00239}00239\ \ \ \ \ \ \ \textcolor{keywordflow}{break};\ \ \textcolor{comment}{//\ Нашли\ свободное\ место}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00240}00240\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00241}00241\ \ \ \ \ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00242}00242\ \ \ \ \ \textcolor{keywordflow}{if}((flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ \&\ 0xFFFFFF00)\ ==\ base\_tag)\ \textcolor{comment}{//\ выбраный\ тег}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00243}00243\ \ \ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00244}00244\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((tag\ \&\ 0xFF)\ ==\ 0)\ \textcolor{comment}{//\ если\ он\ базовый\ -\/\ ищем\ последний}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00245}00245\ \ \ \ \ \ \ \ \ next\_tag\ =\ flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ +\ 1;\ \ \textcolor{comment}{//\ автоинкремент}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00246}00246\ \ \ \ \ \ \ \textcolor{keywordflow}{else}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00247}00247\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ ==\ tag)\ \textcolor{comment}{//\ если\ он\ конкретный\ и\ уже\ существует\ -\/\ то\ ошибка}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00248}00248\ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ конкретный\ тег\ уже\ занят}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00249}00249\ \ \ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00250}00250\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00251}00251\ \ \ \ \ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00252}00252\ \ \ \ \ \textcolor{keywordflow}{if}(next\_tag\ -\/\ tag\ >\ 0xFF)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00253}00253\ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \textcolor{comment}{//\ автоинкремент\ слишком\ большой}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00254}00254\ \ \ \ \ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00255}00255\ \ \ \ \ addr\ +=\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}});} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00256}00256\ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00257}00257\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00258}00258\ \ \ \textcolor{keywordflow}{if}\ ((addr\ +\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}))\ >\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gafeca0be3688dea07ff443f894668003d}{RTT\_FLASH\_SECTOR\_END}})} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00259}00259\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ Нет\ свободного\ места}} \DoxyCodeLine{\Hypertarget{trace_8h_source_l00260}00260\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00261}00261\ \ \ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga21353cb4f5af666237739e62ce019cd6}{RTT\_FlashPrepare}}();} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00262}00262\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00263}00263\ \ \ \textcolor{comment}{//\ Формируем\ структуру\ в\ RAM}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00264}00264\ \ \ \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ flash\_data;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00265}00265\ \ \ flash\_data.\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ \ =\ next\_tag;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00266}00266\ \ \ flash\_data.\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}}\ =\ valid\_count;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00267}00267\ \ \ memcpy(flash\_data.\mbox{\hyperlink{struct_r_t_t___flash_header__t_ae7276198385c8d6f6508f433d042d52a}{data}},\ temp,\ valid\_count);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00268}00268\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00269}00269\ \ \ \textcolor{comment}{//\ Записываем\ структуру\ во\ Flash\ (по\ 4\ байта)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00270}00270\ \ \ \textcolor{keyword}{const}\ uint32\_t\ *p\ =\ (\textcolor{keyword}{const}\ uint32\_t\ *)\&flash\_data;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00271}00271\ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{unsigned}\ i\ =\ 0;\ i\ <\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}})\ /\ 4;\ i++)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00272}00272\ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00273}00273\ \ \ \ \ \textcolor{keywordflow}{if}(HAL\_FLASH\_Program(FLASH\_TYPEPROGRAM\_WORD,\ addr\ +\ i\ *\ 4,\ p[i])\ !=\ HAL\_OK)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00274}00274\ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00275}00275\ \ \ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00276}00276\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00277}00277\ \ \ HAL\_FLASH\_Lock();} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00278}00278\ \ \ \_\_DSB();} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00279}00279\ \ \ \_\_ISB();} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00280}00280\ \ \ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00281}00281\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00282}00282\ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{int})(next\_tag\&0xFF);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00283}00283\ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00284}00284\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00285}00285\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00286}00286\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00287}00287\ \textcolor{comment}{\ \ *\ @brief\ Читает\ последние\ символы\ RTT-\/буфера\ из\ Flash\ по\ тегу}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00288}00288\ \textcolor{comment}{\ \ *\ @param\ tag\ \ \ \ \ \ \ \ Базовый\ или\ конкретный\ идентификатор\ буфера.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00289}00289\ \textcolor{comment}{\ \ *\ @param\ Buffer\ \ \ \ \ Буфер\ назначения\ для\ копирования\ данных}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00290}00290\ \textcolor{comment}{\ \ *\ @param\ tail\_size\ \ Количество\ последних\ символов,\ которые\ нужно\ прочитать}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00291}00291\ \textcolor{comment}{\ \ *\ @param\ read\_size\ \ Количество\ считанных\ символов}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00292}00292\ \textcolor{comment}{\ \ *\ @return\ >=0\ —\ номер\ буфера\ (тег)\ для\ записи,\ <0\ —\ ошибка\ (тег\ не\ найден\ или\ структура\ повреждена)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00293}00293\ \textcolor{comment}{\ \ *}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00294}00294\ \textcolor{comment}{\ \ *\ @details\ \ Копирует\ последние\ tail\_size\ символов\ из\ найденной\ записи\ Flash\ в\ Buffer.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00295}00295\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ Тег\ может\ быть\ базовым\ или\ конкретным:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00296}00296\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ Если\ базовый\ (младший\ байт\ ==\ 0)\ —\ будет\ прочитана\ последняя\ запись\ из\ группы.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00297}00297\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ Если\ конкретный\ (младший\ байт\ !=\ 0)\ —\ прочитывается\ именно\ эта\ запись.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00298}00298\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00299}\mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga734b2ebbf0c77699b739013878cfd146}{00299}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga734b2ebbf0c77699b739013878cfd146}{RTT\_ReadFromFlash}}(uint32\_t\ tag,\ \textcolor{keywordtype}{char}\ *Buffer,\ uint32\_t\ tail\_size,\ uint32\_t\ *read\_size)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00300}00300\ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00301}00301\ \ \ \textcolor{keywordflow}{if}\ (!Buffer\ ||\ tail\_size\ ==\ 0)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00302}00302\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ Неверные\ параметры}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00303}00303\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00304}00304\ \ \ \textcolor{keywordflow}{if}\ (tag\ ==\ 0xFFFFFFFF)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00305}00305\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ Недопустимый\ тег}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00306}00306\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00307}00307\ \ \ uint32\_t\ addr\ =\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga8e56f75d3ab8a89ddde1404ae23c3297}{RTT\_FLASH\_SECTOR\_START}};} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00308}00308\ \ \ \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ *flash\_hdr\ =\ NULL;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00309}00309\ \ \ \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ *target\_hdr\ =\ NULL;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00310}00310\ \ \ uint32\_t\ base\_tag\ =\ tag\ \&\ 0xFFFFFF00;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00311}00311\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00312}00312\ \ \ \textcolor{comment}{//\ Поиск\ записи\ по\ тегу}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00313}00313\ \ \ \textcolor{keywordflow}{while}\ ((addr\ +\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}))\ <=\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gafeca0be3688dea07ff443f894668003d}{RTT\_FLASH\_SECTOR\_END}})} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00314}00314\ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00315}00315\ \ \ \ \ flash\_hdr\ =\ (\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ *)addr;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00316}00316\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00317}00317\ \ \ \ \ \textcolor{keywordflow}{if}\ (flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ ==\ 0xFFFFFFFF)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00318}00318\ \ \ \ \ \ \ \textcolor{keywordflow}{break};\ \ \textcolor{comment}{//\ Достигнут\ конец\ записанных\ структур}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00319}00319\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00320}00320\ \ \ \ \ \textcolor{comment}{//\ выбраный\ тег}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00321}00321\ \ \ \ \ \textcolor{keywordflow}{if}((flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ \&\ 0xFFFFFF00)\ ==\ base\_tag)\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00322}00322\ \ \ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00323}00323\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((tag\ \&\ 0xFF)\ ==\ 0)\ \textcolor{comment}{//\ если\ он\ базовый\ -\/\ ищем\ последний\ \ \ \ \ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00324}00324\ \ \ \ \ \ \ \ \ target\_hdr\ =\ flash\_hdr;\ \ \textcolor{comment}{//\ сохраняем\ последний\ в\ группе}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00325}00325\ \ \ \ \ \ \ \textcolor{keywordflow}{else}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00326}00326\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ ==\ tag)\ \textcolor{comment}{//\ если\ он\ конкретный\ и\ найден\ -\/\ берем\ его}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00327}00327\ \ \ \ \ \ \ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00328}00328\ \ \ \ \ \ \ \ \ \ \ target\_hdr\ =\ flash\_hdr;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00329}00329\ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};\ \ \textcolor{comment}{//\ конкретный\ тег\ найден}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00330}00330\ \ \ \ \ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00331}00331\ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00332}00332\ \ \ \ \ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00333}00333\ \ \ \ \ addr\ +=\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}});} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00334}00334\ \ \ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00335}00335\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00336}00336\ \ \ \textcolor{keywordflow}{if}\ (!target\_hdr)\ \textcolor{keywordflow}{return}\ -\/1;\ \textcolor{comment}{//\ Тег\ не\ найден}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00337}00337\ \ \ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00338}00338\ \ \ \textcolor{comment}{//\ Проверка\ корректности\ размера}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00339}00339\ \ \ \textcolor{keywordflow}{if}\ (target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}}\ >\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}})} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00340}00340\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ Повреждённая\ запись\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00341}00341\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00342}00342\ \ \ \textcolor{comment}{//\ Определяем\ количество\ читаемых\ символов}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00343}00343\ \ \ uint32\_t\ n\ =\ (tail\_size\ >\ target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}})\ ?\ target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}}\ :\ tail\_size;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00344}00344\ \ \ \textcolor{comment}{//\ Начальная\ позиция\ для\ чтения\ последних\ tail\_size\ символов}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00345}00345\ \ \ uint32\_t\ start\ =\ target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}}\ -\/\ n;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00346}00346\ \ \ \textcolor{comment}{//\ Копируем\ данные\ из\ Flash\ в\ RAM}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00347}00347\ \ \ memcpy(Buffer,\ \&target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_ae7276198385c8d6f6508f433d042d52a}{data}}[start],\ n);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00348}00348\ \ \ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00349}00349\ \ \ \textcolor{keywordflow}{if}(read\_size\ !=\ NULL)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00350}00350\ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00351}00351\ \ \ \ \ *read\_size\ =\ n;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00352}00352\ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00261}00261\ \ \ \textcolor{comment}{//\ Копируем\ последние\ n\ символов\ из\ RTT}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00262}00262\ \ \ \textcolor{keywordtype}{char}\ temp[\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}}];} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00263}00263\ \ \ \textcolor{keywordtype}{unsigned}\ valid\_count\ =\ 0;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00264}00264\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00265}00265\ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{unsigned}\ i\ =\ 0;\ i\ <\ n;\ i++)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00266}00266\ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00267}00267\ \ \ \ \ \textcolor{keywordtype}{unsigned}\ idx\ =\ (wr\ +\ buf\_size\ -\/\ n\ +\ i)\ \%\ buf\_size;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00268}00268\ \ \ \ \ \textcolor{keywordtype}{char}\ c\ =\ up-\/>pBuffer[idx];} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00269}00269\ \ \ \ \ \textcolor{keywordflow}{if}\ (c\ !=\ 0)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00270}00270\ \ \ \ \ \ \ temp[valid\_count++]\ =\ c;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00271}00271\ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00272}00272\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00273}00273\ \ \ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga21353cb4f5af666237739e62ce019cd6}{RTT\_FlashPrepare}}();} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00274}00274\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00275}00275\ \ \ \textcolor{comment}{//\ Формируем\ структуру\ в\ RAM}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00276}00276\ \ \ \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ flash\_data;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00277}00277\ \ \ flash\_data.\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ \ =\ next\_tag;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00278}00278\ \ \ flash\_data.\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}}\ =\ valid\_count;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00279}00279\ \ \ memcpy(flash\_data.\mbox{\hyperlink{struct_r_t_t___flash_header__t_ae7276198385c8d6f6508f433d042d52a}{data}},\ temp,\ valid\_count);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00280}00280\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00281}00281\ \ \ \textcolor{comment}{//\ Записываем\ структуру\ во\ Flash\ (по\ 4\ байта)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00282}00282\ \ \ \textcolor{keyword}{const}\ uint32\_t\ *p\ =\ (\textcolor{keyword}{const}\ uint32\_t\ *)\&flash\_data;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00283}00283\ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{unsigned}\ i\ =\ 0;\ i\ <\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}})\ /\ 4;\ i++)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00284}00284\ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00285}00285\ \ \ \ \ \textcolor{keywordflow}{if}(HAL\_FLASH\_Program(FLASH\_TYPEPROGRAM\_WORD,\ addr\ +\ i\ *\ 4,\ p[i])\ !=\ HAL\_OK)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00286}00286\ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00287}00287\ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00288}00288\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00289}00289\ \ \ HAL\_FLASH\_Lock();} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00290}00290\ \ \ \_\_DSB();} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00291}00291\ \ \ \_\_ISB();} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00292}00292\ \ \ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00293}00293\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00294}00294\ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{int})(next\_tag\&0xFF);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00295}00295\ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00296}00296\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00297}00297\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00298}00298\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00299}00299\ \textcolor{comment}{\ \ *\ @brief\ Читает\ последние\ символы\ RTT-\/буфера\ из\ Flash\ по\ тегу}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00300}00300\ \textcolor{comment}{\ \ *\ @param\ tag\ \ \ \ \ \ \ \ Базовый\ или\ конкретный\ идентификатор\ буфера.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00301}00301\ \textcolor{comment}{\ \ *\ @param\ Buffer\ \ \ \ \ Буфер\ назначения\ для\ копирования\ данных}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00302}00302\ \textcolor{comment}{\ \ *\ @param\ tail\_size\ \ Количество\ последних\ символов,\ которые\ нужно\ прочитать}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00303}00303\ \textcolor{comment}{\ \ *\ @param\ read\_size\ \ Количество\ считанных\ символов}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00304}00304\ \textcolor{comment}{\ \ *\ @return\ >=0\ —\ номер\ буфера\ (тег)\ для\ записи,\ <0\ —\ ошибка\ (тег\ не\ найден\ или\ структура\ повреждена)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00305}00305\ \textcolor{comment}{\ \ *}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00306}00306\ \textcolor{comment}{\ \ *\ @details\ \ Копирует\ последние\ tail\_size\ символов\ из\ найденной\ записи\ Flash\ в\ Buffer.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00307}00307\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ Тег\ может\ быть\ базовым\ или\ конкретным:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00308}00308\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ Если\ базовый\ (младший\ байт\ ==\ 0)\ —\ будет\ прочитана\ последняя\ запись\ из\ группы.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00309}00309\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ Если\ конкретный\ (младший\ байт\ !=\ 0)\ —\ прочитывается\ именно\ эта\ запись.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00310}00310\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00311}\mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga734b2ebbf0c77699b739013878cfd146}{00311}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga734b2ebbf0c77699b739013878cfd146}{RTT\_ReadFromFlash}}(uint32\_t\ tag,\ \textcolor{keywordtype}{char}\ *Buffer,\ uint32\_t\ tail\_size,\ uint32\_t\ *read\_size)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00312}00312\ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00313}00313\ \ \ \textcolor{keywordflow}{if}\ (!Buffer\ ||\ tail\_size\ ==\ 0)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00314}00314\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ Неверные\ параметры}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00315}00315\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00316}00316\ \ \ \textcolor{keywordflow}{if}\ (tag\ ==\ 0xFFFFFFFF)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00317}00317\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ Недопустимый\ тег}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00318}00318\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00319}00319\ \ \ uint32\_t\ addr\ =\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga8e56f75d3ab8a89ddde1404ae23c3297}{RTT\_FLASH\_SECTOR\_START}};} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00320}00320\ \ \ \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ *flash\_hdr\ =\ NULL;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00321}00321\ \ \ \mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ *target\_hdr\ =\ NULL;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00322}00322\ \ \ uint32\_t\ base\_tag\ =\ tag\ \&\ 0xFFFFFF00;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00323}00323\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00324}00324\ \ \ \textcolor{comment}{//\ Поиск\ записи\ по\ тегу}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00325}00325\ \ \ \textcolor{keywordflow}{while}\ ((addr\ +\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}))\ <=\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gafeca0be3688dea07ff443f894668003d}{RTT\_FLASH\_SECTOR\_END}})} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00326}00326\ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00327}00327\ \ \ \ \ flash\_hdr\ =\ (\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}}\ *)addr;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00328}00328\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00329}00329\ \ \ \ \ \textcolor{keywordflow}{if}\ (flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ ==\ 0xFFFFFFFF)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00330}00330\ \ \ \ \ \ \ \textcolor{keywordflow}{break};\ \ \textcolor{comment}{//\ Достигнут\ конец\ записанных\ структур}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00331}00331\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00332}00332\ \ \ \ \ \textcolor{comment}{//\ выбраный\ тег}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00333}00333\ \ \ \ \ \textcolor{keywordflow}{if}((flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ \&\ 0xFFFFFF00)\ ==\ base\_tag)\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00334}00334\ \ \ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00335}00335\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((tag\ \&\ 0xFF)\ ==\ 0)\ \textcolor{comment}{//\ если\ он\ базовый\ -\/\ ищем\ последний\ \ \ \ \ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00336}00336\ \ \ \ \ \ \ \ \ target\_hdr\ =\ flash\_hdr;\ \ \textcolor{comment}{//\ сохраняем\ последний\ в\ группе}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00337}00337\ \ \ \ \ \ \ \textcolor{keywordflow}{else}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00338}00338\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(flash\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ ==\ tag)\ \textcolor{comment}{//\ если\ он\ конкретный\ и\ найден\ -\/\ берем\ его}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00339}00339\ \ \ \ \ \ \ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00340}00340\ \ \ \ \ \ \ \ \ \ \ target\_hdr\ =\ flash\_hdr;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00341}00341\ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};\ \ \textcolor{comment}{//\ конкретный\ тег\ найден}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00342}00342\ \ \ \ \ \ \ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00343}00343\ \ \ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00344}00344\ \ \ \ \ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00345}00345\ \ \ \ \ addr\ +=\ \textcolor{keyword}{sizeof}(\mbox{\hyperlink{struct_r_t_t___flash_header__t}{RTT\_FlashHeader\_t}});} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00346}00346\ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00347}00347\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00348}00348\ \ \ \textcolor{keywordflow}{if}\ (!target\_hdr)\ \textcolor{keywordflow}{return}\ -\/1;\ \textcolor{comment}{//\ Тег\ не\ найден}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00349}00349\ \ \ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00350}00350\ \ \ \textcolor{comment}{//\ Проверка\ корректности\ размера}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00351}00351\ \ \ \textcolor{keywordflow}{if}\ (target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}}\ >\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}})} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00352}00352\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;\ \ \textcolor{comment}{//\ Повреждённая\ запись\ \ }} \DoxyCodeLine{\Hypertarget{trace_8h_source_l00353}00353\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00354}00354\ \ \ \_\_DSB();} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00355}00355\ \ \ \_\_ISB();} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00356}00356\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00357}00357\ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{int})(target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ \&\ 0xFF);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00358}00358\ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00359}00359\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00360}00360\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00361}00361\ \textcolor{comment}{\ \ *\ @brief\ Стирание\ сектора\ Flash\ с\ RTT-\/буфером}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00362}00362\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00363}\mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga8d8c6850e32b42871faefce3352012d1}{00363}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga8d8c6850e32b42871faefce3352012d1}{RTT\_EraseFlash}}(\textcolor{keywordtype}{void})} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00364}00364\ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00365}00365\ \ \ FLASH\_EraseInitTypeDef\ eraseInit;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00366}00366\ \ \ uint32\_t\ pageError\ =\ 0;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00367}00367\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00368}00368\ \ \ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga21353cb4f5af666237739e62ce019cd6}{RTT\_FlashPrepare}}();} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00369}00369\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00370}00370\ \ \ eraseInit.TypeErase\ \ \ =\ FLASH\_TYPEERASE\_SECTORS;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00371}00371\ \ \ eraseInit.Sector\ \ \ \ \ \ =\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga3bc1b76864e1d32cbdd174d4caae7724}{RTT\_FLASH\_SECTOR}};} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00372}00372\ \ \ eraseInit.NbSectors\ \ \ =\ 1;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00373}00373\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00374}00374\ \ \ \textcolor{keywordflow}{if}\ (HAL\_FLASHEx\_Erase(\&eraseInit,\ \&pageError)\ !=\ HAL\_OK)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00375}00375\ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00376}00376\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00377}00377\ \ \ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00378}00378\ \ \ \textcolor{keywordflow}{return}\ 0;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00379}00379\ \ \ HAL\_FLASH\_Lock();} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00380}00380\ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00381}00381\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00382}00382\ \textcolor{comment}{/**\ TRACE\_RTT\_FLASH}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00383}00383\ \textcolor{comment}{\ \ *\ @\}}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00384}00384\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00354}00354\ \ \ \textcolor{comment}{//\ Определяем\ количество\ читаемых\ символов}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00355}00355\ \ \ uint32\_t\ n\ =\ (tail\_size\ >\ target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}})\ ?\ target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}}\ :\ tail\_size;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00356}00356\ \ \ \textcolor{comment}{//\ Начальная\ позиция\ для\ чтения\ последних\ tail\_size\ символов}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00357}00357\ \ \ uint32\_t\ start\ =\ target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_afd1a5c51af6f97d170c2ccbbe3e34699}{size}}\ -\/\ n;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00358}00358\ \ \ \textcolor{comment}{//\ Копируем\ данные\ из\ Flash\ в\ RAM}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00359}00359\ \ \ memcpy(Buffer,\ \&target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_ae7276198385c8d6f6508f433d042d52a}{data}}[start],\ n);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00360}00360\ \ \ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00361}00361\ \ \ \textcolor{keywordflow}{if}(read\_size\ !=\ NULL)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00362}00362\ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00363}00363\ \ \ \ \ *read\_size\ =\ n;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00364}00364\ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00365}00365\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00366}00366\ \ \ \_\_DSB();} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00367}00367\ \ \ \_\_ISB();} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00368}00368\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00369}00369\ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{int})(target\_hdr-\/>\mbox{\hyperlink{struct_r_t_t___flash_header__t_a844ee5470a323a749856cbb7a682dc57}{tag}}\ \&\ 0xFF);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00370}00370\ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00371}00371\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00372}00372\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00373}00373\ \textcolor{comment}{\ \ *\ @brief\ Стирание\ сектора\ Flash\ с\ RTT-\/буфером}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00374}00374\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00375}\mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga8d8c6850e32b42871faefce3352012d1}{00375}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga8d8c6850e32b42871faefce3352012d1}{RTT\_EraseFlash}}(\textcolor{keywordtype}{void})} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00376}00376\ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00377}00377\ \ \ FLASH\_EraseInitTypeDef\ eraseInit;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00378}00378\ \ \ uint32\_t\ pageError\ =\ 0;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00379}00379\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00380}00380\ \ \ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga21353cb4f5af666237739e62ce019cd6}{RTT\_FlashPrepare}}();} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00381}00381\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00382}00382\ \ \ eraseInit.TypeErase\ \ \ =\ FLASH\_TYPEERASE\_SECTORS;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00383}00383\ \ \ eraseInit.Sector\ \ \ \ \ \ =\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga3bc1b76864e1d32cbdd174d4caae7724}{RTT\_FLASH\_SECTOR}};} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00384}00384\ \ \ eraseInit.NbSectors\ \ \ =\ 1;} \DoxyCodeLine{\Hypertarget{trace_8h_source_l00385}00385\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00386}00386\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//\ HAL\_MODULE\_ENABLED\ \&\&\ RTT\_TRACE\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00387}00387\ \textcolor{preprocessor}{\#define\ RTT\_FlashPrepare(...)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00388}00388\ \textcolor{preprocessor}{\#define\ RTT\_EraseFlash(...)\ \ \ \ 0}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00389}00389\ \textcolor{preprocessor}{\#define\ RTT\_SaveToFlash(...)\ \ \ 0}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00390}00390\ \textcolor{preprocessor}{\#define\ RTT\_ReadFromFlash(...)\ 0}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00391}00391\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ HAL\_MODULE\_ENABLED\ \&\&\ RTT\_TRACE\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00392}00392\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00393}00393\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00394}00394\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00395}00395\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00396}00396\ \textcolor{comment}{/**\ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00397}00397\ \textcolor{comment}{\ \ *\ @addtogroup\ \ TRACE\_HARDFAULT\ \ \ \ Hardfault\ trace\ defines}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00398}00398\ \textcolor{comment}{\ \ *\ @ingroup\ \ \ \ \ TRACE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00399}00399\ \textcolor{comment}{\ \ *\ @brief\ \ \ \ \ \ \ Модуль\ трассировки\ HardFault\ с\ возможностью\ сохранения\ RTT\ буфера\ во\ Flash}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00400}00400\ \textcolor{comment}{\ \ *\ @details}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00401}00401\ \textcolor{comment}{\ \ *\ Этот\ модуль\ позволяет\ сохранять\ контекст\ процессора\ и\ последние\ символы\ RTT\ буфера\ при\ возникновении\ HardFault.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00402}00402\ \textcolor{comment}{\ \ *}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00403}00403\ \textcolor{comment}{\ \ *\ Механизм\ работы:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00404}00404\ \textcolor{comment}{\ \ *\ \ \ -\/\ При\ срабатывании\ HardFault\ вызывается\ HF\_HandleFault(),\ который:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00405}00405\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 1.\ Получает\ указатель\ на\ стек,\ где\ произошёл\ HardFault\ (MSP\ или\ PSP).}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00406}00406\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 2.\ Выводит\ значения\ регистров\ R0-\/R3,\ R12,\ LR,\ PC,\ PSR\ и\ системных\ регистров\ SCB.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00407}00407\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 3.\ Формирует\ строку\ с\ регистрами\ и\ копирует\ последние\ символы\ RTT\ буфера.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00408}00408\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 4.\ Сохраняет\ данные\ во\ Flash\ с\ базовым\ тегом\ HF\_RTT\_TAG\_BASE.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00409}00409\ \textcolor{comment}{\ \ *\ \ \ -\/\ Для\ восстановления\ последнего\ HardFault\ используется\ HF\_CheckRecovered(),\ который:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00410}00410\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 1.\ Читает\ запись\ во\ Flash\ по\ базовому\ тегу.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00411}00411\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 2.\ Выводит\ сохранённый\ RTT\ буфер\ и\ контекст\ регистров.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00412}00412\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 3.\ Опционально\ стирает\ Flash\ после\ восстановления.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00413}00413\ \textcolor{comment}{\ \ @code}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00414}00414\ \textcolor{comment}{\ \ void\ Hardfault()}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00415}00415\ \textcolor{comment}{\ \ \{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00416}00416\ \textcolor{comment}{\ \ \ \ HF\_HandleFault();}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00417}00417\ \textcolor{comment}{\ \ \ \ NVIC\_SystemReset();}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00418}00418\ \textcolor{comment}{\ \ \}}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00419}00419\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00420}00420\ \textcolor{comment}{\ \ int\ main()}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00421}00421\ \textcolor{comment}{\ \ \{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00422}00422\ \textcolor{comment}{\ \ \ \ if(HF\_CheckRecovered(0))}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00423}00423\ \textcolor{comment}{\ \ \ \ \{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00424}00424\ \textcolor{comment}{\ \ \ \ \ \ //set\ hardfault\ error}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00425}00425\ \textcolor{comment}{\ \ \ \ \ \ RTT\_EraseFlash();\ //\ erase\ rtt\ flash\ after\ message\ readed}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00426}00426\ \textcolor{comment}{\ \ \ \ \}}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00427}00427\ \textcolor{comment}{\ \ \}\ \ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00428}00428\ \textcolor{comment}{\ \ @endcode}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00429}00429\ \textcolor{comment}{\ \ *\ @\{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00430}00430\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00431}00431\ \textcolor{preprocessor}{\#if\ defined(HAL\_MODULE\_ENABLED)\ \&\&\ defined(HARDFAULT\_SERIAL\_TRACE)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00432}00432\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00433}00433\ \textcolor{preprocessor}{\#ifndef\ HF\_RTT\_TAIL\_SIZE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00434}00434\ \textcolor{preprocessor}{\#define\ HF\_RTT\_TAIL\_SIZE\ \ RTT\_FLASH\_BUFFER\_SIZE\ }\textcolor{comment}{///<\ Размер\ буфера\ RTT,\ который\ сохранится\ при\ Hardfault}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00435}00435\ \textcolor{preprocessor}{\#endif}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00436}00436\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00437}00437\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00438}00438\ \textcolor{comment}{\ \ *\ @brief\ Контекст\ стек-\/фрейма\ процессора\ при\ HardFault}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00439}00439\ \textcolor{comment}{\ \ *\ @details\ Сохраняет\ регистры\ R0-\/R3,\ R12,\ LR,\ PC,\ PSR\ для\ последующего\ анализа.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00440}00440\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00441}\mbox{\hyperlink{struct_h_f___stack_frame__t}{00441}}\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00442}\mbox{\hyperlink{struct_h_f___stack_frame__t_a4146ed28926b5f234132b7112119a413}{00442}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a4146ed28926b5f234132b7112119a413}{r0}};\ \ \ \textcolor{comment}{///<\ Регистр\ R0}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00443}\mbox{\hyperlink{struct_h_f___stack_frame__t_a286104d19185714940645a9df814ddea}{00443}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a286104d19185714940645a9df814ddea}{r1}};\ \ \ \textcolor{comment}{///<\ Регистр\ R1}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00444}\mbox{\hyperlink{struct_h_f___stack_frame__t_a5a52e5006dabcf68c0fa4cfb0e03335b}{00444}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a5a52e5006dabcf68c0fa4cfb0e03335b}{r2}};\ \ \ \textcolor{comment}{///<\ Регистр\ R2}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00445}\mbox{\hyperlink{struct_h_f___stack_frame__t_a453c7af42b6928a693af422e17c981d3}{00445}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a453c7af42b6928a693af422e17c981d3}{r3}};\ \ \ \textcolor{comment}{///<\ Регистр\ R3}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00446}\mbox{\hyperlink{struct_h_f___stack_frame__t_a819ee3bc518c460ece1b7c4079f8f80b}{00446}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a819ee3bc518c460ece1b7c4079f8f80b}{r12}};\ \ \textcolor{comment}{///<\ Регистр\ R12}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00447}\mbox{\hyperlink{struct_h_f___stack_frame__t_a6e51904297f7725e96d5b5fb291ef577}{00447}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a6e51904297f7725e96d5b5fb291ef577}{lr}};\ \ \ \textcolor{comment}{///<\ Link\ Register}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00448}\mbox{\hyperlink{struct_h_f___stack_frame__t_a16563896004751c90e41c81ae4570732}{00448}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a16563896004751c90e41c81ae4570732}{pc}};\ \ \ \textcolor{comment}{///<\ Program\ Counter}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00449}\mbox{\hyperlink{struct_h_f___stack_frame__t_ae47cb051ee3c94471bfd4fe7e49c55f9}{00449}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_ae47cb051ee3c94471bfd4fe7e49c55f9}{psr}};\ \ \textcolor{comment}{///<\ Program\ Status\ Register}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00450}00450\ \}\ \mbox{\hyperlink{struct_h_f___stack_frame__t}{HF\_StackFrame\_t}};} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00451}00451\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00452}00452\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00453}00453\ \textcolor{comment}{\ \ *\ @brief\ Проверка\ и\ вывод\ последнего\ HardFault-\/трейса\ из\ Flash}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00454}00454\ \textcolor{comment}{\ \ *\ @details}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00455}00455\ \textcolor{comment}{\ \ *\ Функция\ ищет\ последнюю\ запись\ HardFault\ по\ базовому\ тегу\ HF\_RTT\_TAG\_BASE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00456}00456\ \textcolor{comment}{\ \ *\ и\ выводит\ её\ содержимое\ в\ консоль.\ После\ успешного\ вывода\ Flash\ можно\ опционально\ очистить.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00457}00457\ \textcolor{comment}{\ \ *}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00458}00458\ \textcolor{comment}{\ \ *\ @return\ int}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00459}00459\ \textcolor{comment}{\ \ *\ \ \ -\/\ 1\ —\ данные\ HardFault\ найдены\ и\ выведены}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00460}00460\ \textcolor{comment}{\ \ *\ \ \ -\/\ 0\ —\ данные\ отсутствуют\ или\ тег\ не\ найден}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00461}00461\ \textcolor{comment}{\ \ *\ }} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00462}00462\ \textcolor{comment}{\ \ *\ @note\ Вызов\ рекомендуется\ при\ инициализации\ приложения\ для\ анализа\ предыдущего\ сбоя.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00463}00463\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00464}\mbox{\hyperlink{group___t_r_a_c_e___h_a_r_d_f_a_u_l_t_ga03f8b6f3b537ee1c8e91065c60db504f}{00464}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{group___t_r_a_c_e___h_a_r_d_f_a_u_l_t_ga03f8b6f3b537ee1c8e91065c60db504f}{HF\_CheckRecovered}}(\textcolor{keywordtype}{int}\ erase)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00465}00465\ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00466}00466\ \ \ \textcolor{keywordtype}{char}\ buffer[\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}}];} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00467}00467\ \ \ uint32\_t\ read\_size\ =\ 0;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00468}00468\ \ \ \textcolor{keywordtype}{int}\ n\_hardfault\ =\ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga734b2ebbf0c77699b739013878cfd146}{RTT\_ReadFromFlash}}(\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gadc960255719c7eff4bdfaa850be9b313}{HF\_RTT\_TAG\_BASE}},\ buffer,\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gafcc7ea03d4df8f1909e580b519a7f3ca}{HF\_RTT\_TAIL\_SIZE}},\ \&read\_size);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00469}00469\ \ \ \textcolor{keywordflow}{if}\ (n\_hardfault\ >\ 0)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00470}00470\ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00471}00471\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}\(\backslash\)n-\/-\/-\/\ Recovered\ HardFault\ RTT\ buffer\ \#\%u\ -\/-\/-\/\(\backslash\)n"{}},\ n\_hardfault);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00472}00472\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ read\_size;\ i++)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00473}00473\ \ \ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00474}00474\ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ c\ =\ buffer[i];} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00475}00475\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (c\ ==\ 0\ ||\ c\ ==\ (\textcolor{keywordtype}{char})0xFF)\ \textcolor{keywordflow}{break};} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00476}00476\ \ \ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}\%c"{}},\ c);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00477}00477\ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00478}00478\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00479}00479\ \ \ \ \ \textcolor{keywordflow}{if}(erase)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00480}00480\ \ \ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga8d8c6850e32b42871faefce3352012d1}{RTT\_EraseFlash}}();} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00481}00481\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}\(\backslash\)n-\/-\/-\/-\/-\/-\/-\/-\/-\/\ HardFault\ Dump\ End\ -\/-\/-\/-\/-\/-\/-\/-\/-\/\(\backslash\)n"{}});} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00482}00482\ \ \ \ \ \textcolor{keywordflow}{return}\ 1;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00483}00483\ \ \ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00484}00484\ \ \ \textcolor{keywordflow}{return}\ 0;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00485}00485\ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00486}00486\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00487}00487\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00488}00488\ \textcolor{keyword}{static}\ \mbox{\hyperlink{struct_h_f___stack_frame__t}{HF\_StackFrame\_t}}\ *stack\_frame;} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00489}00489\ \textcolor{keyword}{static}\ uint32\_t\ stack\_dump[\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gaa31234688b333a505aaa57b8ecdedf5b}{HF\_STACK\_DUMP\_WORDS}}];} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00490}00490\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}\ *ret\_adr[10]\ =\ \{0\};\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00491}00491\ \textcolor{comment}{/**}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00492}00492\ \textcolor{comment}{\ \ *\ @brief\ Обработчик\ HardFault}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00493}00493\ \textcolor{comment}{\ \ *\ @details}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00494}00494\ \textcolor{comment}{\ \ *\ Вызывается\ из\ прерывания\ HardFault\ или\ в\ любом\ месте\ где\ понятно\ что\ ошибка\ критическая.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00495}00495\ \textcolor{comment}{\ \ *\ Последовательно\ выполняет:}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00496}00496\ \textcolor{comment}{\ \ *\ \ \ 1.\ Определяет\ активный\ стек\ (MSP\ или\ PSP)\ на\ момент\ сбоя.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00497}00497\ \textcolor{comment}{\ \ *\ \ \ 2.\ Сохраняет\ значения\ регистров\ R0-\/R3,\ R12,\ LR,\ PC,\ PSR.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00498}00498\ \textcolor{comment}{\ \ *\ \ \ 3.\ Выводит\ системные\ регистры\ CFSR,\ HFSR,\ DFSR,\ AFSR,\ MMFAR,\ BFAR.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00499}00499\ \textcolor{comment}{\ \ *\ \ \ 4.\ Формирует\ stack\ trace\ с\ 3\ уровнями\ возврата.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00500}00500\ \textcolor{comment}{\ \ *\ \ \ 5.\ Копирует\ последние\ символы\ RTT\ буфера.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00501}00501\ \textcolor{comment}{\ \ *\ \ \ 6.\ Сохраняет\ все\ данные\ во\ Flash\ через\ RTT\_SaveToFlash\ с\ базовым\ тегом\ HF\_RTT\_TAG\_BASE.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00502}00502\ \textcolor{comment}{\ \ *}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00503}00503\ \textcolor{comment}{\ \ *\ @note\ Функция\ защищена,\ так\ как\ вызывается\ в\ контексте\ сбоя\ —\ минимизирует\ использование\ вызовов\ HAL.}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00504}00504\ \textcolor{comment}{\ \ */}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00505}\mbox{\hyperlink{group___t_r_a_c_e___h_a_r_d_f_a_u_l_t_gadd8e10e7ec3b0204f7f92062ecd452f7}{00505}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{group___t_r_a_c_e___h_a_r_d_f_a_u_l_t_gadd8e10e7ec3b0204f7f92062ecd452f7}{HF\_HandleFault}}(\textcolor{keywordtype}{void})} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00506}00506\ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00507}00507\ \ \ \ \ \textcolor{comment}{//\ Получаем\ указатель\ на\ стек,\ где\ произошёл\ HardFault}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00508}00508\ \ \ \ \ \_\_ASM\ \textcolor{keyword}{volatile}(} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00509}00509\ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}TST\ lr,\ \#4\ \ \ \ \ \ \ \(\backslash\)n"{}}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00510}00510\ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}ITE\ EQ\ \ \ \ \ \ \ \ \ \ \ \(\backslash\)n"{}}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00511}00511\ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}MRSEQ\ \%[ptr],\ MSP\(\backslash\)n"{}}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00512}00512\ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}MRSNE\ \%[ptr],\ PSP\(\backslash\)n"{}}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00513}00513\ \ \ \ \ \ \ \ \ :\ [ptr]\ \textcolor{stringliteral}{"{}=r"{}}(stack\_frame)} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00514}00514\ \ \ \ \ );} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00515}00515\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00516}00516\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}\(\backslash\)n=====\ HardFault\ occurred!\ =====\(\backslash\)n"{}});} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00517}00517\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}R0\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>r0);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00518}00518\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}R1\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>r1);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00519}00519\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}R2\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>r2);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00520}00520\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}R3\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>r3);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00521}00521\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}R12\ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>r12);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00522}00522\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}LR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>lr);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00523}00523\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}PC\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>pc);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00524}00524\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}PSR\ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>psr);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00525}00525\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00526}00526\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}CFSR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>CFSR);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00527}00527\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}HFSR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>HFSR);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00528}00528\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}DFSR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>DFSR);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00529}00529\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}AFSR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>AFSR);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00530}00530\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}MMFAR\ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>MMFAR);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00531}00531\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}BFAR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>BFAR);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00532}00532\ \ \ \ \ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00533}00533\ \ \ \ \ \textcolor{comment}{//\ -\/-\/-\/\ Stack\ trace\ -\/-\/-\/}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00534}00534\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}-\/-\/-\/\ Stack\ trace\ -\/-\/-\/\(\backslash\)n"{}});} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00535}00535\ \ \ \ \ ret\_adr[0]\ =\ \_\_builtin\_return\_address(0);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00536}00536\ \ \ \ \ ret\_adr[1]\ =\ \_\_builtin\_return\_address(1);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00537}00537\ \ \ \ \ ret\_adr[2]\ =\ \_\_builtin\_return\_address(2);} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00538}00538\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00539}00539\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ 3;\ i++)\ \ \textcolor{comment}{//\ развернуть\ n\ уровней}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00540}00540\ \ \ \ \ \{} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00541}00541\ \ \ \ \ \ \ \textcolor{keywordflow}{if}(ret\_adr[i])} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00542}00542\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}\ \ \#\%d:\ 0x\%08lX\(\backslash\)r\(\backslash\)n"{}},\ i,\ ret\_adr[i]);\ \textcolor{comment}{//\ -\/1\ для\ Thumb}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00543}00543\ \ \ \ \ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00544}00544\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga79f222c8ab644de4d47f07528d1edd63}{RTT\_SaveToFlash}}(\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gadc960255719c7eff4bdfaa850be9b313}{HF\_RTT\_TAG\_BASE}},\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gafcc7ea03d4df8f1909e580b519a7f3ca}{HF\_RTT\_TAIL\_SIZE}});} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00545}00545\ \}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00546}00546\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//\ HAL\_MODULE\_ENABLED\ \&\&\ HARDFAULT\_SERIAL\_TRACE}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00547}00547\ \textcolor{preprocessor}{\#define\ HF\_CheckRecovered(...)\ 0}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00548}00548\ \textcolor{preprocessor}{\#define\ HF\_HandleFault(...)}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00549}00549\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ HAL\_MODULE\_ENABLED\ \&\&\ HARDFAULT\_SERIAL\_TRACE}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00550}00550\ \textcolor{comment}{/**\ TRACE\_HARDFAULT}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00551}00551\ \textcolor{comment}{\ \ *\ @\}}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00552}00552\ \textcolor{comment}{\ \ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00553}00553\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00554}00554\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00555}00555\ } -\DoxyCodeLine{\Hypertarget{trace_8h_source_l00556}00556\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\_\_TRACE\_H\_}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00386}00386\ \ \ \textcolor{keywordflow}{if}\ (HAL\_FLASHEx\_Erase(\&eraseInit,\ \&pageError)\ !=\ HAL\_OK)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00387}00387\ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00388}00388\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00389}00389\ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00390}00390\ \ \ \textcolor{keywordflow}{return}\ 0;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00391}00391\ \ \ HAL\_FLASH\_Lock();} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00392}00392\ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00393}00393\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00394}00394\ \textcolor{comment}{/**\ TRACE\_RTT\_FLASH}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00395}00395\ \textcolor{comment}{\ \ *\ @\}}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00396}00396\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00397}00397\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00398}00398\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//\ HAL\_MODULE\_ENABLED\ \&\&\ RTT\_TRACE\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00399}00399\ \textcolor{preprocessor}{\#define\ RTT\_FlashPrepare(...)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00400}00400\ \textcolor{preprocessor}{\#define\ RTT\_EraseFlash(...)\ \ \ \ 0}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00401}00401\ \textcolor{preprocessor}{\#define\ RTT\_SaveToFlash(...)\ \ \ 0}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00402}00402\ \textcolor{preprocessor}{\#define\ RTT\_ReadFromFlash(...)\ 0}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00403}00403\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ HAL\_MODULE\_ENABLED\ \&\&\ RTT\_TRACE\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00404}00404\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00405}00405\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00406}00406\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00407}00407\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00408}00408\ \textcolor{comment}{/**\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00409}00409\ \textcolor{comment}{\ \ *\ @addtogroup\ \ TRACE\_HARDFAULT\ \ \ \ Hardfault\ trace\ defines}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00410}00410\ \textcolor{comment}{\ \ *\ @ingroup\ \ \ \ \ TRACE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00411}00411\ \textcolor{comment}{\ \ *\ @brief\ \ \ \ \ \ \ Модуль\ трассировки\ HardFault\ с\ возможностью\ сохранения\ RTT\ буфера\ во\ Flash}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00412}00412\ \textcolor{comment}{\ \ *\ @details}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00413}00413\ \textcolor{comment}{\ \ *\ Этот\ модуль\ позволяет\ сохранять\ контекст\ процессора\ и\ последние\ символы\ RTT\ буфера\ при\ возникновении\ HardFault.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00414}00414\ \textcolor{comment}{\ \ *}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00415}00415\ \textcolor{comment}{\ \ *\ Механизм\ работы:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00416}00416\ \textcolor{comment}{\ \ *\ \ \ -\/\ При\ срабатывании\ HardFault\ вызывается\ HF\_HandleFault(),\ который:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00417}00417\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 1.\ Получает\ указатель\ на\ стек,\ где\ произошёл\ HardFault\ (MSP\ или\ PSP).}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00418}00418\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 2.\ Выводит\ значения\ регистров\ R0-\/R3,\ R12,\ LR,\ PC,\ PSR\ и\ системных\ регистров\ SCB.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00419}00419\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 3.\ Формирует\ строку\ с\ регистрами\ и\ копирует\ последние\ символы\ RTT\ буфера.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00420}00420\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 4.\ Сохраняет\ данные\ во\ Flash\ с\ базовым\ тегом\ HF\_RTT\_TAG\_BASE.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00421}00421\ \textcolor{comment}{\ \ *\ \ \ -\/\ Для\ восстановления\ последнего\ HardFault\ используется\ HF\_CheckRecovered(),\ который:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00422}00422\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 1.\ Читает\ запись\ во\ Flash\ по\ базовому\ тегу.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00423}00423\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 2.\ Выводит\ сохранённый\ RTT\ буфер\ и\ контекст\ регистров.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00424}00424\ \textcolor{comment}{\ \ *\ \ \ \ \ \ \ 3.\ Опционально\ стирает\ Flash\ после\ восстановления.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00425}00425\ \textcolor{comment}{\ \ *\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00426}00426\ \textcolor{comment}{\ \ *\ Параметры:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00427}00427\ \textcolor{comment}{\ \ *\ -\/\ @ref\ HARDFAULT\_SERIAL\_TRACE\ \ \ -\/\ Включить\ обработку\ и\ serial\ трассировку\ Hardfault}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00428}00428\ \textcolor{comment}{\ \ *\ \ \ Если\ отключена\ то\ вставляются\ заглушки,\ никак\ не\ влияющие\ на\ параметры\ и\ остальную\ программу}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00429}00429\ \textcolor{comment}{\ \ *\ -\/\ @ref\ HF\_RTT\_TAG\_BASE\ \ \ \ \ \ \ \ \ \ -\/\ Базовый\ тег\ RTT\ Flash\ для\ HardFault\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00430}00430\ \textcolor{comment}{\ \ *\ -\/\ @ref\ HF\_RTT\_TAIL\_SIZE\ \ \ \ \ \ \ \ \ -\/\ Размер\ буфера\ RTT,\ который\ сохранится\ при\ Hardfault}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00431}00431\ \textcolor{comment}{\ \ *\ -\/\ @ref\ HF\_STACK\_DUMP\_WORDS\ \ \ \ \ \ -\/\ Сколько\ слов\ стека\ будет\ проанализировано\ во\ время\ Hardfault}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00432}00432\ \textcolor{comment}{\ \ *\ -\/\ @ref\ HF\_FLASH\_ADDR\ \ \ \ \ \ \ \ \ \ \ \ -\/\ Адрес\ FLASH\ куда\ положится\ RTT\ буфер}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00433}00433\ \textcolor{comment}{\ \ *\ -\/\ @ref\ HF\_RAM\_END\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ Конец\ RAM\ памяти\ (чтобы\ во\ время\ анализа\ стека\ не\ выйти\ за\ пределы)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00434}00434\ \textcolor{comment}{\ \ *\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00435}00435\ \textcolor{comment}{\ \ @code}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00436}00436\ \textcolor{comment}{\ \ void\ Hardfault()}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00437}00437\ \textcolor{comment}{\ \ \{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00438}00438\ \textcolor{comment}{\ \ \ \ HF\_HandleFault();}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00439}00439\ \textcolor{comment}{\ \ \ \ NVIC\_SystemReset();}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00440}00440\ \textcolor{comment}{\ \ \}}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00441}00441\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00442}00442\ \textcolor{comment}{\ \ int\ main()}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00443}00443\ \textcolor{comment}{\ \ \{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00444}00444\ \textcolor{comment}{\ \ \ \ if(HF\_CheckRecovered(0))}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00445}00445\ \textcolor{comment}{\ \ \ \ \{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00446}00446\ \textcolor{comment}{\ \ \ \ \ \ //set\ hardfault\ error}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00447}00447\ \textcolor{comment}{\ \ \ \ \ \ RTT\_EraseFlash();\ //\ erase\ rtt\ flash\ after\ message\ readed}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00448}00448\ \textcolor{comment}{\ \ \ \ \}}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00449}00449\ \textcolor{comment}{\ \ \}\ \ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00450}00450\ \textcolor{comment}{\ \ @endcode}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00451}00451\ \textcolor{comment}{\ \ *\ @\{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00452}00452\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00453}00453\ \textcolor{preprocessor}{\#if\ defined(HAL\_MODULE\_ENABLED)\ \&\&\ defined(HARDFAULT\_SERIAL\_TRACE)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00454}00454\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00455}00455\ \textcolor{preprocessor}{\#ifndef\ HF\_RTT\_TAIL\_SIZE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00456}00456\ \textcolor{preprocessor}{\#define\ HF\_RTT\_TAIL\_SIZE\ \ RTT\_FLASH\_BUFFER\_SIZE\ }\textcolor{comment}{///<\ Размер\ буфера\ RTT,\ который\ сохранится\ при\ Hardfault}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00457}00457\ \textcolor{preprocessor}{\#endif}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00458}00458\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00459}00459\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00460}00460\ \textcolor{comment}{\ \ *\ @brief\ Контекст\ стек-\/фрейма\ процессора\ при\ HardFault}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00461}00461\ \textcolor{comment}{\ \ *\ @details\ Сохраняет\ регистры\ R0-\/R3,\ R12,\ LR,\ PC,\ PSR\ для\ последующего\ анализа.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00462}00462\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00463}\mbox{\hyperlink{struct_h_f___stack_frame__t}{00463}}\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00464}\mbox{\hyperlink{struct_h_f___stack_frame__t_a4146ed28926b5f234132b7112119a413}{00464}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a4146ed28926b5f234132b7112119a413}{r0}};\ \ \ \textcolor{comment}{///<\ Регистр\ R0}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00465}\mbox{\hyperlink{struct_h_f___stack_frame__t_a286104d19185714940645a9df814ddea}{00465}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a286104d19185714940645a9df814ddea}{r1}};\ \ \ \textcolor{comment}{///<\ Регистр\ R1}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00466}\mbox{\hyperlink{struct_h_f___stack_frame__t_a5a52e5006dabcf68c0fa4cfb0e03335b}{00466}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a5a52e5006dabcf68c0fa4cfb0e03335b}{r2}};\ \ \ \textcolor{comment}{///<\ Регистр\ R2}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00467}\mbox{\hyperlink{struct_h_f___stack_frame__t_a453c7af42b6928a693af422e17c981d3}{00467}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a453c7af42b6928a693af422e17c981d3}{r3}};\ \ \ \textcolor{comment}{///<\ Регистр\ R3}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00468}\mbox{\hyperlink{struct_h_f___stack_frame__t_a819ee3bc518c460ece1b7c4079f8f80b}{00468}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a819ee3bc518c460ece1b7c4079f8f80b}{r12}};\ \ \textcolor{comment}{///<\ Регистр\ R12}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00469}\mbox{\hyperlink{struct_h_f___stack_frame__t_a6e51904297f7725e96d5b5fb291ef577}{00469}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a6e51904297f7725e96d5b5fb291ef577}{lr}};\ \ \ \textcolor{comment}{///<\ Link\ Register}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00470}\mbox{\hyperlink{struct_h_f___stack_frame__t_a16563896004751c90e41c81ae4570732}{00470}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_a16563896004751c90e41c81ae4570732}{pc}};\ \ \ \textcolor{comment}{///<\ Program\ Counter}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00471}\mbox{\hyperlink{struct_h_f___stack_frame__t_ae47cb051ee3c94471bfd4fe7e49c55f9}{00471}}\ \ \ uint32\_t\ \mbox{\hyperlink{struct_h_f___stack_frame__t_ae47cb051ee3c94471bfd4fe7e49c55f9}{psr}};\ \ \textcolor{comment}{///<\ Program\ Status\ Register}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00472}00472\ \}\ \mbox{\hyperlink{struct_h_f___stack_frame__t}{HF\_StackFrame\_t}};} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00473}00473\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00474}00474\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00475}00475\ \textcolor{comment}{\ \ *\ @brief\ Проверка\ и\ вывод\ последнего\ HardFault-\/трейса\ из\ Flash}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00476}00476\ \textcolor{comment}{\ \ *\ @details}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00477}00477\ \textcolor{comment}{\ \ *\ Функция\ ищет\ последнюю\ запись\ HardFault\ по\ базовому\ тегу\ HF\_RTT\_TAG\_BASE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00478}00478\ \textcolor{comment}{\ \ *\ и\ выводит\ её\ содержимое\ в\ консоль.\ После\ успешного\ вывода\ Flash\ можно\ опционально\ очистить.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00479}00479\ \textcolor{comment}{\ \ *}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00480}00480\ \textcolor{comment}{\ \ *\ @return\ int}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00481}00481\ \textcolor{comment}{\ \ *\ \ \ -\/\ 1\ —\ данные\ HardFault\ найдены\ и\ выведены}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00482}00482\ \textcolor{comment}{\ \ *\ \ \ -\/\ 0\ —\ данные\ отсутствуют\ или\ тег\ не\ найден}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00483}00483\ \textcolor{comment}{\ \ *\ }} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00484}00484\ \textcolor{comment}{\ \ *\ @note\ Вызов\ рекомендуется\ при\ инициализации\ приложения\ для\ анализа\ предыдущего\ сбоя.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00485}00485\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00486}\mbox{\hyperlink{group___t_r_a_c_e___h_a_r_d_f_a_u_l_t_ga03f8b6f3b537ee1c8e91065c60db504f}{00486}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{group___t_r_a_c_e___h_a_r_d_f_a_u_l_t_ga03f8b6f3b537ee1c8e91065c60db504f}{HF\_CheckRecovered}}(\textcolor{keywordtype}{int}\ erase)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00487}00487\ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00488}00488\ \ \ \textcolor{keywordtype}{char}\ buffer[\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_ga501312b24e322de4dd6755ad442f0ba3}{RTT\_FLASH\_BUFFER\_SIZE}}];} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00489}00489\ \ \ uint32\_t\ read\_size\ =\ 0;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00490}00490\ \ \ \textcolor{keywordtype}{int}\ n\_hardfault\ =\ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga734b2ebbf0c77699b739013878cfd146}{RTT\_ReadFromFlash}}(\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gadc960255719c7eff4bdfaa850be9b313}{HF\_RTT\_TAG\_BASE}},\ buffer,\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gafcc7ea03d4df8f1909e580b519a7f3ca}{HF\_RTT\_TAIL\_SIZE}},\ \&read\_size);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00491}00491\ \ \ \textcolor{keywordflow}{if}\ (n\_hardfault\ >\ 0)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00492}00492\ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00493}00493\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}\(\backslash\)n-\/-\/-\/\ Recovered\ HardFault\ RTT\ buffer\ \#\%u\ -\/-\/-\/\(\backslash\)n"{}},\ n\_hardfault);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00494}00494\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ read\_size;\ i++)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00495}00495\ \ \ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00496}00496\ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ c\ =\ buffer[i];} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00497}00497\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (c\ ==\ 0\ ||\ c\ ==\ (\textcolor{keywordtype}{char})0xFF)\ \textcolor{keywordflow}{break};} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00498}00498\ \ \ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}\%c"{}},\ c);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00499}00499\ \ \ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00500}00500\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00501}00501\ \ \ \ \ \textcolor{keywordflow}{if}(erase)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00502}00502\ \ \ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga8d8c6850e32b42871faefce3352012d1}{RTT\_EraseFlash}}();} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00503}00503\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}\(\backslash\)n-\/-\/-\/-\/-\/-\/-\/-\/-\/\ HardFault\ Dump\ End\ -\/-\/-\/-\/-\/-\/-\/-\/-\/\(\backslash\)n"{}});} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00504}00504\ \ \ \ \ \textcolor{keywordflow}{return}\ 1;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00505}00505\ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00506}00506\ \ \ \textcolor{keywordflow}{return}\ 0;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00507}00507\ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00508}00508\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00509}00509\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00510}00510\ \textcolor{keyword}{static}\ \mbox{\hyperlink{struct_h_f___stack_frame__t}{HF\_StackFrame\_t}}\ *stack\_frame;} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00511}00511\ \textcolor{keyword}{static}\ uint32\_t\ stack\_dump[\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gaa31234688b333a505aaa57b8ecdedf5b}{HF\_STACK\_DUMP\_WORDS}}];} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00512}00512\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}\ *ret\_adr[10]\ =\ \{0\};\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00513}00513\ \textcolor{comment}{/**}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00514}00514\ \textcolor{comment}{\ \ *\ @brief\ Обработчик\ HardFault}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00515}00515\ \textcolor{comment}{\ \ *\ @details}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00516}00516\ \textcolor{comment}{\ \ *\ Вызывается\ из\ прерывания\ HardFault\ или\ в\ любом\ месте\ где\ понятно\ что\ ошибка\ критическая.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00517}00517\ \textcolor{comment}{\ \ *\ Последовательно\ выполняет:}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00518}00518\ \textcolor{comment}{\ \ *\ \ \ 1.\ Определяет\ активный\ стек\ (MSP\ или\ PSP)\ на\ момент\ сбоя.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00519}00519\ \textcolor{comment}{\ \ *\ \ \ 2.\ Сохраняет\ значения\ регистров\ R0-\/R3,\ R12,\ LR,\ PC,\ PSR.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00520}00520\ \textcolor{comment}{\ \ *\ \ \ 3.\ Выводит\ системные\ регистры\ CFSR,\ HFSR,\ DFSR,\ AFSR,\ MMFAR,\ BFAR.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00521}00521\ \textcolor{comment}{\ \ *\ \ \ 4.\ Формирует\ stack\ trace\ с\ 3\ уровнями\ возврата.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00522}00522\ \textcolor{comment}{\ \ *\ \ \ 5.\ Копирует\ последние\ символы\ RTT\ буфера.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00523}00523\ \textcolor{comment}{\ \ *\ \ \ 6.\ Сохраняет\ все\ данные\ во\ Flash\ через\ RTT\_SaveToFlash\ с\ базовым\ тегом\ HF\_RTT\_TAG\_BASE.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00524}00524\ \textcolor{comment}{\ \ *}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00525}00525\ \textcolor{comment}{\ \ *\ @note\ Функция\ защищена,\ так\ как\ вызывается\ в\ контексте\ сбоя\ —\ минимизирует\ использование\ вызовов\ HAL.}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00526}00526\ \textcolor{comment}{\ \ */}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00527}\mbox{\hyperlink{group___t_r_a_c_e___h_a_r_d_f_a_u_l_t_gadd8e10e7ec3b0204f7f92062ecd452f7}{00527}}\ \_\_STATIC\_FORCEINLINE\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{group___t_r_a_c_e___h_a_r_d_f_a_u_l_t_gadd8e10e7ec3b0204f7f92062ecd452f7}{HF\_HandleFault}}(\textcolor{keywordtype}{void})} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00528}00528\ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00529}00529\ \ \ \ \ \textcolor{comment}{//\ Получаем\ указатель\ на\ стек,\ где\ произошёл\ HardFault}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00530}00530\ \ \ \ \ \_\_ASM\ \textcolor{keyword}{volatile}(} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00531}00531\ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}TST\ lr,\ \#4\ \ \ \ \ \ \ \(\backslash\)n"{}}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00532}00532\ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}ITE\ EQ\ \ \ \ \ \ \ \ \ \ \ \(\backslash\)n"{}}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00533}00533\ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}MRSEQ\ \%[ptr],\ MSP\(\backslash\)n"{}}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00534}00534\ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}MRSNE\ \%[ptr],\ PSP\(\backslash\)n"{}}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00535}00535\ \ \ \ \ \ \ \ \ :\ [ptr]\ \textcolor{stringliteral}{"{}=r"{}}(stack\_frame)} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00536}00536\ \ \ \ \ );} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00537}00537\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00538}00538\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}\(\backslash\)n=====\ HardFault\ occurred!\ =====\(\backslash\)n"{}});} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00539}00539\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}R0\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>r0);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00540}00540\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}R1\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>r1);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00541}00541\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}R2\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>r2);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00542}00542\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}R3\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>r3);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00543}00543\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}R12\ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>r12);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00544}00544\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}LR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>lr);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00545}00545\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}PC\ \ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>pc);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00546}00546\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}PSR\ =\ 0x\%08X\(\backslash\)n"{}},\ stack\_frame-\/>psr);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00547}00547\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00548}00548\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}CFSR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>CFSR);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00549}00549\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}HFSR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>HFSR);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00550}00550\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}DFSR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>DFSR);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00551}00551\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}AFSR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>AFSR);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00552}00552\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}MMFAR\ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>MMFAR);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00553}00553\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}BFAR\ \ =\ 0x\%08X\(\backslash\)n"{}},\ SCB-\/>BFAR);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00554}00554\ \ \ \ \ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00555}00555\ \ \ \ \ \textcolor{comment}{//\ -\/-\/-\/\ Stack\ trace\ -\/-\/-\/}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00556}00556\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}-\/-\/-\/\ Stack\ trace\ -\/-\/-\/\(\backslash\)n"{}});} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00557}00557\ \ \ \ \ ret\_adr[0]\ =\ \_\_builtin\_return\_address(0);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00558}00558\ \ \ \ \ ret\_adr[1]\ =\ \_\_builtin\_return\_address(1);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00559}00559\ \ \ \ \ ret\_adr[2]\ =\ \_\_builtin\_return\_address(2);} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00560}00560\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00561}00561\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ 3;\ i++)\ \ \textcolor{comment}{//\ развернуть\ n\ уровней}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00562}00562\ \ \ \ \ \{} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00563}00563\ \ \ \ \ \ \ \textcolor{keywordflow}{if}(ret\_adr[i])} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00564}00564\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___s_e_r_i_a_l_gae9b9b8a611e291a2f2aa5abf99f3ebaa}{my\_printf}}(\textcolor{stringliteral}{"{}\ \ \#\%d:\ 0x\%08lX\(\backslash\)r\(\backslash\)n"{}},\ i,\ ret\_adr[i]);\ \textcolor{comment}{//\ -\/1\ для\ Thumb}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00565}00565\ \ \ \ \ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00566}00566\ \ \ \ \ \mbox{\hyperlink{group___t_r_a_c_e___r_t_t___f_l_a_s_h_ga79f222c8ab644de4d47f07528d1edd63}{RTT\_SaveToFlash}}(\mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gadc960255719c7eff4bdfaa850be9b313}{HF\_RTT\_TAG\_BASE}},\ \mbox{\hyperlink{group___t_r_a_c_e___c_o_n_f_i_g_gafcc7ea03d4df8f1909e580b519a7f3ca}{HF\_RTT\_TAIL\_SIZE}});} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00567}00567\ \}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00568}00568\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//\ HAL\_MODULE\_ENABLED\ \&\&\ HARDFAULT\_SERIAL\_TRACE}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00569}00569\ \textcolor{preprocessor}{\#define\ HF\_CheckRecovered(...)\ 0}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00570}00570\ \textcolor{preprocessor}{\#define\ HF\_HandleFault(...)}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00571}00571\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ HAL\_MODULE\_ENABLED\ \&\&\ HARDFAULT\_SERIAL\_TRACE}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00572}00572\ \textcolor{comment}{/**\ TRACE\_HARDFAULT}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00573}00573\ \textcolor{comment}{\ \ *\ @\}}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00574}00574\ \textcolor{comment}{\ \ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00575}00575\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00576}00576\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00577}00577\ } +\DoxyCodeLine{\Hypertarget{trace_8h_source_l00578}00578\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\_\_TRACE\_H\_}} \end{DoxyCode} diff --git a/Doc/latex/trackers_8h_source.tex b/Doc/latex/trackers_8h_source.tex index 0cb113a..10669d6 100644 --- a/Doc/latex/trackers_8h_source.tex +++ b/Doc/latex/trackers_8h_source.tex @@ -19,150 +19,151 @@ \DoxyCodeLine{\Hypertarget{trackers_8h_source_l00015}00015\ \textcolor{comment}{-\/\ user[num\_user\_vars]\ \ \ \ }} \DoxyCodeLine{\Hypertarget{trackers_8h_source_l00016}00016\ \textcolor{comment}{Также\ есть\ ряд\ функций\ (дефайнов)\ для\ обращения\ к\ элементам\ этой\ структуры.}} \DoxyCodeLine{\Hypertarget{trackers_8h_source_l00017}00017\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00018}00018\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00019}00019\ \textcolor{comment}{Если\ трекеры\ @ref\ TRACKERS\_ENABLE\ отключены,\ то\ все\ дефайны\ определяются\ как\ ничего\ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00020}00020\ \textcolor{comment}{и\ на\ производительность\ кода\ не\ влияют\ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00021}00021\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00022}00022\ \textcolor{comment}{@par\ Пример:}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00023}00023\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00024}00024\ \textcolor{comment}{Определяем\ typedef\ трекера\ измерений\ Measure\_TrackerTypeDef}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00025}00025\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00026}00026\ \textcolor{comment}{@verbatim}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00027}00027\ \textcolor{comment}{\ \ typedef\ TrackerTypeDef(MEASURE\_USER\_VARS\_NUMB)\ Measure\_TrackerTypeDef;}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00028}00028\ \textcolor{comment}{@endverbatim}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00029}00029\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00030}00030\ \textcolor{comment}{И\ через\ @ref\ Measure\_TrackerTypeDef\ структура\ подключается\ в\ другие\ структуры}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00031}00031\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00032}00032\ \textcolor{comment}{Для\ работы\ с\ структурой\ можно\ использовать\ функции:}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00033}00033\ \textcolor{comment}{-\/\ Для\ получения\ значения:}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00034}00034\ \textcolor{comment}{\ \ -\/\ TrackerGet\_Ok()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00035}00035\ \textcolor{comment}{\ \ -\/\ TrackerGet\_Err()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00036}00036\ \textcolor{comment}{\ \ -\/\ TrackerGet\_Warn()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00037}00037\ \textcolor{comment}{\ \ -\/\ TrackerGet\_User(n)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00038}00038\ \textcolor{comment}{\ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00039}00039\ \textcolor{comment}{-\/\ Для\ записи\ значения:}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00040}00040\ \textcolor{comment}{\ \ -\/\ TrackerCnt\_Ok()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00041}00041\ \textcolor{comment}{\ \ -\/\ TrackerCnt\_Err()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00042}00042\ \textcolor{comment}{\ \ -\/\ TrackerCnt\_Warn()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00043}00043\ \textcolor{comment}{\ \ -\/\ TrackerCnt\_User()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00044}00044\ \textcolor{comment}{\ \ -\/\ TrackerWrite\_User(n)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00045}00045\ \textcolor{comment}{\ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00046}00046\ \textcolor{comment}{-\/\ Для\ очищения\ значения:}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00047}00047\ \textcolor{comment}{\ \ -\/\ TrackerClear\_All()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00048}00048\ \textcolor{comment}{\ \ -\/\ TrackerClear\_Ok()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00049}00049\ \textcolor{comment}{\ \ -\/\ TrackerClear\_Err()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00050}00050\ \textcolor{comment}{\ \ -\/\ TrackerClear\_Warn()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00051}00051\ \textcolor{comment}{\ \ -\/\ TrackerClear\_User(n)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00052}00052\ \textcolor{comment}{\ \ -\/\ TrackerClear\_UserAll()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00053}00053\ \textcolor{comment}{*\ @\{\ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00054}00054\ \textcolor{comment}{*************************************************************************/}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00055}00055\ \textcolor{preprocessor}{\#ifndef\ \_\_TRACKERS\_H\_}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00056}00056\ \textcolor{preprocessor}{\#define\ \_\_TRACKERS\_H\_}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00057}00057\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{mylibs__defs_8h}{mylibs\_defs.h}}"{}}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00058}00058\ } -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00059}00059\ \textcolor{preprocessor}{\#ifdef\ TRACKERS\_ENABLE}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00060}00060\ \textcolor{comment}{\ \ /**\ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00061}00061\ \textcolor{comment}{\ \ \ \ *\ @brief\ Структура\ для\ счетчиков\ отладки}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00062}00062\ \textcolor{comment}{\ \ \ \ *\ @param\ num\_user\_vars\ -\/\ количество\ пользовательских\ переменных}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00063}00063\ \textcolor{comment}{\ \ \ \ *\ @details\ Содержит\ счетчик\ для\ успешных\ событый\ (cnt\_ok),}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00064}00064\ \textcolor{comment}{\ \ \ \ *\ счетчик\ для\ ошибок\ (cnt\_err),\ счетчик\ для\ предупреждений\ (cnt\_warn).}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00065}00065\ \textcolor{comment}{\ \ \ \ *}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00066}00066\ \textcolor{comment}{\ \ \ \ *\ Также\ есть\ возможность\ объявить\ пользовательские\ переменные\ в\ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00067}00067\ \textcolor{comment}{\ \ \ \ *\ количестве\ \ штук.}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00068}00068\ \textcolor{comment}{\ \ \ \ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00069}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga50ccb119acf302969b7fdcb58f2130e4}{00069}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerTypeDef(num\_user\_vars)\ \ \ \ \ \ \ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00070}00070\ \textcolor{preprocessor}{\ \ struct\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00071}00071\ \textcolor{preprocessor}{\ \ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00072}00072\ \textcolor{preprocessor}{\ \ \ \ uint32\_t\ cnt\_ok;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00073}00073\ \textcolor{preprocessor}{\ \ \ \ uint32\_t\ cnt\_err;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00074}00074\ \textcolor{preprocessor}{\ \ \ \ uint32\_t\ cnt\_warn;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00075}00075\ \textcolor{preprocessor}{\ \ \ \ uint32\_t\ user[num\_user\_vars];\ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00076}00076\ \textcolor{preprocessor}{\ \ \}}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00077}00077\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00078}00078\ \textcolor{comment}{\ \ /**\ @brief\ Получить\ количетство\ пользовательских\ переменных\ */}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00079}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga72be24629fedb8bf70e830373d151fbc}{00079}}\ \textcolor{preprocessor}{\ \ \#define\ num\_of\_usercnts(\_user\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (sizeof(\_user\_)\ /\ sizeof(uint32\_t))}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00080}00080\ \textcolor{comment}{\ \ /**\ @brief\ Проверка\ существует\ ли\ указанная\ пользовательская\ переменная\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00081}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gadd7fd2c6e3a4800f1d5ddab35fd4b43e}{00081}}\ \textcolor{preprocessor}{\ \ \#define\ assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ ((\_uservarnumb\_)\ <\ num\_of\_usercnts((\_cntstruct\_).user))}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00082}00082\ \textcolor{comment}{\ \ /**\ @brief\ Условие\ для\ проверки\ существует\ ли\ указанная\ пользовательская\ переменная\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00083}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gad91d8ca89074270fc040c0449e57cf07}{00083}}\ \textcolor{preprocessor}{\ \ \#define\ if\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ if(assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_))}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00084}00084\ \textcolor{comment}{\ \ /**\ @brief\ Тернарный\ оператор\ для\ проверки\ существует\ ли\ указанная\ пользовательская\ переменная\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00085}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga39b6ffbc561f8caac276415e1ad32c30}{00085}}\ \textcolor{preprocessor}{\ \ \#define\ tern\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ (assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_))\ ?\ \_uservarnumb\_\ :\ 0}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00086}00086\ } -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00087}00087\ \ \ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00088}00088\ \textcolor{comment}{\ \ /**\ @brief\ Считать\ счетчик\ успешных\ событий\ */}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00089}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gab880911066605602a966641682090169}{00089}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_ok}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00090}00090\ \textcolor{comment}{\ \ /**\ @brief\ Считать\ счетчик\ ошибок\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00091}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga9dc91e6b798a081f95f2ccef2c288e5e}{00091}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_err}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00092}00092\ \textcolor{comment}{\ \ /**\ @brief\ Считать\ счетчик\ предупреждений\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00093}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga47ac59a406ee74d4cd9fe0fbaf63a758}{00093}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_warn}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00094}00094\ \textcolor{comment}{\ \ /**\ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00095}00095\ \textcolor{comment}{\ \ \ \ *\ @brief\ Считать\ пользовательскую\ переменную\ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00096}00096\ \textcolor{comment}{\ \ \ \ *\ @note\ \ \ Здесь\ нет\ проверки\ -\/\ существует\ ли\ пользовательская\ переменная!\ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00097}00097\ \textcolor{comment}{\ \ \ \ *\ \ \ \ \ \ \ \ \ Есть\ возможность\ выйти\ за\ границы\ структуры!!!\ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00098}00098\ \textcolor{comment}{\ \ \ \ *\ \ \ \ \ \ \ \ \ Чтобы\ этого\ избежать\ можно\ использовать\ дефайн\ \#ref\ assert\_usertracker()}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00099}00099\ \textcolor{comment}{\ \ \ \ @verbatim\ \ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00100}00100\ \textcolor{comment}{\ \ \ \ \ \ if(assert\_usertracker(struct,\ 0))\ \{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00101}00101\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ TrackerGet\_User(struct,\ 0)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00102}00102\ \textcolor{comment}{\ \ \ \ \ \ \}}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00103}00103\ \textcolor{comment}{\ \ \ \ @endverbatim}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00104}00104\ \textcolor{comment}{\ \ \ \ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00105}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga4b08632669043dfdbd219dda03502bdb}{00105}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_User(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).user[tern\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)]}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00106}00106\ \ \ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00018}00018\ \textcolor{comment}{Параметры\ для\ конфигурации:}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00019}00019\ \textcolor{comment}{-\/\ @ref\ TRACKERS\_ENABLE\ -\/\ Включить\ трекеры}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00020}00020\ \textcolor{comment}{\ \ Если\ трекеры\ @ref\ TRACKERS\_ENABLE\ отключены,\ то\ все\ дефайны\ определяются\ как\ ничего\ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00021}00021\ \textcolor{comment}{\ \ и\ на\ производительность\ кода\ не\ влияют\ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00022}00022\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00023}00023\ \textcolor{comment}{@par\ Пример:}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00024}00024\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00025}00025\ \textcolor{comment}{Определяем\ typedef\ трекера\ измерений\ Measure\_TrackerTypeDef}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00026}00026\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00027}00027\ \textcolor{comment}{@verbatim}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00028}00028\ \textcolor{comment}{\ \ typedef\ TrackerTypeDef(MEASURE\_USER\_VARS\_NUMB)\ Measure\_TrackerTypeDef;}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00029}00029\ \textcolor{comment}{@endverbatim}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00030}00030\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00031}00031\ \textcolor{comment}{И\ через\ @ref\ Measure\_TrackerTypeDef\ структура\ подключается\ в\ другие\ структуры}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00032}00032\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00033}00033\ \textcolor{comment}{Для\ работы\ с\ структурой\ можно\ использовать\ функции:}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00034}00034\ \textcolor{comment}{-\/\ Для\ получения\ значения:}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00035}00035\ \textcolor{comment}{\ \ -\/\ TrackerGet\_Ok()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00036}00036\ \textcolor{comment}{\ \ -\/\ TrackerGet\_Err()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00037}00037\ \textcolor{comment}{\ \ -\/\ TrackerGet\_Warn()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00038}00038\ \textcolor{comment}{\ \ -\/\ TrackerGet\_User(n)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00039}00039\ \textcolor{comment}{\ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00040}00040\ \textcolor{comment}{-\/\ Для\ записи\ значения:}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00041}00041\ \textcolor{comment}{\ \ -\/\ TrackerCnt\_Ok()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00042}00042\ \textcolor{comment}{\ \ -\/\ TrackerCnt\_Err()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00043}00043\ \textcolor{comment}{\ \ -\/\ TrackerCnt\_Warn()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00044}00044\ \textcolor{comment}{\ \ -\/\ TrackerCnt\_User()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00045}00045\ \textcolor{comment}{\ \ -\/\ TrackerWrite\_User(n)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00046}00046\ \textcolor{comment}{\ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00047}00047\ \textcolor{comment}{-\/\ Для\ очищения\ значения:}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00048}00048\ \textcolor{comment}{\ \ -\/\ TrackerClear\_All()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00049}00049\ \textcolor{comment}{\ \ -\/\ TrackerClear\_Ok()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00050}00050\ \textcolor{comment}{\ \ -\/\ TrackerClear\_Err()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00051}00051\ \textcolor{comment}{\ \ -\/\ TrackerClear\_Warn()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00052}00052\ \textcolor{comment}{\ \ -\/\ TrackerClear\_User(n)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00053}00053\ \textcolor{comment}{\ \ -\/\ TrackerClear\_UserAll()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00054}00054\ \textcolor{comment}{*\ @\{\ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00055}00055\ \textcolor{comment}{*************************************************************************/}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00056}00056\ \textcolor{preprocessor}{\#ifndef\ \_\_TRACKERS\_H\_}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00057}00057\ \textcolor{preprocessor}{\#define\ \_\_TRACKERS\_H\_}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00058}00058\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{mylibs__defs_8h}{mylibs\_defs.h}}"{}}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00059}00059\ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00060}00060\ \textcolor{preprocessor}{\#ifdef\ TRACKERS\_ENABLE}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00061}00061\ \textcolor{comment}{\ \ /**\ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00062}00062\ \textcolor{comment}{\ \ \ \ *\ @brief\ Структура\ для\ счетчиков\ отладки}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00063}00063\ \textcolor{comment}{\ \ \ \ *\ @param\ num\_user\_vars\ -\/\ количество\ пользовательских\ переменных}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00064}00064\ \textcolor{comment}{\ \ \ \ *\ @details\ Содержит\ счетчик\ для\ успешных\ событый\ (cnt\_ok),}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00065}00065\ \textcolor{comment}{\ \ \ \ *\ счетчик\ для\ ошибок\ (cnt\_err),\ счетчик\ для\ предупреждений\ (cnt\_warn).}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00066}00066\ \textcolor{comment}{\ \ \ \ *}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00067}00067\ \textcolor{comment}{\ \ \ \ *\ Также\ есть\ возможность\ объявить\ пользовательские\ переменные\ в\ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00068}00068\ \textcolor{comment}{\ \ \ \ *\ количестве\ \ штук.}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00069}00069\ \textcolor{comment}{\ \ \ \ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00070}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga50ccb119acf302969b7fdcb58f2130e4}{00070}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerTypeDef(num\_user\_vars)\ \ \ \ \ \ \ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00071}00071\ \textcolor{preprocessor}{\ \ struct\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00072}00072\ \textcolor{preprocessor}{\ \ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00073}00073\ \textcolor{preprocessor}{\ \ \ \ uint32\_t\ cnt\_ok;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00074}00074\ \textcolor{preprocessor}{\ \ \ \ uint32\_t\ cnt\_err;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00075}00075\ \textcolor{preprocessor}{\ \ \ \ uint32\_t\ cnt\_warn;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00076}00076\ \textcolor{preprocessor}{\ \ \ \ uint32\_t\ user[num\_user\_vars];\ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00077}00077\ \textcolor{preprocessor}{\ \ \}}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00078}00078\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00079}00079\ \textcolor{comment}{\ \ /**\ @brief\ Получить\ количетство\ пользовательских\ переменных\ */}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00080}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga72be24629fedb8bf70e830373d151fbc}{00080}}\ \textcolor{preprocessor}{\ \ \#define\ num\_of\_usercnts(\_user\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (sizeof(\_user\_)\ /\ sizeof(uint32\_t))}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00081}00081\ \textcolor{comment}{\ \ /**\ @brief\ Проверка\ существует\ ли\ указанная\ пользовательская\ переменная\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00082}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gadd7fd2c6e3a4800f1d5ddab35fd4b43e}{00082}}\ \textcolor{preprocessor}{\ \ \#define\ assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ ((\_uservarnumb\_)\ <\ num\_of\_usercnts((\_cntstruct\_).user))}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00083}00083\ \textcolor{comment}{\ \ /**\ @brief\ Условие\ для\ проверки\ существует\ ли\ указанная\ пользовательская\ переменная\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00084}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gad91d8ca89074270fc040c0449e57cf07}{00084}}\ \textcolor{preprocessor}{\ \ \#define\ if\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ if(assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_))}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00085}00085\ \textcolor{comment}{\ \ /**\ @brief\ Тернарный\ оператор\ для\ проверки\ существует\ ли\ указанная\ пользовательская\ переменная\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00086}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga39b6ffbc561f8caac276415e1ad32c30}{00086}}\ \textcolor{preprocessor}{\ \ \#define\ tern\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ (assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_))\ ?\ \_uservarnumb\_\ :\ 0}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00087}00087\ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00088}00088\ \ \ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00089}00089\ \textcolor{comment}{\ \ /**\ @brief\ Считать\ счетчик\ успешных\ событий\ */}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00090}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gab880911066605602a966641682090169}{00090}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_ok}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00091}00091\ \textcolor{comment}{\ \ /**\ @brief\ Считать\ счетчик\ ошибок\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00092}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga9dc91e6b798a081f95f2ccef2c288e5e}{00092}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_err}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00093}00093\ \textcolor{comment}{\ \ /**\ @brief\ Считать\ счетчик\ предупреждений\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00094}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga47ac59a406ee74d4cd9fe0fbaf63a758}{00094}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_warn}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00095}00095\ \textcolor{comment}{\ \ /**\ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00096}00096\ \textcolor{comment}{\ \ \ \ *\ @brief\ Считать\ пользовательскую\ переменную\ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00097}00097\ \textcolor{comment}{\ \ \ \ *\ @note\ \ \ Здесь\ нет\ проверки\ -\/\ существует\ ли\ пользовательская\ переменная!\ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00098}00098\ \textcolor{comment}{\ \ \ \ *\ \ \ \ \ \ \ \ \ Есть\ возможность\ выйти\ за\ границы\ структуры!!!\ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00099}00099\ \textcolor{comment}{\ \ \ \ *\ \ \ \ \ \ \ \ \ Чтобы\ этого\ избежать\ можно\ использовать\ дефайн\ \#ref\ assert\_usertracker()}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00100}00100\ \textcolor{comment}{\ \ \ \ @verbatim\ \ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00101}00101\ \textcolor{comment}{\ \ \ \ \ \ if(assert\_usertracker(struct,\ 0))\ \{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00102}00102\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ TrackerGet\_User(struct,\ 0)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00103}00103\ \textcolor{comment}{\ \ \ \ \ \ \}}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00104}00104\ \textcolor{comment}{\ \ \ \ @endverbatim}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00105}00105\ \textcolor{comment}{\ \ \ \ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00106}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga4b08632669043dfdbd219dda03502bdb}{00106}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_User(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).user[tern\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)]}} \DoxyCodeLine{\Hypertarget{trackers_8h_source_l00107}00107\ \ \ } -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00108}00108\ \ \ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00109}00109\ \textcolor{comment}{\ \ /**\ @brief\ Инкрементирование\ счетчика\ успешных\ событий\ */}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00110}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga23de0006aa08984cfeddb6aa5e512fa1}{00110}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_ok++}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00111}00111\ \textcolor{comment}{\ \ /**\ @brief\ Инкрементирование\ счетчика\ ошибок\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00112}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga49af29ab3927cad105c1d2b018a767e9}{00112}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_err++}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00113}00113\ \textcolor{comment}{\ \ /**\ @brief\ Инкрементирование\ счетчика\ предупреждений\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00114}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga8017fb05a56a1b667244f1f786fa9c57}{00114}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_warn++}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00115}00115\ \textcolor{comment}{\ \ /**\ @brief\ Инкрементирование\ пользовательской\ переменной\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00116}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga1b7549afc4a1760b54a9b93b0f6d105e}{00116}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_User(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ \ \ if\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ (\_cntstruct\_).user[\_uservarnumb\_]++;}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00117}00117\ \textcolor{comment}{\ \ /**\ @brief\ Запись\ числа\ в\ пользовательскую\ переменную\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00118}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gad2f4062a9ac8c2ab062a364f640ebc51}{00118}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerWrite\_User(\_cntstruct\_,\ \_uservarnumb\_,\ \_val\_)\ \ \ \ if\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ (\_cntstruct\_).user[\_uservarnumb\_]\ =\ (\_val\_)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00119}00119\ \textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00120}00120\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ всей\ структуры\ */}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00121}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga704f7b9f8c65c9bcec48ce7cb77a2d3b}{00121}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_All(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ memset(\&(\_cntstruct\_),\ 0,\ sizeof(\_cntstruct\_))}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00122}00122\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ счетчика\ успешных\ событий\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00123}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga5dd8bac8c7ab5832019d55d7a68371b9}{00123}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_ok\ =\ 0}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00124}00124\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ счетчика\ ошибок\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00125}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gae860b6947c6e317e14d40bd7b4b8eb74}{00125}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_err\ =\ 0}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00126}00126\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ счетчика\ предупреждений\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00127}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga365a8c60bd13b75154feda649dd21ead}{00127}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_warn\ =\ 0}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00128}00128\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ пользовательской\ переменной\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00129}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga063dab1067005e1600ea32531fdf3f8d}{00129}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_User(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ if\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ (\_cntstruct\_).user[\_uservarnumb\_]\ =\ 0;}\textcolor{comment}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00130}00130\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ всех\ пользовательских\ переменных\ */}\textcolor{preprocessor}{}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00131}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gaaec7ec19977bb26fa1919dfe920b82d5}{00131}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_UserAll(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ memset(\&(\_cntstruct\_).user,\ 0,\ sizeof((\_cntstruct\_).user))}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00132}00132\ } -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00133}00133\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//TRACKERS\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00134}00134\ \ \ } -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00135}00135\ \textcolor{preprocessor}{\ \ \#define\ TrackerTypeDef(num\_user\_vars)\ void\ *}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00136}00136\ } -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00137}00137\ \textcolor{preprocessor}{\ \ \#define\ num\_of\_usercnts(\_user\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00138}00138\ \textcolor{preprocessor}{\ \ \#define\ assert\_tracecnt(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ 0}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00139}00139\ \textcolor{preprocessor}{\ \ \#define\ if\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ if(0)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00140}00140\ \textcolor{preprocessor}{\ \ \#define\ tern\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ 0}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00141}00141\ } -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00142}00142\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ dummy}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00143}00143\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ dummy}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00144}00144\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ dummy\ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00145}00145\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_User(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ dummy}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00146}00146\ \ \ } -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00147}00147\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00148}00148\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00149}00149\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00150}00150\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_User(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00151}00151\ \textcolor{preprocessor}{\ \ \#define\ TrackerWrite\_User(\_cntstruct\_,\ \_uservarnumb\_,\ \_val\_)}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00152}00152\ } -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00153}00153\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_All(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00154}00154\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00155}00155\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00156}00156\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00157}00157\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_User(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00158}00158\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_UserAll(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00159}00159\ } -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00160}00160\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//TRACKERS\_ENABLE}} -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00161}00161\ \ \ } -\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00162}00162\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\_\_TRACKERS\_H\_}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00108}00108\ \ \ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00109}00109\ \ \ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00110}00110\ \textcolor{comment}{\ \ /**\ @brief\ Инкрементирование\ счетчика\ успешных\ событий\ */}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00111}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga23de0006aa08984cfeddb6aa5e512fa1}{00111}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_ok++}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00112}00112\ \textcolor{comment}{\ \ /**\ @brief\ Инкрементирование\ счетчика\ ошибок\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00113}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga49af29ab3927cad105c1d2b018a767e9}{00113}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_err++}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00114}00114\ \textcolor{comment}{\ \ /**\ @brief\ Инкрементирование\ счетчика\ предупреждений\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00115}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga8017fb05a56a1b667244f1f786fa9c57}{00115}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_warn++}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00116}00116\ \textcolor{comment}{\ \ /**\ @brief\ Инкрементирование\ пользовательской\ переменной\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00117}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga1b7549afc4a1760b54a9b93b0f6d105e}{00117}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_User(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ \ \ if\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ (\_cntstruct\_).user[\_uservarnumb\_]++;}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00118}00118\ \textcolor{comment}{\ \ /**\ @brief\ Запись\ числа\ в\ пользовательскую\ переменную\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00119}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gad2f4062a9ac8c2ab062a364f640ebc51}{00119}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerWrite\_User(\_cntstruct\_,\ \_uservarnumb\_,\ \_val\_)\ \ \ \ if\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ (\_cntstruct\_).user[\_uservarnumb\_]\ =\ (\_val\_)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00120}00120\ \textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00121}00121\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ всей\ структуры\ */}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00122}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga704f7b9f8c65c9bcec48ce7cb77a2d3b}{00122}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_All(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ memset(\&(\_cntstruct\_),\ 0,\ sizeof(\_cntstruct\_))}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00123}00123\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ счетчика\ успешных\ событий\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00124}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga5dd8bac8c7ab5832019d55d7a68371b9}{00124}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_ok\ =\ 0}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00125}00125\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ счетчика\ ошибок\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00126}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gae860b6947c6e317e14d40bd7b4b8eb74}{00126}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_err\ =\ 0}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00127}00127\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ счетчика\ предупреждений\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00128}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga365a8c60bd13b75154feda649dd21ead}{00128}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\_cntstruct\_).cnt\_warn\ =\ 0}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00129}00129\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ пользовательской\ переменной\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00130}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_ga063dab1067005e1600ea32531fdf3f8d}{00130}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_User(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ if\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ (\_cntstruct\_).user[\_uservarnumb\_]\ =\ 0;}\textcolor{comment}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00131}00131\ \textcolor{comment}{\ \ /**\ @brief\ Очистка\ всех\ пользовательских\ переменных\ */}\textcolor{preprocessor}{}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00132}\mbox{\hyperlink{group___t_r_a_c_k_e_r_s_gaaec7ec19977bb26fa1919dfe920b82d5}{00132}}\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_UserAll(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ memset(\&(\_cntstruct\_).user,\ 0,\ sizeof((\_cntstruct\_).user))}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00133}00133\ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00134}00134\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//TRACKERS\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00135}00135\ \ \ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00136}00136\ \textcolor{preprocessor}{\ \ \#define\ TrackerTypeDef(num\_user\_vars)\ void\ *}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00137}00137\ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00138}00138\ \textcolor{preprocessor}{\ \ \#define\ num\_of\_usercnts(\_user\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00139}00139\ \textcolor{preprocessor}{\ \ \#define\ assert\_tracecnt(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ 0}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00140}00140\ \textcolor{preprocessor}{\ \ \#define\ if\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ if(0)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00141}00141\ \textcolor{preprocessor}{\ \ \#define\ tern\_assert\_usertracker(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ 0}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00142}00142\ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00143}00143\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ dummy}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00144}00144\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ dummy}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00145}00145\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ dummy\ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00146}00146\ \textcolor{preprocessor}{\ \ \#define\ TrackerGet\_User(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ dummy}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00147}00147\ \ \ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00148}00148\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00149}00149\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00150}00150\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00151}00151\ \textcolor{preprocessor}{\ \ \#define\ TrackerCnt\_User(\_cntstruct\_,\ \_uservarnumb\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00152}00152\ \textcolor{preprocessor}{\ \ \#define\ TrackerWrite\_User(\_cntstruct\_,\ \_uservarnumb\_,\ \_val\_)}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00153}00153\ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00154}00154\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_All(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00155}00155\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Ok(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00156}00156\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Err(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00157}00157\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_Warn(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00158}00158\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_User(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00159}00159\ \textcolor{preprocessor}{\ \ \#define\ TrackerClear\_UserAll(\_cntstruct\_)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00160}00160\ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00161}00161\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//TRACKERS\_ENABLE}} +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00162}00162\ \ \ } +\DoxyCodeLine{\Hypertarget{trackers_8h_source_l00163}00163\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\_\_TRACKERS\_H\_}} \end{DoxyCode} diff --git a/MyLibsGeneral/Inc/evolve_optimizer.h b/MyLibsGeneral/Inc/evolve_optimizer.h index d011766..0a63941 100644 --- a/MyLibsGeneral/Inc/evolve_optimizer.h +++ b/MyLibsGeneral/Inc/evolve_optimizer.h @@ -13,8 +13,14 @@ - Мутацию для поиска оптимальных параметров - Несколько независимых оптимизаторов в одной программе -Если библиотека отключена @ref ENABLE_EVOLVE_OPTIMIZATION, то вставляются -заглушки, никак не влияющие на параметры и остальную программу + +Параметры для конфигурации: +- @ref ENABLE_EVOLVE_OPTIMIZATION - Включить оптимизацию параметров + Если библиотека отключена @ref ENABLE_EVOLVE_OPTIMIZATION, то вставляются + заглушки, никак не влияющие на параметры и остальную программу +- @ref EVOLVE_MAX_PARAMS - Максимальное количество параметров +- @ref EVOLVE_MAX_CANDIDATES - Максимальное количество кандидатов для обучения + @par Пример использования: @code @@ -71,6 +77,9 @@ param_i16 = PARAM_UNSCALE_Q16(params[3], 500, 5000); #define PARAM_UNSCALE_Q16(q16_val, min_val, max_val) \ (((float)(q16_val) / 65536.0f) * ((float)(max_val) - (float)(min_val)) + (float)(min_val)) +#ifndef local_time +#define local_time() HAL_GetTick() ///< Локальное время +#endif /** * @brief Структура эволюционного оптимизатора @@ -117,31 +126,33 @@ static int cmp_idx(const void *a, const void *b) { * @param n_best Количество лучших, усредняемых * @param iq_mutation Амплитуда мутации в Q16.16 * @param start_params Начальные параметры (Q16.16) + * @return 0 — если окей, + * -1 — если ошибка */ -__STATIC_INLINE HAL_StatusTypeDef EvolveOptimizer_Init(EvolveOptimizer_t* opt, +__STATIC_INLINE int EvolveOptimizer_Init(EvolveOptimizer_t* opt, uint16_t n_params, uint16_t n_cand, uint16_t n_best, uint16_t iq_mutation, int32_t* start_params) { - if(check_null_ptr_2(opt, start_params)) - return HAL_ERROR; + if((opt = NULL) || (start_params == NULL)) + return -1; if(n_params > EVOLVE_MAX_PARAMS) - return HAL_ERROR; + return -1; opt->n_params = n_params; if(n_cand > EVOLVE_MAX_CANDIDATES) - return HAL_ERROR; + return -1; opt->n_cand = n_cand; if(n_best > EVOLVE_MAX_CANDIDATES/2) - return HAL_ERROR; + return -1; opt->n_best = n_best; if(iq_mutation > 32768) - return HAL_ERROR; + return -1; opt->iq_mutation = iq_mutation; for (uint16_t i = 0; i < n_cand; i++) { @@ -150,10 +161,10 @@ __STATIC_INLINE HAL_StatusTypeDef EvolveOptimizer_Init(EvolveOptimizer_t* opt, } opt->loss[i] = 0; } - uint32_t seed = HAL_GetTick() + (ADC1->DR & 0xFF); + uint32_t seed = local_time() + (ADC1->DR & 0xFF); srand(seed); - return HAL_OK; + return 0; } @@ -162,6 +173,8 @@ __STATIC_INLINE HAL_StatusTypeDef EvolveOptimizer_Init(EvolveOptimizer_t* opt, * @param opt Указатель на структуру оптимизатора * @param params Массив параметров, которые будут обновлены (на выходе — новые параметры) * @param loss Loss текущего кандидата (Q16.16) + * @return 0 — если окей, + * -1 — если ошибка * @details * Сохраняет loss текущего кандидата и формирует параметры следующего кандидата. * Если накоплено n_cand кандидатов, генерируется новое поколение. @@ -171,28 +184,28 @@ __STATIC_INLINE HAL_StatusTypeDef EvolveOptimizer_Init(EvolveOptimizer_t* opt, * @note Функция использует глобальную внутреннюю переменную для сортировки. * Надо убедится что только один экземпляр функции запущен в момент времени */ -__STATIC_INLINE HAL_StatusTypeDef EvolveOptimizer_Step(EvolveOptimizer_t* opt, +__STATIC_INLINE int EvolveOptimizer_Step(EvolveOptimizer_t* opt, int32_t* params, int32_t loss) { - if(check_null_ptr_2(opt, params)) - return HAL_ERROR; + if((opt = NULL) || (params == NULL)) + return -1; uint16_t n_params = opt->n_params; if(n_params > EVOLVE_MAX_PARAMS) - return HAL_ERROR; + return -1; uint16_t n_cand = opt->n_cand; if(n_cand > EVOLVE_MAX_CANDIDATES) - return HAL_ERROR; + return -1; uint16_t n_best = opt->n_best; if(n_best > EVOLVE_MAX_CANDIDATES/2) - return HAL_ERROR; + return -1; uint16_t mut = opt->iq_mutation; if(mut > 32768) - return HAL_ERROR; + return -1; // 1. Сохраняем loss текущего кандидата opt->loss[opt->cand_index] = loss; @@ -248,7 +261,7 @@ __STATIC_INLINE HAL_StatusTypeDef EvolveOptimizer_Step(EvolveOptimizer_t* opt, for (uint16_t i = 0; i < opt->n_params; i++) params[i] = opt->candidates[opt->cand_index][i]; - return HAL_OK; + return 0; } #else // ENABLE_EVOLVE_OPTIMIZATION //заглушки diff --git a/MyLibsGeneral/Inc/trace.h b/MyLibsGeneral/Inc/trace.h index f313efa..c43a836 100644 --- a/MyLibsGeneral/Inc/trace.h +++ b/MyLibsGeneral/Inc/trace.h @@ -16,9 +16,14 @@ * @addtogroup TRACE_SERIAL Serial trace defines * @ingroup TRACE * @brief Дефайны для работы с serial трассировкой (SWO, RTT) - * @details Определяется дефайн @ref my_printf() и @ref log_printf() для работы с serial трассировкой: - - для RTT это будет вызов функции SEGGER_RTT_printf(), с подключением библиотеки SEGGER_RTT.h - - для SWO это будет просто printf() + * @details В зависимости от настроек определяется дефайн @ref my_printf() и @ref log_printf() для работы с трассировкой: + - @ref SERIAL_TRACE_ENABLE - Если трассировка отключена, то все дефайны определяются как 'ничего' + и на производительность кода не влияют + + - @ref RTT_TRACE_ENABLE - для RTT это будет вызов функции SEGGER_RTT_printf(), с подключением библиотеки SEGGER_RTT.h + Предварительно надо подключить библиотеку SEGGER RTT и вызвать функцию SEGGER_RTT_Init() + + - @ref SWO_TRACE_ENABLE для SWO это будет просто printf() Но библиотеку STDOUT надо подключить самостоятельно: @@ -39,8 +44,7 @@ - Выставить Trace Port = SWO - ITM - выбрать нужный порт (для Keil нулевой порт) - - Если трассировка @ref SERIAL_TRACE_ENABLE отключена, то все дефайны определяются как 'ничего' - и на производительность кода не влияют + * @{ * * @def my_printf(...) @@ -159,6 +163,13 @@ my_printf("\n[%lu] [%s] (%s:%d) " fmt, \ * если слот с таким тегом уже занят, запись не выполняется. * - Автоинкремент позволяет хранить несколько последовательных записей в пределах одного базового тега, * без необходимости вручную отслеживать адреса Flash или позиции буферов. + * + * Параметры: + * - @ref RTT_FLASH_BUFFER_SIZE - Размер буфера RTT в Flash + * - @ref RTT_FLASH_SECTOR - Сектор FLASH куда положится RTT буфер + * - @ref RTT_FLASH_SECTOR_START - Начало сектора RTT_FLASH_SECTOR + * - @ref RTT_FLASH_SECTOR_END - Конец сектора RTT_FLASH_SECTOR + * * @{ */ @@ -198,6 +209,7 @@ __STATIC_FORCEINLINE void RTT_FlashPrepare(void) * - Если базовый (младший байт == 0) — будет выбран первый свободный слот с автоинкрементом. * Автоинкремент формируется в пределах от 0x1 до 0xFF * - Если конкретный (младший байт != 0) — запись выполняется только с этим тегом, иначе ошибка. + * */ __STATIC_FORCEINLINE int RTT_SaveToFlash(uint32_t tag, uint32_t tail_size) { @@ -410,6 +422,16 @@ __STATIC_FORCEINLINE int RTT_EraseFlash(void) * 1. Читает запись во Flash по базовому тегу. * 2. Выводит сохранённый RTT буфер и контекст регистров. * 3. Опционально стирает Flash после восстановления. + * + * Параметры: + * - @ref HARDFAULT_SERIAL_TRACE - Включить обработку и serial трассировку Hardfault + * Если отключена то вставляются заглушки, никак не влияющие на параметры и остальную программу + * - @ref HF_RTT_TAG_BASE - Базовый тег RTT Flash для HardFault + * - @ref HF_RTT_TAIL_SIZE - Размер буфера RTT, который сохранится при Hardfault + * - @ref HF_STACK_DUMP_WORDS - Сколько слов стека будет проанализировано во время Hardfault + * - @ref HF_FLASH_ADDR - Адрес FLASH куда положится RTT буфер + * - @ref HF_RAM_END - Конец RAM памяти (чтобы во время анализа стека не выйти за пределы) + * @code void Hardfault() { diff --git a/MyLibsGeneral/Inc/trackers.h b/MyLibsGeneral/Inc/trackers.h index cc6e0d7..9313f39 100644 --- a/MyLibsGeneral/Inc/trackers.h +++ b/MyLibsGeneral/Inc/trackers.h @@ -15,9 +15,10 @@ - user[num_user_vars] Также есть ряд функций (дефайнов) для обращения к элементам этой структуры. - -Если трекеры @ref TRACKERS_ENABLE отключены, то все дефайны определяются как ничего -и на производительность кода не влияют +Параметры для конфигурации: +- @ref TRACKERS_ENABLE - Включить трекеры + Если трекеры @ref TRACKERS_ENABLE отключены, то все дефайны определяются как ничего + и на производительность кода не влияют @par Пример: