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

SETUP > SENSORS: up to four INA3221 parts on the sensor bus, at 0x40 to 0x43, and per channel its shunt and what it watches. More...

#include <stdbool.h>
#include <stdint.h>
#include "link_pages.h"
#include "settings.h"

Go to the source code of this file.

Data Structures

struct  settings_sensors_map_t

Macros

#define SET_INA_FIT(a)
 The row ids: part a's FITTED, channel c's WATCHES, SHUNT and LIMIT. a is 0 to 3, c 0 to 11.
#define SET_INA_W(c)
#define SET_INA_SH(c)
#define SET_INA_LIM(c)
 Channel c's LIMIT row, 0 to 11.

Enumerations

enum  {
  SENS_W_NONE = 0 , SENS_W_OUT_1 = 1 , SENS_W_PORT_1 = 9 , SENS_W_SUPPLY = 13 ,
  SENS_W_COUNT = 14
}

Functions

const setting_def_t * settings_sensors_def (setting_id_t id)
bool settings_sensors_row (setting_id_t id)
int settings_sensors_part (setting_id_t id)
uint16_t settings_sensors_watch_code (int option)
int settings_sensors_watch_option (uint16_t code)
 The WATCHES option of a SENSE_MAP WATCH value.
uint16_t settings_sensors_limit_ma (int c)
 Channel c's LIMIT as SENSE_LIMIT's LIMIT_MA takes it.
void settings_sensors_unset (float *values)
int settings_sensors_migrate (float *values)
void settings_sensors_map (settings_sensors_map_t *m)
uint8_t settings_sensors_fast (void)
uint8_t settings_sensors_fitted (void)
uint16_t settings_sensors_meter_dmohm (void)
 The shunt of the channel the servo rail's meter reads.
uint16_t settings_sensors_dmohm (int c)
 A channel's shunt as the map carries it.

Detailed Description

SETUP > SENSORS: up to four INA3221 parts on the sensor bus, at 0x40 to 0x43, and per channel its shunt and what it watches.

Rows, in schema order: 0x40 FITTED to 0x43 FITTED, then per channel c – c = 3 a + ch - 1 for part a's channel ch, 0 to 11 – its WATCHES, its SHUNT and its LIMIT. A shunt of 0 switches the channel off; the next value up is 5.0mOhm (setting_def_t.off_below), and the top is 1000.0mOhm. What a channel watches is one of NONE, OUT 1 to OUT 8, PORT 1 to PORT 4 and SUPPLY: the output channels, the programming ports and the supply rail. LIMIT is the current a 50ms window's highest reading may reach before the band says so, 10 to 32767mA in 10mA steps on the arrows, 0 (OFF) for none: SENSE_LIMIT's LIMIT_MA (protocol 4.27), an alert only.

The map the rows make (settings_sensors_map()) is what the panel writes to the IOmcu's SENSE_MAP page (protocol 4.25), and the one INA3221 frame of SENSE (registers 8 to 10) it writes to an older IOmcu instead.

Migration. A build before SENSORS kept one INA3221 in four keys: ina3221_en, ina3221_adr, ina3221_mohm and ina3221_ch. They stay in the schema, in no category and on no screen, loaded and saved as stored, so a panel taken back to 0.21 finds its set-up. A SENSORS key the store does not hold is seeded from them at start-up, as a default is, until a save writes it (settings_sensors_migrate()):

  • FITTED: the old part's address, when the old INA3221 was on;
  • SHUNT: the old part's CH1 the old shunt, CH2 and CH3 the old shunt with CH1+2+3 and 0 (off) with CH1; every other channel 100.0mOhm;
  • WATCHES: CH1 of the old part – 0x40 while it was off – PORT n while the servo tester's target is programming port n, else OUT 1; every other channel NONE;
  • LIMIT: OFF, which 0.21 and the builds up to 0.21 had none of.

A fresh panel holds no key, and the old keys' defaults (off, 0x40, 100.0mOhm, CH1) seed the schema's defaults: nothing fitted, every shunt 100.0mOhm, 0x40 CH1 watching OUT 1.

Pure C, as settings.c is.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ SET_INA_FIT

#define SET_INA_FIT ( a)
Value:
((setting_id_t)(SET_INA_FIT_0 + (int)(a)))
setting_id_t
Every setting's id, in schema order.
Definition settings.h:67

The row ids: part a's FITTED, channel c's WATCHES, SHUNT and LIMIT. a is 0 to 3, c 0 to 11.

◆ SET_INA_LIM

#define SET_INA_LIM ( c)
Value:
@ SET_INA_CH_0
Definition settings.h:139
#define SET_INA_CH_ROWS
Definition settings.h:64

Channel c's LIMIT row, 0 to 11.

◆ SET_INA_SH

#define SET_INA_SH ( c)
Value:

◆ SET_INA_W

#define SET_INA_W ( c)
Value:

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

WATCHES' options, in their order.

Enumerator
SENS_W_OUT_1 

OUT 1 to OUT 8: 1 to 8

SENS_W_PORT_1 

PORT 1 to PORT 4: 9 to 12

Function Documentation

◆ settings_sensors_def()

const setting_def_t * settings_sensors_def ( setting_id_t id)

The schema row of id: a SENSORS row, or one of the four kept keys of 0.21; NULL for any other id.

◆ settings_sensors_dmohm()

uint16_t settings_sensors_dmohm ( int c)

A channel's shunt as the map carries it.

Parameters
cthe channel
Returns
the shunt in 0.1mOhm; 0 off

◆ settings_sensors_fast()

uint8_t settings_sensors_fast ( void )

settings_sensors_map()'s FAST: the channel watching the servo tester's target, LINK_SM_FAST_NONE for none.

◆ settings_sensors_fitted()

uint8_t settings_sensors_fitted ( void )

The fitted parts: bit a for 0x40 + a.

◆ settings_sensors_limit_ma()

uint16_t settings_sensors_limit_ma ( int c)

Channel c's LIMIT as SENSE_LIMIT's LIMIT_MA takes it.

Parameters
cthe channel, 0 to 11.
Returns
the limit, mA, at most 32767; 0 for none and for a c out of range.

◆ settings_sensors_map()

void settings_sensors_map ( settings_sensors_map_t * m)

The map the values in force make, into m. FAST is the lowest channel with a shunt on a fitted part that watches the servo tester's target: an output, OUT 1 to OUT 8, while the target is OUTPUTS, and PORT n while it is programming port n (SET_SERVO_TARGET n).

◆ settings_sensors_meter_dmohm()

uint16_t settings_sensors_meter_dmohm ( void )

The shunt of the channel the servo rail's meter reads.

Returns
FAST's shunt, else the one-part frame's (settings_sensors_map_t), in 0.1mOhm; 0 for no part fitted

◆ settings_sensors_migrate()

int settings_sensors_migrate ( float * values)

After the store is read and its values coerced: every SENSORS value still NAN seeded from the old INA3221 keys and the servo tester's target, as the file comment says. Returns how many were seeded.

◆ settings_sensors_part()

int settings_sensors_part ( setting_id_t id)

The part, 0 to 3, a SENSORS row belongs to; -1 for any other id.

◆ settings_sensors_row()

bool settings_sensors_row ( setting_id_t id)

Whether id is a SENSORS row.

◆ settings_sensors_unset()

void settings_sensors_unset ( float * values)

Before the store is read: every SENSORS value set to NAN, a value no store holds, so settings_sensors_migrate() can tell a key the store did not have. values is the model's array of SETTING_COUNT.

◆ settings_sensors_watch_code()

uint16_t settings_sensors_watch_code ( int option)

The SENSE_MAP WATCH value of WATCHES option option; NONE for one out of range.

◆ settings_sensors_watch_option()

int settings_sensors_watch_option ( uint16_t code)

The WATCHES option of a SENSE_MAP WATCH value.

Parameters
codea SENSE_MAP WATCH value.
Returns
the option, SENS_W_*; SENS_W_NONE for a value no option has.