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

The programmer for servos by Hitec as the SERVO screen runs it: the session with one servo, driven step by step through the panel's half of the HITEC link page, read only. More...

#include <stdatomic.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "hitec_card.h"
#include "hitec_link.h"
#include "hitec_reg.h"
#include "hitec_session.h"
#include "link_pages.h"

Go to the source code of this file.

Data Structures

struct  hitec_prog_msg_t
 The last message, its level, its arguments and its number. More...
struct  hitec_prog_cmd_t
 One call for the task that owns the link module. More...
struct  hitec_prog_gate_t
 The pass a command needs to be carried out, as kst_prog.h's gate. More...
struct  hitec_prog_feed_t
 What the task that owns the link module publishes, every frame. More...
struct  hitec_prog_t
 The programmer's state. More...

Macros

#define HITEC_PROG_SUPPLY_MV   5000u
 The programming voltage and current until set otherwise.
#define HITEC_PROG_SUPPLY_MA   1000u
 The programming current limit until set otherwise, mA.
#define HITEC_PROG_MV_MIN   LINK_HITEC_SUPPLY_MIN_MV
 The lowest programming voltage a POWER takes, mV.
#define HITEC_PROG_MV_MAX   LINK_HITEC_SUPPLY_MAX_MV
 The highest, mV: a higher setting is taken as this one.
#define HITEC_PROG_MA_MIN   50u
 The lowest current limit a POWER takes, mA.
#define HITEC_PROG_MA_MAX   3000u
 The highest, mA: the PD mini's.
#define HITEC_PROG_PIN_LAST   47u
 The highest GPIO of the IOmcu, and a pin that is not known.
#define HITEC_PROG_NO_PIN   0xFFu
 A pin that is not known.
#define HITEC_PROG_START_MS   2000u
 A command the link's task has not answered this long is given up, ms.
#define HITEC_PROG_RUN_MS   (HITEC_LINK_RUN_MAX_MS + 5000u)
 A request without an outcome this long after its command was taken is aborted, ms: HITEC_LINK_RUN_MAX_MS and 5000ms.
#define HITEC_PROG_CARD_MS   3000u
 A write waits this long for the card to take its record, ms.
#define HITEC_RULE_BIT(r)
 The bit of rule r in a rule set.
#define HITEC_PROG_CUT_CHECK   0xFFu
 HITEC_PROG_MSG_WRITE_CUT's kind of a cut in the read-back.
#define HITEC_PROG_SLOW_PCT   30
 The speed below which SPEED asks, %.
#define HITEC_PROG_FS_FAR_US   300
 How far from 1500us a failsafe position asks, us.

Enumerations

enum  hitec_prog_state_t {
  HITEC_PROG_DOWN = 0 , HITEC_PROG_NO_PAGE , HITEC_PROG_SYNC , HITEC_PROG_PWM ,
  HITEC_PROG_OTHER , HITEC_PROG_OPENING , HITEC_PROG_ENTERING , HITEC_PROG_HELD ,
  HITEC_PROG_READING , HITEC_PROG_CLEARING , HITEC_PROG_LEAVING , HITEC_PROG_RELEASING ,
  HITEC_PROG_RECORDING , HITEC_PROG_WRITING
}
 Where the programmer is. More...
enum  hitec_prog_msg_id_t {
  HITEC_PROG_MSG_NONE = 0 , HITEC_PROG_MSG_READ , HITEC_PROG_MSG_DOWN , HITEC_PROG_MSG_NO_PAGE ,
  HITEC_PROG_MSG_BUSY , HITEC_PROG_MSG_NEED_DISARM , HITEC_PROG_MSG_STOP_LATCHED , HITEC_PROG_MSG_NEED_TARGET ,
  HITEC_PROG_MSG_NO_PIN , HITEC_PROG_MSG_RX_PENDING , HITEC_PROG_MSG_NEED_PD_C , HITEC_PROG_MSG_SUPPLY_CAPS ,
  HITEC_PROG_MSG_HELD_KST , HITEC_PROG_MSG_HELD_OTHER , HITEC_PROG_MSG_NO_C , HITEC_PROG_MSG_NO_D ,
  HITEC_PROG_MSG_ENTRY_BAD , HITEC_PROG_MSG_READ_FAIL , HITEC_PROG_MSG_NOT_IN_MODE , HITEC_PROG_MSG_STOPPED ,
  HITEC_PROG_MSG_ABORTED , HITEC_PROG_MSG_CLEARED , HITEC_PROG_MSG_UNSAFE , HITEC_PROG_MSG_LEFT ,
  HITEC_PROG_MSG_RELEASED , HITEC_PROG_MSG_SESSION_ENDED , HITEC_PROG_MSG_TIMEOUT , HITEC_PROG_MSG_NO_ANSWER ,
  HITEC_PROG_MSG_RESTARTED , HITEC_PROG_MSG_NACK , HITEC_PROG_MSG_REFUSED , HITEC_PROG_MSG_NO_LINE ,
  HITEC_PROG_MSG_SUPPLY , HITEC_PROG_MSG_UNKNOWN , HITEC_PROG_MSG_WRITTEN , HITEC_PROG_MSG_REPAIRED ,
  HITEC_PROG_MSG_RESTORED , HITEC_PROG_MSG_WRITE_OFF , HITEC_PROG_MSG_NOT_READ , HITEC_PROG_MSG_MUST_READ ,
  HITEC_PROG_MSG_NO_CHANGES , HITEC_PROG_MSG_EDITS_PENDING , HITEC_PROG_MSG_EDIT_REFUSED , HITEC_PROG_MSG_RECORD_FAILED ,
  HITEC_PROG_MSG_WRITE_CUT , HITEC_PROG_MSG_VERIFY_FAIL , HITEC_PROG_MSG_RECORD , HITEC_PROG_MSG_REC_SAME ,
  HITEC_PROG_MSG_REC_DONE , HITEC_PROG_MSG_REC_MIX , HITEC_PROG_MSG_REC_OTHER , HITEC_PROG_MSG_RECORD_HELD ,
  HITEC_PROG_MSG_FORGOTTEN , HITEC_PROG_MSG_RECORD_BAD , HITEC_PROG_MSG_SUM_OK , HITEC_PROG_MSG_COUNT
}
 What the screen says. More...
enum  hitec_prog_level_t { HITEC_PROG_INFO = 0 , HITEC_PROG_WARN , HITEC_PROG_DANGER }
 The level of a message.
enum  hitec_prog_cmd_kind_t {
  HITEC_PROG_CMD_OPEN = 0 , HITEC_PROG_CMD_STEP , HITEC_PROG_CMD_CLEAR , HITEC_PROG_CMD_CLOSE ,
  HITEC_PROG_CMD_ABORT
}
 The kinds of command for the task that owns the link module. More...
enum  hitec_prog_rule_t {
  HITEC_RULE_SPEED = 0 , HITEC_RULE_DEAD_BAND , HITEC_RULE_OVERLOAD , HITEC_RULE_END ,
  HITEC_RULE_CENTRE , HITEC_RULE_DIRECTION , HITEC_RULE_FS_FAR , HITEC_RULE_COUNT
}
 The soft rules of an edit: bit n of a rule set is rule n. More...
enum  hitec_prog_edit_t { HITEC_PROG_EDIT_OK = 0 , HITEC_PROG_EDIT_CHECK , HITEC_PROG_EDIT_REFUSED }
 What an edit came to. More...
enum  hitec_prog_rec_t {
  HITEC_PROG_REC_NONE = 0 , HITEC_PROG_REC_SAME , HITEC_PROG_REC_DONE , HITEC_PROG_REC_MIX ,
  HITEC_PROG_REC_OTHER
}
 What the servo read holds of a record. More...
enum  hitec_prog_wr_t { HITEC_PROG_WR_EDITS = 0 , HITEC_PROG_WR_REPAIR , HITEC_PROG_WR_RESTORE }
 What a write is. More...

Functions

void hitec_prog_gate_init (hitec_prog_gate_t *g)
 Sets up a gate: no pass offered.
void hitec_prog_gate_offer (hitec_prog_gate_t *g, uint32_t id)
 The pass of command id is there to be taken.
bool hitec_prog_gate_claim (hitec_prog_gate_t *g, uint32_t id)
 The link's task, with command id out of its queue.
bool hitec_prog_gate_revoke (hitec_prog_gate_t *g, uint32_t id)
 The model gives command id up.
void hitec_prog_init (hitec_prog_t *p)
 Sets up the programmer: nothing fed, D series, the default supply.
void hitec_prog_gate_set (hitec_prog_t *p, hitec_prog_gate_t *g)
 The gate the link's task claims each command at; NULL for none.
void hitec_prog_feed (hitec_prog_t *p, const hitec_prog_feed_t *f)
 The feed of this frame: answers and outcomes are taken, the session's next step goes out, and the state follows the page.
bool hitec_prog_take (hitec_prog_t *p, hitec_prog_cmd_t *out)
 The next command for the link's task.
hitec_prog_state_t hitec_prog_state (const hitec_prog_t *p)
 Where the programmer is.
void hitec_prog_bench_armed (hitec_prog_t *p, bool armed)
 The bench is armed or asked to arm.
bool hitec_prog_series_set (hitec_prog_t *p, uint8_t series)
 The series of the next CONNECT; taken in PWM only. A change of series drops what the last read found: hitec_prog_servo() and hitec_prog_model() return NULL until the next read.
uint8_t hitec_prog_series (const hitec_prog_t *p)
 The series: the session's while the port is held, else the one the next CONNECT uses.
void hitec_prog_supply_set (hitec_prog_t *p, uint16_t mv, uint16_t ma)
 The programming voltage and current limit the next CONNECT asks.
void hitec_prog_supply_caps (hitec_prog_t *p, uint16_t max_mv, uint16_t max_ma)
 The SUPPLY screen's limits, 0 for none.
uint16_t hitec_prog_mv (const hitec_prog_t *p)
 The voltage a POWER of the next CONNECT asks: the setting, at most HITEC_PROG_MV_MAX and at least HITEC_PROG_MV_MIN.
uint16_t hitec_prog_ma (const hitec_prog_t *p)
 The current limit a POWER of the next CONNECT asks, HITEC_PROG_MA_MIN to HITEC_PROG_MA_MAX.
bool hitec_prog_mv_capped (const hitec_prog_t *p)
 Whether the setting is above HITEC_PROG_MV_MAX and is taken as it.
hitec_prog_msg_id_t hitec_prog_connect (hitec_prog_t *p)
 CONNECT on the SERVO screen's programming port.
hitec_prog_msg_id_t hitec_prog_read (hitec_prog_t *p)
 READ ALL.
hitec_prog_msg_id_t hitec_prog_leave (hitec_prog_t *p)
 LEAVE: programming mode ends and the port goes back to PWM.
hitec_prog_msg_id_t hitec_prog_clear (hitec_prog_t *p)
 CLEAR the page's STOPPED flag, then the entry or the read.
void hitec_prog_abort (hitec_prog_t *p)
 ABORT the running operation; the port stays held.
hitec_prog_msg_id_t hitec_prog_release (hitec_prog_t *p)
 RELEASE PORT: CLOSE the port another session holds.
const hitec_prog_msg_t * hitec_prog_message (const hitec_prog_t *p)
 The last message.
hitec_prog_level_t hitec_prog_level (unsigned id)
 The level of message id.
uint8_t hitec_prog_port (const hitec_prog_t *p)
 The programming port the overlay names: the session's while one holds it, the held port of another session, else the tester's; 0 while the tester drives the standard outputs.
uint8_t hitec_prog_pin (const hitec_prog_t *p)
 The GPIO that port drives: the HITEC page's while it holds the line, else the PROG page's.
bool hitec_prog_precharge (const hitec_prog_t *p)
 Whether the line receives by PRECHARGE: the open line's mode while the page holds one, else the mode its next OPEN takes.
bool hitec_prog_on_port (const hitec_prog_t *p)
 Whether the SERVO screen's tester drives a programming port.
bool hitec_prog_holds_port (const hitec_prog_t *p)
 Whether the session or another one holds a port, or a request of this model is on its way: no other programmer opens and the bench takes no arm.
bool hitec_prog_port_taken (const hitec_link_readout_t *rd)
 The link task's view: the page holds a port, or a request runs.
bool hitec_prog_in_mode (const hitec_prog_t *p)
 Whether the servo is in programming mode.
bool hitec_prog_stopped (const hitec_prog_t *p)
 Whether the page's STOPPED flag is set on this panel's port.
bool hitec_prog_rail (const hitec_prog_t *p)
 Whether a PD mini answers the page (LINK_HT_F_RAIL).
const hitec_image_t * hitec_prog_servo (const hitec_prog_t *p)
 The servo as the last full read found it; NULL with none.
const hitec_model_t * hitec_prog_model (const hitec_prog_t *p)
 The model of that servo; NULL with none.
uint8_t hitec_prog_layout (const hitec_prog_t *p)
 The layout the values are decoded with: the model's, or the series' measured one before a read.
bool hitec_prog_progress (const hitec_prog_t *p, unsigned *done, unsigned *total)
 The progress of the running read.
unsigned hitec_prog_retry_code (const hitec_prog_t *p)
 The decoder's code of the last failed try of the running transaction, while it goes again.
const hitec_image_t * hitec_prog_draft (const hitec_prog_t *p)
 The draft: the servo read with the edits; NULL with no servo read.
bool hitec_prog_can_edit (const hitec_prog_t *p)
 Whether an edit is taken now: the port held and idle, the servo in programming mode and read, the port not stopped.
bool hitec_prog_editable (const hitec_prog_t *p, uint8_t id)
 Whether parameter id of the servo's layout takes an edit.
hitec_prog_edit_t hitec_prog_edit (hitec_prog_t *p, uint8_t id, int32_t value)
 Edit the draft: value in the unit of parameter id.
uint16_t hitec_prog_pending (const hitec_prog_t *p, uint8_t *id, int32_t *value)
 The edit that waits for a confirmation.
hitec_prog_edit_t hitec_prog_confirm (hitec_prog_t *p)
 Take the edit that waits: its rules are confirmed for its value.
void hitec_prog_cancel (hitec_prog_t *p)
 Drop the edit that waits; the draft stays as it was.
uint16_t hitec_prog_rules (const hitec_prog_t *p, uint8_t id, int32_t value)
 The soft rules value of parameter id breaks against the servo read.
bool hitec_prog_differs (const hitec_prog_t *p, const hitec_image_t *img, uint8_t id)
 Whether parameter id differs in img from the servo read: in its decoded value or in its stored value.
unsigned hitec_prog_changes (const hitec_prog_t *p)
 The writable parameters in which the draft differs from the servo read.
void hitec_prog_discard (hitec_prog_t *p)
 DISCARD EDITS: the draft is the servo read again, and every confirmation ends.
hitec_prog_msg_id_t hitec_prog_write_enable (hitec_prog_t *p, bool on)
 ENABLE WRITE TO SERVO.
bool hitec_prog_write_on (const hitec_prog_t *p)
 Whether ENABLE WRITE TO SERVO is on.
hitec_prog_msg_id_t hitec_prog_write_gate (const hitec_prog_t *p, uint8_t kind)
 Why a write of kind is not taken now, the switch included.
hitec_prog_msg_id_t hitec_prog_write (hitec_prog_t *p)
 WRITE n VALUES: the draft to the servo, then its read-back.
bool hitec_prog_sum_bad (const hitec_prog_t *p)
 Whether the classic servo read has cells 0x00 to 0x1C that do not sum to 0.
hitec_prog_msg_id_t hitec_prog_repair (hitec_prog_t *p)
 REPAIR: the classic balance 0x1C alone, then the read-back.
bool hitec_prog_first_done (const hitec_prog_t *p)
 Whether the first write of this CONNECT has gone out.
bool hitec_prog_write_progress (const hitec_prog_t *p, unsigned *done, unsigned *total, uint8_t *kind)
 The progress of the running write.
bool hitec_prog_record (const hitec_prog_t *p)
 Whether a record of a write stands.
hitec_prog_rec_t hitec_prog_record_verdict (const hitec_prog_t *p)
 What the last servo read holds of the record.
hitec_prog_msg_id_t hitec_prog_restore (hitec_prog_t *p)
 RESTORE: the values before the recorded write back to the servo, as a write; the record stays until it ends verified.
bool hitec_prog_restore_image (const hitec_prog_t *p, hitec_image_t *out)
 The image RESTORE writes: the servo read with the record's values before the write.
hitec_prog_msg_id_t hitec_prog_forget (hitec_prog_t *p)
 FORGET: discard the record without a write.
bool hitec_prog_file_due (const hitec_prog_t *p)
 Whether the record's text is to go to the card.
size_t hitec_prog_file_take (hitec_prog_t *p, char *out, size_t n)
 The record's text for the card: fill out and return its length; 0 while none is due, no card is mounted or n is under HITEC_CARD_TEXT_MAX.
void hitec_prog_file_done (hitec_prog_t *p, bool ok)
 How the card took the text hitec_prog_file_take() gave.
bool hitec_prog_file_load (hitec_prog_t *p, const char *text, size_t len)
 The record's text as the card held it at the start.

Detailed Description

The programmer for servos by Hitec as the SERVO screen runs it: the session with one servo, driven step by step through the panel's half of the HITEC link page, read only.

Hitec is a name or trademark of its owner; it is used here only to say which servos this module works with.

The session runs on the panel (protocols/hitec/include/hitec_session.h): this model holds it, hands each of its steps to the task that owns the link module (hitec_link.h) as a command, and feeds each outcome back. The IOmcu's page runs one raw transaction at a time and holds no session (shared/outputs/hitec_port.h).

What it does:

  • CONNECT takes the SERVO screen's programming port from PWM (OPEN), enters programming mode for the series the operator chose (classic HS-5xxx and HS-7xxx, or D series) and reads the series' full set. It is refused, and nothing is sent, on an ARMED bench or one asked to arm, with STOP latched, with the tester on the standard outputs, with no pin on the port, on an IOmcu without the page, for a D series line whose receive mode is not held yet, for a classic servo with no PD mini answering (classic serial mode starts only at power-up), and with a programming voltage or current above the SUPPLY limits.
  • READ ALL reads the full set again: 21 D series registers, or 100 classic cells. The model is identified from what was read.
  • LEAVE ends programming mode (a D series reboot, a classic supply cycle) and gives the port back to PWM (CLOSE), also after a STOP.
  • CLEAR clears the page's STOPPED flag and goes on: the entry again where the supply went off, or the read. It is refused while STOP is latched at the panel: the heartbeat is withheld until a switch to ARMED, and the IOmcu would refuse the CLEAR as UNSAFE.
  • ABORT ends the running operation; the port stays held.
  • RELEASE PORT closes a port the page holds and this panel did not open: one the bench console opened, or one held over a panel restart or a link loss. The supply stays as it is.

Writing (hitec_prog_write.c):

  • The values are edited in a draft (hitec_prog_edit()) through the parameter table of hitec_reg.h: a value no step of its encoding gives is refused, a value that breaks a soft rule (hitec_prog_rule_t) waits for a confirmation. A rule confirmed for a value is asked again for a value further from the servo's, or on its other side. A write, a read and DISCARD EDITS end every confirmation.
  • The switch ENABLE WRITE TO SERVO is off at every CONNECT and LEAVE, when the link goes, at a stop, after a write that did not end verified, and when a read finds other values than the ones held. The caller switches it off at every entry of the screen.
  • WRITE n VALUES runs hitec_session_write(): D series writes 20ms apart, the save, 100ms, the reboot, 1000ms, the read-back; classic per cell the value, then the balance 0x1C, then the read-back of cells 0x00 to 0x23. It is refused on an ARMED bench, with STOP latched, on a STOPPED port, with no servo read, with the switch off and while a record of an earlier write stands.
  • REPAIR writes the classic balance 0x1C alone when the cells 0x00 to 0x1C of the servo read do not sum to 0.
  • The record (hitec_card.h): before the first step of a write the servo's values, the target and the port are recorded, with a card in its file as well, and the write waits for the card. A write that ends verified clears it. A record that stands is compared with the next full read (hitec_prog_rec_t); RESTORE writes the values before the write back, and FORGET discards the record.
  • A write that fails once a step went out leaves what the servo holds unknown: READ ALL comes before the next write.

Every model is written: the D series with the HFP-30's registers, the classic servos with the HPP-21 Plus's cells (hitec_reg.h).

The programming voltage is the SERVO programmer's setting; the page takes LINK_HITEC_SUPPLY_MIN_MV to LINK_HITEC_SUPPLY_MAX_MV for a POWER, so a higher one is taken as LINK_HITEC_SUPPLY_MAX_MV (hitec_prog_mv()).

Every refusal, outcome and session result becomes one message (hitec_prog_msg_id_t) the screen has a text for.

Pure C. The caller hands in hitec_prog_feed_t every frame and carries out the commands hitec_prog_take() gives. One task only.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ HITEC_RULE_BIT

#define HITEC_RULE_BIT ( r)
Value:
((uint16_t)(1u << (r)))

The bit of rule r in a rule set.

Enumeration Type Documentation

◆ hitec_prog_cmd_kind_t

The kinds of command for the task that owns the link module.

Enumerator
HITEC_PROG_CMD_OPEN 

hitec_link_open()

HITEC_PROG_CMD_STEP 

hitec_link_step()

HITEC_PROG_CMD_CLEAR 

hitec_link_clear()

HITEC_PROG_CMD_CLOSE 

hitec_link_close()

HITEC_PROG_CMD_ABORT 

hitec_link_abort(); answered by none

◆ hitec_prog_edit_t

What an edit came to.

Enumerator
HITEC_PROG_EDIT_OK 

the draft holds it

HITEC_PROG_EDIT_CHECK 

it waits for CHECK THIS CHANGE

HITEC_PROG_EDIT_REFUSED 

refused; the message says why

◆ hitec_prog_msg_id_t

What the screen says.

Enumerator
HITEC_PROG_MSG_READ 

read; arg the D series model number, reg the D series ID or the classic version

HITEC_PROG_MSG_DOWN 

no IOmcu answers

HITEC_PROG_MSG_NO_PAGE 

the IOmcu has no HITEC page

HITEC_PROG_MSG_BUSY 

another operation runs

HITEC_PROG_MSG_NEED_DISARM 

ARMED or asked to arm

HITEC_PROG_MSG_STOP_LATCHED 

STOP is latched at the panel

HITEC_PROG_MSG_NEED_TARGET 

the tester drives the standard outputs

HITEC_PROG_MSG_NO_PIN 

the port has no pin

HITEC_PROG_MSG_RX_PENDING 

the D series receive mode is not held by the IOmcu yet

HITEC_PROG_MSG_NEED_PD_C 

classic, and no PD mini answers

HITEC_PROG_MSG_SUPPLY_CAPS 

the programming voltage or current is above the SUPPLY limits

HITEC_PROG_MSG_HELD_KST 

the KST page holds the port

HITEC_PROG_MSG_HELD_OTHER 

the page holds a port this panel did not open; arg its port

HITEC_PROG_MSG_NO_C 

no classic servo answered

HITEC_PROG_MSG_NO_D 

no D series servo answered

HITEC_PROG_MSG_ENTRY_BAD 

bytes came that do not fit the series' entry

HITEC_PROG_MSG_READ_FAIL 

a read failed on every try; arg the address

HITEC_PROG_MSG_NOT_IN_MODE 

no servo is in programming mode

HITEC_PROG_MSG_STOPPED 

a stop cut the operation

HITEC_PROG_MSG_ABORTED 

ABORT ended it

HITEC_PROG_MSG_CLEARED 

CLEAR was taken

HITEC_PROG_MSG_UNSAFE 

refused: the IOmcu trusts neither heartbeat nor link

HITEC_PROG_MSG_LEFT 

the port is back in PWM

HITEC_PROG_MSG_RELEASED 

another's port closed; arg its port

HITEC_PROG_MSG_SESSION_ENDED 

the port went back to PWM with no command of this model

HITEC_PROG_MSG_TIMEOUT 

no answer or no outcome in time

HITEC_PROG_MSG_NO_ANSWER 

the link did not answer

HITEC_PROG_MSG_RESTARTED 

the IOmcu started again, or another writer sent a command

HITEC_PROG_MSG_NACK 

a frame refused; arg the reason

HITEC_PROG_MSG_REFUSED 

refused for a reason with no message of its own; arg link_hitec_refusal_t

HITEC_PROG_MSG_NO_LINE 

OPEN: the IOmcu found no free line

HITEC_PROG_MSG_SUPPLY 

POWER: the supply did not switch

HITEC_PROG_MSG_UNKNOWN 

a code the tables do not hold; arg the code

HITEC_PROG_MSG_WRITTEN 

a write verified; arg the values

HITEC_PROG_MSG_REPAIRED 

the classic balance written

HITEC_PROG_MSG_RESTORED 

the record's values written back

HITEC_PROG_MSG_WRITE_OFF 

the write switch is off

HITEC_PROG_MSG_NOT_READ 

no servo read

HITEC_PROG_MSG_MUST_READ 

a write failed: READ ALL first

HITEC_PROG_MSG_NO_CHANGES 

the draft is the servo's

HITEC_PROG_MSG_EDITS_PENDING 

edits not written stand

HITEC_PROG_MSG_EDIT_REFUSED 

an edit refused; arg hitec_set_t

HITEC_PROG_MSG_RECORD_FAILED 

the card took no record; nothing was written

HITEC_PROG_MSG_WRITE_CUT 

a write ended after a step went out; arg the address (a balance: the cell it balances), reg the hitec_step_kind_t of the step out or HITEC_PROG_CUT_CHECK

HITEC_PROG_MSG_VERIFY_FAIL 

the read-back differs; arg the addresses that differ

HITEC_PROG_MSG_RECORD 

a record stands, not compared yet; arg its pin, reg its port

HITEC_PROG_MSG_REC_SAME 

the servo holds the values before the recorded write; as RECORD

HITEC_PROG_MSG_REC_DONE 

it holds the write's values

HITEC_PROG_MSG_REC_MIX 

it holds both

HITEC_PROG_MSG_REC_OTHER 

it is another servo; as RECORD

HITEC_PROG_MSG_RECORD_HELD 

a write refused: a record stands

HITEC_PROG_MSG_FORGOTTEN 

the record discarded

HITEC_PROG_MSG_RECORD_BAD 

the card's record does not read; arg hitec_card_result_t

HITEC_PROG_MSG_SUM_OK 

REPAIR refused: the sum is right

◆ hitec_prog_rec_t

What the servo read holds of a record.

Enumerator
HITEC_PROG_REC_NONE 

no record, or not compared

HITEC_PROG_REC_SAME 

the values before the write

HITEC_PROG_REC_DONE 

the values the write was to leave

HITEC_PROG_REC_MIX 

some of each

HITEC_PROG_REC_OTHER 

another servo: another series, port, model, or a value that is neither

◆ hitec_prog_rule_t

The soft rules of an edit: bit n of a rule set is rule n.

Enumerator
HITEC_RULE_SPEED 

SPEED below 30%

HITEC_RULE_DEAD_BAND 

DEAD BAND below the servo's

HITEC_RULE_OVERLOAD 

OVERLOAD PROTECTION switched off

HITEC_RULE_END 

an end point differs from the servo's

HITEC_RULE_CENTRE 

NEUTRAL or CENTRE differs from it

HITEC_RULE_DIRECTION 

DIRECTION reversed

HITEC_RULE_FS_FAR 

a failsafe position more than 300us from 1500us

◆ hitec_prog_state_t

Where the programmer is.

Enumerator
HITEC_PROG_DOWN 

no IOmcu answers

HITEC_PROG_NO_PAGE 

the IOmcu has no HITEC page

HITEC_PROG_SYNC 

the page has not been read yet

HITEC_PROG_PWM 

the page holds no port: the tester has it

HITEC_PROG_OTHER 

the page holds a port this panel did not open

HITEC_PROG_OPENING 

OPEN is on its way

HITEC_PROG_ENTERING 

the entry into programming mode runs

HITEC_PROG_HELD 

the port is this panel's, nothing runs

HITEC_PROG_READING 

a read runs

HITEC_PROG_CLEARING 

CLEAR is on its way

HITEC_PROG_LEAVING 

the leave runs, then CLOSE

HITEC_PROG_RELEASING 

CLOSE of another's port is on its way

HITEC_PROG_RECORDING 

a write waits for the card's record

HITEC_PROG_WRITING 

a write runs, with its read-back

◆ hitec_prog_wr_t

What a write is.

Enumerator
HITEC_PROG_WR_EDITS 

WRITE n VALUES

HITEC_PROG_WR_REPAIR 

REPAIR: the classic balance

HITEC_PROG_WR_RESTORE 

the record's values back

Function Documentation

◆ hitec_prog_abort()

void hitec_prog_abort ( hitec_prog_t * p)

ABORT the running operation; the port stays held.

Parameters
pThe programmer.

◆ hitec_prog_bench_armed()

void hitec_prog_bench_armed ( hitec_prog_t * p,
bool armed )

The bench is armed or asked to arm.

Parameters
pThe programmer.
armedtrue while it is.

◆ hitec_prog_can_edit()

bool hitec_prog_can_edit ( const hitec_prog_t * p)

Whether an edit is taken now: the port held and idle, the servo in programming mode and read, the port not stopped.

Parameters
pThe programmer.
Returns
true when it is.

◆ hitec_prog_cancel()

void hitec_prog_cancel ( hitec_prog_t * p)

Drop the edit that waits; the draft stays as it was.

Parameters
pThe programmer.

◆ hitec_prog_changes()

unsigned hitec_prog_changes ( const hitec_prog_t * p)

The writable parameters in which the draft differs from the servo read.

Parameters
pThe programmer.
Returns
The count; 0 with no servo read.

◆ hitec_prog_clear()

hitec_prog_msg_id_t hitec_prog_clear ( hitec_prog_t * p)

CLEAR the page's STOPPED flag, then the entry or the read.

Parameters
pThe programmer.
Returns
HITEC_PROG_MSG_NONE when it starts, else the message said.

◆ hitec_prog_confirm()

hitec_prog_edit_t hitec_prog_confirm ( hitec_prog_t * p)

Take the edit that waits: its rules are confirmed for its value.

Parameters
pThe programmer.
Returns
What the edit came to; HITEC_PROG_EDIT_REFUSED with none waiting.

◆ hitec_prog_connect()

hitec_prog_msg_id_t hitec_prog_connect ( hitec_prog_t * p)

CONNECT on the SERVO screen's programming port.

Parameters
pThe programmer.
Returns
HITEC_PROG_MSG_NONE when it starts, else the message said.

◆ hitec_prog_differs()

bool hitec_prog_differs ( const hitec_prog_t * p,
const hitec_image_t * img,
uint8_t id )

Whether parameter id differs in img from the servo read: in its decoded value or in its stored value.

Parameters
pThe programmer.
imgThe image; the draft for NULL.
idhitec_param_t.
Returns
true when it differs.

◆ hitec_prog_discard()

void hitec_prog_discard ( hitec_prog_t * p)

DISCARD EDITS: the draft is the servo read again, and every confirmation ends.

Parameters
pThe programmer.

◆ hitec_prog_draft()

const hitec_image_t * hitec_prog_draft ( const hitec_prog_t * p)

The draft: the servo read with the edits; NULL with no servo read.

Parameters
pThe programmer.
Returns
The draft.

◆ hitec_prog_edit()

hitec_prog_edit_t hitec_prog_edit ( hitec_prog_t * p,
uint8_t id,
int32_t value )

Edit the draft: value in the unit of parameter id.

A value equal to the draft's changes nothing. A value hitec_param_set() refuses is refused (HITEC_PROG_MSG_EDIT_REFUSED, arg its hitec_set_t). A value that breaks a soft rule not confirmed for it waits: hitec_prog_pending() names it, hitec_prog_confirm() takes it, hitec_prog_cancel() drops it.

Parameters
pThe programmer.
idhitec_param_t.
valueThe value.
Returns
What the edit came to.

◆ hitec_prog_editable()

bool hitec_prog_editable ( const hitec_prog_t * p,
uint8_t id )

Whether parameter id of the servo's layout takes an edit.

Parameters
pThe programmer.
idhitec_param_t.
Returns
true for a writable parameter of the layout.

◆ hitec_prog_feed()

void hitec_prog_feed ( hitec_prog_t * p,
const hitec_prog_feed_t * f )

The feed of this frame: answers and outcomes are taken, the session's next step goes out, and the state follows the page.

Parameters
pThe programmer.
fThe feed.

◆ hitec_prog_file_done()

void hitec_prog_file_done ( hitec_prog_t * p,
bool ok )

How the card took the text hitec_prog_file_take() gave.

Only the answer to the text that holds the record of the write waiting in HITEC_PROG_RECORDING releases that write, or ends it when the card refused the text. The answer to a text taken before that write began, the record of an aborted or timed-out write or the text that clears a record, only frees the card for the next text.

Parameters
pThe programmer.
oktrue when the card holds it whole.

◆ hitec_prog_file_due()

bool hitec_prog_file_due ( const hitec_prog_t * p)

Whether the record's text is to go to the card.

Parameters
pThe programmer.
Returns
true while one is due and none is out.

◆ hitec_prog_file_load()

bool hitec_prog_file_load ( hitec_prog_t * p,
const char * text,
size_t len )

The record's text as the card held it at the start.

Parameters
pThe programmer.
textThe text.
lenIts length in bytes.
Returns
false, with HITEC_PROG_MSG_RECORD_BAD, for a text that does not parse.

◆ hitec_prog_file_take()

size_t hitec_prog_file_take ( hitec_prog_t * p,
char * out,
size_t n )

The record's text for the card: fill out and return its length; 0 while none is due, no card is mounted or n is under HITEC_CARD_TEXT_MAX.

Parameters
pThe programmer.
outReceives the text.
nBytes at out.
Returns
The length.

◆ hitec_prog_first_done()

bool hitec_prog_first_done ( const hitec_prog_t * p)

Whether the first write of this CONNECT has gone out.

Parameters
pThe programmer.
Returns
true after it.

◆ hitec_prog_forget()

hitec_prog_msg_id_t hitec_prog_forget ( hitec_prog_t * p)

FORGET: discard the record without a write.

Parameters
pThe programmer.
Returns
HITEC_PROG_MSG_NONE when taken; BUSY while a write runs.

◆ hitec_prog_gate_claim()

bool hitec_prog_gate_claim ( hitec_prog_gate_t * g,
uint32_t id )

The link's task, with command id out of its queue.

Parameters
gThe gate.
idThe command's id.
Returns
true when the command is to be carried out; false: it is dropped, with no answer.

◆ hitec_prog_gate_init()

void hitec_prog_gate_init ( hitec_prog_gate_t * g)

Sets up a gate: no pass offered.

Parameters
gThe gate.

◆ hitec_prog_gate_offer()

void hitec_prog_gate_offer ( hitec_prog_gate_t * g,
uint32_t id )

The pass of command id is there to be taken.

Parameters
gThe gate.
idThe command's id.

◆ hitec_prog_gate_revoke()

bool hitec_prog_gate_revoke ( hitec_prog_gate_t * g,
uint32_t id )

The model gives command id up.

Parameters
gThe gate.
idThe command's id.
Returns
true when the command is not carried out and never is.

◆ hitec_prog_gate_set()

void hitec_prog_gate_set ( hitec_prog_t * p,
hitec_prog_gate_t * g )

The gate the link's task claims each command at; NULL for none.

With none, a command nobody answers within HITEC_PROG_START_MS counts as one that may have run: an ABORT follows it.

Parameters
pThe programmer.
gThe gate.

◆ hitec_prog_holds_port()

bool hitec_prog_holds_port ( const hitec_prog_t * p)

Whether the session or another one holds a port, or a request of this model is on its way: no other programmer opens and the bench takes no arm.

Parameters
pThe programmer.
Returns
true while held.

◆ hitec_prog_in_mode()

bool hitec_prog_in_mode ( const hitec_prog_t * p)

Whether the servo is in programming mode.

Parameters
pThe programmer.
Returns
true after an entry, until a leave.

◆ hitec_prog_init()

void hitec_prog_init ( hitec_prog_t * p)

Sets up the programmer: nothing fed, D series, the default supply.

Parameters
pThe programmer.

◆ hitec_prog_layout()

uint8_t hitec_prog_layout ( const hitec_prog_t * p)

The layout the values are decoded with: the model's, or the series' measured one before a read.

Parameters
pThe programmer.
Returns
hitec_layout_t.

◆ hitec_prog_leave()

hitec_prog_msg_id_t hitec_prog_leave ( hitec_prog_t * p)

LEAVE: programming mode ends and the port goes back to PWM.

Taken while the port is this panel's and nothing runs, STOPPED or not.

Parameters
pThe programmer.
Returns
HITEC_PROG_MSG_NONE when it starts, else the message said.

◆ hitec_prog_level()

hitec_prog_level_t hitec_prog_level ( unsigned id)

The level of message id.

Parameters
idhitec_prog_msg_id_t.
Returns
hitec_prog_level_t.

◆ hitec_prog_ma()

uint16_t hitec_prog_ma ( const hitec_prog_t * p)

The current limit a POWER of the next CONNECT asks, HITEC_PROG_MA_MIN to HITEC_PROG_MA_MAX.

Parameters
pThe programmer.
Returns
mA.

◆ hitec_prog_message()

const hitec_prog_msg_t * hitec_prog_message ( const hitec_prog_t * p)

The last message.

Parameters
pThe programmer.
Returns
The message.

◆ hitec_prog_model()

const hitec_model_t * hitec_prog_model ( const hitec_prog_t * p)

The model of that servo; NULL with none.

Parameters
pThe programmer.
Returns
The model.

◆ hitec_prog_mv()

uint16_t hitec_prog_mv ( const hitec_prog_t * p)

The voltage a POWER of the next CONNECT asks: the setting, at most HITEC_PROG_MV_MAX and at least HITEC_PROG_MV_MIN.

Parameters
pThe programmer.
Returns
mV.

◆ hitec_prog_mv_capped()

bool hitec_prog_mv_capped ( const hitec_prog_t * p)

Whether the setting is above HITEC_PROG_MV_MAX and is taken as it.

Parameters
pThe programmer.
Returns
true when capped.

◆ hitec_prog_on_port()

bool hitec_prog_on_port ( const hitec_prog_t * p)

Whether the SERVO screen's tester drives a programming port.

Parameters
pThe programmer.
Returns
true when it does.

◆ hitec_prog_pending()

uint16_t hitec_prog_pending ( const hitec_prog_t * p,
uint8_t * id,
int32_t * value )

The edit that waits for a confirmation.

Parameters
pThe programmer.
idReceives its hitec_param_t; may be NULL.
valueReceives its value; may be NULL.
Returns
Its rule set; 0 with none waiting.

◆ hitec_prog_pin()

uint8_t hitec_prog_pin ( const hitec_prog_t * p)

The GPIO that port drives: the HITEC page's while it holds the line, else the PROG page's.

Parameters
pThe programmer.
Returns
The pin, HITEC_PROG_NO_PIN when not known.

◆ hitec_prog_port()

uint8_t hitec_prog_port ( const hitec_prog_t * p)

The programming port the overlay names: the session's while one holds it, the held port of another session, else the tester's; 0 while the tester drives the standard outputs.

Parameters
pThe programmer.
Returns
The port, from 0.

◆ hitec_prog_port_taken()

bool hitec_prog_port_taken ( const hitec_link_readout_t * rd)

The link task's view: the page holds a port, or a request runs.

Parameters
rdThe module's readout.
Returns
true while the bench takes no arm and no supply change.

◆ hitec_prog_precharge()

bool hitec_prog_precharge ( const hitec_prog_t * p)

Whether the line receives by PRECHARGE: the open line's mode while the page holds one, else the mode its next OPEN takes.

Parameters
pThe programmer.
Returns
true for PRECHARGE.

◆ hitec_prog_progress()

bool hitec_prog_progress ( const hitec_prog_t * p,
unsigned * done,
unsigned * total )

The progress of the running read.

Parameters
pThe programmer.
doneReceives the addresses read.
totalReceives the addresses it reads.
Returns
true while a read runs.

◆ hitec_prog_rail()

bool hitec_prog_rail ( const hitec_prog_t * p)

Whether a PD mini answers the page (LINK_HT_F_RAIL).

Parameters
pThe programmer.
Returns
true when one does.

◆ hitec_prog_read()

hitec_prog_msg_id_t hitec_prog_read ( hitec_prog_t * p)

READ ALL.

Parameters
pThe programmer.
Returns
HITEC_PROG_MSG_NONE when it starts, else the message said.

◆ hitec_prog_record()

bool hitec_prog_record ( const hitec_prog_t * p)

Whether a record of a write stands.

Parameters
pThe programmer.
Returns
true when one does.

◆ hitec_prog_record_verdict()

hitec_prog_rec_t hitec_prog_record_verdict ( const hitec_prog_t * p)

What the last servo read holds of the record.

Parameters
pThe programmer.
Returns
hitec_prog_rec_t; HITEC_PROG_REC_NONE while not compared.

◆ hitec_prog_release()

hitec_prog_msg_id_t hitec_prog_release ( hitec_prog_t * p)

RELEASE PORT: CLOSE the port another session holds.

Parameters
pThe programmer.
Returns
HITEC_PROG_MSG_NONE when it starts, else the message said.

◆ hitec_prog_repair()

hitec_prog_msg_id_t hitec_prog_repair ( hitec_prog_t * p)

REPAIR: the classic balance 0x1C alone, then the read-back.

Parameters
pThe programmer.
Returns
HITEC_PROG_MSG_NONE when it starts, else the message said.

◆ hitec_prog_restore()

hitec_prog_msg_id_t hitec_prog_restore ( hitec_prog_t * p)

RESTORE: the values before the recorded write back to the servo, as a write; the record stays until it ends verified.

Taken once the servo read is compared and is not another servo.

Parameters
pThe programmer.
Returns
HITEC_PROG_MSG_NONE when it starts, else the message said.

◆ hitec_prog_restore_image()

bool hitec_prog_restore_image ( const hitec_prog_t * p,
hitec_image_t * out )

The image RESTORE writes: the servo read with the record's values before the write.

Parameters
pThe programmer.
outReceives it.
Returns
false with no record or no servo read.

◆ hitec_prog_retry_code()

unsigned hitec_prog_retry_code ( const hitec_prog_t * p)

The decoder's code of the last failed try of the running transaction, while it goes again.

Parameters
pThe programmer.
Returns
hitec_rx_t, 0 while no try failed.

◆ hitec_prog_rules()

uint16_t hitec_prog_rules ( const hitec_prog_t * p,
uint8_t id,
int32_t value )

The soft rules value of parameter id breaks against the servo read.

Parameters
pThe programmer.
idhitec_param_t.
valueThe value.
Returns
The rule set; 0 with no servo read.

◆ hitec_prog_series()

uint8_t hitec_prog_series ( const hitec_prog_t * p)

The series: the session's while the port is held, else the one the next CONNECT uses.

Parameters
pThe programmer.
Returns
hitec_family_t.

◆ hitec_prog_series_set()

bool hitec_prog_series_set ( hitec_prog_t * p,
uint8_t series )

The series of the next CONNECT; taken in PWM only. A change of series drops what the last read found: hitec_prog_servo() and hitec_prog_model() return NULL until the next read.

Parameters
pThe programmer.
serieshitec_family_t.
Returns
true when taken.

◆ hitec_prog_servo()

const hitec_image_t * hitec_prog_servo ( const hitec_prog_t * p)

The servo as the last full read found it; NULL with none.

Parameters
pThe programmer.
Returns
The image.

◆ hitec_prog_state()

hitec_prog_state_t hitec_prog_state ( const hitec_prog_t * p)

Where the programmer is.

Parameters
pThe programmer.
Returns
The state.

◆ hitec_prog_stopped()

bool hitec_prog_stopped ( const hitec_prog_t * p)

Whether the page's STOPPED flag is set on this panel's port.

Parameters
pThe programmer.
Returns
true while stopped.

◆ hitec_prog_sum_bad()

bool hitec_prog_sum_bad ( const hitec_prog_t * p)

Whether the classic servo read has cells 0x00 to 0x1C that do not sum to 0.

Parameters
pThe programmer.
Returns
true when REPAIR has something to write.

◆ hitec_prog_supply_caps()

void hitec_prog_supply_caps ( hitec_prog_t * p,
uint16_t max_mv,
uint16_t max_ma )

The SUPPLY screen's limits, 0 for none.

Parameters
pThe programmer.
max_mvThe voltage limit, mV.
max_maThe current limit, mA.

◆ hitec_prog_supply_set()

void hitec_prog_supply_set ( hitec_prog_t * p,
uint16_t mv,
uint16_t ma )

The programming voltage and current limit the next CONNECT asks.

Parameters
pThe programmer.
mvThe voltage, mV.
maThe current limit, mA.

◆ hitec_prog_take()

bool hitec_prog_take ( hitec_prog_t * p,
hitec_prog_cmd_t * out )

The next command for the link's task.

Parameters
pThe programmer.
outReceives it.
Returns
true when one was taken.

◆ hitec_prog_write()

hitec_prog_msg_id_t hitec_prog_write ( hitec_prog_t * p)

WRITE n VALUES: the draft to the servo, then its read-back.

Parameters
pThe programmer.
Returns
HITEC_PROG_MSG_NONE when it starts, else the message said.

◆ hitec_prog_write_enable()

hitec_prog_msg_id_t hitec_prog_write_enable ( hitec_prog_t * p,
bool on )

ENABLE WRITE TO SERVO.

Off is always taken. On needs the state hitec_prog_can_edit() needs, a SAFE bench and no STOP latched.

Parameters
pThe programmer.
onThe switch.
Returns
HITEC_PROG_MSG_NONE when taken, else the message said.

◆ hitec_prog_write_gate()

hitec_prog_msg_id_t hitec_prog_write_gate ( const hitec_prog_t * p,
uint8_t kind )

Why a write of kind is not taken now, the switch included.

Parameters
pThe programmer.
kindhitec_prog_wr_t.
Returns
HITEC_PROG_MSG_NONE when it is taken, else the reason.

◆ hitec_prog_write_on()

bool hitec_prog_write_on ( const hitec_prog_t * p)

Whether ENABLE WRITE TO SERVO is on.

Parameters
pThe programmer.
Returns
true when on.

◆ hitec_prog_write_progress()

bool hitec_prog_write_progress ( const hitec_prog_t * p,
unsigned * done,
unsigned * total,
uint8_t * kind )

The progress of the running write.

Parameters
pThe programmer.
doneReceives the plan's steps done.
totalReceives its steps.
kindReceives the hitec_step_kind_t of the step out; 0xFF in the read-back.
Returns
true while a write runs.