ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_io_log.h File Reference

Redirect ra8_log output into an ra8_io stream. More...

#include "ra8_err.h"
#include "ra8_io_stream.h"
Include dependency graph for ra8_io_log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ra8_err_t ra8_io_log_attach (ra8_io_stream_t *s)
 Route ra8_log output to a bound ra8_io stream.
void ra8_io_log_detach (void)
 Restore the default ITM log backend.

Detailed Description

Redirect ra8_log output into an ra8_io stream.

Tag
[Ring 4 / PAL] {World: NS}

Bridges the ra8_core logger to the ra8_io stream facade: attach a bound ra8_io_stream_t and every subsequent log byte (the [TAG] LEVEL: message line the logger would have sent to ITM) is written to that stream instead. This makes the log destination run-time selectable – a UART, a USB-CDC link, a RAM capture buffer, or a raw block device – without ra8_core depending on ra8_io. Detach to restore the default ITM backend.

Since
0.1.0

Definition in file ra8_io_log.h.

Function Documentation

◆ ra8_io_log_attach()

ra8_err_t ra8_io_log_attach ( ra8_io_stream_t * s)
nodiscard

Route ra8_log output to a bound ra8_io stream.

Parameters
[in]sBound stream to receive log bytes (must out-live the redirect).
Returns
ra8_err_t Error code.
Return values
k_ra8_okLogging now flows to s.
k_ra8_err_null_ptrs was NULL.
k_ra8_err_not_initializeds has no sink bound.
Precondition
s is bound to a sink and out-lives the redirect.
ra8_log_init has run (or will run) for the default path.
Postcondition
Subsequent log lines are written to s.
Call ra8_io_log_detach to restore the ITM backend.
Note
Not thread-safe with respect to concurrent logging.
Since
0.1.0

Definition at line 61 of file ra8_io_log.c.

References ra8_io_stream_t::iface, internal_io_log_byte(), k_ra8_err_not_initialized, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_set_byte_sink(), and s_tag.

Referenced by main().

◆ ra8_io_log_detach()

void ra8_io_log_detach ( void )

Restore the default ITM log backend.

Clears any stream installed by ra8_io_log_attach.

Precondition
None.
None.
Postcondition
Subsequent log output goes to the ITM port again.
The previously attached stream receives no further bytes.
Note
Not thread-safe with respect to concurrent logging.
Since
0.1.0

Definition at line 71 of file ra8_io_log.c.

References ra8_log_set_byte_sink().