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

The IOmcu's own pages and the output pages: IDENTITY, STATUS, CONTROL, BENCH, CHANNELS, CHAN_CFG, OUTPUTS, SERVO and PROG, and the glue that makes the silicon agree with the bank. More...

#include <string.h>
#include "iomcu.h"
#include "sense_limit.h"
#include "sense_map.h"
#include "out_store.h"
#include "outputs_pages.h"
#include "pd_uart.h"
#include "update_hw.h"

Functions

void identity_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out)
 Reads the IDENTITY page.
void control_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out)
 Reads the CONTROL page.
void status_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out)
 Reads the STATUS page.
void bench_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out)
 Reads the BENCH page.
void save_outputs (const iomcu_state_t *s)
 Asks for the output configuration to be saved.
void channels_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out)
 Reads the CHANNELS page.
uint8_t channels_write (void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
 Writes the CHANNELS page.
static bool target_sync (void)
 The tester's sweep pointed where the PROG page's TARGET says.
static void slots_rerate (void)
 The slots bound now, at the rates they run at now.
static uint8_t ports_bind (void)
 The programming ports' pins bound as the PROG page holds them: the TARGET port at the SERVO rate while it names one, every other port at PROG_PORT_RATE_HZ (prog_port_port_hz()).
void ports_apply (void)
 Makes the programming ports' pins agree with the PROG page.
void hw_apply_only (uint8_t may_bind)
 Makes the silicon agree with the bank, binding only the slots in may_bind.
void hw_apply (void)
 Makes the silicon agree with the bank, binding every slot.
static bool bank_armed (const iomcu_state_t *s)
 Armed, or asked to arm by a frame served earlier in this pass.
void chan_cfg_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out)
 Reads the CHAN_CFG page.
uint8_t chan_cfg_take (iomcu_state_t *s, const uint16_t *next, const uint16_t *slots, bool save)
 Takes a whole CHAN_CFG page into force, when it passes the checks.
uint8_t chan_cfg_write (void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
 Writes the CHAN_CFG page.
void slots_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out)
 Reads the OUTPUTS page.
void prog_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out)
 Reads the PROG page.
uint8_t prog_write (void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
 Writes the PROG page.
void servo_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out)
 Reads the SERVO page.
uint8_t servo_write (void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
 Writes the SERVO page.
uint8_t slots_take (iomcu_state_t *s, const uint16_t *next, bool save)
 Takes a whole OUTPUTS page (slots) into force, when it passes the checks.
uint8_t slots_write (void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
 Writes the OUTPUTS page.
uint8_t control_write (void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
 Writes the CONTROL page.

Detailed Description

The IOmcu's own pages and the output pages: IDENTITY, STATUS, CONTROL, BENCH, CHANNELS, CHAN_CFG, OUTPUTS, SERVO and PROG, and the glue that makes the silicon agree with the bank.

The rules are in shared/outputs and shared/safety; see iomcu.h for the other files.

SPDX-License-Identifier: MIT

Function Documentation

◆ bank_armed()

bool bank_armed ( const iomcu_state_t * s)
static

Armed, or asked to arm by a frame served earlier in this pass.

Parameters
sThe state whose CONTROL page holds the ARM register.
Returns
True when the bank is driving or the ARM register is set.

◆ bench_read()

void bench_read ( void * ctx,
uint8_t off,
uint8_t n,
uint16_t * out )

Reads the BENCH page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to read.
nNumber of registers to read.
outReceives the n register values.

◆ chan_cfg_read()

void chan_cfg_read ( void * ctx,
uint8_t off,
uint8_t n,
uint16_t * out )

Reads the CHAN_CFG page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to read.
nNumber of registers to read.
outReceives the n register values.

◆ chan_cfg_take()

uint8_t chan_cfg_take ( iomcu_state_t * s,
const uint16_t * next,
const uint16_t * slots,
bool save )

Takes a whole CHAN_CFG page into force, when it passes the checks.

Parameters
sThe state to update.
nextThe new CHAN_CFG register values.
slotsThe OUTPUTS page prepared beside next by a BIND commit, or NULL for a CHAN_CFG write.
saveTrue to save the configuration to flash.
Returns
0 to accept, or a link_nack_t to refuse. A refused page leaves the page in force unchanged.

◆ chan_cfg_write()

uint8_t chan_cfg_write ( void * ctx,
uint8_t off,
uint8_t n,
const uint16_t * in )

Writes the CHAN_CFG page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to write.
nNumber of registers to write.
inThe n register values to write.
Returns
0 to accept, or a link_nack_t to refuse.

◆ channels_read()

void channels_read ( void * ctx,
uint8_t off,
uint8_t n,
uint16_t * out )

Reads the CHANNELS page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to read.
nNumber of registers to read.
outReceives the n register values.

◆ channels_write()

uint8_t channels_write ( void * ctx,
uint8_t off,
uint8_t n,
const uint16_t * in )

Writes the CHANNELS page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to write.
nNumber of registers to write.
inThe n register values to write.
Returns
0 to accept, or a link_nack_t to refuse.

◆ control_read()

void control_read ( void * ctx,
uint8_t off,
uint8_t n,
uint16_t * out )

Reads the CONTROL page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to read.
nNumber of registers to read.
outReceives the n register values.

◆ control_write()

uint8_t control_write ( void * ctx,
uint8_t off,
uint8_t n,
const uint16_t * in )

Writes the CONTROL page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to write.
nNumber of registers to write.
inThe n register values to write.
Returns
0 to accept, or a link_nack_t to refuse.

◆ hw_apply_only()

void hw_apply_only ( uint8_t may_bind)

Makes the silicon agree with the bank, binding only the slots in may_bind.

Parameters
may_bindBit mask of the slots that may be bound. The others are released and left unbound.

◆ identity_read()

void identity_read ( void * ctx,
uint8_t off,
uint8_t n,
uint16_t * out )

Reads the IDENTITY page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to read.
nNumber of registers to read.
outReceives the n register values.

◆ ports_bind()

uint8_t ports_bind ( void )
static

The programming ports' pins bound as the PROG page holds them: the TARGET port at the SERVO rate while it names one, every other port at PROG_PORT_RATE_HZ (prog_port_port_hz()).

Never the pin the wire driver holds: it is the driver's until the KST or HITEC port gives it back, and the page keeps the port's pulse switch and target meanwhile. The pins the wire driver holds, as a mask of ports.

Returns
The programming ports whose pins the wire driver holds, one bit per port.

◆ prog_read()

void prog_read ( void * ctx,
uint8_t off,
uint8_t n,
uint16_t * out )

Reads the PROG page.

Parameters
ctxUnused.
offFirst register to read.
nNumber of registers to read.
outReceives the n register values.

◆ prog_write()

uint8_t prog_write ( void * ctx,
uint8_t off,
uint8_t n,
const uint16_t * in )

Writes the PROG page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to write.
nNumber of registers to write.
inThe n register values to write.
Returns
0 to accept, or a link_nack_t to refuse.

◆ save_outputs()

void save_outputs ( const iomcu_state_t * s)

Asks for the output configuration to be saved.

Parameters
sThe state whose output configuration is saved.

◆ servo_read()

void servo_read ( void * ctx,
uint8_t off,
uint8_t n,
uint16_t * out )

Reads the SERVO page.

Parameters
ctxUnused.
offFirst register to read.
nNumber of registers to read.
outReceives the n register values.

◆ servo_write()

uint8_t servo_write ( void * ctx,
uint8_t off,
uint8_t n,
const uint16_t * in )

Writes the SERVO page.

Parameters
ctxUnused.
offFirst register to write.
nNumber of registers to write.
inThe n register values to write.
Returns
0 to accept, or a link_nack_t to refuse.

◆ slots_read()

void slots_read ( void * ctx,
uint8_t off,
uint8_t n,
uint16_t * out )

Reads the OUTPUTS page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to read.
nNumber of registers to read.
outReceives the n register values.

◆ slots_take()

uint8_t slots_take ( iomcu_state_t * s,
const uint16_t * next,
bool save )

Takes a whole OUTPUTS page (slots) into force, when it passes the checks.

Parameters
sThe state to update.
nextThe new slot register values.
saveTrue to save the configuration to flash.
Returns
0 to accept, or a link_nack_t to refuse.

◆ slots_write()

uint8_t slots_write ( void * ctx,
uint8_t off,
uint8_t n,
const uint16_t * in )

Writes the OUTPUTS page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to write.
nNumber of registers to write.
inThe n register values to write.
Returns
0 to accept, or a link_nack_t to refuse.

◆ status_read()

void status_read ( void * ctx,
uint8_t off,
uint8_t n,
uint16_t * out )

Reads the STATUS page.

Parameters
ctxThe iomcu_state_t the page reads or writes.
offFirst register to read.
nNumber of registers to read.
outReceives the n register values.

◆ target_sync()

bool target_sync ( void )
static

The tester's sweep pointed where the PROG page's TARGET says.

A change returns the SERVO page's rate to 0 (servo_page_target()); true when that moved the rate the slots run at, which then wants the slots bound again.

Returns
True when that moved the rate the slots run at, so the slots must be bound again.