Compute the RX edge-buffer capacity for a validation frame.
GPIO ISR RX requires a power-of-two circular buffer. Size that buffer from the frame under test (two edges per bit plus framing headroom), rather than from AutoResearch's oversized shared byte buffer.
Definition at line 65 of file validation.h.
67 {
68 constexpr size_t kEdgesPerByte = 16;
69 constexpr size_t kFramingEdges = 2;
70 const size_t max_size =
static_cast<size_t>(-1);
71
73 if (shared_buffer_bytes >
max_size / 8) {
74 return 0;
75 }
76 return shared_buffer_bytes * 8;
77 }
78
79 if (expected_data_bytes > (max_size - kFramingEdges) / kEdgesPerByte) {
80 return 0;
81 }
82 const size_t required =
83 expected_data_bytes * kEdgesPerByte + kFramingEdges;
84 size_t capacity = 1;
85 while (capacity < required) {
86 if (capacity > max_size / 2) {
87 return 0;
88 }
89 capacity *= 2;
90 }
91 return capacity;
92}
@ ISR
Platform-neutral interrupt-driven edge capture backend when available.
References fl::FL_NO_EXCEPT, and fl::ISR.