56typedef enum : uint64_t {
69typedef enum : uint32_t {
76typedef enum : uint32_t {
86typedef enum : uint32_t {
92typedef enum : uint32_t {
97typedef enum : uint32_t {
119typedef enum : uint8_t {
126typedef enum : uint32_t {
143typedef enum : uint16_t {
151typedef enum : uint32_t {
167typedef enum : uint32_t {
259 uint32_t (*
read)(
void*
ctx, uint8_t* buf, uint32_t max);
281 void (*wr)(
void*, uint8_t),
282 uint32_t (*rd)(
void*, uint8_t*, uint32_t),
355 if ((x ==
nullptr) || (y ==
nullptr) || (
s_gt911.reported == 0U)) {
378 g->
reg_ptr = (uint16_t)(((uint32_t)g->
reg_ptr << 8U) | (uint32_t)
byte);
473 for (uint32_t i = 0U; i < n; i++) {
526 return (uint32_t)(off / 4U);
540 s_i3c.addr_done =
false;
542 s_i3c.reading =
false;
545 s_i3c.rx_primed =
false;
553typedef enum : uint32_t {
569 if (dev !=
nullptr) {
570 if (dev->
stop !=
nullptr) {
580 "IIC addr=0x%02X R %uB",
581 (
unsigned)
s_i3c.target_7b,
582 (
unsigned)
s_i3c.rx_len);
584 (void)snprintf(ln,
sizeof(ln),
"IIC addr=0x%02X W", (
unsigned)
s_i3c.target_7b);
589 s_i3c.addr_done =
false;
607 s_i3c.addr_done =
true;
610 if (dev ==
nullptr) {
622 s_i3c.rx_primed =
false;
651 s_i3c.periph_addr_7b = addr;
652 s_i3c.periph_mode = (addr != 0U);
671 s_i3c.periph_rx_byte =
695 return (uint32_t)
s_i3c.periph_rx_byte;
709 if (
byte !=
s_i3c.periph_rx_byte) {
710 s_i3c.periph_echo_bad =
true;
712 s_i3c.periph_xfers++;
728 if (
s_i3c.periph_mode) {
733 if (!
s_i3c.addr_done) {
741 if ((dev !=
nullptr) && (dev->
write !=
nullptr)) {
759 if (
s_i3c.periph_mode) {
763 if (!
s_i3c.rx_primed) {
765 s_i3c.rx_primed =
true;
809 if (
s_i3c.periph_mode) {
938 (void)
priv_emu_io_errf(
" I3C/I2C GT911 : %u touch frame(s) drained via ra8_touch -> I3C\n",
942 (void)
priv_emu_io_errf(
" I3C/I2C LSM6DSO: %u register read(s) answered (WHO_AM_I + samples)\n",
945 if (
s_i3c.periph_mode) {
949 const bool echo_ok = (
s_i3c.periph_xfers > 0U) && !
s_i3c.periph_echo_bad;
951 " I3C/I2C target: addr=0x%02X %u peripheral write+read xfer(s) accepted,"
953 (
unsigned)
s_i3c.periph_addr_7b,
954 (
unsigned)
s_i3c.periph_xfers,
955 echo_ok ?
"Y" :
"N");
969 .name =
"I3C/I2C+GT911",
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.
Register-accurate peripheral-model framework for the board emulator.
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).
static void internal_gt911_write(void *ctx, uint8_t byte)
Controller -> GT911: pointer bytes first (MSB,LSB), then payload.
static void internal_i3c_address_phase(uint8_t address_byte)
Consume the address byte after a (re)START: select + ACK a device.
gt911_reg_t
GoodIX GT911 protocol constants (ra8_touch_gt911_regs.h + ra8_touch.c).
@ k_gt911_reg_command
Command register (sleep/wake/ack).
@ k_gt911_reg_status
Status: bit7 ready, bits[3:0] count.
@ k_gt911_reg_point0
First 8-byte per-point record.
@ k_gt911_reg_product
4-byte ASCII product id "911\0".
static void internal_gt911_stop(void *ctx)
STOP / transfer end: reset the GT911 pointer-capture state.
static void internal_i3c_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
MMIO write inside the I3C/IIC_B window.
bool board_periph_touch_last(uint16_t *x, uint16_t *y)
Report the coordinates of the most recently drained touch contact.
static uint32_t internal_gt911_read_status(gt911_state_t *g, uint8_t *buf)
Fill buf with the GT911 status byte for the current frame.
i3c_addr_t
I2C address-byte layout on the wire (addr<<1 | R/W).
@ k_i3c_dev_rx_max
Per-read device response staging cap.
@ k_i3c_addr_shift
7-bit address occupies bits [7:1].
@ k_i3c_dev_max
Device-registry capacity on the bus.
@ k_i3c_addr_mask7
7-bit target-address mask.
@ k_i3c_addr_rnw
LSB: 1 == read, 0 == write.
@ k_i3c_byte_mask
One data byte.
i3c_periph_phase_t
Target (peripheral) mode transaction phase.
@ k_i3c_periph_idle
No target transaction armed.
@ k_i3c_periph_tx_armed
Controller is reading: TDBEF0 raised.
@ k_i3c_periph_rx_armed
Controller wrote a byte: RDBFF0 raised.
static void internal_i3c_reset(void)
Clear the I3C channel + GT911 state and (re)populate the bus.
i3c_map_t
I3C-in-I2C-mode (IIC_B) block geometry (ra8_i3c_i2c_regs.h).
@ k_i3c_off_ntdtbp0
NTDTBP0 transfer data buffer port.
@ k_i3c_span
Through BCST at +0x210.
@ k_i3c_off_ntst
NTST normal-transfer status.
@ k_i3c_off_cndctl
CNDCTL START/RESTART/STOP request.
@ k_i3c_off_msdvad
MSDVAD own/target device address.
@ k_i3c_off_bcst
BCST bus condition status (BFREF).
@ k_i3c_base
I3C0 base (== IIC_B channel 0).
@ k_i3c_off_bst
BST bus status (W0C flags).
@ k_i3c_reg_words
Shadow word count for the window.
gt911_const_t
GT911 magic byte values + record geometry.
@ k_gt911_status_one
One active contact in bits[3:0].
@ k_gt911_ptr_bytes
16-bit register-pointer width.
@ k_gt911_point_bytes
Bytes per per-point record.
@ k_gt911_addr_7b
EK-RA8D2 carrier GT911 default address.
@ k_gt911_status_ready
Buffer-ready (bit 7).
@ k_gt911_id_bytes
PRODUCT_ID payload length.
@ k_gt911_id3
NUL terminator.
@ k_gt911_id0
'9' – first product-id byte ra8_touch checks.
@ k_gt911_seq_max
Injected raw-point sequence FIFO depth.
@ k_gt911_press
Synthetic contact pressure (size lsb).
static void internal_i3c_report(void)
Print the GT911 touch line when the firmware drained any contact.
bool board_periph_touch_seq_push(uint16_t x, uint16_t y)
Queue one raw touch point onto the modelled GT911 injection FIFO.
static const board_periph_block_t s_k_i3c_block
This block's descriptor (static lifetime; the core keeps the pointer).
i3c_bst_bit_t
BST (Bus Status) flags the polling driver observes / clears (W0C).
@ k_i3c_bst_spcnddf
STOP-condition detected (bit 1).
@ k_i3c_bst_todf
Timeout detected (bit 20).
@ k_i3c_bst_alf
Arbitration lost (bit 16).
@ k_i3c_bst_tendf
Transfer-end / address ACK (bit 8).
@ k_i3c_bst_nackdf
NACK detected (bit 4).
@ k_i3c_bst_stcnddf
START-condition detected (bit 0).
static void internal_i3c_cndctl_write(uint32_t value)
Dispatch a CNDCTL write -> START / repeated-START / STOP.
static void internal_i3c_close_transfer(void)
Close a transaction (STOP): release the bus and notify the device.
i3c_ntst_bit_t
NTST (Normal Transfer Status) flags.
@ k_i3c_ntst_rdbff0
RX data-buffer full (bit 1).
@ k_i3c_ntst_tdbef0
TX data-buffer empty (bit 0).
static void internal_i3c_periph_tx_write(uint8_t byte)
Target-mode NTDTBP0 write: capture + verify the firmware echo, end xfer.
static gt911_state_t s_gt911
i3c_cndctl_bit_t
CNDCTL condition-request bits (ra8_i3c_i2c_regs.h).
@ k_i3c_cndctl_stcnd
STCND issue START.
@ k_i3c_cndctl_srcnd
SRCND issue repeated-START.
@ k_i3c_cndctl_spcnd
SPCND issue STOP.
static void internal_i3c_reg_write(uint64_t off, uint32_t value)
Write a register on the modelled I3C/IIC_B channel.
static void internal_gt911_arm_next_from_seq(gt911_state_t *g)
Arm the head of the injected sequence FIFO when nothing is pending.
static uint32_t internal_i3c_ntdtbp0_read(void)
Serve one NTDTBP0 read from the staged device response.
gt911_pt_off_t
Byte offsets inside one 8-byte GT911 point record (ra8_touch.c).
@ k_gt911_pt_track
track_id.
@ k_gt911_pt_x_lsb
X low byte.
@ k_gt911_pt_sz_lsb
size low (pressure).
@ k_gt911_pt_x_msb
X high byte.
@ k_gt911_pt_y_lsb
Y low byte.
@ k_gt911_pt_y_msb
Y high byte.
static void internal_i3c_open_transfer(void)
Begin a transaction (START or repeated-START): arm the address phase.
static void internal_i3c_periph_open(uint32_t msdvad)
Enter / leave target mode when the firmware (re)programmes MSDVAD.
static uint32_t internal_gt911_read(void *ctx, uint8_t *buf, uint32_t max)
GT911 -> controller: answer a read at the current register pointer.
void board_periph_touch_seq_reset(void)
Clear the modelled GT911 injected-touch sequence FIFO.
void priv_i2c_device_register(uint8_t addr_7b, void(*wr)(void *, uint8_t), uint32_t(*rd)(void *, uint8_t *, uint32_t), void(*stop)(void *), void *ctx)
Register a device model in the first free bus slot (drop if full).
i2c_console_t
Console-tap line buffer capacity for an I2C transaction summary.
@ k_i2c_console_line_cap
Max chars in an "I2C addr=.. .." line.
static void internal_i3c_ntdtbp0_write(uint32_t value)
Handle a write to NTDTBP0 (address byte, then controller TX payload).
i3c_bcst_bit_t
BCST (Bus Condition Status) flags.
@ k_i3c_bcst_bfref
Bus-free flag (bit 0): 1 == idle.
static uint32_t internal_gt911_read_point0(gt911_state_t *g, uint8_t *buf, uint32_t max)
Fill buf with one GT911 point0 record for the armed contact.
uint32_t board_periph_touch_reported(void)
Count of touch contacts the firmware has drained from the GT911 model.
i3c_periph_stim_t
Synthetic controller-write byte stream for the target-mode model.
@ k_i3c_periph_step
Per-transaction increment of that byte.
@ k_i3c_periph_seed
First byte the external controller writes.
static i2c_device_t * internal_i2c_device_find(uint8_t addr_7b)
Find the registered device answering addr_7b, or NULL.
static uint64_t internal_i3c_reg_read(uint64_t off)
Read a register from the modelled I3C/IIC_B channel.
static i2c_device_t s_i2c_dev[k_i3c_dev_max]
static void internal_board_periph_i2c_register(void)
Self-register the I3C/I2C block before main runs (decentralized).
static uint64_t internal_i3c_read(uc_engine *uc, uint64_t addr, unsigned size)
MMIO read inside the I3C/IIC_B window.
void board_periph_touch_inject(uint16_t x, uint16_t y)
Arm a pending touch contact for the modelled GT911 device.
static uint32_t internal_i3c_word(uint64_t off)
Index of the I3C shadow word for off (already range-checked).
static uint32_t internal_i3c_periph_rx_read(void)
Target-mode NTDTBP0 read: hand the firmware the written byte, go to TX.
static uint32_t internal_i3c_periph_ntst(void)
Target-mode NTST: arm a fresh controller write when idle, else reflect.
Module-private interfaces shared by the board_periph_i2c TUs.
void priv_board_i2c_imu_fuel_reset(void)
Re-lay the IMU + fuel-gauge register files (block reset path).
uint32_t priv_board_i2c_imu_reads(void)
IMU register reads answered this run (report telemetry).
void priv_board_i2c_imu_fuel_register(void)
Register the LSM6DSO + MAX17048 devices on the modelled bus.
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_gt911_read(uint16_t reg, uint8_t *buf, uint32_t len)
Read len bytes from the GT911 starting at reg.
A modelled peripheral block's self-description for the core registry.
One GoodIX GT911 touch device on the modelled I2C bus.
uint32_t reported
Contacts the firmware has drained.
uint16_t click_x
Armed contact X.
uint8_t seq_pos
Next queued point to arm.
uint16_t click_y
Armed contact Y.
uint16_t seq_y[k_gt911_seq_max]
Queued raw-point Y sequence.
bool click_pending
A contact is armed and unread.
uint8_t seq_len
Points queued in the FIFO.
uint16_t reg_ptr
Active 16-bit register pointer.
uint8_t ptr_bytes
Pointer bytes captured this write (0..2).
uint16_t seq_x[k_gt911_seq_max]
Queued raw-point X sequence.
A device on the modelled I2C bus: 7-bit address + read/write callbacks.
void(* stop)(void *ctx)
STOP/transfer end.
uint32_t(* read)(void *ctx, uint8_t *buf, uint32_t max)
Device->controller.
uint8_t addr_7b
7-bit address.
bool present
Slot occupied.
void(* write)(void *ctx, uint8_t byte)
Controller->device.
One I3C-in-I2C-mode channel: register shadow + a transfer state machine.
uint8_t periph_rx_byte
Synthetic controller-write byte for this xfer.
bool busy
True between START and STOP.
uint8_t periph_addr_7b
Own 7-bit address the firmware claimed in MSDVAD.
bool periph_echo_bad
A firmware echo did not match the written byte.
uint32_t periph_xfers
Completed controller write+read target xfers.
uint32_t rx_len
Valid bytes in rx.
uint32_t reg[k_i3c_reg_words]
Reflect-on-read register shadow.
bool acked
The addressed target ACKed.
uint32_t ntst
NTST flags (TDBEF0 / RDBFF0).
bool rx_primed
The FSP dummy first read was consumed.
uint8_t periph_phase
i3c_periph_phase_t – target-xfer position.
bool addr_done
Address phase of the current (re)START done.
uint8_t target_7b
7-bit address selected this transfer.
bool periph_mode
IIC_B opened as an addressed target (MSDVAD set).
uint32_t bst
BST flags (NACKDF / TENDF / ...).
uint32_t rx_pos
Next byte index served from rx.
uint8_t rx[k_i3c_dev_rx_max]
Staged device response for a read.
bool reading
Current transfer direction is read.