Test RX channel functionality with low-frequency pattern.
Validates the given RX channel can capture edge transitions by generating a simple test pattern (HIGH/LOW toggles) and verifying the captured timing data matches expectations.
160 {
161 FL_WARN(
"Testing RX channel with low-frequency pattern...");
162
163 if (!rx) {
164 FL_ERROR(
"Failed to test RX channel - null channel provided");
165 return false;
166 }
167
168 int pin_rx = rx->
getPin();
169
170
172 config.signal_range_min_ns = 100;
173 config.signal_range_max_ns = 30000000;
174 config.start_low = true;
175
176
181
182 if (!rx->
begin(config)) {
183 FL_ERROR(
"Failed to initialize RX channel");
184 return false;
185 }
186
187
188
189 FL_WARN(
"Generating test pattern on GPIO " << pin_tx <<
"...");
197
198
199 FL_WARN(
"Waiting for RX capture...");
200 auto wait_result = rx->
wait(100);
201
203 FL_ERROR(
"RX channel test FAILED - timeout waiting for data");
204 FL_ERROR(
" No edges captured within 100ms");
205 FL_ERROR(
" This suggests the RX channel cannot read from GPIO " << pin_rx);
206 return false;
207 }
208
209
212
213 if (edge_count < 3) {
214 FL_ERROR(
"RX channel test FAILED - insufficient edges captured");
215 FL_ERROR(
" Expected at least 3 edges, got " << edge_count);
216 FL_ERROR(
" Pin loopback may not be working correctly");
217 return false;
218 }
219
220
221 bool timing_ok = true;
222 for (size_t i = 0; i < edge_count && i < 3; i++) {
223 uint32_t duration_ms = edge_buffer[i].ns / 1000000;
224 if (duration_ms < 5 || duration_ms > 20) {
225 FL_WARN(
"WARNING: Edge " << i <<
" timing unusual: " << duration_ms <<
"ms (expected ~10ms)");
226 timing_ok = false;
227 }
228 }
229
230 if (timing_ok) {
231 FL_WARN(
"✓ RX channel test PASSED");
232 FL_WARN(
" Captured " << edge_count <<
" edges");
233 FL_WARN(
" Timing appears correct (~10ms per edge)");
234 return true;
235 } else {
236 FL_WARN(
"✓ RX channel test PASSED (with timing warnings)");
237 FL_WARN(
" Captured " << edge_count <<
" edges");
238 FL_WARN(
" Timing may be affected by system load");
239 return true;
240 }
241}
bool begin(const RxChannelConfig &config) FL_NOEXCEPT
size_t getRawEdgeTimes(fl::span< EdgeTime > out, size_t offset=0) FL_NOEXCEPT
RxWaitResult wait(u32 timeout_ms) FL_NOEXCEPT
int getPin() const FL_NOEXCEPT
A fixed-size array implementation similar to std::array.
void delay(u32 ms, bool run_async=true) FL_NOEXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
void pinMode(int pin, PinMode mode)
Set pin mode (input, output, pull-up, pull-down)
void digitalWrite(int pin, PinValue val)
Write digital value to pin.
@ TIMEOUT
Operation timed out.