whiskers 0.2.0
RP2350 BadUSB Tool
Loading...
Searching...
No Matches
usb.h
Go to the documentation of this file.
1/* Copyright (c) 2026 Zane A. Maple
2 Licensed under the MIT license. See LICENSE in the main repository for more information. */
3
4#ifndef W_HAL_USB_H
5#define W_HAL_USB_H
6
7#include "shared.h"
8
31#define USB_LANG_CODE { 0x04, 0x09 }
36#define USB_MANUFACTURER_STRING "vllabs"
41#define USB_PRODUCT_STRING "\'whiskers\'"
46/* Turns out you only need custom PIDs and VIDs if your device either follows the USB standard to a tee (it doesn't) or you use the USB trademark (which we aren't) */
47#define USB_PID 0x0400
52#define USB_VID 0xcafe
57
66typedef struct usb_mods
67{
68 char lang[2];
69 /* Note the +1 here is for the string end */
70 char manu_string[32 + 1];
71 char prod_string[32 + 1];
72 char serial_string[32 + 1];
73
74 uint16_t vid;
75 uint16_t pid;
76} w_usb_mods;
77
87typedef struct usb_callbacks
88{
89 void (*mounted_cb)(void);
90 void (*unmounted_cb)(void);
91 void (*suspend_cb)(bool);
92 void (*unsuspend_cb)(void);
93} w_usb_cbs;
94
105void usb_setup_msc(char vendor_string[8], char product_string[16], _DISK_INFO *di);
106
111void usb_initialize_defaults(w_usb_cbs *cbs);
112
118void usb_initialize_custom(w_usb_cbs *cbs, w_usb_mods *mods);
182void usb_keyboard_send_report(const uint8_t rep[8]);
186void usb_loop();
191#endif
Shared structs, error codes, and functions for all HAL files.
Struct holding callback functions for internal USB events.
Definition usb.h:88
void(* unmounted_cb)(void)
Definition usb.h:90
void(* unsuspend_cb)(void)
Definition usb.h:92
void(* mounted_cb)(void)
Definition usb.h:89
void(* suspend_cb)(bool)
Definition usb.h:91
USB Modifiers.
Definition usb.h:67
void usb_remote_wakeup_host()
If the host allows us, this function will wake it up.
void usb_initialize_defaults(w_usb_cbs *cbs)
Starts the internal USB stack with default values.
void usb_setup_msc(char vendor_string[8], char product_string[16], _DISK_INFO *di)
Sets up the MSC Class USB interface.
void usb_keyboard_send_report(const uint8_t rep[8])
Sends a standard HID keyboard report.
void usb_loop()
For TinyUSB based systems, this refreshes tud_task(). This must be called at least once every millise...
void usb_initialize_custom(w_usb_cbs *cbs, w_usb_mods *mods)
Starts the internal USB stack with custom descriptors.