|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
Register image conversions and the field table. More...
Macros | |
| #define | ONE(name, reg, shift, bits, access, unit, conv) |
| #define | TWO(name, lo, hi, hi_shift, hi_bits, access, unit, conv) |
| #define | UNNAMED(reg, shift, bits) |
| #define | ED KST_ACCESS_EDITABLE |
| #define | LK KST_ACCESS_LOCKED |
| #define | NV KST_ACCESS_NEVER |
| #define | REG_BIT(reg) |
Enumerations | |
| enum | { CONV_RAW = 0 , CONV_DUTY , CONV_BOOST , CONV_STRETCH , CONV_DEAD_BAND , CONV_PULSE , CONV_NEUTRAL , CONV_PROT1_TIME , CONV_PROT1_PWM , CONV_THERMO } |
| Conversions between a raw value and its displayed value. | |
Functions | |
| const kst_field_t * | kst_field (kst_field_id_t id) |
The table row of id; NULL for an id outside the table. | |
| static unsigned | part_mask (unsigned shift, unsigned bits) |
| Mask of a run of bits in one register. | |
| static unsigned | width (const kst_field_t *f) |
| Total width of a field in bits. | |
| uint16_t | kst_field_raw_max (kst_field_id_t id) |
| Largest raw value the field's bits hold; 0 for an id outside the table. | |
| uint8_t | kst_field_reg_mask (kst_field_id_t id, uint8_t reg) |
Bits of register reg that belong to id. | |
| uint16_t | kst_field_get (const kst_image_t *img, kst_field_id_t id) |
| Raw value of a field; 0 for a bad argument. | |
| bool | kst_field_set (kst_image_t *img, kst_field_id_t id, uint16_t raw) |
| Set a field's bits. | |
| bool | kst_field_edit (kst_image_t *img, kst_field_id_t id, uint16_t raw) |
| Set a field as an edit does: kst_field_set(), and for KST_F_DUTY the copy in register 0x01 as well. | |
| static int32_t | thermo (unsigned raw) |
| 1 bits upward from bit 0, up to the first 0. | |
| bool | kst_field_display (kst_field_id_t id, uint16_t raw, int32_t *display) |
| Raw value to displayed value. | |
| bool | kst_field_raw_from_display (kst_field_id_t id, int32_t display, uint16_t *raw) |
| Displayed value to the nearest raw value. | |
| kst_type_t | kst_type (const kst_image_t *img) |
The type of img; KST_TYPE_NONE for NULL. | |
| const char * | kst_type_name (kst_type_t type) |
| "V8", "V6", and "" for any other value. | |
| static void | fp_fail (kst_fingerprint_t *fp, kst_fp_rule_t rule, uint32_t regs) |
| Record a broken layout rule and the registers it concerns. | |
| bool | kst_fingerprint (const kst_image_t *img, kst_fingerprint_t *out) |
| True when the image has the measured layout. | |
Variables | |
| static const kst_field_t | k_fields [KST_F_COUNT] |
| In the order of kst_field_id_t. | |
Register image conversions and the field table.
SPDX-License-Identifier: MIT
| #define ONE | ( | name, | |
| reg, | |||
| shift, | |||
| bits, | |||
| access, | |||
| unit, | |||
| conv ) |
| #define REG_BIT | ( | reg | ) |
| #define TWO | ( | name, | |
| lo, | |||
| hi, | |||
| hi_shift, | |||
| hi_bits, | |||
| access, | |||
| unit, | |||
| conv ) |
| #define UNNAMED | ( | reg, | |
| shift, | |||
| bits ) |
| const kst_field_t * kst_field | ( | kst_field_id_t | id | ) |
The table row of id; NULL for an id outside the table.
| id | Field. |
| bool kst_field_display | ( | kst_field_id_t | id, |
| uint16_t | raw, | ||
| int32_t * | display ) |
Raw value to displayed value.
False where the displayed value of that raw value is not established: Stretch index 6 and 7.
Max. Duty round(raw x 100 / 255) % Boost 50us + 12.5us x raw Stretch 1 << index Dead Band 0.2us x (65 - raw) Pulse Lower, Pulse Upper, Uncontrolled Pos 0.8us x raw Neutral 810us + raw x 409 / 2048us, to 0.1us; the constants are a fit through 3 values and uncertain by about 1us Uncontrolled Time, prot1_time 0.1s x raw; prot1_time shown capped at 100.0s prot1_pwm round(raw x 97 / 255) % prot_pot_err, prot_pwm_err count of 1 bits upward from bit 0. The vendor tool shows 0 for registers 17 = FF, 18 = FF; here that image gives 12 SPD 0.1% x raw all others raw
| id | Field. |
| raw | Raw value. |
| display | Receives the displayed value. |
| bool kst_field_edit | ( | kst_image_t * | img, |
| kst_field_id_t | id, | ||
| uint16_t | raw ) |
Set a field as an edit does: kst_field_set(), and for KST_F_DUTY the copy in register 0x01 as well.
Both known images hold 0x01 equal to 0x02.
| img | Image to change. |
| id | Field. |
| raw | Raw value. |
| uint16_t kst_field_get | ( | const kst_image_t * | img, |
| kst_field_id_t | id ) |
Raw value of a field; 0 for a bad argument.
| img | Image to read. |
| id | Field. |
| bool kst_field_raw_from_display | ( | kst_field_id_t | id, |
| int32_t | display, | ||
| uint16_t * | raw ) |
Displayed value to the nearest raw value.
False when the value lies outside what the field encodes, when Stretch is not a power of two from 1 to 32, and for prot1_time and prot1_pwm, whose encoding on write is not observed.
| id | Field. |
| display | Displayed value. |
| raw | Receives the raw value. |
| uint16_t kst_field_raw_max | ( | kst_field_id_t | id | ) |
Largest raw value the field's bits hold; 0 for an id outside the table.
| id | Field. |
| uint8_t kst_field_reg_mask | ( | kst_field_id_t | id, |
| uint8_t | reg ) |
Bits of register reg that belong to id.
| id | Field. |
| reg | Register address. |
| bool kst_field_set | ( | kst_image_t * | img, |
| kst_field_id_t | id, | ||
| uint16_t | raw ) |
Set a field's bits.
No other bit of the image changes. False, and no change, when raw does not fit the field.
| img | Image to change. |
| id | Field. |
| raw | Raw value. |
| bool kst_fingerprint | ( | const kst_image_t * | img, |
| kst_fingerprint_t * | out ) |
True when the image has the measured layout.
out may be NULL.
| img | Image to check. |
| out | Receives the broken rules and deviating registers; may be NULL. |
| kst_type_t kst_type | ( | const kst_image_t * | img | ) |
The type of img; KST_TYPE_NONE for NULL.
| img | Image to read. |
| const char * kst_type_name | ( | kst_type_t | type | ) |
"V8", "V6", and "" for any other value.
| type | Servo type. |