|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The panel's half of the SENSE_MAP page. More...
Macros | |
| #define | STATUS_AT ((uint8_t)LINK_SM_ID_0) |
| #define | STATUS_N ((uint8_t)(LINK_SM_FLAGS - LINK_SM_ID_0 + 1)) |
Functions | |
| void | sense_map_link_init (sense_map_link_t *s) |
| Sets up the SENSE_MAP link state. | |
| static void | forget_reads (sense_map_link_t *s, uint32_t now_ms) |
| What was read and said under the map in force: news again under the next. | |
| void | sense_map_link_lost (sense_map_link_t *s) |
| The link went: nothing on the page is known. | |
| void | sense_map_link_came_up (sense_map_link_t *s, uint16_t minor, uint32_t now_ms) |
An IOmcu answered with protocol minor minor; below LINK_MINOR_SENSE_MAP nothing is sent to it. | |
| static void | raise (sense_map_link_t *s, uint8_t ev, uint8_t parts) |
| Raises an event for the parts it is about. | |
| void | sense_map_link_want (sense_map_link_t *s, const sense_map_want_t *w, uint32_t now_ms) |
| The map SENSORS asks for now. | |
| static bool | fitted_any (const sense_map_link_t *s) |
| Whether any part is enabled by the map asked or held. | |
| bool | sense_map_link_next (sense_map_link_t *s, uint32_t now_ms, bool idle, sense_map_link_op_t *op) |
The next exchange owed at now_ms into op; false for none. | |
| static unsigned | held_mirror (const sense_map_link_t *s) |
| The part SENSE reports on, by the map in force: FAST's, else the lowest fitted; 4 for none. | |
| uint16_t | sense_map_link_mirror_dmohm (const sense_map_link_t *s, unsigned ch) |
The shunt in 0.1mOhm of CH ch (1 to 3) of the part SENSE mirrors, as the page holds the map: the part SENSE's CLIPPED flag and SERVO_SENSE are about. | |
| bool | sense_map_link_waits_for_pins (const sense_map_link_t *s, const sense_link_t *sl) |
| Whether the map waits for SENSE's pins: it enables a part while SENSE has not been read since link-up or the sensor bus's pins it holds are not the ones asked. | |
| static void | judge (sense_map_link_t *s, uint32_t now_ms) |
| What a read of IDs and FLAGS says that the operator is told. | |
| static void | take_status (sense_map_link_t *s, const uint16_t *regs) |
| Takes a status read: the IDs and the FLAGS. | |
| void | sense_map_link_done (sense_map_link_t *s, int result, const uint16_t *regs, uint32_t now_ms) |
| How it went: SENSE_MAP_LINK_ACK with the registers read (NULL for a write), a NACK's reason, or SENSE_MAP_LINK_NO_ANSWER. | |
| bool | sense_map_link_page (const sense_map_link_t *s) |
| Whether the IOmcu has the page: up, 4.25 or later, and no read refused. | |
| bool | sense_map_link_held (const sense_map_link_t *s) |
| Whether the page holds the map asked: read since link-up, not refused, and nothing owed. | |
| bool | sense_map_link_in_force (const sense_map_link_t *s) |
| Whether the IOmcu goes by a map written to it, not the one derived from SENSE: FLAGS' IN_FORCE as last read, or a write taken since. | |
| bool | sense_map_link_take_reread (sense_map_link_t *s) |
| Whether a write was taken since the last call: SENSE's set-up is to be read again. | |
| uint8_t | sense_map_link_event (sense_map_link_t *s, uint32_t now_ms, uint8_t *part, uint16_t *id) |
The events since the last call, SENSE_MAP_LINK_EV_*, the lowest bit first, one at a time; 0 for none, and 0 while the last one handed out is younger than SENSE_MAP_LINK_EVENT_GAP_MS at now_ms. | |
| bool | sense_map_link_event_stands (const sense_map_link_t *s, uint8_t ev, uint8_t part) |
Whether the cause of event ev for part part still holds: the map refused, the part dark, or, for SILENT and WRONG, the part fitted on a link that answers. | |
| void | sense_map_link_event_back (sense_map_link_t *s, uint8_t ev, uint8_t part) |
| Put back an event sense_map_link_event() handed out that never reached the band, with the part it named. | |
| static sens_part_t | old_part (const sense_link_t *sl, uint32_t now_ms) |
| An IOmcu older than 4.25: the mirror part as SENSE reads it. | |
| sens_part_t | sense_map_link_part (const sense_map_link_t *s, const sense_link_t *sl, unsigned a, unsigned mirror, uint32_t now_ms) |
What fitted part a is doing at now_ms, a sens_part_t. | |
| uint16_t | sense_map_link_status (const sense_map_link_t *s, const sense_link_t *sl, unsigned mirror, uint32_t now_ms) |
| The four parts' sense_map_link_part(), 4 bits each, part 0 lowest; SENS_PART_UNKNOWN for a part not fitted. | |
Variables | |
| static const uint8_t | k_ev [4] |
|
static |
Whether any part is enabled by the map asked or held.
| s | The link state. |
|
static |
What was read and said under the map in force: news again under the next.
| s | The link state. |
| now_ms | The time, in ms. |
|
static |
The part SENSE reports on, by the map in force: FAST's, else the lowest fitted; 4 for none.
| s | The link state. |
|
static |
What a read of IDs and FLAGS says that the operator is told.
| s | The link state. |
| now_ms | The time, in ms. |
|
static |
An IOmcu older than 4.25: the mirror part as SENSE reads it.
| sl | The SENSE link. |
| now_ms | The time, in ms. |
|
static |
Raises an event for the parts it is about.
| s | The link state. |
| ev | The event bit. |
| parts | The parts the event is about, one bit each. |
| void sense_map_link_came_up | ( | sense_map_link_t * | s, |
| uint16_t | minor, | ||
| uint32_t | now_ms ) |
An IOmcu answered with protocol minor minor; below LINK_MINOR_SENSE_MAP nothing is sent to it.
| s | The link state. |
| minor | The IOmcu's protocol minor version. |
| now_ms | The time, in ms. |
| void sense_map_link_done | ( | sense_map_link_t * | s, |
| int | result, | ||
| const uint16_t * | regs, | ||
| uint32_t | now_ms ) |
How it went: SENSE_MAP_LINK_ACK with the registers read (NULL for a write), a NACK's reason, or SENSE_MAP_LINK_NO_ANSWER.
| s | The link state. |
| result | The result: an acknowledgement, a NACK's reason or SENSE_MAP_LINK_NO_ANSWER. |
| regs | The registers read, or NULL for a write. |
| now_ms | The time, in ms. |
| uint8_t sense_map_link_event | ( | sense_map_link_t * | s, |
| uint32_t | now_ms, | ||
| uint8_t * | part, | ||
| uint16_t * | id ) |
The events since the last call, SENSE_MAP_LINK_EV_*, the lowest bit first, one at a time; 0 for none, and 0 while the last one handed out is younger than SENSE_MAP_LINK_EVENT_GAP_MS at now_ms.
part is the lowest part it names, 0 to 3 (0 for REFUSED), with its ID for WRONG in id. SILENT and WRONG are handed out a part at a time.
| s | The link state. |
| now_ms | The time, in ms. |
| part | Receives the lowest part the event names, 0 to 3. |
| id | Receives the ID for WRONG. |
| void sense_map_link_event_back | ( | sense_map_link_t * | s, |
| uint8_t | ev, | ||
| uint8_t | part ) |
Put back an event sense_map_link_event() handed out that never reached the band, with the part it named.
Not once its cause is over (sense_map_link_event_stands()).
| s | The link state. |
| ev | The event, a SENSE_MAP_LINK_EV_* bit. |
| part | The part, 0 to 3. |
| bool sense_map_link_event_stands | ( | const sense_map_link_t * | s, |
| uint8_t | ev, | ||
| uint8_t | part ) |
Whether the cause of event ev for part part still holds: the map refused, the part dark, or, for SILENT and WRONG, the part fitted on a link that answers.
| s | The link state. |
| ev | The event, a SENSE_MAP_LINK_EV_* bit. |
| part | The part, 0 to 3. |
| bool sense_map_link_held | ( | const sense_map_link_t * | s | ) |
Whether the page holds the map asked: read since link-up, not refused, and nothing owed.
False on an IOmcu older than 4.25.
| s | The link state. |
| bool sense_map_link_in_force | ( | const sense_map_link_t * | s | ) |
Whether the IOmcu goes by a map written to it, not the one derived from SENSE: FLAGS' IN_FORCE as last read, or a write taken since.
False before the page is read and on an IOmcu older than 4.25.
| s | The link state. |
| void sense_map_link_init | ( | sense_map_link_t * | s | ) |
Sets up the SENSE_MAP link state.
| s | The link state to set up. |
| void sense_map_link_lost | ( | sense_map_link_t * | s | ) |
The link went: nothing on the page is known.
| s | The link state. |
| uint16_t sense_map_link_mirror_dmohm | ( | const sense_map_link_t * | s, |
| unsigned | ch ) |
The shunt in 0.1mOhm of CH ch (1 to 3) of the part SENSE mirrors, as the page holds the map: the part SENSE's CLIPPED flag and SERVO_SENSE are about.
0 without a map read, or for no such part.
| s | The link state. |
| ch | The channel, 1 to 3. |
| bool sense_map_link_next | ( | sense_map_link_t * | s, |
| uint32_t | now_ms, | ||
| bool | idle, | ||
| sense_map_link_op_t * | op ) |
The next exchange owed at now_ms into op; false for none.
The write goes only while idle.
| s | The link state. |
| now_ms | The time, in ms. |
| idle | true while the bus is idle. |
| op | Receives the exchange owed. |
| bool sense_map_link_page | ( | const sense_map_link_t * | s | ) |
Whether the IOmcu has the page: up, 4.25 or later, and no read refused.
| s | The link state. |
| sens_part_t sense_map_link_part | ( | const sense_map_link_t * | s, |
| const sense_link_t * | sl, | ||
| unsigned | a, | ||
| unsigned | mirror, | ||
| uint32_t | now_ms ) |
What fitted part a is doing at now_ms, a sens_part_t.
sl is SENSE's link, which reads the mirror part mirror (0 to 3, 0xFF none) on an IOmcu older than 4.25.
| s | The link state. |
| sl | The SENSE link. |
| a | The fitted part, 0 to 3. |
| mirror | The part SENSE mirrors, 0 to 3, or 0xFF for none. |
| now_ms | The time, in ms. |
| uint16_t sense_map_link_status | ( | const sense_map_link_t * | s, |
| const sense_link_t * | sl, | ||
| unsigned | mirror, | ||
| uint32_t | now_ms ) |
The four parts' sense_map_link_part(), 4 bits each, part 0 lowest; SENS_PART_UNKNOWN for a part not fitted.
| s | The link state. |
| sl | The SENSE link. |
| mirror | The part SENSE mirrors, 0 to 3, or 0xFF for none. |
| now_ms | The time, in ms. |
| bool sense_map_link_take_reread | ( | sense_map_link_t * | s | ) |
Whether a write was taken since the last call: SENSE's set-up is to be read again.
Cleared.
| s | The link state. |
| bool sense_map_link_waits_for_pins | ( | const sense_map_link_t * | s, |
| const sense_link_t * | sl ) |
Whether the map waits for SENSE's pins: it enables a part while SENSE has not been read since link-up or the sensor bus's pins it holds are not the ones asked.
The page judges a map against the pins it holds, so SENSE writes them first.
| s | The link state. |
| sl | The SENSE link. |
| void sense_map_link_want | ( | sense_map_link_t * | s, |
| const sense_map_want_t * | w, | ||
| uint32_t | now_ms ) |
The map SENSORS asks for now.
| s | The link state. |
| w | The map to ask for. |
| now_ms | The time, in ms. |
|
static |
Takes a status read: the IDs and the FLAGS.
| s | The link state. |
| regs | The registers read. |
|
static |