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

The panel's half of the Hitec receive mode: SETUP > INTERFACES > Hitec D receive (SET_HITEC_RX) written to the HITEC page's register 23 (LINK_HT_W_RX_MODE, protocol 4.24), and what SETUP marks on the row. More...

#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

 The panel's state of the Hitec receive mode. More...

Macros

#define HITEC_RX_LINK_ACK   0
 How an exchange went, as tone_link.h has it: the ACK, a NACK's reason (LINK_NACK_*), or no answer.
#define HITEC_RX_LINK_NO_ANSWER   (-1)
#define HITEC_RX_LINK_RETRY_MS   500u
 A write nobody answered goes again this much later.

Enumerations

enum  hitec_rx_link_mark_t {
  HITEC_RX_LINK_HELD = 0 , HITEC_RX_LINK_PENDING , HITEC_RX_LINK_REFUSED , HITEC_RX_LINK_OLD ,
  HITEC_RX_LINK_NO_LINE
}
 What the row of SETUP says, hitec_rx_link_mark(). More...

Functions

void hitec_rx_link_init (hitec_rx_link_t *l)
 No IOmcu, PULL-UP asked, nothing owed.
void hitec_rx_link_want (hitec_rx_link_t *l, uint8_t mode)
 The setting as it is now; a change owes it.
void hitec_rx_link_came_up (hitec_rx_link_t *l, uint16_t minor)
 A link-up edge with an IOmcu of minor: the mode is owed again.
void hitec_rx_link_lost (hitec_rx_link_t *l)
 The link went down.
bool hitec_rx_link_next (const hitec_rx_link_t *l, uint32_t now_ms, uint16_t *value)
 Whether to write the page's register 23 at now_ms, and with what.
void hitec_rx_link_done (hitec_rx_link_t *l, int result, uint32_t now_ms)
 How the write hitec_rx_link_next() gave went: HITEC_RX_LINK_ACK, a NACK's reason, or HITEC_RX_LINK_NO_ANSWER.
hitec_rx_link_mark_t hitec_rx_link_mark (const hitec_rx_link_t *l)
 What the row says now.

Detailed Description

The panel's half of the Hitec receive mode: SETUP > INTERFACES > Hitec D receive (SET_HITEC_RX) written to the HITEC page's register 23 (LINK_HT_W_RX_MODE, protocol 4.24), and what SETUP marks on the row.

The mode is owed to the IOmcu at every link-up, an IOmcu restart included (it starts at PULL-UP), and at every edit. It is written while owed, one write a poll, armed or not: the IOmcu takes it at its next OPEN of a D series line and changes nothing that runs. An acknowledgement is the mode held. A write nobody answered stays owed and goes again HITEC_RX_LINK_RETRY_MS later. A refusal ends the debt until the next edit or link-up: the same write is refused every time.

An IOmcu older than 4.24 is sent nothing: it refuses the register with LINK_NACK_READ_ONLY and receives with the pull-up. With PRECHARGE asked the row says so (HITEC_RX_LINK_OLD); with PULL-UP asked there is nothing to say. An IOmcu older than 4.23 has no HITEC page and no Hitec line; with PRECHARGE asked the row says that instead (HITEC_RX_LINK_NO_LINE).

Pure logic: the caller makes the exchange and reports how it went.

SPDX-License-Identifier: MIT

Enumeration Type Documentation

◆ hitec_rx_link_mark_t

What the row of SETUP says, hitec_rx_link_mark().

Enumerator
HITEC_RX_LINK_HELD 

Nothing: the IOmcu holds the mode, no IOmcu answers, or one older than 4.24 with PULL-UP asked.

HITEC_RX_LINK_PENDING 

The mode asked is not acknowledged yet.

HITEC_RX_LINK_REFUSED 

The IOmcu refused it.

HITEC_RX_LINK_OLD 

An IOmcu of 4.23 with PRECHARGE asked: it receives with the pull-up.

HITEC_RX_LINK_NO_LINE 

An IOmcu older than 4.23 with PRECHARGE asked: it has no Hitec line.

Function Documentation

◆ hitec_rx_link_came_up()

void hitec_rx_link_came_up ( hitec_rx_link_t * l,
uint16_t minor )

A link-up edge with an IOmcu of minor: the mode is owed again.

Parameters
lThe link state.
minorThe protocol minor version of the IOmcu.

◆ hitec_rx_link_done()

void hitec_rx_link_done ( hitec_rx_link_t * l,
int result,
uint32_t now_ms )

How the write hitec_rx_link_next() gave went: HITEC_RX_LINK_ACK, a NACK's reason, or HITEC_RX_LINK_NO_ANSWER.

Parameters
lThe link state.
resultThe write's result: an acknowledgement, a NACK's reason or HITEC_RX_LINK_NO_ANSWER.
now_msThe time of the answer, in ms.

◆ hitec_rx_link_init()

void hitec_rx_link_init ( hitec_rx_link_t * l)

No IOmcu, PULL-UP asked, nothing owed.

Parameters
lThe link state to set up.

◆ hitec_rx_link_lost()

void hitec_rx_link_lost ( hitec_rx_link_t * l)

The link went down.

Parameters
lThe link state.

◆ hitec_rx_link_mark()

hitec_rx_link_mark_t hitec_rx_link_mark ( const hitec_rx_link_t * l)

What the row says now.

Parameters
lThe link state.
Returns
The mark the row shows now.

◆ hitec_rx_link_next()

bool hitec_rx_link_next ( const hitec_rx_link_t * l,
uint32_t now_ms,
uint16_t * value )

Whether to write the page's register 23 at now_ms, and with what.

False while nothing is owed, no IOmcu answers, it is older than 4.24, or an unanswered write is younger than HITEC_RX_LINK_RETRY_MS.

Parameters
lThe link state.
now_msThe time of the poll, in ms.
valueReceives the register 23 value to write.
Returns
true when a write is due.

◆ hitec_rx_link_want()

void hitec_rx_link_want ( hitec_rx_link_t * l,
uint8_t mode )

The setting as it is now; a change owes it.

A value above LINK_HITEC_RX_PRECHARGE is PULL-UP.

Parameters
lThe link state.
modeThe setting; a value above LINK_HITEC_RX_PRECHARGE is PULL-UP.