49typedef enum : uint32_t {
64typedef enum : uint64_t {
84typedef enum : uint32_t {
94typedef enum : uint32_t {
106typedef enum : uint32_t {
111typedef enum : uint32_t {
133typedef enum : uint8_t {
141typedef enum : uint8_t {
156typedef enum : uint32_t {
246 if (dev !=
nullptr) {
247 if (dev->
stop !=
nullptr) {
257 "RIIC addr=0x%02X R %uB",
261 (void)snprintf(ln,
sizeof(ln),
"RIIC addr=0x%02X W", (
unsigned)s->
target_7b);
288 if (dev ==
nullptr) {
328 if ((dev !=
nullptr) && (dev->
write !=
nullptr)) {
760 for (uint32_t i = 0U; i < (uint32_t)
k_riic_count; i++) {
777 for (uint32_t ch = 0U; ch < (uint32_t)
k_riic_count; ch++) {
778 if (
s_riic[ch].tgt_cycles > 0U) {
779 (void)
priv_emu_io_errf(
" RIIC target : own 0x%02X serviced %u controller write+read "
780 "cycle(s), echo=%s\n",
781 (
unsigned)
s_riic[ch].tgt_own_addr,
782 (
unsigned)
s_riic[ch].tgt_cycles,
783 s_riic[ch].tgt_echo_bad ?
"MISMATCH" :
"OK");
798 .name =
"RIIC+PI4IOE",
Multi-channel console log store backing the board view's tabbed console.
void board_console_push(board_console_ch_t ch, const char *line)
Append one completed line to a channel ring and the ALL ring.
@ k_board_console_ch_i2c
I2C (IIC_B + RIIC) transfer summaries.
Decentralized peripheral-block registry for the board emulator core.
void board_periph_register_block(const board_periph_block_t *block)
Register a peripheral block's descriptor with the core registry.
@ k_block_order_i2c
I3C/I2C + GT911 (no tick today).
riic_addr_t
I2C address-byte layout on the wire (addr<<1 | R/W).
@ k_riic_addr_shift
7-bit address occupies bits [7:1].
@ k_riic_addr_rnw
LSB: 1 == read, 0 == write.
@ k_riic_dev_rx_max
Per-read device response staging cap.
@ k_riic_addr_mask7
7-bit target-address mask.
@ k_riic_byte_mask
One data byte.
static uint32_t internal_riic_target_iccr2(const riic_state_t *s)
ICCR2 read in target mode: assert TRS only while the controller reads.
riic_icser_bit_t
ICSER (status enable) own-address slot-enable bits (ra8_i2c_regs.h).
@ k_riic_icser_sar0e
SAR0E: own-address slot 0 enable (bit 0).
@ k_riic_icser_slots
Any own-address slot enabled (SARyE).
@ k_riic_icser_sar1e
SAR1E: own-address slot 1 enable (bit 1).
@ k_riic_icser_sar2e
SAR2E: own-address slot 2 enable (bit 2).
static void internal_riic_target_open(riic_state_t *s, uint32_t icser)
(Dis)arm target mode on an ICSER write; latch the firmware's own address.
static void internal_riic_close_transfer(riic_state_t *s)
Close a transaction (STOP): release the bus and notify the device.
riic_icsr2_bit_t
ICSR2 (status 2) flags the driver polls / clears (ra8_i2c_regs.h).
@ k_riic_icsr2_start
START: start-condition detected (bit 2).
@ k_riic_icsr2_rdrf
RDRF: receive data full (bit 5).
@ k_riic_icsr2_tmof
TMOF: timeout detected (bit 0).
@ k_riic_icsr2_nackf
NACKF: NACK detected (bit 4).
@ k_riic_icsr2_tdre
TDRE: transmit data empty (bit 7).
@ k_riic_icsr2_tend
TEND: transmit end (bit 6).
@ k_riic_icsr2_stop
STOP: stop-condition detected (bit 3).
@ k_riic_icsr2_al
AL: arbitration lost (bit 1).
static void internal_riic_reset(void)
Clear the RIIC channels + expander state and (re)populate the bus.
static void internal_riic_address_phase(riic_state_t *s, uint8_t address_byte)
Consume the address byte after a (re)START: select + ACK a device.
riic_tgt_stim_t
Target-mode synthetic-controller payload + script size.
@ k_riic_tgt_payload1
Second byte the synthetic controller writes.
@ k_riic_tgt_payload_len
Bytes per write (and expected echo length).
@ k_riic_tgt_cycles
Write+read cycles the stimulus drives.
@ k_riic_tgt_cap
Echo-capture buffer bound.
@ k_riic_tgt_payload0
First byte the synthetic controller writes.
static void internal_riic_open_transfer(riic_state_t *s)
Begin a transaction (START or repeated-START): arm the address phase.
riic_icsr1_bit_t
ICSR1 (status 1) own-address match flags (ra8_i2c_regs.h).
@ k_riic_icsr1_aas0
AAS0: own-address slot 0 matched (bit 0).
static uint64_t internal_riic_target_reg_read(riic_state_t *s, uint64_t off)
Register read while target mode is armed (own-address responder path).
static uint64_t internal_riic_reg_read(riic_state_t *s, uint64_t off)
Read a register from one modelled RIIC channel.
riic_map_t
RIIC block geometry (ra8_i2c_regs.h, byte-wide register file).
@ k_riic_off_iccr1
ICCR1 control 1 (ICE / IICRST).
@ k_riic_off_sarl2
SARL2 own-address low, slot 2.
@ k_riic_count
IIC0 / IIC1 / IIC2.
@ k_riic_span
All three channel windows.
@ k_riic_base
IIC0 base (channel 0).
@ k_riic_reg_bytes
Shadow byte count for one channel.
@ k_riic_off_icser
ICSER own-address enable (SARyE).
@ k_riic_off_icmr3
ICMR3 mode 3 (ACKWP/ACKBT/WAIT).
@ k_riic_off_icdrt
ICDRT transmit data register.
@ k_riic_off_sarl0
SARL0 own-address low, slot 0.
@ k_riic_stride
Bytes per RIIC channel.
@ k_riic_off_icsr2
ICSR2 status 2 (TDRE/TEND/...).
@ k_riic_off_iccr2
ICCR2 control 2 (ST/RS/SP/BBSY).
@ k_riic_off_icsr1
ICSR1 status 1 (AASy own-addr).
@ k_riic_off_sarl1
SARL1 own-address low, slot 1.
@ k_riic_off_icdrr
ICDRR receive data register.
static void internal_riic_report(void)
Print the PI4IOE line and any target-role responder activity.
static void internal_riic_target_icsr2_write(riic_state_t *s, uint32_t value)
ICSR2 W0C write in target mode: advance the write->read->done script.
static uint64_t internal_riic_read(uc_engine *uc, uint64_t addr, unsigned size)
MMIO read inside the RIIC window: route to the addressed channel.
riic_console_t
Console-tap line buffer capacity for a RIIC transaction summary.
@ k_riic_console_line_cap
Max chars in a "RIIC addr=.. .." line.
static void internal_riic_target_icdrt(riic_state_t *s, uint8_t byte)
ICDRT write in target mode: capture the firmware's echo byte.
riic_iccr2_bit_t
ICCR2 (control 2) bits the model acts on (ra8_i2c_regs.h).
@ k_riic_iccr2_st
ST: issue START (bit 1).
@ k_riic_iccr2_bbsy
BBSY: bus-busy flag, RO (bit 7).
@ k_riic_iccr2_rs
RS: issue repeated-START (bit 2).
@ k_riic_iccr2_sp
SP: issue STOP (bit 3).
@ k_riic_iccr2_trs
TRS: transmit/receive mode (bit 5).
@ k_riic_iccr2_mst
MST: controller/peripheral (bit 6).
static const uint8_t s_k_riic_tgt_payload[k_riic_tgt_payload_len]
The synthetic controller's write payload (echoed back on read).
static uint32_t internal_riic_target_icdrr(riic_state_t *s)
ICDRR read in target mode: serve the address byte, then the payload.
static void internal_riic_target_complete_read(riic_state_t *s)
Close one cycle: verify the echo, then loop the script or quiesce the bus.
static void internal_riic_reg_write(riic_state_t *s, uint64_t off, uint32_t value)
Write a register on one modelled RIIC channel.
static void internal_board_periph_riic_register(void)
Self-register the RIIC block before main runs (decentralized).
static const board_periph_block_t s_k_riic_block
This block's descriptor (static lifetime; the core keeps the pointer).
static void internal_riic_icdrt_write(riic_state_t *s, uint32_t value)
Handle a write to ICDRT (address byte, then controller TX payload).
static void internal_riic_target_begin_read(riic_state_t *s)
Arm the read phase: present transmit-ready + transmit-end for the echo.
static void internal_riic_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
MMIO write inside the RIIC window: route to the addressed channel.
riic_tgt_phase_t
RIIC target (peripheral) role: phases + synthetic external controller.
@ k_riic_tgt_read
Controller is reading the echo (TDRE/TEND).
@ k_riic_tgt_done
Script complete; the bus is quiet (no match).
@ k_riic_tgt_write
Controller is writing the payload (RDRF/STOP).
@ k_riic_tgt_idle
No own address armed; target model inert.
static void internal_riic_target_begin_write(riic_state_t *s)
Arm the write phase: present the address-match + receive-ready state.
static uint32_t internal_riic_icdrr_read(riic_state_t *s)
Serve one ICDRR read from the staged device response.
static void internal_riic_iccr2_write(riic_state_t *s, uint64_t off, uint32_t value)
Dispatch an ICCR2 write -> START / repeated-START / STOP.
static uint32_t internal_riic_target_icsr1(const riic_state_t *s)
ICSR1 read in target mode: assert the own-address match while active.
static riic_state_t s_riic[k_riic_count]
The three modelled RIIC controller channels.
Internal RIIC bus-device registry and board-device models.
riic_device_t * priv_riic_device_find(uint8_t addr_7b)
Find the registered RIIC device answering one 7-bit address.
void priv_riic_devices_reset(void)
Reset and repopulate the board's RIIC device registry.
void priv_riic_devices_report(void)
Report activity observed by the registered board devices.
Bounded raw-descriptor I/O seam for the RA8 emulator.
emu_io_result_t priv_emu_io_errf(const char *format,...)
Format bounded text and write it to the injected error descriptor.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
static ra8_err_t internal_riic_read(void *ctx, uint8_t addr, uint8_t *data, uint32_t len)
RIIC backend: controller read.
static ra8_err_t internal_riic_write(void *ctx, uint8_t addr, const uint8_t *data, uint32_t len, bool send_stop)
RIIC backend: controller write.
A modelled peripheral block's self-description for the core registry.
One device registered on the modelled RIIC bus.
uint32_t(* read)(void *ctx, uint8_t *buf, uint32_t max)
Device->controller.
void(* stop)(void *ctx)
STOP/transfer end.
void(* write)(void *ctx, uint8_t byte)
Controller->device.
One RIIC channel: register shadow + a controller transfer machine.
bool rx_primed
The dummy first ICDRR read was consumed.
uint8_t tgt_phase
riic_tgt_phase_t of the current script.
uint8_t target_7b
7-bit address selected this transfer.
uint8_t tgt_rd[k_riic_tgt_cap]
Captured echo bytes (bounds-checked).
uint32_t tgt_icsr2
Target-role ICSR2 flags (RDRF/STOP/...).
uint8_t tgt_own_addr
Firmware's 7-bit own address (SARLy>>1).
uint32_t tgt_rd_len
Bytes the firmware transmitted this read.
uint32_t icsr2
ICSR2 flags (TDRE/TEND/RDRF/NACKF).
bool addr_done
Address phase of the (re)START done.
uint8_t rx[k_riic_dev_rx_max]
Staged device response for a read.
uint32_t tgt_wr_pos
ICDRR serves consumed this write (0=addr).
bool reading
Current transfer direction is read.
bool tgt_echo_bad
A firmware echo did not match the write.
uint32_t rx_len
Valid bytes in rx.
uint32_t tgt_cycles
Completed write+read cycles.
uint32_t rx_pos
Next byte index served from rx.
bool acked
The addressed target ACKed.
bool tgt_armed
Own address enabled (ICSER.SARyE set).
bool busy
True between START and STOP.
uint8_t reg[k_riic_reg_bytes]
Reflect-on-read register shadow.