rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
edge_ring.h
Go to the documentation of this file.
1
37
38#pragma once
39
40#include <stdbool.h>
41#include <stddef.h>
42#include <stdint.h>
43
44#include "tone.h"
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
51#define EDGE_COUNT_BITS 31u
52#define EDGE_COUNT_MASK 0x7FFFFFFFu
53
61uint32_t edge_word(uint32_t count, bool level);
62
69uint32_t edge_word_count(uint32_t word);
76bool edge_word_level(uint32_t word);
77
88uint64_t edge_tick(uint32_t count, uint64_t est);
89
91typedef struct {
92 uint32_t rd;
93 uint32_t last;
94 uint32_t overruns;
96
106
129size_t edge_ring_take(edge_ring_t *r, const uint32_t *ring, uint32_t size,
130 uint32_t wr, uint64_t est, tone_edge_t *out, size_t max,
131 bool *overrun);
132
133#ifdef __cplusplus
134}
135#endif
uint64_t edge_tick(uint32_t count, uint64_t est)
The tick of the counter value count nearest est, with a counter that started at 0 and counts down.
Definition edge_ring.c:32
bool edge_word_level(uint32_t word)
The word's level after the edge.
Definition edge_ring.c:27
uint32_t edge_word_count(uint32_t word)
A word's 31-bit count and level.
Definition edge_ring.c:22
uint32_t edge_word(uint32_t count, bool level)
The word the program pushes for an edge at counter value count.
Definition edge_ring.c:17
size_t edge_ring_take(edge_ring_t *r, const uint32_t *ring, uint32_t size, uint32_t wr, uint64_t est, tone_edge_t *out, size_t max, bool *overrun)
Take the words in ring ( size words, a power of two) written since the last call, wr being the slot t...
Definition edge_ring.c:52
void edge_ring_init(edge_ring_t *r)
Start reading a ring from slot 0, as after the DMA channel restarts.
Definition edge_ring.c:45
Read position of an edge ring.
Definition edge_ring.h:91
uint32_t overruns
Definition edge_ring.h:94
uint32_t rd
Definition edge_ring.h:92
uint32_t last
Definition edge_ring.h:93
One edge: the tick it happened at and the level after it.
Definition tone.h:182
ESC (electronic speed controller) tones from the edges of one motor phase.