Select one of the symbols to view example projects that use it.
 
Outline
#include "config.h"
#include <helper/log.h>
#include <target/rtt.h>
#include "rtt.h"
#define CHANNEL_NAME_SIZE
handle_rtt_setup_command(struct command_invocation *)
handle_rtt_start_command(struct command_invocation *)
handle_rtt_stop_command(struct command_invocation *)
handle_rtt_polling_interval_command(struct command_invocation *)
handle_rtt_channels_command(struct command_invocation *)
handle_channel_list(struct command_invocation *)
rtt_subcommand_handlers
rtt_target_command_handlers
Files
loading...
SourceVuDevelopment ToolsOpenOCDsrc/rtt/tcl.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2019-2020 by Marc Schink <dev@zapb.de> *//* ... */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <helper/log.h> #include <target/rtt.h> #include "rtt.h" #define CHANNEL_NAME_SIZE 128 COMMAND_HANDLER(handle_rtt_setup_command) { struct rtt_source source; const char *DEFAULT_ID = "SEGGER RTT"; const char *selected_id; if (CMD_ARGC < 2 || CMD_ARGC > 3) return ERROR_COMMAND_SYNTAX_ERROR; if (CMD_ARGC == 2) selected_id = DEFAULT_ID; else selected_id = CMD_ARGV[2]; source.find_cb = &target_rtt_find_control_block; source.read_cb = &target_rtt_read_control_block; source.start = &target_rtt_start; source.stop = &target_rtt_stop; source.read = &target_rtt_read_callback; source.write = &target_rtt_write_callback; source.read_channel_info = &target_rtt_read_channel_info; target_addr_t address; uint32_t size; COMMAND_PARSE_NUMBER(target_addr, CMD_ARGV[0], address); COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], size); rtt_register_source(source, get_current_target(CMD_CTX)); if (rtt_setup(address, size, selected_id) != ERROR_OK) return ERROR_FAIL; return ERROR_OK; }{ ... } COMMAND_HANDLER(handle_rtt_start_command) { if (CMD_ARGC > 0) return ERROR_COMMAND_SYNTAX_ERROR; if (!rtt_configured()) { command_print(CMD, "RTT is not configured"); return ERROR_FAIL; }if (!rtt_configured()) { ... } return rtt_start(); }{ ... } COMMAND_HANDLER(handle_rtt_stop_command) { if (CMD_ARGC > 0) return ERROR_COMMAND_SYNTAX_ERROR; return rtt_stop(); }{ ... } COMMAND_HANDLER(handle_rtt_polling_interval_command) { if (CMD_ARGC == 0) { int ret; unsigned int interval; ret = rtt_get_polling_interval(&interval); if (ret != ERROR_OK) { command_print(CMD, "Failed to get polling interval"); return ret; }if (ret != ERROR_OK) { ... } command_print(CMD, "%u ms", interval); }if (CMD_ARGC == 0) { ... } else if (CMD_ARGC == 1) { int ret; unsigned int interval; COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], interval); ret = rtt_set_polling_interval(interval); if (ret != ERROR_OK) { command_print(CMD, "Failed to set polling interval"); return ret; }if (ret != ERROR_OK) { ... } }else if (CMD_ARGC == 1) { ... } else { return ERROR_COMMAND_SYNTAX_ERROR; }else { ... } return ERROR_OK; }{ ... } COMMAND_HANDLER(handle_rtt_channels_command) { int ret; char channel_name[CHANNEL_NAME_SIZE]; const struct rtt_control *ctrl; struct rtt_channel_info info; if (!rtt_found_cb()) { command_print(CMD, "rtt: Control block not available"); return ERROR_FAIL; }if (!rtt_found_cb()) { ... } ctrl = rtt_get_control(); command_print(CMD, "Channels: up=%u, down=%u", ctrl->num_up_channels, ctrl->num_down_channels); command_print(CMD, "Up-channels:"); info.name = channel_name; info.name_length = sizeof(channel_name); for (unsigned int i = 0; i < ctrl->num_up_channels; i++) { ret = rtt_read_channel_info(i, RTT_CHANNEL_TYPE_UP, &info); if (ret != ERROR_OK) return ret; if (!info.size) continue; command_print(CMD, "%u: %s %u %u", i, info.name, info.size, info.flags); }for (unsigned int i = 0; i < ctrl->num_up_channels; i++) { ... } command_print(CMD, "Down-channels:"); for (unsigned int i = 0; i < ctrl->num_down_channels; i++) { ret = rtt_read_channel_info(i, RTT_CHANNEL_TYPE_DOWN, &info); if (ret != ERROR_OK) return ret; if (!info.size) continue; command_print(CMD, "%u: %s %u %u", i, info.name, info.size, info.flags); }for (unsigned int i = 0; i < ctrl->num_down_channels; i++) { ... } return ERROR_OK; }{ ... } COMMAND_HANDLER(handle_channel_list) { char channel_name[CHANNEL_NAME_SIZE]; const struct rtt_control *ctrl; struct rtt_channel_info info; if (CMD_ARGC != 0) return ERROR_COMMAND_SYNTAX_ERROR; if (!rtt_found_cb()) { command_print(CMD, "rtt: Control block not available"); return ERROR_FAIL; }if (!rtt_found_cb()) { ... } ctrl = rtt_get_control(); info.name = channel_name; info.name_length = sizeof(channel_name); command_print(CMD, "{"); for (unsigned int i = 0; i < ctrl->num_up_channels; i++) { int ret = rtt_read_channel_info(i, RTT_CHANNEL_TYPE_UP, &info); if (ret != ERROR_OK) return ret; if (!info.size) continue; command_print(CMD, " {\n" " name %s\n" " size 0x%" PRIx32 "\n" " flags 0x%" PRIx32 "\n" " }", info.name, info.size, info.flags); }for (unsigned int i = 0; i < ctrl->num_up_channels; i++) { ... } command_print(CMD, "}\n{"); for (unsigned int i = 0; i < ctrl->num_down_channels; i++) { int ret = rtt_read_channel_info(i, RTT_CHANNEL_TYPE_DOWN, &info); if (ret != ERROR_OK) return ret; if (!info.size) continue; command_print(CMD, " {\n" " name %s\n" " size 0x%" PRIx32 "\n" " flags 0x%" PRIx32 "\n" " }", info.name, info.size, info.flags); }for (unsigned int i = 0; i < ctrl->num_down_channels; i++) { ... } command_print(CMD, "}"); return ERROR_OK; }{ ... } static const struct command_registration rtt_subcommand_handlers[] = { { .name = "setup", .handler = handle_rtt_setup_command, .mode = COMMAND_ANY, .help = "setup RTT", .usage = "<address> <size> [ID]" ...}, { .name = "start", .handler = handle_rtt_start_command, .mode = COMMAND_EXEC, .help = "start RTT", .usage = "" ...}, { .name = "stop", .handler = handle_rtt_stop_command, .mode = COMMAND_EXEC, .help = "stop RTT", .usage = "" ...}, { .name = "polling_interval", .handler = handle_rtt_polling_interval_command, .mode = COMMAND_EXEC, .help = "show or set polling interval in ms", .usage = "[interval]" ...}, { .name = "channels", .handler = handle_rtt_channels_command, .mode = COMMAND_EXEC, .help = "list available channels", .usage = "" ...}, { .name = "channellist", .handler = handle_channel_list, .mode = COMMAND_EXEC, .help = "list available channels", .usage = "" ...}, COMMAND_REGISTRATION_DONE ...}; const struct command_registration rtt_target_command_handlers[] = { { .name = "rtt", .mode = COMMAND_EXEC, .help = "RTT target commands", .usage = "", .chain = rtt_subcommand_handlers ...}, COMMAND_REGISTRATION_DONE ...};
Details
Show:
from
Types: Columns:
Click anywhere in the source to view detailed information here...