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

Caller-supplied calendar source used to stamp files. More...

#include <ra8_fs_seams.h>

Data Fields

ra8_err_t(* now )(void *ctx, ra8_fs_datetime_t *out)
 Report the current civil time.
void * ctx
 Caller-owned context passed back into now.

Detailed Description

Caller-supplied calendar source used to stamp files.

One function pointer plus a cookie, in the shape every other seam in this library uses (ra8_fs_backend_t for blocks, ra8_fs_lock_t for mutual exclusion). Production wiring is a three-line adapter over ra8_rtc_get() that lives with the caller; the host tests inject a fake that returns a fixed instant, which is what makes the on-disk bytes assertable.

Invariant
now is non-NULL in an installed binding (ra8_fs_set_clock rejects one that is not).
Example:
static ra8_err_t rtc_now(void* ctx, ra8_fs_datetime_t* out) {
(void)ctx;
ra8_rtc_time_t r = {};
if (e != k_ra8_ok) { return e; }
out->year = r.year; out->month = r.month; out->day = r.day;
out->hour = r.hour; out->minute = r.minute; out->second = r.second;
return k_ra8_ok;
}
const ra8_fs_clock_t clk = { .now = rtc_now, .ctx = nullptr };
(void)ra8_fs_set_clock(&clk);
@ 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_fs_set_clock(const ra8_fs_clock_t *clock)
Install (or remove) the calendar source used to stamp files.
ra8_err_t ra8_rtc_get(ra8_rtc_datetime_t *out)
Read the calendar registers.
Definition ra8_rtc.c:385
void * ctx
Caller-owned context passed back into now.
Broken-down civil date and time used at the filesystem boundary.
uint8_t hour
Hour of day, 0..23.
uint8_t minute
Minute of hour, 0..59.
uint8_t second
Second of minute, 0..59.
uint8_t month
Month of year, 1..12.
uint16_t year
Full civil year, e.g.
uint8_t day
Day of month, 1..31.
See also
ra8_fs_set_clock()
Since
0.1.0

Definition at line 194 of file ra8_fs_seams.h.

Field Documentation

◆ ctx

void* ra8_fs_clock_t::ctx

Caller-owned context passed back into now.

Definition at line 205 of file ra8_fs_seams.h.

◆ now

ra8_err_t(* ra8_fs_clock_t::now) (void *ctx, ra8_fs_datetime_t *out)

Report the current civil time.

Parameters
[in]ctxCaller cookie from ra8_fs_clock_t::ctx.
[out]outReceives the reading; only written on k_ra8_ok.
Returns
k_ra8_ok on success; any other code makes the filesystem fall back to the FAT epoch for that one stamp.

Definition at line 202 of file ra8_fs_seams.h.

Referenced by ra8_fs_set_clock().


The documentation for this struct was generated from the following file: