|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The sensor bus's sampling schedule. More...
Enumerations | |
| enum | rot_t { ROT_NONE = 0 , ROT_TEMP , ROT_DIAG , ROT_ENERGY , ROT_CHARGE , ROT_ADC , ROT_FLAGS0 , ROT_CONFIG0 = ROT_FLAGS0 + SENSE_I3221_PARTS } |
| What a rotation item reads. More... | |
Functions | |
| static void | acc_clear (sense_acc_t *a) |
| Clear a window accumulator. | |
| static void | acc_current (sense_acc_t *a, sense_value_t v) |
| Add one current sample to a window accumulator. | |
| static void | acc_voltage (sense_acc_t *a, int32_t uv) |
| Add one bus voltage sample to a window accumulator. | |
| static void | acc_close (const sense_acc_t *a, uint64_t number, sense_window_t *w) |
| Close a window: write its totals from an accumulator. | |
| static void | ring_close (int32_t top, int32_t bottom, const sense_acc_t *a, sense_ring_win_t *e) |
FAST's window into a ring entry: every sample counted, a clipped one as the end of the range it read. top and bottom are the ends of FAST's range. | |
| static void | ring_push (sense_sched_t *s, uint64_t number, const sense_acc_t *a) |
Window number has closed with FAST's a, empty with no FAST: the ring moves on by as many places as numbers have passed, and the places of skipped numbers read not closed. | |
| static void | init_part (sense_sched_t *s, unsigned a) |
Part a's set-up from the map: its channels with a shunt. | |
| static bool | ch_read (const sense_sched_t *s, unsigned c) |
Whether channel c is read: its part set up and the channel on. | |
| void | sense_sched_init (sense_sched_t *s, const sense_sched_io_t *io, const sense_sched_cfg_t *cfg) |
A schedule over io for the parts cfg enables. | |
| const ina3221_t * | sense_sched_fast_part (const sense_sched_t *s) |
| FAST's INA3221, or NULL with no FAST channel. | |
| void | sense_sched_arm (sense_sched_t *s) |
| The edge into driving: the run's peaks start again and the INA228's totals are cleared on the next tick. | |
| bool | sense_sched_window (const sense_sched_t *s, unsigned src, sense_window_t *out) |
The last complete window of source src (a channel, or SENSE_SRC_INA228); false before one has closed. | |
| bool | sense_sched_ring (const sense_sched_t *s, unsigned back, sense_ring_win_t *out) |
FAST's window numbered back before the newest complete one, back under SENSE_WIN_RING; false, and out not closed, for a number that was skipped, lies before the first window, or before one has closed. | |
| static bool | i228_ok (sense_sched_t *s, sense_err_t e) |
| An INA228 transaction's result: the first failure after the clear ends the run's totals. | |
| static void | roll_windows (sense_sched_t *s, uint64_t now_ms) |
| The windows: the one being filled closes when the clock passes its end, and the next one starts empty. | |
| static uint64_t | stamp (sense_sched_t *s) |
| A read is done: its time, µs, with the windows rolled to it, so what it read goes into the window it was read in. | |
| static bool | read_ch_current (sense_sched_t *s, unsigned c, sense_value_t *v, uint64_t *at_us) |
Channel c's current into its window; true with a sample. at_us, when given, is when the read was done, sample or not. | |
| static void | read_ch_bus (sense_sched_t *s, unsigned c) |
| Read channel c's bus voltage into its window. | |
| static void | read_other (sense_sched_t *s) |
| The next channel beside FAST, in turn. | |
| static void | read_volt (sense_sched_t *s) |
| The next channel's bus voltage: every channel in turn, one that is not read leaving its turn empty, so each is read every SENSE_CHANNELS even ticks. | |
| static void | read_i228_current (sense_sched_t *s) |
| Read the INA228's current into its window and the run's peaks. | |
| static void | read_i228_vbus (sense_sched_t *s) |
| Read the INA228's bus voltage into its window and the run's minimum. | |
| static void | read_i228 (sense_sched_t *s, uint32_t n) |
The INA228's slot n: CURRENT on even ones, VBUS on odd ones. | |
| static void | verify_i228 (sense_sched_t *s) |
| The INA228's ADC_CONFIG read back. | |
| static void | verify_i3221 (sense_sched_t *s, unsigned a) |
Part a's Configuration read back. | |
| static void | read_flags (sense_sched_t *s, unsigned a) |
| Read part a's Mask/Enable flags; kept when the read succeeds. | |
| static void | read_rotation (sense_sched_t *s) |
| The next rotation item. | |
| uint16_t | sense_sched_enc_still_ms (const sense_sched_t *s) |
| How long the encoder's angle has stayed within SENSE_ENC_STILL_TOL counts of its anchor, ms, saturating at 65535; 0 with no anchor. | |
| static void | enc_anchor (sense_enc_t *e, uint16_t raw, uint64_t at_ms) |
An angle sample at at_ms: the anchor moves when the angle has left its tolerance. | |
| static void | read_enc (sense_sched_t *s) |
| The encoder's slot: STATUS and RAW ANGLE, and every SENSE_ENC_MAG_EVERY-th time the field's AGC and MAGNITUDE as well, in place of STATUS. | |
| static void | totals (sense_sched_t *s) |
| The totals: cleared once the arm owes it. | |
| void | sense_sched_tick (sense_sched_t *s) |
| One tick: every 1ms. | |
Variables | |
| static const uint8_t | k_rotation [SENSE_ROTATION] |
| The INA228's eight slots where they always were; each INA3221's Mask/Enable and Configuration 20ms apart, part 0's in the slots one part had before; four slots empty. | |
| enum rot_t |
What a rotation item reads.
An INA3221 item names its part.
|
static |
Clear a window accumulator.
| a | The accumulator. |
|
static |
Close a window: write its totals from an accumulator.
| a | The accumulator. |
| number | Number of the window. |
| w | Receives the window. |
|
static |
Add one current sample to a window accumulator.
| a | The accumulator. |
| v | The sample. |
|
static |
Add one bus voltage sample to a window accumulator.
| a | The accumulator. |
| uv | Voltage, in µV. |
|
static |
Whether channel c is read: its part set up and the channel on.
| s | The schedule. |
| c | Channel index, 0 to 11. |
|
static |
An angle sample at at_ms: the anchor moves when the angle has left its tolerance.
| e | The encoder state. |
| raw | The angle, 0 to 4095 counts. |
| at_ms | The time of the sample, in ms. |
|
static |
An INA228 transaction's result: the first failure after the clear ends the run's totals.
| s | The schedule. |
| e | The result of the transaction. |
|
static |
Part a's set-up from the map: its channels with a shunt.
| s | The schedule. |
| a | Part index, 0 to 3. |
|
static |
Read channel c's bus voltage into its window.
| s | The schedule. |
| c | Channel index, 0 to 11. |
|
static |
Channel c's current into its window; true with a sample. at_us, when given, is when the read was done, sample or not.
| s | The schedule. |
| c | Channel index, 0 to 11. |
| v | Receives the current. |
| at_us | Receives the time of the read, in µs; may be NULL. |
|
static |
The encoder's slot: STATUS and RAW ANGLE, and every SENSE_ENC_MAG_EVERY-th time the field's AGC and MAGNITUDE as well, in place of STATUS.
The angle is read in every slot, 500Hz. Each register is a transaction of its own (as5600.h).
| s | The schedule. |
|
static |
Read part a's Mask/Enable flags; kept when the read succeeds.
| s | The schedule. |
| a | Part index, 0 to 3. |
|
static |
The INA228's slot n: CURRENT on even ones, VBUS on odd ones.
| s | The schedule. |
| n | The slot number. |
|
static |
Read the INA228's current into its window and the run's peaks.
| s | The schedule. |
|
static |
Read the INA228's bus voltage into its window and the run's minimum.
| s | The schedule. |
|
static |
The next channel beside FAST, in turn.
| s | The schedule. |
|
static |
The next rotation item.
| s | The schedule. |
|
static |
The next channel's bus voltage: every channel in turn, one that is not read leaving its turn empty, so each is read every SENSE_CHANNELS even ticks.
| s | The schedule. |
|
static |
FAST's window into a ring entry: every sample counted, a clipped one as the end of the range it read. top and bottom are the ends of FAST's range.
| top | The current at the top code, in µA. |
| bottom | The current at the bottom code, in µA. |
| a | The accumulator. |
| e | Receives the ring entry. |
|
static |
Window number has closed with FAST's a, empty with no FAST: the ring moves on by as many places as numbers have passed, and the places of skipped numbers read not closed.
| s | The schedule. |
| number | Number of the window. |
| a | FAST's accumulator, or the empty one with no FAST. |
|
static |
The windows: the one being filled closes when the clock passes its end, and the next one starts empty.
In 64 bits, so the numbering runs on past the 32-bit millisecond count's wrap at 49.7 days.
| s | The schedule. |
| now_ms | The current time, in ms. |
| void sense_sched_arm | ( | sense_sched_t * | s | ) |
The edge into driving: the run's peaks start again and the INA228's totals are cleared on the next tick.
| s | The schedule. |
| uint16_t sense_sched_enc_still_ms | ( | const sense_sched_t * | s | ) |
How long the encoder's angle has stayed within SENSE_ENC_STILL_TOL counts of its anchor, ms, saturating at 65535; 0 with no anchor.
| s | The schedule. |
| const ina3221_t * sense_sched_fast_part | ( | const sense_sched_t * | s | ) |
FAST's INA3221, or NULL with no FAST channel.
| s | The schedule. |
| void sense_sched_init | ( | sense_sched_t * | s, |
| const sense_sched_io_t * | io, | ||
| const sense_sched_cfg_t * | cfg ) |
A schedule over io for the parts cfg enables.
A part whose set-up the driver refuses is left unset, never addressed, and its error kept in i228_setup or i3221_setup[a]; a FAST that names a channel off is taken as none. The bus is the caller's to open at 400kHz.
| s | The schedule to set up. |
| io | The callbacks the schedule calls. |
| cfg | The parts to enable. |
| bool sense_sched_ring | ( | const sense_sched_t * | s, |
| unsigned | back, | ||
| sense_ring_win_t * | out ) |
FAST's window numbered back before the newest complete one, back under SENSE_WIN_RING; false, and out not closed, for a number that was skipped, lies before the first window, or before one has closed.
| s | The schedule. |
| back | How many windows before the newest complete one. |
| out | Receives the window. |
| void sense_sched_tick | ( | sense_sched_t * | s | ) |
One tick: every 1ms.
| s | The schedule. |
| bool sense_sched_window | ( | const sense_sched_t * | s, |
| unsigned | src, | ||
| sense_window_t * | out ) |
The last complete window of source src (a channel, or SENSE_SRC_INA228); false before one has closed.
| s | The schedule. |
| src | The source: a channel, or SENSE_SRC_INA228. |
| out | Receives the window. |
|
static |
A read is done: its time, µs, with the windows rolled to it, so what it read goes into the window it was read in.
| s | The schedule. |
|
static |
The totals: cleared once the arm owes it.
| s | The schedule. |
|
static |
The INA228's ADC_CONFIG read back.
A part found reset is offline from here. The read-back is stamped as any read: the windows are rolled to the time it was done, and the one being filled then is emptied – it holds samples at the reset range. The voltage of the last slot pairs with no current, and the totals are no longer the run's.
| s | The schedule. |
|
static |
Part a's Configuration read back.
A part found reset is offline from here, which ends a capture on it as lost (sense_cap_step()); the windows being filled from it at the time the read-back was done are emptied.
| s | The schedule. |
| a | Part index, 0 to 3. |
|
static |
The INA228's eight slots where they always were; each INA3221's Mask/Enable and Configuration 20ms apart, part 0's in the slots one part had before; four slots empty.