|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The tone service. More...
Macros | |
| #define | U16_MAX 65535u |
Functions | |
| static uint16_t | clip16 (uint64_t v) |
| Clip a 64-bit count to 16 bits. | |
| static uint16_t | round16 (float v) |
| A non-negative float rounded to the nearest integer, clipped to 16 bits. | |
| void | tone_svc_init (tone_svc_t *s) |
| Clear the service state. | |
| uint64_t | tone_svc_ticks (uint64_t us) |
us microseconds after the capture started, in ticks. | |
| void | tone_svc_cfg (const tone_cmd_t *cmd, tone_cfg_t *c) |
| The detector's configuration for an order: the defaults of tone.h at the capture's tick, with the order's range, split, gap and minimum. | |
| void | tone_svc_rec (const tone_beep_t *b, tone_rec_t *r) |
| A detector beep in the page's units, ticks of TONE_SVC_TICK_HZ. | |
| static bool | restart (tone_svc_t *s, const tone_cmd_t *cmd) |
| Restart under a new order: the detector, the hold-off horizon, the ring reader and the flags. | |
| static void | report (const tone_svc_t *s, tone_status_t *st) |
| Fill the status for this pass. | |
| size_t | tone_svc_step (tone_svc_t *s, const tone_cmd_t *cmd, const uint32_t *ring, uint32_t wr, uint64_t now, bool fifo_overrun, tone_rec_t *rec, tone_status_t *st) |
| One pass. | |
|
static |
Clip a 64-bit count to 16 bits.
| v | Count to clip. |
v, or 65535 when it is larger.
|
static |
Fill the status for this pass.
| s | Service state. |
| st | Receives the status; cleared first. |
|
static |
Restart under a new order: the detector, the hold-off horizon, the ring reader and the flags.
False when the order's settings are refused.
| s | Service state. |
| cmd | Order from core 0. |
|
static |
A non-negative float rounded to the nearest integer, clipped to 16 bits.
| v | Value to round. |
| void tone_svc_cfg | ( | const tone_cmd_t * | cmd, |
| tone_cfg_t * | c ) |
The detector's configuration for an order: the defaults of tone.h at the capture's tick, with the order's range, split, gap and minimum.
| cmd | Order from core 0. |
| c | Receives the detector settings. |
| void tone_svc_init | ( | tone_svc_t * | s | ) |
Clear the service state.
| s | Service state; cleared to zero. |
| void tone_svc_rec | ( | const tone_beep_t * | b, |
| tone_rec_t * | r ) |
A detector beep in the page's units, ticks of TONE_SVC_TICK_HZ.
| b | Beep from the detector. |
| r | Receives the beep in the page's units. |
| size_t tone_svc_step | ( | tone_svc_t * | s, |
| const tone_cmd_t * | cmd, | ||
| const uint32_t * | ring, | ||
| uint32_t | wr, | ||
| uint64_t | now, | ||
| bool | fifo_overrun, | ||
| tone_rec_t * | rec, | ||
| tone_status_t * | st ) |
One pass.
ring is the capture ring (TONE_RING_WORDS words), wr the slot the DMA writes next, now the present in ticks since the capture started, fifo_overrun true when the state machine dropped a word (its FIFO was full): the words read in that pass and in the next are discarded, the beep under way ends and the status shows the overrun. The caller reads the flag before wr, so the next pass's boundary lies after the flag was cleared; words the FIFO still held at the drop reach the ring before that boundary unless the DMA stalls for a whole pass, 1ms, and a stall that long overflows the FIFO again. The beeps finished go to rec, at most TONE_SVC_BEEPS; the count is returned. st is always written.
| s | Service state. |
| cmd | Order from core 0. |
| ring | Capture ring, TONE_RING_WORDS words. |
| wr | Slot the DMA writes next. |
| now | Present, in ticks since the capture started. |
| fifo_overrun | true when the state machine dropped a word. |
| rec | Receives the finished beeps; NULL to take none. |
| st | Receives the status; always written. |
rec. | uint64_t tone_svc_ticks | ( | uint64_t | us | ) |
us microseconds after the capture started, in ticks.
| us | Time, microseconds. |