50 rtt.sink_list_length = 1;
51 rtt.sink_list = calloc(
rtt.sink_list_length,
60 rtt.polling_interval = 100;
76 ret =
rtt.source.read(
rtt.target, &
rtt.ctrl,
rtt.sink_list,
90 size_t id_length = strlen(
id);
93 LOG_ERROR(
"rtt: Invalid control block ID");
99 strncpy(
rtt.id,
id, id_length + 1);
101 rtt.configured =
true;
132 if (!
rtt.found_cb ||
rtt.changed) {
143 LOG_INFO(
"rtt: No control block found");
159 rtt.polling_interval, 1,
NULL);
169 if (!
rtt.configured) {
197 for (
size_t i =
rtt.sink_list_length; i <
length; i++)
211 if (channel_index >=
rtt.sink_list_length) {
216 LOG_DEBUG(
"rtt: Registering sink for channel %u", channel_index);
225 tmp->
next =
rtt.sink_list[channel_index];
227 rtt.sink_list[channel_index] = tmp;
237 LOG_DEBUG(
"rtt: Unregistering sink for channel %u", channel_index);
239 if (channel_index >=
rtt.sink_list_length)
242 prev_sink =
rtt.sink_list[channel_index];
245 prev_sink = sink, sink = sink->
next) {
248 if (sink ==
rtt.sink_list[channel_index])
249 rtt.sink_list[channel_index] = sink->next;
267 *interval =
rtt.polling_interval;
277 if (
rtt.polling_interval != interval) {
283 rtt.polling_interval = interval;
291 if (channel_index >=
rtt.ctrl.num_up_channels) {
292 LOG_WARNING(
"rtt: Down-channel %u is not available", channel_index);
307 return rtt.configured;
323 return rtt.source.read_channel_info(
rtt.target, &
rtt.ctrl,
#define ERROR_COMMAND_ARGUMENT_INVALID
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
bool changed
Whether configuration changed.
int rtt_stop(void)
Stop Real-Time Transfer (RTT).
target_addr_t addr
Start address to search for the control block.
bool found_cb
Whether the control block was found.
unsigned int polling_interval
bool started
Whether RTT is started.
int rtt_start(void)
Start Real-Time Transfer (RTT).
bool configured
Whether RTT is configured.
struct rtt_control ctrl
Control block.
int rtt_register_sink(unsigned int channel_index, rtt_sink_read read, void *user_data)
Register an RTT sink.
bool rtt_configured(void)
Get whether RTT is configured.
bool rtt_found_cb(void)
Get whether RTT control block was found.
struct rtt_sink_list ** sink_list
int rtt_set_polling_interval(unsigned int interval)
Set the polling interval.
size_t size
Size of the control block search area.
int rtt_unregister_sink(unsigned int channel_index, rtt_sink_read read, void *user_data)
Unregister an RTT sink.
int rtt_init(void)
Initialize Real-Time Transfer (RTT).
bool rtt_started(void)
Get whether RTT is started.
int rtt_register_source(const struct rtt_source source, struct target *target)
Register an RTT source for a target.
int rtt_exit(void)
Shutdown Real-Time Transfer (RTT).
static int adjust_sink_list(size_t length)
const struct rtt_control * rtt_get_control(void)
Get the RTT control block.
int rtt_get_polling_interval(unsigned int *interval)
Get the polling interval.
int rtt_setup(target_addr_t address, size_t size, const char *id)
Setup RTT.
int rtt_read_channel_info(unsigned int channel_index, enum rtt_channel_type type, struct rtt_channel_info *info)
Read channel information.
static int read_channel_callback(void *user_data)
int rtt_write_channel(unsigned int channel_index, const uint8_t *buffer, size_t *length)
Write to an RTT channel.
#define RTT_CB_MAX_ID_LENGTH
Control block ID length in bytes, including the trailing null-terminator.
int(* rtt_sink_read)(unsigned int channel, const uint8_t *buffer, size_t length, void *user_data)
rtt_channel_type
Channel type.
struct rtt_sink_list * next
rtt_source_find_ctrl_block find_cb
rtt_source_read_ctrl_block read_cb
rtt_source_read_channel_info read_channel_info
int target_unregister_timer_callback(int(*callback)(void *priv), void *priv)
int target_register_timer_callback(int(*callback)(void *priv), unsigned int time_ms, enum target_timer_type type, void *priv)
The period is very approximate, the callback can happen much more often or much more rarely than spec...
static struct ublast_lowlevel_priv info