67#define HITEC_MEM_SIZE 256u
70#define HITEC_C_SUM_LAST 0x1Cu
71#define HITEC_C_FACTORY 0x30u
72#define HITEC_C_BLOCK_LEN 0x24u
73#define HITEC_C_NAME 0x60u
74#define HITEC_C_NAME_LEN 16u
75#define HITEC_C_DATE 0x70u
76#define HITEC_C_SERIAL 0x80u
77#define HITEC_C_SERIAL_LEN 7u
80#define HITEC_D_REG_MODEL 0x00u
81#define HITEC_D_REG_FACTORY 0x6Eu
82#define HITEC_D_REG_SAVE 0x70u
83#define HITEC_D_REG_REBOOT 0x46u
84#define HITEC_D_FACTORY_KEY 0x0F0Fu
85#define HITEC_D_SAVE_KEY 0xFFFFu
87#define HITEC_D_POS_MAX 16383u
263#define HITEC_LAYOUT_BIT(l) ((uint8_t)(1u << (l)))
406#define HITEC_FS_LIMP 0
407#define HITEC_FS_OFF 1
410#define HITEC_OVERLOAD_OFF 0
419#define HITEC_ADDR_NONE 0xFFu
587#define HITEC_D_WRITE_GAP_MS 20u
589#define HITEC_D_SAVE_GAP_MS 100u
592#define HITEC_D_REBOOT_WAIT_MS 1000u
599#define HITEC_PLAN_MAX 56u
bool hitec_image_put_reg(hitec_image_t *img, uint8_t addr, uint16_t value)
Store a D series register as read.
Definition hitec_reg.c:260
bool hitec_c_rebalance(hitec_image_t *img)
Write the balance into cell 0x1C of a classic draft.
Definition hitec_reg.c:413
const char * hitec_model_name(uint8_t model)
The model's name as Hitec writes it, "D485HW", "HS-5645MG"; "" for the OTHER and NONE models.
Definition hitec_reg.c:498
const uint8_t * hitec_d_read_list(size_t *n)
The D series registers a full read takes: the 19 the HFP-30 reads, less 0x6E (write only),...
Definition hitec_reg.c:370
uint8_t hitec_c_balance(const hitec_image_t *img)
The value of cell 0x1C that makes cells 0x00 to 0x1C sum to 0.
Definition hitec_reg.c:407
uint8_t hitec_image_cell(const hitec_image_t *img, uint8_t cell)
A classic cell; 0 for NULL.
Definition hitec_reg.c:311
bool hitec_image_known(const hitec_image_t *img, uint8_t addr)
True when byte addr was read.
Definition hitec_reg.c:306
bool hitec_image_forget(hitec_image_t *img, uint8_t addr)
Mark a cell or a D series register as not known: the servo may hold another value than the image.
Definition hitec_reg.c:294
uint16_t hitec_image_reg(const hitec_image_t *img, uint8_t addr)
A D series register; 0 for NULL or an odd address.
Definition hitec_reg.c:316
uint8_t hitec_layout_series(uint8_t layout)
The series of a layout.
Definition hitec_reg.c:435
bool hitec_param_ok(uint8_t layout, uint8_t id, int32_t value)
True when value is a value an edit of id takes.
Definition hitec_reg.c:772
bool hitec_image_put_cell(hitec_image_t *img, uint8_t cell, uint8_t value)
Store a classic cell as read.
Definition hitec_reg.c:250
bool hitec_identify(const hitec_image_t *img, hitec_model_t *out)
Identify the model from a read image.
Definition hitec_reg.c:452
bool hitec_image_put_version(hitec_image_t *img, uint8_t version)
Store the classic reply to the first command (0x67).
Definition hitec_reg.c:272
bool hitec_d_mirror(uint16_t pos, uint16_t *out)
A D series position mirrored by a direction change: 16384 less the position, as the HFP-30 writes it.
Definition hitec_reg.c:424
hitec_plan_result_t hitec_plan(const hitec_image_t *from, const hitec_image_t *to, hitec_plan_t *out)
The writes that take a servo from image from to to.
Definition hitec_reg.c:1229
void hitec_image_init(hitec_image_t *img, uint8_t series)
Empty an image of series: no byte known, no version.
Definition hitec_reg.c:232
int32_t hitec_param_clamp(uint8_t layout, uint8_t id, int32_t value)
The nearest value an edit of id takes.
Definition hitec_reg.c:779
bool hitec_c_factory(hitec_image_t *img)
Classic factory reset on a draft: cells 0x00 to 0x23 from the factory block 0x30 to 0x53,...
Definition hitec_reg.c:1014
void hitec_d_factory_plan(hitec_plan_t *out)
The D series factory reset: 0x6E = 0x0F0F, save, reboot, as the HFP-30 writes it.
Definition hitec_reg.c:1249
bool hitec_writable(uint8_t series, uint8_t addr)
True when a plan writes addr of series.
Definition hitec_reg.c:1073
uint8_t hitec_c_eeprom_sum(const hitec_image_t *img)
Sum of classic cells 0x00 to 0x1C modulo 256; 0 is a good image.
Definition hitec_reg.c:402
const hitec_range_t * hitec_c_read_ranges(size_t *n)
The classic cells a full read takes: 0x00 to 0x23, the factory block 0x30 to 0x53,...
Definition hitec_reg.c:378
hitec_get_t hitec_param_get(const hitec_image_t *img, uint8_t layout, uint8_t id, hitec_value_t *out)
Decode a parameter.
Definition hitec_reg.c:733
hitec_set_t hitec_param_set(hitec_image_t *img, uint8_t layout, uint8_t id, int32_t value)
Edit a draft: encode value and write its side effects.
Definition hitec_reg.c:981
const hitec_param_info_t * hitec_param(uint8_t layout, uint8_t id)
The row of id for layout; NULL when the layout has no such parameter.
Definition hitec_reg.c:505
hitec_layout_t
Register layouts.
Definition hitec_reg.h:255
@ HITEC_LAYOUT_HS7
Definition hitec_reg.h:258
@ HITEC_LAYOUT_HS5
Definition hitec_reg.h:257
@ HITEC_LAYOUT_D
Definition hitec_reg.h:256
#define HITEC_C_NAME_LEN
Definition hitec_reg.h:74
hitec_model_id_t
Models the module knows by name.
Definition hitec_reg.h:293
@ HITEC_MODEL_HS7955TG
Definition hitec_reg.h:300
@ HITEC_MODEL_D_OTHER
Definition hitec_reg.h:297
@ HITEC_MODEL_HS7_OTHER
Definition hitec_reg.h:302
@ HITEC_MODEL_HS5645MG
Definition hitec_reg.h:298
@ HITEC_MODEL_D645MW
Definition hitec_reg.h:296
@ HITEC_MODEL_C_OTHER
Definition hitec_reg.h:303
@ HITEC_MODEL_HS5_OTHER
Definition hitec_reg.h:301
@ HITEC_MODEL_HS5955TG
Definition hitec_reg.h:299
@ HITEC_MODEL_D485HW
Definition hitec_reg.h:295
@ HITEC_MODEL_NONE
Definition hitec_reg.h:294
hitec_param_t
The parameters of both series.
Definition hitec_reg.h:342
@ HITEC_P_C_DATE
Definition hitec_reg.h:364
@ HITEC_P_C_RESOLUTION
Definition hitec_reg.h:376
@ HITEC_P_C_SERIAL
Definition hitec_reg.h:365
@ HITEC_P_D_R04
Definition hitec_reg.h:357
@ HITEC_P_C_DIRECTION
Definition hitec_reg.h:372
@ HITEC_P_D_RD6
Definition hitec_reg.h:362
@ HITEC_P_D_POSITION
Definition hitec_reg.h:344
@ HITEC_P_D_R8A
Definition hitec_reg.h:359
@ HITEC_P_D_RIGHT_END
Definition hitec_reg.h:349
@ HITEC_P_D_MODEL
Definition hitec_reg.h:343
@ HITEC_P_C_DEAD_BAND
Definition hitec_reg.h:367
@ HITEC_P_D_SOFT_START
Definition hitec_reg.h:353
@ HITEC_P_C_FS_POSITION
Definition hitec_reg.h:374
@ HITEC_P_C_CENTRE
Definition hitec_reg.h:369
@ HITEC_P_D_SMART_SENSOR
Definition hitec_reg.h:355
@ HITEC_P_D_NEUTRAL
Definition hitec_reg.h:347
@ HITEC_P_D_SPEED
Definition hitec_reg.h:351
@ HITEC_P_C_SPEED
Definition hitec_reg.h:368
@ HITEC_P_C_FAILSAFE
Definition hitec_reg.h:373
@ HITEC_P_D_FAILSAFE
Definition hitec_reg.h:352
@ HITEC_P_C_CHECKSUM
Definition hitec_reg.h:366
@ HITEC_P_C_LEFT_END
Definition hitec_reg.h:370
@ HITEC_P_D_DEAD_BAND
Definition hitec_reg.h:350
@ HITEC_P_D_OVERLOAD
Definition hitec_reg.h:354
@ HITEC_P_D_SENSITIVITY
Definition hitec_reg.h:356
@ HITEC_P_D_ID
Definition hitec_reg.h:345
@ HITEC_P_D_RD4
Definition hitec_reg.h:361
@ HITEC_P_C_VERSION
Definition hitec_reg.h:363
@ HITEC_P_C_OVERLOAD
Definition hitec_reg.h:375
@ HITEC_P_C_RIGHT_END
Definition hitec_reg.h:371
@ HITEC_P_D_R8C
Definition hitec_reg.h:360
@ HITEC_P_D_LEFT_END
Definition hitec_reg.h:348
@ HITEC_P_D_DIRECTION
Definition hitec_reg.h:346
@ HITEC_P_D_R22
Definition hitec_reg.h:358
#define HITEC_MEM_SIZE
Bytes of an image: 256 classic cells or 128 D series registers.
Definition hitec_reg.h:67
hitec_plan_result_t
Result of planning.
Definition hitec_reg.h:608
@ HITEC_PLAN_ERR_ARG
Definition hitec_reg.h:610
@ HITEC_PLAN_OK
Definition hitec_reg.h:609
@ HITEC_PLAN_ERR_UNKNOWN
Definition hitec_reg.h:611
#define HITEC_PLAN_MAX
The longest plan: a classic restore of all 35 writable cells with a balance after each of the 19 sett...
Definition hitec_reg.h:599
hitec_unit_t
Unit of a decoded value.
Definition hitec_reg.h:381
@ HITEC_UNIT_DATE
Definition hitec_reg.h:390
@ HITEC_UNIT_STEP
Definition hitec_reg.h:385
@ HITEC_UNIT_PERCENT
Definition hitec_reg.h:384
@ HITEC_UNIT_FS_US
Definition hitec_reg.h:387
@ HITEC_UNIT_RAW
Definition hitec_reg.h:382
@ HITEC_UNIT_CHOICE
Definition hitec_reg.h:386
@ HITEC_UNIT_OVERLOAD
Definition hitec_reg.h:388
@ HITEC_UNIT_QUARTER_US
Definition hitec_reg.h:389
@ HITEC_UNIT_NUMBER
Definition hitec_reg.h:391
@ HITEC_UNIT_COUNTS
Definition hitec_reg.h:383
hitec_set_t
Result of an edit.
Definition hitec_reg.h:487
@ HITEC_SET_ERR_RAW
D series: a position edit beside a position above 16383, and smart sensor off with 0x8A = 0x8C = 0,...
Definition hitec_reg.h:495
@ HITEC_SET_ERR_MIRROR
Definition hitec_reg.h:497
@ HITEC_SET_ERR_RO
Definition hitec_reg.h:491
@ HITEC_SET_ERR_UNKNOWN
Definition hitec_reg.h:496
@ HITEC_SET_OK
Definition hitec_reg.h:488
@ HITEC_SET_ERR_RANGE
Definition hitec_reg.h:492
@ HITEC_SET_ERR_ORDER
Definition hitec_reg.h:498
@ HITEC_SET_ERR_ARG
Definition hitec_reg.h:489
hitec_get_t
Result of a decode.
Definition hitec_reg.h:454
@ HITEC_GET_UNKNOWN
Definition hitec_reg.h:458
@ HITEC_GET_ERR_ARG
Definition hitec_reg.h:459
@ HITEC_GET_OK
Definition hitec_reg.h:455
@ HITEC_GET_RAW
Definition hitec_reg.h:456
hitec_access_t
Access of a parameter.
Definition hitec_reg.h:413
@ HITEC_RW
Definition hitec_reg.h:415
@ HITEC_RO
Definition hitec_reg.h:414
hitec_choice_t
The values of the CHOICE parameters.
Definition hitec_reg.h:395
@ HITEC_ON
Definition hitec_reg.h:399
@ HITEC_SUM_BAD
Definition hitec_reg.h:402
@ HITEC_CCW
Definition hitec_reg.h:397
@ HITEC_RES_HIGH
Definition hitec_reg.h:401
@ HITEC_SUM_OK
Definition hitec_reg.h:403
@ HITEC_RES_NORMAL
Definition hitec_reg.h:400
@ HITEC_CW
Definition hitec_reg.h:396
@ HITEC_OFF
Definition hitec_reg.h:398
hitec_step_kind_t
Kind of a write.
Definition hitec_reg.h:570
@ HITEC_STEP_D_REBOOT
Definition hitec_reg.h:575
@ HITEC_STEP_C_CELL
Definition hitec_reg.h:571
@ HITEC_STEP_C_SUM
Definition hitec_reg.h:572
@ HITEC_STEP_D_SAVE
Definition hitec_reg.h:574
@ HITEC_STEP_D_WRITE
Definition hitec_reg.h:573
hitec_src_t
Where an entry comes from.
Definition hitec_reg.h:280
@ HITEC_SRC_CAPTURED
A vendor programmer's writes captured on the wire.
Definition hitec_reg.h:284
@ HITEC_SRC_RCBENCH
Written through the rcbench IOmcu and read back.
Definition hitec_reg.h:282
@ HITEC_SRC_READ
Read from a servo; no write recorded.
Definition hitec_reg.h:286
@ HITEC_SRC_DOC
Documentation only: Hitec's D series manual, community documents, third-party observations.
Definition hitec_reg.h:289
Hitec servo programming protocols: frames, transactions, the reply decoders and the driver interface.
The registers or cells of one servo, as read.
Definition hitec_reg.h:95
uint8_t version
Definition hitec_reg.h:100
uint8_t series
Definition hitec_reg.h:99
uint8_t has_version
Definition hitec_reg.h:101
uint8_t known[HITEC_MEM_SIZE/8u]
Definition hitec_reg.h:98
uint8_t mem[HITEC_MEM_SIZE]
Classic cells; D series registers, low byte first.
Definition hitec_reg.h:97
What identification found.
Definition hitec_reg.h:308
uint8_t layout
Definition hitec_reg.h:310
uint8_t src
Definition hitec_reg.h:311
char name[HITEC_C_NAME_LEN+1u]
Classic: the name cells up to the first 0x00, a byte outside printable ASCII as ?; D series: empty.
Definition hitec_reg.h:315
uint16_t number
Definition hitec_reg.h:312
uint8_t model
Definition hitec_reg.h:309
One row of the parameter table.
Definition hitec_reg.h:428
uint8_t access
Definition hitec_reg.h:436
uint8_t addr2
Definition hitec_reg.h:432
int32_t min
Definition hitec_reg.h:439
uint8_t step
Definition hitec_reg.h:438
int32_t max
Definition hitec_reg.h:440
uint8_t unit
Definition hitec_reg.h:435
uint8_t src
Definition hitec_reg.h:437
uint8_t addr
Definition hitec_reg.h:431
uint8_t enc
Definition hitec_reg.h:434
uint8_t layouts
Definition hitec_reg.h:430
uint8_t id
Definition hitec_reg.h:429
uint8_t size
Definition hitec_reg.h:433
An ordered list of writes.
Definition hitec_reg.h:602
uint8_t n
Definition hitec_reg.h:603
hitec_step_t step[HITEC_PLAN_MAX]
Definition hitec_reg.h:604
A run of classic cells.
Definition hitec_reg.h:185
uint8_t first
Definition hitec_reg.h:186
uint8_t count
Definition hitec_reg.h:187
One write of a plan.
Definition hitec_reg.h:579
uint16_t wait_ms
Definition hitec_reg.h:583
uint16_t value
Definition hitec_reg.h:582
uint8_t kind
Definition hitec_reg.h:580
uint8_t addr
Definition hitec_reg.h:581
A decoded value and the raw value beside it.
Definition hitec_reg.h:464
uint32_t raw
The stored value: the register, the cell, or 2 to 4 cells high byte first; the sum for CHECKSUM; 0 fo...
Definition hitec_reg.h:470
int32_t value
Definition hitec_reg.h:465