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

The PD mini's jobs: which transaction goes next, and the step that runs the phases of one. More...

#include "pdmini_int.h"

Functions

static bool en_ready (pdmini_t *d, uint32_t now)
 Whether an ON may be written: four writes that do not take leave the output stuck – an input not ready for an ON – and it is tried again two seconds on.
static bool write_en (pdmini_t *d, uint32_t now)
 OUTPUT_EN towards what is asked: twice with the argument taken to mean it, then – until a read-back has shown which argument means on – twice with the other, in case this module reads it the way the vendor's sheet says.
static bool poll (pdmini_t *d, uint32_t now, uint32_t margin)
 The reading furthest past its due by margin ms or more, started; false for none.
static bool next_job (pdmini_t *d, uint32_t now)
 The next transaction, or false for none now.
static bool off_now (const pdmini_t *d)
 Whether an OFF waits on the transaction under way: next_job() would write it to an output read on, or write it – or read the state for it – over an ON still being confirmed.
static bool overtaken (const pdmini_t *d)
 Whether the write waiting for its pins has been overtaken: an OUTPUT_EN towards what is no longer asked, an ON whose set points have changed since they were read back for it, set points no longer the ones asked, or a set point while an OFF is asked and the output is or may be on – the OFF goes first.
void pdmini_step (pdmini_t *d, uint32_t now_ms)
 Run one pass of the driver.

Detailed Description

The PD mini's jobs: which transaction goes next, and the step that runs the phases of one.

See pdmini.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ en_ready()

bool en_ready ( pdmini_t * d,
uint32_t now )
static

Whether an ON may be written: four writes that do not take leave the output stuck – an input not ready for an ON – and it is tried again two seconds on.

False while it waits out that pause.

Parameters
dDriver state.
nowCurrent time, in milliseconds.
Returns
true when an ON may be written.

◆ next_job()

bool next_job ( pdmini_t * d,
uint32_t now )
static

The next transaction, or false for none now.

Parameters
dDriver state.
nowCurrent time, in milliseconds.
Returns
true when a transaction was started; false for none now.

◆ off_now()

bool off_now ( const pdmini_t * d)
static

Whether an OFF waits on the transaction under way: next_job() would write it to an output read on, or write it – or read the state for it – over an ON still being confirmed.

Parameters
dDriver state.
Returns
true when an OFF is waiting.

◆ overtaken()

bool overtaken ( const pdmini_t * d)
static

Whether the write waiting for its pins has been overtaken: an OUTPUT_EN towards what is no longer asked, an ON whose set points have changed since they were read back for it, set points no longer the ones asked, or a set point while an OFF is asked and the output is or may be on – the OFF goes first.

Parameters
dDriver state.
Returns
true when the write is no longer wanted and is not sent.

◆ pdmini_step()

void pdmini_step ( pdmini_t * d,
uint32_t now_ms )

Run one pass of the driver.

Call every pass.

Parameters
dDriver state.
now_msCurrent time, in milliseconds.

◆ poll()

bool poll ( pdmini_t * d,
uint32_t now,
uint32_t margin )
static

The reading furthest past its due by margin ms or more, started; false for none.

Furthest past its due, so a slow module answering every display read near its period does not starve the others. Unsigned, so a reading untaken for 2^31 ms or more – a module first seen 25 days after start – is late rather than early.

Parameters
dDriver state.
nowCurrent time, in milliseconds.
marginLeast time past its due, in milliseconds.
Returns
true when a reading was started.

◆ write_en()

bool write_en ( pdmini_t * d,
uint32_t now )
static

OUTPUT_EN towards what is asked: twice with the argument taken to mean it, then – until a read-back has shown which argument means on – twice with the other, in case this module reads it the way the vendor's sheet says.

Written when the output reads otherwise, so an OFF that tries the other argument goes only to an output that is on and cannot switch on one that was off. An ON is false when en_ready() says not now; an OFF is never held back, and four that do not take only say stuck.

Parameters
dDriver state.
nowCurrent time, in milliseconds.
Returns
true when the write was started; false when an ON must wait.