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

The control task's half of the programmer for servos by Hitec: the HITEC page's link module (hitec_link.h), the commands of the programmer's model and what the model is fed. More...

#include <stdatomic.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "arming.h"
#include "hitec_link.h"
#include "hitec_prog.h"
#include "hitec_rx_link.h"
#include "link_host.h"
#include "link_pages.h"
#include "outputs.h"
#include "panel.h"
#include "prog_link.h"
#include "storage.h"
#include "supply_link.h"

Functions

static void hitec_command (const hitec_prog_cmd_t *c)
 Carry out one command.
void hitec_commands (void)
 The Hitec programmer's commands, at most 4 a pass; control task.
static int hitec_xchg (void *ctx, const hitec_link_xfer_t *x, uint16_t *regs)
 One exchange of the HITEC page, as hitec_link_xchg_fn: a write, or a read of up to 32 registers into regs.
void hitec_pass (bool link_up)
 One pass of the HITEC page's module; control task, every pass.
bool hitec_taken (void)
 Whether the HITEC page holds a port or a request runs.
void hitec_publish (hitec_prog_feed_t *f)
 What the Hitec programmer's model is fed; under the snapshot's lock.

Variables

hitec_link_t s_hitec_link
 The HITEC page's module (4.23). Control task only.
hitec_prog_gate_t s_hitec_gate
 The gate a command in the queue is claimed at (hitec_prog.h).
QueueHandle_t s_hitec_q
 The model's commands, app_main -> control task.
static uint32_t s_hitec_answer_id
 The id of the last command carried out; 0 none.
static uint8_t s_hitec_answer
 What the link module said to it: hitec_link_start_t.
static uint32_t s_hitec_outcomes
 Counts the outcomes handed out.
static hitec_link_outcome_t s_hitec_outcome
 The last outcome handed out.
static uint32_t s_hitec_stops
 The stops an abort was sent for: arming_stop_count()'s count.

Detailed Description

The control task's half of the programmer for servos by Hitec: the HITEC page's link module (hitec_link.h), the commands of the programmer's model and what the model is fed.

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

The model (hitec_prog.h) runs in the render loop. It hands its commands over through s_hitec_q and reads what became of them in the snapshot: the number of the last command carried out with what the link module said, and a count of the outcomes handed out with the last of them.

hitec_link_service() runs every pass of the control task, 5ms, with at most HITEC_LINK_PASS_MAX exchanges, so a request's status read follows the page within one pass. hitec_commands(), hitec_pass() and hitec_publish() are kept out of line: their locals stay out of control_task()'s frame, from which the task's deepest chain starts.

SPDX-License-Identifier: MIT

Function Documentation

◆ hitec_command()

void hitec_command ( const hitec_prog_cmd_t * c)
static

Carry out one command.

No port is taken on an armed bench: an OPEN is answered BUSY and nothing is sent.

Parameters
cThe command.

◆ hitec_pass()

void hitec_pass ( bool link_up)

One pass of the HITEC page's module; control task, every pass.

Parameters
link_upwhether the IOmcu answers

◆ hitec_publish()

void hitec_publish ( hitec_prog_feed_t * f)

What the Hitec programmer's model is fed; under the snapshot's lock.

Parameters
freceives the feed

◆ hitec_taken()

bool hitec_taken ( void )

Whether the HITEC page holds a port or a request runs.

Returns
true while it does

◆ hitec_xchg()

int hitec_xchg ( void * ctx,
const hitec_link_xfer_t * x,
uint16_t * regs )
static

One exchange of the HITEC page, as hitec_link_xchg_fn: a write, or a read of up to 32 registers into regs.

Parameters
ctxUnused.
xThe exchange.
regsReceives a read's registers.
Returns
HITEC_LINK_ACK, a NACK's reason, or HITEC_LINK_NO_ANSWER.

Variable Documentation

◆ s_hitec_gate

hitec_prog_gate_t s_hitec_gate

The gate a command in the queue is claimed at (hitec_prog.h).

The gate the Hitec programmer's commands are claimed at; the one part both tasks touch.

The gate a command in the queue is claimed at (hitec_prog.h).

◆ s_hitec_link

hitec_link_t s_hitec_link

The HITEC page's module (4.23). Control task only.

The HITEC page's module (4.23); control task only.

The HITEC page's module (4.23). Control task only.

◆ s_hitec_q

QueueHandle_t s_hitec_q

The model's commands, app_main -> control task.

app_main -> control task