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

SENSE_WIN_A and SENSE_WIN_B, read for the log. More...

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

Macros

#define NONE   0xFFu

Functions

void sense_win_link_init (sense_win_link_t *s)
 Sets up the SENSE_WIN link state.
void sense_win_link_lost (sense_win_link_t *s)
 The link went: nothing read is the IOmcu's now.
void sense_win_link_came_up (sense_win_link_t *s, uint16_t minor)
 An IOmcu answered with protocol minor minor; below LINK_MINOR_SENSE_MAP nothing is sent to it.
void sense_win_link_want (sense_win_link_t *s, uint8_t parts)
 The parts enabled in the map the IOmcu holds, bit a for 0x40 + a: the pages to read.
bool sense_win_link_next (sense_win_link_t *s, uint32_t now_ms, sense_win_link_op_t *op)
 The next read owed at now_ms into op; false for none.
void sense_win_link_done (sense_win_link_t *s, int result, const uint16_t *regs)
 How it went: SENSE_WIN_LINK_ACK with the registers read, a NACK's reason, or SENSE_WIN_LINK_NO_ANSWER.
static bool holds (bool have, const uint16_t *r, uint16_t window)
 Whether a read r kept as have holds window window.
bool sense_win_link_window (const sense_win_link_t *s, uint16_t window, bench_chw_t *out)
 The channels whose last or previous read holds window number window into out: out->ok bit c for channel c with readings, its current and voltage flags, and the figures; every other channel 0.
void sense_win_link_ring (bench_chw_t *out, unsigned fast, const bench_state_t *b)
 FAST's channel fast (0 to 11) of out from the window ring's window that b carries in its first channel (sense_link_win_bench()): the ring holds every window of FAST, the pages only the last.

Variables

static const uint8_t k_page [2]

Detailed Description

SENSE_WIN_A and SENSE_WIN_B, read for the log.

See sense_win_link.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ holds()

bool holds ( bool have,
const uint16_t * r,
uint16_t window )
static

Whether a read r kept as have holds window window.

Parameters
havetrue when the read was kept.
rThe registers read.
windowThe window number.
Returns
true when the read holds window.

◆ sense_win_link_came_up()

void sense_win_link_came_up ( sense_win_link_t * s,
uint16_t minor )

An IOmcu answered with protocol minor minor; below LINK_MINOR_SENSE_MAP nothing is sent to it.

Parameters
sThe link state.
minorThe IOmcu's protocol minor version.

◆ sense_win_link_done()

void sense_win_link_done ( sense_win_link_t * s,
int result,
const uint16_t * regs )

How it went: SENSE_WIN_LINK_ACK with the registers read, a NACK's reason, or SENSE_WIN_LINK_NO_ANSWER.

BAD_PAGE stops the reads until the next link-up.

Parameters
sThe link state.
resultThe result: an acknowledgement, a NACK's reason or SENSE_WIN_LINK_NO_ANSWER.
regsThe registers read, or NULL for a write.

◆ sense_win_link_init()

void sense_win_link_init ( sense_win_link_t * s)

Sets up the SENSE_WIN link state.

Parameters
sThe link state to set up.

◆ sense_win_link_lost()

void sense_win_link_lost ( sense_win_link_t * s)

The link went: nothing read is the IOmcu's now.

Parameters
sThe link state.

◆ sense_win_link_next()

bool sense_win_link_next ( sense_win_link_t * s,
uint32_t now_ms,
sense_win_link_op_t * op )

The next read owed at now_ms into op; false for none.

With both pages due, a second call gives the other.

Parameters
sThe link state.
now_msThe time, in ms.
opReceives the read owed.
Returns
true when a read is owed.

◆ sense_win_link_ring()

void sense_win_link_ring ( bench_chw_t * out,
unsigned fast,
const bench_state_t * b )

FAST's channel fast (0 to 11) of out from the window ring's window that b carries in its first channel (sense_link_win_bench()): the ring holds every window of FAST, the pages only the last.

Nothing for a fast of LINK_SM_FAST_NONE or a b with no new window.

Parameters
outReceives the channels.
fastFAST's channel, 0 to 11, or LINK_SM_FAST_NONE.
bThe state that carries the window.

◆ sense_win_link_want()

void sense_win_link_want ( sense_win_link_t * s,
uint8_t parts )

The parts enabled in the map the IOmcu holds, bit a for 0x40 + a: the pages to read.

A page no longer wanted forgets its last read.

Parameters
sThe link state.
partsThe parts to read: bit a for part a.

◆ sense_win_link_window()

bool sense_win_link_window ( const sense_win_link_t * s,
uint16_t window,
bench_chw_t * out )

The channels whose last or previous read holds window number window into out: out->ok bit c for channel c with readings, its current and voltage flags, and the figures; every other channel 0.

Returns whether any channel has readings. out is always written.

Parameters
sThe link state.
windowThe window number to find.
outReceives the channels.
Returns
true when any channel has readings.

Variable Documentation

◆ k_page

const uint8_t k_page[2]
static
Initial value: