CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
usb_hid.h
Go to the documentation of this file.
1// USB HID Module - Composite Device
2// CDC + optional HID/CCID interfaces registered by modules
3//
4// Interface descriptor types (UsbInterfaceClass, UsbHidCallbacks, UsbInterfaceDef)
5// are defined once in cdc_core/UsbManager.h and re-exported here as global aliases
6// for the legacy C-style apply API.
7
8#pragma once
9
10#include <stdbool.h>
11#include <stddef.h>
12#include <stdint.h>
13
14#ifdef __cplusplus
15#include "cdc_core/UsbManager.h"
16
17// Re-export the canonical types from cdc::core into the global namespace so that
18// the runtime apply API can keep using unqualified type names without enforcing
19// the namespace on existing call sites.
21using UsbHidCallbacks = cdc::core::UsbHidCallbacks;
22using UsbInterfaceDef = cdc::core::UsbInterfaceSpec;
23
24extern "C" {
25#endif
26
27// Initialize HID-related resources (if any).
28// TinyUSB init is performed by usb_cdc_init().
29bool usb_hid_init(void);
30
31// Apply active interface list (ordered). Attempts soft reconnect; sets needs_replug
32// if host may require replug.
33bool usb_hid_apply_config(const UsbInterfaceDef* defs, size_t count, bool* needs_replug);
34
35// Add (true) or remove (false) the MSC mass-storage interface and re-enumerate.
36void usb_hid_set_msc(bool active);
37
38// Check if USB is ready (CDC or HID).
39bool usb_hid_ready(void);
40
41// Per-instance HID helpers (instance is 0..n-1 in registration order)
42bool usb_hid_instance_ready(uint8_t instance);
43bool usb_hid_send_report(uint8_t instance, uint8_t report_id, const uint8_t* data, uint16_t len);
44
45#ifdef __cplusplus
46}
47#endif
bool usb_hid_init(void)
Public USB HID/composite configuration API implementation.
Definition usb_hid.cpp:373
bool usb_hid_ready(void)
Returns whether TinyUSB stack is ready.
Definition usb_hid.cpp:431
bool usb_hid_send_report(uint8_t instance, uint8_t report_id, const uint8_t *data, uint16_t len)
Sends one HID report on the selected interface instance.
Definition usb_hid.cpp:452
void usb_hid_set_msc(bool active)
Adds or removes the MSC interface and re-enumerates the device.
Definition usb_hid.cpp:414
bool usb_hid_apply_config(const UsbInterfaceDef *defs, size_t count, bool *needs_replug)
Applies the runtime interface configuration and optionally triggers re-enumeration.
Definition usb_hid.cpp:388
bool usb_hid_instance_ready(uint8_t instance)
Returns whether a specific HID instance endpoint is ready.
Definition usb_hid.cpp:440