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

Caller-filled I2C controller-transfer seam (write / read / write-then-read). More...

#include <ra8_i2c_bus_ops.h>

Data Fields

ra8_err_t(* write )(void *ctx, uint8_t addr, const uint8_t *data, uint32_t len, bool send_stop)
 Controller write of len bytes to 7-bit address addr.
ra8_err_t(* read )(void *ctx, uint8_t addr, uint8_t *data, uint32_t len)
 Controller read of len bytes from 7-bit address addr.
ra8_err_t(* transfer )(void *ctx, uint8_t addr, const uint8_t *wr, uint32_t wr_len, uint8_t *rd, uint32_t rd_len)
 Combined write-then-RESTART-then-read in one transaction.
void * ctx
 Opaque cookie handed to every callback (binder-owned).

Detailed Description

Caller-filled I2C controller-transfer seam (write / read / write-then-read).

A device driver stores this struct by value from its config and routes every bus transaction through the three callbacks. The ctx cookie is opaque to the driver; the binder that filled the seam decides what it points at (the Ring-4 ra8_io_i2c_bus_as_ops() points it at the bound ra8_io_i2c_bus_t handle, which must therefore out-live the driver). Tests may fill the seam directly with local trampolines.

Invariant
write, read, and transfer are non-NULL once filled.
Whatever ctx references out-lives every callback call.
Example:
(void)ra8_io_i2c_bus_as_ops(&bus, &ops);
ra8_touch_cfg_t cfg = { .bus = ops, ... };
ra8_err_t ra8_io_i2c_bus_as_ops(const ra8_io_i2c_bus_t *bus, ra8_i2c_bus_ops_t *out)
Expose a bound bus through the Ring-3 seam ra8_i2c_bus_ops_t.
ra8_err_t ra8_io_i2c_bus_bind_i3c_compat(ra8_io_i2c_bus_t *bus, uint8_t channel)
Bind bus to I3C channel channel in I2C-compatibility mode.
Caller-filled I2C controller-transfer seam (write / read / write-then-read).
Caller-allocated I2C-bus handle binding a backend to its context.
See also
ra8_io_i2c_bus_as_ops Ring-4 binder over the ra8_io I2C facade.
ra8_touch_cfg_t Ring-3 consumer (GT911 touch driver).
ra8_smbus_cfg_t Ring-3 consumer (SMBus 3.2 layer).
Since
0.1.0

Definition at line 78 of file ra8_i2c_bus_ops.h.

Field Documentation

◆ ctx

void* ra8_i2c_bus_ops_t::ctx

Opaque cookie handed to every callback (binder-owned).

Definition at line 138 of file ra8_i2c_bus_ops.h.

Referenced by ra8_io_i2c_bus_as_ops().

◆ read

ra8_err_t(* ra8_i2c_bus_ops_t::read) (void *ctx, uint8_t addr, uint8_t *data, uint32_t len)

Controller read of len bytes from 7-bit address addr.

Issues START, the address byte with R/W# = 1, drains len bytes, then issues STOP and releases the bus.

Parameters
[in]ctxBinder-owned cookie (the ctx member below).
[in]addr7-bit peripheral address.
[out]dataDestination buffer (non-NULL).
[in]lenByte count (non-zero).
Returns
ra8_err_t forwarded from the bound transport.

Definition at line 112 of file ra8_i2c_bus_ops.h.

Referenced by ra8_io_i2c_bus_as_ops(), and ra8_smbus_init().

◆ transfer

ra8_err_t(* ra8_i2c_bus_ops_t::transfer) (void *ctx, uint8_t addr, const uint8_t *wr, uint32_t wr_len, uint8_t *rd, uint32_t rd_len)

Combined write-then-RESTART-then-read in one transaction.

The classic "address a register, read its contents" shape: writes wr_len bytes, injects a repeated START, reads rd_len bytes, then issues STOP. Matches ra8_i2c_transfer / ra8_i3c_transfer.

Parameters
[in]ctxBinder-owned cookie (the ctx member below).
[in]addr7-bit peripheral address.
[in]wrBytes to send first (NULL only when wr_len 0).
[in]wr_lenNumber of bytes to send.
[out]rdDestination buffer (NULL only when rd_len 0).
[in]rd_lenNumber of bytes to read.
Returns
ra8_err_t forwarded from the bound transport.

Definition at line 131 of file ra8_i2c_bus_ops.h.

Referenced by internal_validate_cfg(), ra8_io_i2c_bus_as_ops(), and ra8_smbus_init().

◆ write

ra8_err_t(* ra8_i2c_bus_ops_t::write) (void *ctx, uint8_t addr, const uint8_t *data, uint32_t len, bool send_stop)

Controller write of len bytes to 7-bit address addr.

When send_stop is true the transaction ends with STOP and the bus is released; when false the bus is held so the next call on the same bus injects a repeated-START. Matches the ra8_i2c_write contract (ra8_i3c_write uses the inverted restart flag; binders adapt).

Parameters
[in]ctxBinder-owned cookie (the ctx member below).
[in]addr7-bit peripheral address.
[in]dataBytes to send (non-NULL when len > 0).
[in]lenByte count.
[in]send_stoptrue = STOP after the payload; false = hold.
Returns
ra8_err_t forwarded from the bound transport.

Definition at line 96 of file ra8_i2c_bus_ops.h.

Referenced by internal_validate_cfg(), ra8_io_i2c_bus_as_ops(), and ra8_smbus_init().


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