|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include "usb_badge/usb_cdc.h"#include "usb_badge/usb_hid.h"#include "cdc_core/feature_flags.h"#include "cdc_log.h"#include "esp_err.h"#include "esp_idf_version.h"#include "esp_rom_sys.h"#include "esp_system.h"#include "freertos/FreeRTOS.h"#include "freertos/task.h"#include "tusb.h"#include "class/cdc/cdc.h"#include <cstring>Go to the source code of this file.
Functions | |
| static void | usb_device_task (void *arg) |
| TinyUSB device task. | |
| static void | usb_shutdown_handler (void) |
| Public USB CDC API implementation. | |
| static bool | usb_start_stack (void) |
| bool | usb_cdc_init (void) |
| bool | usb_cdc_start (void) |
| Starts USB CDC runtime (or triggers re-enumeration in early-debug mode). | |
| bool | usb_cdc_ready (void) |
| Returns whether USB CDC is connected and ready. | |
| size_t | usb_cdc_write (const uint8_t *data, size_t len) |
| Writes byte buffer to USB CDC endpoint. | |
| size_t | usb_cdc_print (const char *str) |
| Writes null-terminated string to USB CDC. | |
| size_t | usb_cdc_read (uint8_t *data, size_t len) |
| Reads bytes from USB CDC endpoint. | |
| int | usb_cdc_getchar (void) |
| Reads one character from USB CDC stream. | |
| size_t | usb_cdc_available (void) |
| Returns number of bytes available for read. | |
| void | usb_cdc_flush (void) |
| Flushes pending USB CDC writes. | |
Variables | |
| static const char * | TAG = "USB" |
| static bool | g_usb_prepared = false |
| Internal USB CDC startup and task state. | |
| static bool | g_usb_started = false |
| static TaskHandle_t | g_usb_task = nullptr |
| size_t usb_cdc_available | ( | void | ) |
Returns number of bytes available for read.
Definition at line 268 of file usb_cdc.cpp.
References g_usb_started.
| void usb_cdc_flush | ( | void | ) |
Flushes pending USB CDC writes.
Flush TX buffer (blocking)
Definition at line 276 of file usb_cdc.cpp.
References g_usb_started.
| int usb_cdc_getchar | ( | void | ) |
Reads one character from USB CDC stream.
Definition at line 254 of file usb_cdc.cpp.
References g_usb_started.
| bool usb_cdc_init | ( | void | ) |
USB CDC Serial Interface
Provides serial console via TinyUSB CDC. Initialize USB subsystem with CDC serial Behavior depends on CONFIG_USB_EARLY_DEBUG:
Definition at line 129 of file usb_cdc.cpp.
References g_usb_prepared, LOG_E, LOG_I, TAG, usb_hid_init(), and usb_start_stack().
Referenced by initCoreServices().
| size_t usb_cdc_print | ( | const char * | str | ) |
Writes null-terminated string to USB CDC.
| str | String to write. |
Definition at line 234 of file usb_cdc.cpp.
References usb_cdc_write().
| size_t usb_cdc_read | ( | uint8_t * | data, |
| size_t | len ) |
Reads bytes from USB CDC endpoint.
| data | Output buffer. |
| len | Maximum bytes to read. |
Definition at line 245 of file usb_cdc.cpp.
References g_usb_started.
| bool usb_cdc_ready | ( | void | ) |
Returns whether USB CDC is connected and ready.
Definition at line 196 of file usb_cdc.cpp.
References g_usb_started.
| bool usb_cdc_start | ( | void | ) |
Starts USB CDC runtime (or triggers re-enumeration in early-debug mode).
Definition at line 166 of file usb_cdc.cpp.
References g_usb_prepared, g_usb_started, LOG_I, TAG, and usb_start_stack().
Referenced by startApp().
| size_t usb_cdc_write | ( | const uint8_t * | data, |
| size_t | len ) |
Writes byte buffer to USB CDC endpoint.
| data | Data buffer. |
| len | Number of bytes to write. |
Definition at line 206 of file usb_cdc.cpp.
References g_usb_started.
Referenced by host_usb_cdc_write(), and usb_cdc_print().
|
static |
TinyUSB device task.
TinyUSB device task loop.
| arg | Task parameter (unused). |
Definition at line 78 of file usb_cdc.cpp.
Referenced by usb_start_stack().
|
static |
Public USB CDC API implementation.
Starts the TinyUSB stack and creates the USB device task.
Definition at line 94 of file usb_cdc.cpp.
Referenced by usb_start_stack().
|
static |
Definition at line 108 of file usb_cdc.cpp.
References g_usb_started, g_usb_task, LOG_E, TAG, usb_device_task(), and usb_shutdown_handler().
Referenced by usb_cdc_init(), and usb_cdc_start().
|
static |
Internal USB CDC startup and task state.
Definition at line 38 of file usb_cdc.cpp.
Referenced by usb_cdc_init(), and usb_cdc_start().
|
static |
Definition at line 39 of file usb_cdc.cpp.
Referenced by usb_cdc_available(), usb_cdc_flush(), usb_cdc_getchar(), usb_cdc_read(), usb_cdc_ready(), usb_cdc_start(), usb_cdc_write(), and usb_start_stack().
|
static |
Definition at line 40 of file usb_cdc.cpp.
Referenced by usb_start_stack().
|
static |
USB CDC Serial Implementation
Uses TinyUSB for USB CDC serial console. Based on cdc-badge-os-legacy/components/usb_badge/usb_hid.cpp
Definition at line 32 of file usb_cdc.cpp.