rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
sense_page_int.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <stdbool.h>
14#include <stdint.h>
15
16#include "sense_page.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
29static inline int64_t div_round(int64_t a, int64_t d)
30{
31 return (a >= 0) ? (a + d / 2) / d : -((-a + d / 2) / d);
32}
33
40static inline uint16_t reg_i16(int64_t v)
41{
42 if (v > 32767) {
43 v = 32767;
44 } else if (v < -32767) {
45 v = -32767;
46 }
47 return (uint16_t)(int16_t)v;
48}
49
56static inline uint16_t reg_u16(int64_t v)
57{
58 if (v < 0) {
59 return 0u;
60 }
61 return (v > 65535) ? 65535u : (uint16_t)v;
62}
63
76uint8_t sense_cfg_check(const sense_page_t *p, const uint16_t *next,
77 const outputs_t *o, uint64_t taken);
78
86void sense_cfg_take(sense_page_t *p, const uint16_t *next);
87
94
102bool sense_map_on_addr(const uint16_t *map, uint16_t addr);
103
111bool sense_map_watches(const sense_page_t *p);
112
120
127void sense_map_cfg(const uint16_t *map, sense_i3221_cfg_t *out);
128
137
138#ifdef __cplusplus
139}
140#endif
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition esc_stick_panel_int.h:295
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 ...
Definition sense_limit.c:82
bool sense_map_on_addr(const uint16_t *map, uint16_t addr)
Whether the map map fits an INA3221 at addr.
Definition sense_map.c:106
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.
Definition sense_map.c:317
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 L...
Definition sense_map.c:285
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 S...
Definition sense_map.c:357
void sense_page_forget(sense_page_t *p)
Every register core 1 fills, on both pages and the map's, cleared.
Definition sense_page.c:220
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_forge...
Definition sense_page.c:268
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,...
Definition sense_page.c:241
The SENSE, SERVO_SENSE and SERVO_WIN link pages at the IOmcu: the I2C bus of the two current monitors...
static int64_t div_round(int64_t a, int64_t d)
a / d to the nearest, halves away from zero; d positive.
Definition sense_page_int.h:29
static uint16_t reg_i16(int64_t v)
A signed register: two's complement, held to -32767 .. 32767.
Definition sense_page_int.h:40
static uint16_t reg_u16(int64_t v)
An unsigned register, held to 0 .. 65535.
Definition sense_page_int.h:56
The state of a bank of channels and slots.
Definition outputs.h:143
The INA3221s: which are fitted, each channel's shunt, and FAST.
Definition sense_sched.h:275
The state of the SENSE page: its three register images, the generations, the pins and the map and lim...
Definition sense_page.h:78
What core 1 hands back after each step.
Definition sense_svc.h:100