ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
hdmi_cec.cpp
Go to the documentation of this file.
1#include "hdmi_cec.h"
2
3#include "esphome/core/hal.h"
4#include "esphome/core/log.h"
5#ifdef USE_ESP8266
6#include <Arduino.h>
7#endif
8#ifdef USE_RP2040
9#include <pico/time.h>
10#endif
11
13
14ESPHOME_LOG_TAG(TAG, "hdmi_cec");
15
16#if defined(USE_ESP8266) || defined(USE_RP2040)
17// The timer interrupt of these platforms carries no argument
18static HDMICEC *ack_timer_owner = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
19#endif
20
21// Bit timing from the HDMI 1.4 CEC specification, in microseconds
22static constexpr uint32_t START_BIT_MIN_US = 3500; // a low period at least this long is a start bit
23static constexpr uint32_t START_BIT_NOM_US = 3700;
24static constexpr uint32_t START_BIT_HIGH_US = 800;
25static constexpr uint32_t HIGH_BIT_MIN_US = 400; // shortest low period of a logical 1
26static constexpr uint32_t HIGH_BIT_US = 600; // nominal low period of a logical 1
27static constexpr uint32_t LOW_BIT_US = 1500; // nominal low period of a logical 0
28static constexpr uint32_t SAFE_SAMPLE_US = 1050; // the line is sampled here; a longer low period is a logical 0
29static constexpr uint32_t TOTAL_BIT_US = 2400;
30static constexpr uint32_t SIGNAL_FREE_TIME_AFTER_RECEIVE = TOTAL_BIT_US * 5; // also for a new initiator
31static constexpr uint32_t SIGNAL_FREE_TIME_AFTER_XMIT_FAIL = TOTAL_BIT_US * 3;
32static constexpr uint32_t SIGNAL_FREE_TIME_AFTER_XMIT_SUCCESS = TOTAL_BIT_US * 7;
33static constexpr uint32_t ABORTED_FRAME_US = TOTAL_BIT_US * 15; // no edge for this long: our frame was cut short
34static constexpr uint8_t MAX_ATTEMPTS = 8; // CEC allows 5, but a busy bus counts as an attempt here too
35
36Frame::Frame(uint8_t initiator_addr, uint8_t destination_addr, std::span<const uint8_t> payload) {
37 this->data_[0] = ((initiator_addr & 0xf) << 4) | (destination_addr & 0xf);
38 this->size_ = 1 + payload.size();
39 std::copy(payload.begin(), payload.end(), this->data_.begin() + 1);
40}
41
43 // The line is open drain with a weak pull-up: driven low to send, released to read
44 this->pin_->setup();
45 this->isr_pin_ = this->pin_->to_isr();
46 this->set_pin_input_high_();
47 this->required_idle_period_ = SIGNAL_FREE_TIME_AFTER_RECEIVE;
48 if (!this->setup_ack_timer_()) {
49 ESP_LOGE(TAG, "Failed to set up the acknowledge timer");
50 this->mark_failed();
51 return;
52 }
54 // loop() only has work once the interrupt queues a frame or send() queues one
55 this->disable_loop();
56}
57
59 ESP_LOGCONFIG(TAG,
60 "HDMI-CEC:\n"
61 " Address: 0x%X\n"
62 " Monitor mode: %s\n"
63 " Promiscuous mode: %s",
64 this->address_, YESNO(this->monitor_mode_), YESNO(this->promiscuous_mode_));
65 LOG_PIN(" Pin: ", this->pin_);
66}
67
69 const uint8_t dropped = atomic_get(this->dropped_frames_);
70 if (dropped != this->reported_dropped_frames_) {
71 const uint8_t count = dropped - this->reported_dropped_frames_;
72 ESP_LOGW(TAG, "%u received frame%s dropped (queue full or oversized)", count,
73 count == 1 ? LOG_STR_LITERAL("") : LOG_STR_LITERAL("s"));
74 this->reported_dropped_frames_ = dropped;
75 }
76 // One inbound frame per pass keeps the time spent in the automations bounded
77 if (const Frame *frame = this->frames_queue_.front()) {
78 ESP_LOGD_HEX(TAG, frame->bytes().data(), frame->size(), Frame::MAX_LENGTH, "Received: %s");
79#ifdef HDMI_CEC_MESSAGE_CALLBACK_COUNT
80 this->message_callbacks_.call(frame->initiator_addr(), frame->destination_addr(), frame->payload());
81#endif
83 }
84 // A frame being sent stays at the front of the queue until its attempts are over
85 if (!this->send_queue_.is_empty()) {
86 this->transmit_message_();
87 }
88 if (this->frames_queue_.is_empty() && this->send_queue_.is_empty()) {
89 this->disable_loop();
90 }
91}
92
93bool HDMICEC::send(uint8_t source, uint8_t destination, std::span<const uint8_t> payload) {
94 if (this->monitor_mode_) {
95 ESP_LOGW(TAG, "Monitor mode, not sending 0x%X->0x%X", source, destination);
96 return false;
97 }
98 if (source > 0xf || destination > 0xf) {
99 ESP_LOGE(TAG, "Send abort: logical address 0x%X->0x%X out of range", source, destination);
100 return false;
101 }
102 if (payload.size() > Frame::MAX_PAYLOAD_LENGTH) {
103 ESP_LOGE(TAG, "Send abort 0x%X->0x%X: payload of %zu bytes exceeds %zu", source, destination, payload.size(),
105 return false;
106 }
107 Frame *frame = this->send_queue_.back();
108 if (frame == nullptr) {
109 ESP_LOGW(TAG, "Send queue full, frame 0x%X->0x%X dropped", source, destination);
110 return false;
111 }
112 *frame = Frame(source, destination, payload);
113 this->send_queue_.push_back();
114 this->enable_loop();
115 return true;
116}
117
119 const uint32_t now = micros();
120 const uint32_t since_last_edge = now - atomic_get(this->last_edge_us_);
121 if (this->transmitting_) {
122 // The interrupt sees our own frame; wait for its end of message bit, or give up when the
123 // bus went quiet without one
124 if (!atomic_get(this->eom_received_) && since_last_edge < ABORTED_FRAME_US) {
125 return;
126 }
127 this->transmitting_ = false;
128 atomic_set(this->eom_received_, false); // the end of our own frame is not a foreign one
129 const Frame *frame = this->send_queue_.front();
130 // A broadcast is acknowledged by nobody; a directed frame on every byte
131 const bool bytes_ok = this->n_bytes_received_ == frame->size();
132 const bool acks_ok = this->n_acks_received_ == (frame->is_broadcast() ? 0 : frame->size());
133 if (bytes_ok && acks_ok) {
134 ESP_LOGD(TAG, "Send frame success in %u attempt%s", this->transmit_attempts_,
135 this->transmit_attempts_ > 1 ? LOG_STR_LITERAL("s") : LOG_STR_LITERAL(""));
136 } else if (!bytes_ok) {
137 ESP_LOGD(TAG, "Send frame incorrect on attempt %u, saw %u bytes but expected %zu", this->transmit_attempts_,
138 this->n_bytes_received_, frame->size());
139 } else {
140 ESP_LOGD(TAG, "Send frame not acknowledged on attempt %u", this->transmit_attempts_);
141 }
142 this->finish_attempt_(bytes_ok && acks_ok);
143 } else if (atomic_get(this->eom_received_)) {
144 // Another device finished a frame; the standard asks a new initiator to wait after it
145 this->required_idle_period_ = SIGNAL_FREE_TIME_AFTER_RECEIVE;
146 atomic_set(this->eom_received_, false);
147 }
148
149 const Frame *frame = this->send_queue_.front();
150 // An edge within the signal free time means the bus is in use or not yet free for us; a start
151 // bit refused by a held line drives no edge, so that attempt is timed on its own
152 if (frame == nullptr || since_last_edge < this->required_idle_period_ ||
154 return;
155 }
156
157 this->last_attempt_us_ = now;
158 this->transmit_attempts_++;
159#ifdef ESPHOME_LOG_HAS_DEBUG
160 if (this->transmit_attempts_ == 1) {
162 ESP_LOGD(TAG, "Sending: %s", format_hex_pretty_to(line, frame->bytes().data(), frame->size()));
163 }
164#endif
165 // The interrupt counts the bytes and acknowledge bits of our own frame
166 this->n_bytes_received_ = 0;
167 this->n_acks_received_ = 0;
168 atomic_set(this->eom_received_, false);
169 this->transmitting_ = true;
170 if (!this->transmit_frame_(frame)) {
171 // The line was held, or another initiator sent at the same time
172 this->transmitting_ = false;
173 this->finish_attempt_(false);
174 }
175 // Otherwise the acknowledge result arrives through the interrupt
176}
177
178void HDMICEC::finish_attempt_(bool sent_ok) {
179 this->required_idle_period_ = sent_ok ? SIGNAL_FREE_TIME_AFTER_XMIT_SUCCESS : SIGNAL_FREE_TIME_AFTER_XMIT_FAIL;
180 if (!sent_ok) {
181 if (this->transmit_attempts_ < MAX_ATTEMPTS) {
182 return; // the signal free time has to pass before the retry
183 }
184 ESP_LOGW(TAG, "Frame not sent after %u attempts, dropped", this->transmit_attempts_);
185 }
186 this->transmit_attempts_ = 0;
187 this->send_queue_.pop_front();
188}
189
190bool HDMICEC::transmit_frame_(const Frame *frame) {
191 if (!this->send_start_bit_()) {
192 return false;
193 }
194 const auto bytes = frame->bytes();
195 for (size_t byte_inx = 0; byte_inx < bytes.size(); byte_inx++) {
196 const uint8_t current_byte = bytes[byte_inx];
197 // Most significant bit first. The four initiator address bits watch for a collision with
198 // another initiator that started at the same moment; a lower address wins by holding the line
199 for (int8_t i = 7; i >= 0; i--) {
200 const bool bit_value = (current_byte >> i) & 0x1;
201 if (!this->send_bit_(bit_value) && byte_inx == 0 && i >= 4) {
202 ESP_LOGD(TAG, "Bus collision on sending initiator address 0x%X on attempt %u", frame->initiator_addr(),
203 this->transmit_attempts_);
204 return false;
205 }
206 }
207 // End of message bit, then the acknowledge bit which the receiver may pull low
208 this->send_bit_(byte_inx == bytes.size() - 1);
209 this->send_bit_(true);
210 }
211 return true;
212}
213
215 if (!this->isr_pin_.digital_read()) {
216 ESP_LOGD(TAG, "Bus occupied before start bit on attempt %u", this->transmit_attempts_);
217 return false;
218 }
219 this->set_pin_output_low_();
220 delay_microseconds_safe(START_BIT_NOM_US);
221 // Release the line and check that nobody else keeps it low
222 this->set_pin_input_high_();
223 delay_microseconds_safe(START_BIT_HIGH_US / 2);
224 bool value = this->isr_pin_.digital_read();
225 delay_microseconds_safe(START_BIT_HIGH_US / 2);
226 value &= this->isr_pin_.digital_read();
227 if (!value) {
228 ESP_LOGD(TAG, "Bus collision on sending start bit on attempt %u", this->transmit_attempts_);
229 }
230 return value;
231}
232
233bool HDMICEC::send_bit_(bool bit_value) {
234 const uint32_t start_us = micros();
235 this->set_pin_output_low_();
236 delay_microseconds_safe(bit_value ? HIGH_BIT_US : LOW_BIT_US);
237 this->set_pin_input_high_();
238 bool clear = true;
239 if (bit_value) {
240 // Sample in the middle of the safe sample period: a line still low means another initiator
241 // is sending a logical 0 at the same time
242 uint32_t elapsed = micros() - start_us;
243 if (elapsed < SAFE_SAMPLE_US) {
244 delay_microseconds_safe(SAFE_SAMPLE_US - elapsed);
245 }
246 clear = this->isr_pin_.digital_read();
247 }
248 const uint32_t elapsed = micros() - start_us;
249 if (elapsed < TOTAL_BIT_US) {
250 delay_microseconds_safe(TOTAL_BIT_US - elapsed);
251 }
252 return clear;
253}
254
255void IRAM_ATTR HDMICEC::send_ack_() {
256 // The acknowledge has to start right at this falling edge; the timer releases the line
257 this->set_pin_output_low_();
258 this->start_ack_timer_();
259}
260
261#if defined(USE_ESP32)
263 gptimer_config_t config = {
264 .clk_src = GPTIMER_CLK_SRC_DEFAULT,
265 .direction = GPTIMER_COUNT_UP,
266 .resolution_hz = 1000000, // one tick per microsecond
267 };
268 if (gptimer_new_timer(&config, &this->ack_timer_) != ESP_OK) {
269 return false;
270 }
271 gptimer_event_callbacks_t callbacks = {.on_alarm = HDMICEC::ack_timer_isr_s};
272 // The alarm reloads the count to zero itself, so the interrupt only has to start the timer
273 gptimer_alarm_config_t alarm = {
274 .alarm_count = LOW_BIT_US, .reload_count = 0, .flags = {.auto_reload_on_alarm = true}};
275 return gptimer_register_event_callbacks(this->ack_timer_, &callbacks, this) == ESP_OK &&
276 gptimer_set_alarm_action(this->ack_timer_, &alarm) == ESP_OK && gptimer_enable(this->ack_timer_) == ESP_OK;
277}
278
279void IRAM_ATTR HDMICEC::start_ack_timer_() { gptimer_start(this->ack_timer_); }
280
281bool IRAM_ATTR HDMICEC::ack_timer_isr_s(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *arg) {
282 auto *self = static_cast<HDMICEC *>(arg);
283 self->set_pin_input_high_();
284 gptimer_stop(timer);
285 return false; // no task to wake
286}
287
288#elif defined(USE_ESP8266)
289static constexpr uint32_t TIMER1_TICKS_PER_US = 5; // TIM_DIV16 of the 80 MHz clock
290
292 ack_timer_owner = this;
293 timer1_isr_init();
294 timer1_attachInterrupt(HDMICEC::ack_timer_isr_s);
295 timer1_enable(TIM_DIV16, TIM_EDGE, TIM_SINGLE); // a write arms one shot
296 return true;
297}
298
299void IRAM_ATTR HDMICEC::start_ack_timer_() { timer1_write(LOW_BIT_US * TIMER1_TICKS_PER_US); }
300
301void IRAM_ATTR HDMICEC::ack_timer_isr_s() { ack_timer_owner->set_pin_input_high_(); }
302
303#elif defined(USE_RP2040)
305 this->ack_alarm_ = hardware_alarm_claim_unused(false);
306 if (this->ack_alarm_ < 0) {
307 return false; // every hardware alarm is taken
308 }
309 ack_timer_owner = this;
310 hardware_alarm_set_callback(this->ack_alarm_, HDMICEC::ack_timer_isr_s);
311 return true;
312}
313
314void IRAM_ATTR HDMICEC::start_ack_timer_() {
315 hardware_alarm_set_target(this->ack_alarm_, make_timeout_time_us(LOW_BIT_US));
316}
317
318void IRAM_ATTR HDMICEC::ack_timer_isr_s(uint alarm_num) { ack_timer_owner->set_pin_input_high_(); }
319
320#else
321bool HDMICEC::setup_ack_timer_() { return true; }
322
323// Without a one-shot timer the interrupt holds the line itself
324void IRAM_ATTR HDMICEC::start_ack_timer_() {
325 delay_microseconds_safe(LOW_BIT_US);
326 this->set_pin_input_high_();
327}
328#endif
329
330void IRAM_ATTR HDMICEC::gpio_isr_s(HDMICEC *self) { self->gpio_isr_(); }
331
332void IRAM_ATTR HDMICEC::gpio_isr_() {
333 const uint32_t now = micros();
334 const bool level = this->isr_pin_.digital_read();
335 if (level == this->prev_pin_level_) {
336 return; // a mode change of the pin, not a bus edge
337 }
338 this->prev_pin_level_ = level;
339 atomic_set(this->last_edge_us_, now);
340
341 if (!level) {
342 // Falling edge: the start of a low period
343 if (now - this->last_falling_edge_us_ > START_BIT_NOM_US + TOTAL_BIT_US) {
344 // The bus was quiet; whatever was gathered belongs to an aborted frame
345 this->reset_receiver_();
346 }
347 this->last_falling_edge_us_ = now;
348 if (this->recv_ack_queued_) {
349 // Acknowledge by stretching this low period
350 this->send_ack_();
351 this->recv_ack_queued_ = false;
352 }
353 return;
354 }
355
356 // Rising edge: the low period tells the bit value
357 const uint32_t pulse_duration = now - this->last_falling_edge_us_;
358 if (pulse_duration > START_BIT_MIN_US) {
359 this->reset_receiver_();
361 // Without a free slot the frame is neither acknowledged nor delivered, so its initiator retries
362 this->recv_frame_ = this->frames_queue_.back();
363 if (this->recv_frame_ != nullptr) {
364 this->recv_frame_->clear();
365 }
366 return;
367 }
368 if (pulse_duration < HIGH_BIT_MIN_US / 4) {
369 return; // glitch
370 }
371 const bool value = pulse_duration <= SAFE_SAMPLE_US;
372 // Our own frame is on the bus until its end of message; send() may give it any initiator address
373 const bool own_frame = this->transmitting_ && !atomic_get(this->eom_received_);
374
375 switch (this->receiver_state_) {
377 break;
378
380 this->recv_byte_ = (this->recv_byte_ << 1) | value;
381 if (++this->recv_bit_counter_ == 8) {
382 if (this->recv_length_++ == 0) {
383 this->recv_header_ = this->recv_byte_;
384 }
385 if (this->recv_frame_ != nullptr && !this->recv_frame_->push_back(this->recv_byte_)) {
386 this->recv_frame_ = nullptr; // longer than the bus allows: corrupt, do not deliver it
387 }
388 this->recv_bit_counter_ = 0;
390 }
391 break;
392
394 this->recv_eom_ = value;
395 // A frame for us is acknowledged on the next bit, unless there is no room for it (so its
396 // initiator retries) or it is our own, which includes a polling message from a device
397 // claiming our logical address. A polling message for us (header only) needs no room, and
398 // goes unacknowledged only when nobody holds the address
399 if (!this->monitor_mode_ && !own_frame && (this->recv_frame_ != nullptr || (value && this->recv_length_ == 1)) &&
400 (this->recv_header_ & 0xf) == this->address_ && (this->recv_header_ >> 4) != this->address_) {
401 this->recv_ack_queued_ = true;
402 }
404 break;
405
407 if (own_frame) {
408 // A low acknowledge bit means the addressed device took the byte
409 // (for a broadcast it means some device refused it)
410 this->n_bytes_received_++;
411 if (!value) {
412 this->n_acks_received_++;
413 }
414 }
415 if (!this->recv_eom_) {
417 break;
418 }
419 atomic_set(this->eom_received_, true); // publishes the tally above to loop()
420 // The application only gets frames that are not our own and not a polling message (header
421 // only), which the acknowledge answered already, and that are addressed to us unless
422 // promiscuous
423 const uint8_t destination = this->recv_header_ & 0xf;
424 const bool wanted = this->recv_length_ > 1 && !own_frame && (this->recv_header_ >> 4) != this->address_ &&
425 (this->promiscuous_mode_ || destination == 0xf || destination == this->address_);
426 if (!wanted) {
427 // nothing to deliver
428 } else if (this->recv_frame_ == nullptr) {
430 } else {
431 this->frames_queue_.push_back();
433 }
434 this->reset_receiver_();
435 break;
436 }
437}
438
439void IRAM_ATTR HDMICEC::reset_receiver_() {
441 this->recv_bit_counter_ = 0;
442 this->recv_length_ = 0;
443 this->recv_ack_queued_ = false;
444 this->recv_frame_ = nullptr;
445}
446
447} // namespace esphome::hdmi_cec
void mark_failed()
Mark this component as failed.
void enable_loop_soon_any_context()
Thread and ISR-safe version of enable_loop() that can be called from any context.
void enable_loop()
Enable this component's loop.
Definition component.h:261
void disable_loop()
Disable this component's loop.
void attach_interrupt(void(*func)(T *), T *arg, gpio::InterruptType type) const
Definition gpio.h:29
ISRInternalGPIOPin to_isr() const
Definition gpio.cpp:96
One CEC bus message: a header byte with the initiator and destination addresses, then up to 15 payloa...
Definition hdmi_cec.h:35
ESPHOME_ALWAYS_INLINE bool push_back(uint8_t data)
False when the frame is full already; the bus allows no more.
Definition hdmi_cec.h:53
std::span< const uint8_t > bytes() const
Definition hdmi_cec.h:48
static constexpr size_t MAX_LENGTH
Definition hdmi_cec.h:37
static constexpr size_t MAX_PAYLOAD_LENGTH
Definition hdmi_cec.h:38
std::span< const uint8_t > payload() const
The bytes after the header, starting with the opcode.
Definition hdmi_cec.h:50
ESPHOME_ALWAYS_INLINE uint8_t initiator_addr() const
Definition hdmi_cec.h:44
ESPHOME_ALWAYS_INLINE size_t size() const
Definition hdmi_cec.h:47
ESPHOME_ALWAYS_INLINE bool is_broadcast() const
Definition hdmi_cec.h:46
ESPHOME_ALWAYS_INLINE uint8_t destination_addr() const
Definition hdmi_cec.h:45
std::array< uint8_t, MAX_LENGTH > data_
Definition hdmi_cec.h:62
ESPHOME_ALWAYS_INLINE void clear()
Definition hdmi_cec.h:51
ESPHOME_ALWAYS_INLINE void pop_front()
Definition hdmi_cec.h:75
ESPHOME_ALWAYS_INLINE Frame * back()
Definition hdmi_cec.h:76
ESPHOME_ALWAYS_INLINE void push_back()
Definition hdmi_cec.h:77
ESPHOME_ALWAYS_INLINE Frame * front()
Definition hdmi_cec.h:74
ESPHOME_ALWAYS_INLINE bool is_empty() const
Definition hdmi_cec.h:78
The HDMI-CEC bus on one GPIO pin.
Definition hdmi_cec.h:97
std::atomic< uint32_t > last_edge_us_
Definition hdmi_cec.h:190
void dump_config() override
Definition hdmi_cec.cpp:58
FrameRingBuffer< QUEUE_SIZE > send_queue_
Definition hdmi_cec.h:173
void setup() override
Definition hdmi_cec.cpp:42
static void gpio_isr_s(HDMICEC *self)
Definition hdmi_cec.cpp:330
std::atomic< uint8_t > dropped_frames_
Definition hdmi_cec.h:200
bool send(uint8_t source, uint8_t destination, std::span< const uint8_t > payload)
Queue a frame for transmission; false when the queue is full or in monitor mode.
Definition hdmi_cec.cpp:93
gptimer_handle_t ack_timer_
Definition hdmi_cec.h:183
static void ack_timer_isr_s()
Definition hdmi_cec.cpp:301
StaticCallbackManager< HDMI_CEC_MESSAGE_CALLBACK_COUNT, void(uint8_t, uint8_t, std::span< const uint8_t >)> message_callbacks_
Definition hdmi_cec.h:178
ISRInternalGPIOPin isr_pin_
Definition hdmi_cec.h:181
void send_ack_()
Pull the line low for the acknowledge bit of a frame addressed to us.
Definition hdmi_cec.cpp:255
ESPHOME_ALWAYS_INLINE void set_pin_output_low_()
Definition hdmi_cec.h:163
void finish_attempt_(bool sent_ok)
Keep the frame for another attempt, or drop it once the attempts are used up.
Definition hdmi_cec.cpp:178
ReceiverState receiver_state_
Definition hdmi_cec.h:208
std::atomic< bool > eom_received_
Definition hdmi_cec.h:199
bool send_bit_(bool bit_value)
Send one bit; false when a logical 1 found the line held low by another initiator.
Definition hdmi_cec.cpp:233
ESPHOME_ALWAYS_INLINE void set_pin_input_high_()
Definition hdmi_cec.h:162
FrameRingBuffer< QUEUE_SIZE > frames_queue_
Definition hdmi_cec.h:170
InternalGPIOPin * pin_
Definition hdmi_cec.h:180
bool transmit_frame_(const Frame *frame)
Drive the frame onto the line; false when another initiator sent at the same time.
Definition hdmi_cec.cpp:190
unsigned count
Definition gif.cpp:51
@ INTERRUPT_ANY_EDGE
Definition gpio_pin.h:54
ESPHOME_ALWAYS_INLINE void atomic_set(std::atomic< T > &atom, T value)
Definition hdmi_cec.h:25
ESPHOME_LOG_TAG(TAG, "hdmi_cec")
ESPHOME_ALWAYS_INLINE T atomic_get(const std::atomic< T > &atom)
Definition hdmi_cec.h:28
uint32_t value
Definition hal.cpp:41
char * format_hex_pretty_to(char *buffer, size_t buffer_size, const uint8_t *data, size_t length, char separator)
Format byte array as uppercase hex to buffer (base implementation).
Definition helpers.cpp:498
uint32_t IRAM_ATTR HOT micros()
Definition hal.cpp:43
void delay_microseconds_safe(uint32_t us)
Delay for the given amount of microseconds, possibly yielding to other processes during the wait.
Definition helpers.cpp:889
constexpr size_t format_hex_pretty_size(size_t byte_count)
Calculate buffer size needed for format_hex_pretty_to with separator: "XX:XX:...:XX\0".
Definition helpers.h:1687
static void uint32_t