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

The SENSE_LIMIT link page at the IOmcu (protocol 4.27): a current limit for each of SENSE_MAP's 12 channels, and the channels whose window passed its limit. More...

#include <stdint.h>
#include "sense_page.h"

Go to the source code of this file.

Functions

void sense_limit_read (sense_page_t *p, uint8_t off, uint8_t n, uint16_t *out)
 A SENSE_LIMIT read from the link.
void sense_limit_peek (const sense_page_t *p, uint8_t off, uint8_t n, uint16_t *out)
 The registers as they stand, OVER kept: for a report, not the link.
uint8_t sense_limit_write (sense_page_t *p, uint8_t off, uint8_t n, const uint16_t *in)
 A SENSE_LIMIT write, judged whole.
void sense_limit_kept (const sense_page_t *p, uint16_t *kept)
 What is kept: the 12 limits into kept.
uint8_t sense_limit_restore (sense_page_t *p, const uint16_t *kept)
 Kept limits back at boot, through sense_limit_write()'s checks: 0, or the refusal, which leaves every limit 0.

Detailed Description

The SENSE_LIMIT link page at the IOmcu (protocol 4.27): a current limit for each of SENSE_MAP's 12 channels, and the channels whose window passed its limit.

The registers and the rule are in link_pages.h (LINK_SL_*); the state is the SENSE page's (sense_page_t). An alert only: nothing here stops or drives an output.

Host-tested in test_sense_limit.

SPDX-License-Identifier: MIT

Function Documentation

◆ sense_limit_kept()

void sense_limit_kept ( const sense_page_t * p,
uint16_t * kept )

What is kept: the 12 limits into kept.

Parameters
pPage state, not changed.
keptReceives LINK_SL_KEPT (12) limit values. Not checked for NULL.

◆ sense_limit_peek()

void sense_limit_peek ( const sense_page_t * p,
uint8_t off,
uint8_t n,
uint16_t * out )

The registers as they stand, OVER kept: for a report, not the link.

Nothing is done when p or out is NULL, or when off and n reach past the page.

Parameters
pPage state, not changed.
offFirst register, 0 to LINK_SL_COUNT - 1.
nNumber of registers to copy.
outReceives the n register values.

◆ sense_limit_read()

void sense_limit_read ( sense_page_t * p,
uint8_t off,
uint8_t n,
uint16_t * out )

A SENSE_LIMIT read from the link.

A read that covers OVER clears it once out holds it.

Nothing is done when p or out is NULL, or when off and n reach past the page.

Parameters
pPage state, read and cleared in place.
offFirst register, 0 to LINK_SL_COUNT - 1.
nNumber of registers to read.
outReceives the n register values.

◆ sense_limit_restore()

uint8_t sense_limit_restore ( sense_page_t * p,
const uint16_t * kept )

Kept limits back at boot, through sense_limit_write()'s checks: 0, or the refusal, which leaves every limit 0.

Parameters
pPage state, written through sense_limit_write().
keptThe LINK_SL_KEPT (12) kept limit values.
Returns
0 when all 12 limits are taken. Otherwise the refusal from sense_limit_write(): LINK_NACK_BAD_RANGE for a NULL pointer, LINK_NACK_BAD_VALUE for a limit above LINK_SL_MA_MAX.

◆ sense_limit_write()

uint8_t sense_limit_write ( sense_page_t * p,
uint8_t off,
uint8_t n,
const uint16_t * in )

A SENSE_LIMIT write, judged whole.

Refused: off the page (BAD_RANGE), reaching register 12 (READ_ONLY), a limit above 32767 (BAD_VALUE).

Taken in any bank state.

Parameters
pPage state, written only when the whole write is taken.
offFirst register, 0 to LINK_SL_COUNT - 1.
nNumber of registers to write.
inThe n new limit values, each at most LINK_SL_MA_MAX (32767).
Returns
0 when taken. LINK_NACK_BAD_RANGE for a NULL pointer or a range off the page. LINK_NACK_READ_ONLY when the range reaches register 12. LINK_NACK_BAD_VALUE when a value is above LINK_SL_MA_MAX.