|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include <UsbManager.h>
Public Member Functions | |
| const char * | getName () const override |
| bool | init () override |
| Initializes USB manager service state. | |
| bool | start () override |
| Starts USB manager service state. | |
| void | stop () override |
| Stops USB manager service state. | |
| ServiceState | getState () const override |
| bool | registerInterface (UsbHidInterface type, const char *moduleName, const UsbInterfaceSpec &def) |
| Registers a HID interface request from a module. | |
| void | unregisterInterface (UsbHidInterface type, const char *moduleName) |
| Unregisters a previously registered HID interface. | |
| uint8_t | activeInterfaceMask () const |
| bool | applyConfiguration () |
| Applies current interface set to USB HID stack. | |
| bool | needsReplug () const |
| bool | hidSlotsFull () const |
| Reports whether the HID interface budget is exhausted. | |
| bool | newlyRequiresReplug (bool wasNeededBefore) const |
| Tests whether a toggle newly introduced a replug requirement. | |
| Public Member Functions inherited from cdc::core::IService | |
| virtual | ~IService ()=default |
Static Public Member Functions | |
| static UsbManager & | instance () |
| Returns singleton USB manager instance. | |
UsbManager - HID interface arbitration
CDC is always enabled (handled by usb_badge). HID interfaces are optional and registered by modules at runtime.
Definition at line 52 of file UsbManager.h.
|
inline |
Definition at line 67 of file UsbManager.h.
| bool cdc::core::UsbManager::applyConfiguration | ( | ) |
Applies current interface set to USB HID stack.
Definition at line 130 of file UsbManager.cpp.
References cdc::core::Ccid, cdc::core::Fido, cdc::core::Keyboard, and usb_hid_apply_config().
Referenced by registerInterface(), and unregisterInterface().
|
inlineoverridevirtual |
Get service name (for logging/debugging)
Implements cdc::core::IService.
Definition at line 56 of file UsbManager.h.
|
inlineoverridevirtual |
Get current service state
Implements cdc::core::IService.
Definition at line 61 of file UsbManager.h.
|
inline |
Reports whether the HID interface budget is exhausted.
Definition at line 75 of file UsbManager.h.
|
overridevirtual |
Initializes USB manager service state.
Implements cdc::core::IService.
Definition at line 23 of file UsbManager.cpp.
References cdc::core::INITIALIZED.
|
static |
Returns singleton USB manager instance.
Definition at line 14 of file UsbManager.cpp.
Referenced by cdc::core::ModuleRegistry::classifyStartFailure(), cdc::serial::cmdModuleDisable(), cdc::serial::cmdModuleEnable(), cdc::ui::onModuleSelect(), cdc::mod_fido2::Fido2Module::start(), cdc::mod_gpg::GpgModule::start(), cdc::mod_fido2::Fido2Module::stop(), and cdc::mod_gpg::GpgModule::stop().
|
inline |
Definition at line 69 of file UsbManager.h.
Referenced by cdc::serial::cmdModuleDisable(), cdc::serial::cmdModuleEnable(), and cdc::ui::onModuleSelect().
|
inline |
Tests whether a toggle newly introduced a replug requirement.
Callers snapshot needsReplug() before performing a module toggle and pass it here afterwards; returns true only on a false-to-true transition.
| wasNeededBefore | needsReplug() value captured before the toggle. |
Definition at line 85 of file UsbManager.h.
| bool cdc::core::UsbManager::registerInterface | ( | UsbHidInterface | type, |
| const char * | moduleName, | ||
| const UsbInterfaceSpec & | def ) |
Registers a HID interface request from a module.
| type | HID interface slot. |
| moduleName | Owning module name. |
| def | Interface descriptor definition. |
Definition at line 73 of file UsbManager.cpp.
References applyConfiguration(), LOG_I, LOG_W, and TAG.
|
overridevirtual |
Starts USB manager service state.
Implements cdc::core::IService.
Definition at line 32 of file UsbManager.cpp.
References cdc::core::STARTED.
|
overridevirtual |
Stops USB manager service state.
Implements cdc::core::IService.
Definition at line 40 of file UsbManager.cpp.
References cdc::core::STOPPED.
| void cdc::core::UsbManager::unregisterInterface | ( | UsbHidInterface | type, |
| const char * | moduleName ) |
Unregisters a previously registered HID interface.
| type | HID interface slot. |
| moduleName | Requesting module name. |
Definition at line 106 of file UsbManager.cpp.
References applyConfiguration(), LOG_I, LOG_W, and TAG.
Referenced by cdc::mod_fido2::Fido2Module::start(), cdc::mod_fido2::Fido2Module::stop(), and cdc::mod_gpg::GpgModule::stop().