ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_io_log.c
Go to the documentation of this file.
1
16
17#include "ra8_io_log.h"
18
19#include <stdint.h>
20
21#include "ra8_attributes.h"
22#include "ra8_check.h"
23#include "ra8_err.h"
24#include "ra8_io_stream.h"
25#include "ra8_log.h"
26
28static const char* const s_tag = "ra8_io_log";
29
52RA8_INTERNAL static void internal_io_log_byte(void* ctx, uint8_t byte)
53{
54 if (ctx == nullptr) {
55 return; /* GCOVR_EXCL_LINE -- ctx is the stream ra8_io_log_attach validated non-NULL. */
56 }
58 (void)ra8_io_stream_write(s, &byte, 1U, nullptr);
59}
60
62{
63 RA8_CHECK_NULL_PTR(s, s_tag, "s must not be nullptr");
64 if (s->iface == nullptr) {
66 }
68 return k_ra8_ok;
69}
70
72{
73 ra8_log_set_byte_sink(nullptr, nullptr);
74}
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Definition ra8_check.h:243
Error Code Definitions for ra8-firmware.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
Definition ra8_err.h:235
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
ra8_err_t ra8_io_log_attach(ra8_io_stream_t *s)
Route ra8_log output to a bound ra8_io stream.
Definition ra8_io_log.c:61
static void internal_io_log_byte(void *ctx, uint8_t byte)
Byte sink: write one log byte to the attached stream.
Definition ra8_io_log.c:52
void ra8_io_log_detach(void)
Restore the default ITM log backend.
Definition ra8_io_log.c:71
Redirect ra8_log output into an ra8_io stream.
ra8_io targetable byte-stream facade – one writer, many destinations.
ra8_err_t ra8_io_stream_write(ra8_io_stream_t *s, const uint8_t *buf, uint32_t len, uint32_t *out_written)
Write len bytes to the bound sink.
Lightweight Logging Interface for ra8-firmware.
void ra8_log_set_byte_sink(ra8_log_byte_sink_fn_t fn, void *ctx)
Install (or clear) an optional byte sink for log output.
Definition ra8_log.c:56
Caller-allocated byte-stream handle binding a sink to its context.
const ra8_io_stream_iface_t * iface
Bound sink vtable (private).