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

Caller-filled SPI transfer seam: one full-duplex byte exchange. More...

#include <ra8_spi_bus_ops.h>

Data Fields

ra8_err_t(* xfer8 )(void *ctx, uint8_t tx, uint8_t *rx)
 Full-duplex single-byte exchange on the bound bus.
void * ctx
 Opaque cookie handed to xfer8 (binder-owned).

Detailed Description

Caller-filled SPI transfer seam: one full-duplex byte exchange.

A device driver stores this struct by value from its config and routes every SPI byte through xfer8(ctx, ...). The ctx cookie is opaque to the driver; the binder that filled the seam decides what it points at (the Ring-4 ra8_io_spi_bus_as_ops() points it at the bound ra8_io_spi_bus_t handle, which must therefore out-live the driver). Tests may fill the seam directly with a local trampoline.

Invariant
xfer8 is non-NULL once the seam has been filled.
Whatever ctx references out-lives every xfer8 call.
Example:
(void)ra8_io_spi_bus_bind_spi_b(&bus, 0U);
(void)ra8_io_spi_bus_as_ops(&bus, &ops);
ra8_epaper_cfg_t cfg = { .bus = ops, ... };
ra8_err_t ra8_io_spi_bus_as_ops(const ra8_io_spi_bus_t *bus, ra8_spi_bus_ops_t *out)
Expose a bound bus through the Ring-3 seam ra8_spi_bus_ops_t.
ra8_err_t ra8_io_spi_bus_bind_spi_b(ra8_io_spi_bus_t *bus, uint8_t channel)
Bind bus to SPI_B channel channel.
Caller-allocated SPI-bus handle binding a backend to its context.
Caller-filled SPI transfer seam: one full-duplex byte exchange.
See also
ra8_io_spi_bus_as_ops Ring-4 binder over the ra8_io SPI facade.
ra8_epaper_cfg_t First Ring-3 consumer of this seam.
Since
0.1.0

Definition at line 75 of file ra8_spi_bus_ops.h.

Field Documentation

◆ ctx

void* ra8_spi_bus_ops_t::ctx

Opaque cookie handed to xfer8 (binder-owned).

Definition at line 92 of file ra8_spi_bus_ops.h.

Referenced by internal_ra8_epaper_recv16(), internal_ra8_epaper_send16(), and ra8_io_spi_bus_as_ops().

◆ xfer8

ra8_err_t(* ra8_spi_bus_ops_t::xfer8) (void *ctx, uint8_t tx, uint8_t *rx)

Full-duplex single-byte exchange on the bound bus.

Shifts tx out on COPI while capturing the CIPO byte into *rx. rx may be NULL to discard the received byte. Matches the ra8_spi_xfer8 / ra8_sci_spi_xfer8 contract byte for byte.

Parameters
[in]ctxBinder-owned cookie (the ctx member below).
[in]txByte to shift out.
[out]rxReceive slot; may be NULL to discard.
Returns
ra8_err_t forwarded from the bound transport.

Definition at line 90 of file ra8_spi_bus_ops.h.

Referenced by internal_ra8_epaper_recv16(), internal_ra8_epaper_send16(), ra8_epaper_validate_cfg(), and ra8_io_spi_bus_as_ops().


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