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

Adapter that forwards ra8_log bytes into an ra8_io stream. More...

#include "ra8_io_log.h"
#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_check.h"
#include "ra8_err.h"
#include "ra8_io_stream.h"
#include "ra8_log.h"
Include dependency graph for ra8_io_log.c:

Go to the source code of this file.

Functions

static void internal_io_log_byte (void *ctx, uint8_t byte)
 Byte sink: write one log byte to the attached stream.
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.

Variables

static const char *const s_tag = "ra8_io_log"
 Module log tag.

Detailed Description

Adapter that forwards ra8_log bytes into an ra8_io stream.

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

Installs a ra8_log_byte_sink_fn_t that writes each log byte to a bound ra8_io_stream_t. The dependency runs the right way: ra8_core defines the sink callback type, ra8_io implements it.

Definition in file ra8_io_log.c.

Function Documentation

◆ internal_io_log_byte()

void internal_io_log_byte ( void * ctx,
uint8_t byte )
static

Byte sink: write one log byte to the attached stream.

Best-effort: a stream write error is ignored so a failing log destination never propagates an error into the logging call site.

Parameters
[in]ctxThe attached ra8_io_stream_t (as a void cookie).
[in]byteLog byte to forward.
Returns
void
Precondition
ctx is the stream passed to ra8_io_log_attach.
The stream out-lives the redirect.
Postcondition
The byte was offered to the stream (errors ignored).
No global state is mutated.
Note
Not thread-safe with respect to concurrent logging.
Since
0.1.0

Definition at line 52 of file ra8_io_log.c.

References RA8_INTERNAL, and ra8_io_stream_write().

Referenced by ra8_io_log_attach().

◆ 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().

Variable Documentation

◆ s_tag

const char* const s_tag = "ra8_io_log"
static

Module log tag.

Definition at line 28 of file ra8_io_log.c.