MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/platforms/esp/32/drivers/uart/channel_driver_uart.cpp:30–1143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28#include "platforms/shared/mock/esp/32/drivers/uart_peripheral_mock.h"
29
30FL_TEST_FILE(FL_FILEPATH) {
31
32using namespace fl;
33
34namespace {
35
36/// UART bit duration at 4.0 Mbps = 250ns
37constexpr uint32_t UART_BIT_NS = 250;
38
39/// WS2812 timing constants for channel driver tests
40constexpr uint32_t WS2812_T0H = 400;
41constexpr uint32_t WS2812_T0L = 850;
42constexpr uint32_t WS2812_T1H = 800;
43constexpr uint32_t WS2812_T1L = 450;
44
45/// Create a default UART test configuration at 4.0 Mbps
46UartPeripheralConfig defaultConfig() {
47 return UartPeripheralConfig(4000000, 17, -1, 4096, 0, 1, 1);
48}
49
50/// Convert UART waveform bits (from mock) into EdgeTime entries.
51fl::vector<EdgeTime> waveformToEdges(const fl::vector<bool>& waveform, uint32_t bit_ns) {
52 fl::vector<EdgeTime> edges;
53 if (waveform.empty()) return edges;
54
55 // Prepend idle HIGH period (UART idle = mark = HIGH)
56 EdgeTime idle;
57 idle.ns = bit_ns * 2;
58 idle.high = 1;
59 edges.push_back(idle);
60
61 bool current_level = waveform[0];
62 uint32_t run_length = 1;
63
64 for (size_t i = 1; i < waveform.size(); i++) {
65 if (waveform[i] == current_level) {
66 run_length++;
67 } else {
68 EdgeTime edge;
69 edge.ns = run_length * bit_ns;
70 edge.high = current_level ? 1 : 0;
71 edges.push_back(edge);
72 current_level = waveform[i];
73 run_length = 1;
74 }
75 }
76 EdgeTime edge;
77 edge.ns = run_length * bit_ns;
78 edge.high = current_level ? 1 : 0;
79 edges.push_back(edge);
80
81 return edges;
82}
83
84/// Decode UART wave8 edges back to LED bytes using forward-only edge cursor.
85size_t decodeUartWave8FromEdges(fl::span<const EdgeTime> edges, fl::span<uint8_t> out) {
86 const uint32_t BIT_NS = UART_BIT_NS;
87 const uint32_t HALF_BIT_NS = BIT_NS / 2;

Callers

nothing calls this directly

Calls 15

encodeLedsToUartFunction · 0.85
defaultConfigFunction · 0.85
waveformToEdgesFunction · 0.85
decodeUartWave8FromEdgesFunction · 0.85
resetCapturedDataMethod · 0.80
getCapturedByteCountMethod · 0.80
verifyStartStopBitsMethod · 0.80
setVirtualTimeModeMethod · 0.80
getResetDurationMethod · 0.80
pumpTimeMethod · 0.80

Tested by

no test coverage detected