ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
cdc_acm.h
Go to the documentation of this file.
1#pragma once
3#if defined(USE_ZEPHYR_CDC_ACM_RATE_CALLBACK)
4
6#include <zephyr/device.h>
7
8namespace esphome::zephyr {
9
11class CdcAcm final {
12 public:
17 template<typename F> static void add_on_rate_callback(F &&callback) {
18 if (rate_callbacks.size() == 0)
19 start();
20 rate_callbacks.add(std::forward<F>(callback));
21 }
22
24 static void rate_changed(const device *dev);
25
26 protected:
27 static void start();
28 static void post_rate(const device *dev);
29 static inline CallbackManager<void(const device *, uint32_t)> rate_callbacks;
30};
31
32} // namespace esphome::zephyr
33
34#endif
Passes the bit rate a USB host sets on a CDC ACM port from the USB driver's thread to the main loop.
Definition cdc_acm.h:11
static CallbackManager< void(const device *, uint32_t)> rate_callbacks
Definition cdc_acm.h:29
static void post_rate(const device *dev)
Definition cdc_acm.cpp:44
static void start()
Definition cdc_acm.cpp:26
static void add_on_rate_callback(F &&callback)
Call from setup().
Definition cdc_acm.h:17
static void rate_changed(const device *dev)
Called by the USB driver, from its own thread, after the host set the bit rate of dev.
Definition cdc_acm.cpp:38
static void uint32_t