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

SENSE_LIMIT, the panel's half. See sense_limit_link.h. More...

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

Functions

void sense_limit_link_init (sense_limit_link_t *s)
 Clears the service: no link, no limits asked.
void sense_limit_link_lost (sense_limit_link_t *s)
 The link went: what was read is no longer the IOmcu's.
void sense_limit_link_came_up (sense_limit_link_t *s, uint16_t minor, uint32_t now_ms)
 An IOmcu answered.
void sense_limit_link_want (sense_limit_link_t *s, const uint16_t *ma, uint32_t now_ms)
 The limits SETUP > SENSORS asks. A change clears a refusal.
static bool any_limit (const uint16_t *ma)
 Whether any channel has a limit.
static bool owed (const sense_limit_link_t *s)
 Whether the limits wanted are owed to the page.
bool sense_limit_link_next (sense_limit_link_t *s, uint32_t now_ms, sense_limit_link_op_t *op)
 The next exchange owed.
static void take_over (sense_limit_link_t *s, uint16_t over, uint16_t count)
 Takes OVER and OVER_COUNT as a read returned them, each bit with the limit the page held, the one it was judged by.
void sense_limit_link_done (sense_limit_link_t *s, int result, const uint16_t *regs, uint32_t now_ms)
 How the exchange sense_limit_link_next() named went.
sense_limit_link_ev_t sense_limit_link_event (sense_limit_link_t *s, uint32_t now_ms, unsigned *ch, uint16_t *ma)
 The next band alert.
uint16_t sense_limit_link_held_ma (const sense_limit_link_t *s, unsigned ch)
 A channel's limit the page holds.
sense_limit_st_t sense_limit_link_status (const sense_limit_link_t *s)
 What SETUP > SENSORS shows of the limits.
uint16_t sense_limit_link_unheld (const sense_limit_link_t *s)
 The channels whose LIMIT row SETUP marks.

Detailed Description

SENSE_LIMIT, the panel's half. See sense_limit_link.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ any_limit()

bool any_limit ( const uint16_t * ma)
static

Whether any channel has a limit.

Parameters
maLINK_SL_KEPT limits in mA
Returns
true when one of them is not 0 (OFF)

◆ owed()

bool owed ( const sense_limit_link_t * s)
static

Whether the limits wanted are owed to the page.

Parameters
sthe service
Returns
true when a limit is wanted, not refused, and differs from what the page holds

◆ sense_limit_link_came_up()

void sense_limit_link_came_up ( sense_limit_link_t * s,
uint16_t minor,
uint32_t now_ms )

An IOmcu answered.

Parameters
sthe service; NULL does nothing.
minorits protocol minor; below LINK_MINOR_SENSE_LIMIT (27) the page is sent nothing.
now_msthe time, ms; a limit asked before rests from it.

◆ sense_limit_link_done()

void sense_limit_link_done ( sense_limit_link_t * s,
int result,
const uint16_t * regs,
uint32_t now_ms )

How the exchange sense_limit_link_next() named went.

Parameters
sthe service; NULL does nothing.
resultSENSE_LIMIT_LINK_ACK, a NACK's reason (LINK_NACK_*), or SENSE_LIMIT_LINK_NO_ANSWER.
regsfor an answered read, the registers it asked for; else NULL.
now_msthe time, ms.

◆ sense_limit_link_event()

sense_limit_link_ev_t sense_limit_link_event ( sense_limit_link_t * s,
uint32_t now_ms,
unsigned * ch,
uint16_t * ma )

The next band alert.

Parameters
sthe service.
now_msthe time, ms.
chfor EV_OVER the channel, 0 to 11; may be NULL.
mafor EV_OVER the limit the window was judged by, mA; may be NULL.
Returns
the alert; EV_NONE for none, for a NULL s and while the last is younger than SENSE_LIMIT_LINK_GAP_MS.

◆ sense_limit_link_held_ma()

uint16_t sense_limit_link_held_ma ( const sense_limit_link_t * s,
unsigned ch )

A channel's limit the page holds.

Parameters
sthe service.
chthe channel, 0 to 11.
Returns
the limit, mA; 0 for none, not read, or ch out of range.

◆ sense_limit_link_init()

void sense_limit_link_init ( sense_limit_link_t * s)

Clears the service: no link, no limits asked.

Parameters
sthe service; NULL does nothing.

◆ sense_limit_link_lost()

void sense_limit_link_lost ( sense_limit_link_t * s)

The link went: what was read is no longer the IOmcu's.

The limits asked stay, and OVER_COUNT as last read, for the link-up read.

Parameters
sthe service; NULL does nothing.

◆ sense_limit_link_next()

bool sense_limit_link_next ( sense_limit_link_t * s,
uint32_t now_ms,
sense_limit_link_op_t * op )

The next exchange owed.

Parameters
sthe service.
now_msthe time, ms.
opwhere the exchange goes; zeroed for none.
Returns
true for an exchange to make and report to sense_limit_link_done(); false for none, and for a NULL s or op.

◆ sense_limit_link_status()

sense_limit_st_t sense_limit_link_status ( const sense_limit_link_t * s)

What SETUP > SENSORS shows of the limits.

Parameters
sthe service.
Returns
the status; SENSE_LIMIT_ST_UNKNOWN with no link or a NULL s.

◆ sense_limit_link_unheld()

uint16_t sense_limit_link_unheld ( const sense_limit_link_t * s)

The channels whose LIMIT row SETUP marks.

Parameters
sthe service.
Returns
bit c for channel c: on an IOmcu without the page every limit asked that is not 0; else, once the page is read, every limit the page holds otherwise than asked, owed or refused. 0 with no link.

◆ sense_limit_link_want()

void sense_limit_link_want ( sense_limit_link_t * s,
const uint16_t * ma,
uint32_t now_ms )

The limits SETUP > SENSORS asks. A change clears a refusal.

Parameters
sthe service; NULL does nothing.
maLIMIT_MA[0] to [11], mA, 0 for none; above 32767 taken as
  1. NULL does nothing.
now_msthe time, ms; a change rests SENSE_LIMIT_LINK_SETTLE_MS from it.

◆ take_over()

void take_over ( sense_limit_link_t * s,
uint16_t over,
uint16_t count )
static

Takes OVER and OVER_COUNT as a read returned them, each bit with the limit the page held, the one it was judged by.

A count that moved with no bit is a reply lost, its bits with it; a count of 0 is an IOmcu that started again with no window over since.

Parameters
sthe service
overOVER, one bit a channel
countOVER_COUNT