rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
gt911_emu.c File Reference

The GT911 register file as an I2C target sees it (gt911_emu.h). More...

#include "gt911_emu.h"
#include <string.h>

Functions

void gt911_emu_init (gt911_emu_t *e, uint16_t res_x, uint16_t res_y)
 Clear the register file and set the resolution it reports.
static uint8_t lo (uint16_t v)
 The low byte of v.
static uint8_t hi (uint16_t v)
 The high byte of v.
uint8_t gt911_emu_peek (const gt911_emu_t *e, uint16_t reg)
 The byte at reg, as a read would return it, without side effects.
void gt911_emu_rx (gt911_emu_t *e, uint8_t b)
 The master wrote b.
uint8_t gt911_emu_tx (gt911_emu_t *e)
 The master reads a byte: the one at the pointer, which then moves on.
void gt911_emu_finish (gt911_emu_t *e)
 A STOP, a repeated START or an abort ended the transfer.
bool gt911_emu_publish (gt911_emu_t *e, const gt911_emu_frame_t *f)
 Make f the frame the master reads next.
bool gt911_emu_withdraw (gt911_emu_t *e)
 Withdraw an unacknowledged frame: the status reads 0x00.

Detailed Description

The GT911 register file as an I2C target sees it (gt911_emu.h).

SPDX-License-Identifier: MIT

Function Documentation

◆ gt911_emu_finish()

void gt911_emu_finish ( gt911_emu_t * e)

A STOP, a repeated START or an abort ended the transfer.

Parameters
eThe emulator.

◆ gt911_emu_init()

void gt911_emu_init ( gt911_emu_t * e,
uint16_t res_x,
uint16_t res_y )

Clear the register file and set the resolution it reports.

Parameters
eThe emulator.
res_xColumns.
res_yRows.

◆ gt911_emu_peek()

uint8_t gt911_emu_peek ( const gt911_emu_t * e,
uint16_t reg )

The byte at reg, as a read would return it, without side effects.

Parameters
eThe emulator.
regThe register.
Returns
The byte.

◆ gt911_emu_publish()

bool gt911_emu_publish ( gt911_emu_t * e,
const gt911_emu_frame_t * f )

Make f the frame the master reads next.

Refused while a transfer is under way or the previous frame is not yet acknowledged, so a master never reads the status of one frame and the points of another. Refused too for more than GT911_EMU_POINTS points. Point slots past f->n read 0x00.

Parameters
eThe emulator.
fThe frame.
Returns
Whether it is published.

◆ gt911_emu_rx()

void gt911_emu_rx ( gt911_emu_t * e,
uint8_t b )

The master wrote b.

Parameters
eThe emulator.
bThe byte.

◆ gt911_emu_tx()

uint8_t gt911_emu_tx ( gt911_emu_t * e)

The master reads a byte: the one at the pointer, which then moves on.

Parameters
eThe emulator.
Returns
The byte.

◆ gt911_emu_withdraw()

bool gt911_emu_withdraw ( gt911_emu_t * e)

Withdraw an unacknowledged frame: the status reads 0x00.

Parameters
eThe emulator.
Returns
False while a transfer is under way, and nothing is withdrawn.