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

What sense_page.c and sense_map.c share: the SENSE set-up's checks and its taking, and the map's own helpers the SENSE page calls. More...

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

Go to the source code of this file.

Functions

static int64_t div_round (int64_t a, int64_t d)
 a / d to the nearest, halves away from zero; d positive.
static uint16_t reg_i16 (int64_t v)
 A signed register: two's complement, held to -32767 .. 32767.
static uint16_t reg_u16 (int64_t v)
 An unsigned register, held to 0 .. 65535.
uint8_t sense_cfg_check (const sense_page_t *p, const uint16_t *next, const outputs_t *o, uint64_t taken)
 A SENSE set-up next (LINK_SN_CONFIG_COUNT registers) judged as a write is: values, pins, addresses and channels; 0 or the refusal.
void sense_cfg_take (sense_page_t *p, const uint16_t *next)
 next in force: the generation moves, and every reading of the set-up before it goes (sense_page_forget()).
void sense_page_forget (sense_page_t *p)
 Every register core 1 fills, on both pages and the map's, cleared.
bool sense_map_on_addr (const uint16_t *map, uint16_t addr)
 Whether the map map fits an INA3221 at addr.
bool sense_map_watches (const sense_page_t *p)
 Whether a channel the map reads watches an output channel or a programming port: the map in force's LINK_CAP_SERVO_SENSE.
void sense_limit_judge (sense_page_t *p, const sense_snap_t *s)
 Core 1's counts of windows over each channel's limit in s into OVER and OVER_COUNT: what each gained since the last snapshot taken.
void sense_map_cfg (const uint16_t *map, sense_i3221_cfg_t *out)
 The map's kept registers as the schedule's INA3221 set-up.
void sense_map_publish (sense_page_t *p, const sense_snap_t *s)
 The snapshot's per-part state into SENSE_MAP's read-only registers, and every channel's window into SENSE_WIN_A and SENSE_WIN_B.

Detailed Description

What sense_page.c and sense_map.c share: the SENSE set-up's checks and its taking, and the map's own helpers the SENSE page calls.

Not for any other module.

SPDX-License-Identifier: MIT

Function Documentation

◆ div_round()

int64_t div_round ( int64_t a,
int64_t d )
inlinestatic

a / d to the nearest, halves away from zero; d positive.

Parameters
aThe dividend.
dThe divisor, positive.
Returns
a / d, rounded to the nearest, halves away from zero.

◆ reg_i16()

uint16_t reg_i16 ( int64_t v)
inlinestatic

A signed register: two's complement, held to -32767 .. 32767.

Parameters
vThe value in register units.
Returns
The value held to -32767 to 32767, as two's complement.

◆ reg_u16()

uint16_t reg_u16 ( int64_t v)
inlinestatic

An unsigned register, held to 0 .. 65535.

Parameters
vThe value in register units.
Returns
The value held to 0 to 65535.

◆ sense_cfg_check()

uint8_t sense_cfg_check ( const sense_page_t * p,
const uint16_t * next,
const outputs_t * o,
uint64_t taken )

A SENSE set-up next (LINK_SN_CONFIG_COUNT registers) judged as a write is: values, pins, addresses and channels; 0 or the refusal.

Not the bank's state: the caller asks that.

Parameters
pThe page.
nextThe set-up to judge, LINK_SN_CONFIG_COUNT registers.
oThe outputs model.
takenBit n: pin n is held by another page.
Returns
0, or LINK_NACK_BAD_VALUE for a refused set-up.

◆ sense_cfg_take()

void sense_cfg_take ( sense_page_t * p,
const uint16_t * next )

next in force: the generation moves, and every reading of the set-up before it goes (sense_page_forget()).

Parameters
pThe page.
nextThe set-up, LINK_SN_CONFIG_COUNT registers.

◆ sense_limit_judge()

void sense_limit_judge ( sense_page_t * p,
const sense_snap_t * s )

Core 1's counts of windows over each channel's limit in s into OVER and OVER_COUNT: what each gained since the last snapshot taken.

Parameters
pThe page.
sThe snapshot.

◆ sense_map_cfg()

void sense_map_cfg ( const uint16_t * map,
sense_i3221_cfg_t * out )

The map's kept registers as the schedule's INA3221 set-up.

Parameters
mapThe map's registers.
outReceives the INA3221 set-up of the schedule.

◆ sense_map_on_addr()

bool sense_map_on_addr ( const uint16_t * map,
uint16_t addr )

Whether the map map fits an INA3221 at addr.

Parameters
mapThe map's registers.
addrThe INA3221 address.
Returns
true when the map fits an INA3221 at addr.

◆ sense_map_publish()

void sense_map_publish ( sense_page_t * p,
const sense_snap_t * s )

The snapshot's per-part state into SENSE_MAP's read-only registers, and every channel's window into SENSE_WIN_A and SENSE_WIN_B.

Parameters
pThe page, updated in place.
sThe snapshot.

◆ sense_map_watches()

bool sense_map_watches ( const sense_page_t * p)

Whether a channel the map reads watches an output channel or a programming port: the map in force's LINK_CAP_SERVO_SENSE.

Parameters
pThe page.
Returns
true when a channel the map reads watches an output channel or a programming port.

◆ sense_page_forget()

void sense_page_forget ( sense_page_t * p)

Every register core 1 fills, on both pages and the map's, cleared.

Parameters
pThe page.