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

Stick programming: the beep detector. More...

#include "esc_stick.h"
#include "esc_stick_int.h"
#include <string.h>

Functions

void esc_det_init (esc_det_t *d, const esc_stick_timing_t *t, uint8_t long_equals_short)
 Set up the beep detector.
void esc_det_drop_group (esc_det_t *d)
 Forget any group under way, as if the line had been silent.
void esc_det_floor_only (esc_det_t *d)
 Floor only: no pulses, no groups.
void esc_det_count (esc_det_t *d)
 Pulses and groups from the next reading on; the floor is kept.
int32_t esc_det_floor_ma (const esc_det_t *d)
 The idle floor, mA.
static uint32_t readings_in (const esc_det_t *d, uint32_t ms)
 How many readings a span of ms must hold, at the longest interval seen that was not late. 0 while no interval is known.
static void close_pulse (esc_det_t *d, uint32_t t_ms)
 Close the pulse that has just fallen and judge its length.
esc_det_event_t esc_det_reading (esc_det_t *d, uint32_t t_ms, int32_t ma, bool late)
 One reading, at t_ms, of ma; late marks it as having come too long after the one before.

Detailed Description

Stick programming: the beep detector.

It turns the supply readings into pulses and the pulses into groups. See esc_stick.h, and esc_stick.c for the rules that make a count safe.

SPDX-License-Identifier: MIT

Function Documentation

◆ close_pulse()

void close_pulse ( esc_det_t * d,
uint32_t t_ms )
static

Close the pulse that has just fallen and judge its length.

Counts the pulse as a short or a long beep, or marks the group bad when it is no beep.

Parameters
dThe beep detector.
t_msTime of the first low reading after the pulse, ms.

◆ esc_det_count()

void esc_det_count ( esc_det_t * d)

Pulses and groups from the next reading on; the floor is kept.

Parameters
dThe detector.

◆ esc_det_drop_group()

void esc_det_drop_group ( esc_det_t * d)

Forget any group under way, as if the line had been silent.

In esc_det.c.

Parameters
dThe beep detector.

◆ esc_det_floor_ma()

int32_t esc_det_floor_ma ( const esc_det_t * d)

The idle floor, mA.

Parameters
dThe detector.
Returns
The idle floor, mA.

◆ esc_det_floor_only()

void esc_det_floor_only ( esc_det_t * d)

Floor only: no pulses, no groups.

In esc_det.c.

Parameters
dThe beep detector.

◆ esc_det_init()

void esc_det_init ( esc_det_t * d,
const esc_stick_timing_t * t,
uint8_t long_equals_short )

Set up the beep detector.

Parameters
dThe detector.
tThe timing.
long_equals_shortCount of short beeps that one long beep equals, 0 when every beep is short.

◆ esc_det_reading()

esc_det_event_t esc_det_reading ( esc_det_t * d,
uint32_t t_ms,
int32_t ma,
bool late )

One reading, at t_ms, of ma; late marks it as having come too long after the one before.

Parameters
dThe detector.
t_msTime of the reading, ms.
maCurrent, mA.
latetrue when the reading came too long after the one before.
Returns
The event the reading caused.

◆ readings_in()

uint32_t readings_in ( const esc_det_t * d,
uint32_t ms )
static

How many readings a span of ms must hold, at the longest interval seen that was not late. 0 while no interval is known.

Parameters
dThe beep detector.
msSpan, ms.
Returns
The readings the span must hold, or 0 while no interval is known.