whiskers
0.4.0
RP2350 BadUSB Tool
Toggle main menu visibility
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
66
typedef
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
87
typedef
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
105
void
usb_setup_msc
(
char
vendor_string[8],
char
product_string[16], _DISK_INFO *di);
106
111
void
usb_initialize_defaults
(w_usb_cbs *cbs);
112
118
void
usb_initialize_custom
(w_usb_cbs *cbs, w_usb_mods *mods);
184
void
usb_keyboard_send_report
(
const
uint8_t rep[8]);
188
void
usb_loop
();
192
void
usb_remote_wakeup_host
();
193
#endif
shared.h
Shared structs, error codes, and functions for all HAL files.
usb_callbacks
Struct holding callback functions for internal USB events.
Definition
usb.h:88
usb_callbacks::unmounted_cb
void(*) unmounted_cb(void)
Definition
usb.h:90
usb_callbacks::mounted_cb
void(*) mounted_cb(void)
Definition
usb.h:89
usb_callbacks::suspend_cb
void(*) suspend_cb(bool)
Definition
usb.h:91
usb_callbacks::unsuspend_cb
void(*) unsuspend_cb(void)
Definition
usb.h:92
usb_mods
USB Modifiers.
Definition
usb.h:67
usb_mods::lang
char lang[2]
Definition
usb.h:68
usb_mods::manu_string
char manu_string[32+1]
Definition
usb.h:70
usb_mods::serial_string
char serial_string[32+1]
Definition
usb.h:72
usb_mods::pid
uint16_t pid
Definition
usb.h:75
usb_mods::prod_string
char prod_string[32+1]
Definition
usb.h:71
usb_mods::vid
uint16_t vid
Definition
usb.h:74
usb_remote_wakeup_host
void usb_remote_wakeup_host()
If the host allows us, this function will wake it up.
usb_initialize_defaults
void usb_initialize_defaults(w_usb_cbs *cbs)
Starts the internal USB stack with default values.
usb_setup_msc
void usb_setup_msc(char vendor_string[8], char product_string[16], _DISK_INFO *di)
Sets up the MSC Class USB interface.
usb_keyboard_send_report
void usb_keyboard_send_report(const uint8_t rep[8])
Sends a standard HID keyboard report.
usb_loop
void usb_loop()
For TinyUSB based systems, this refreshes tud_task(). This must be called at least once every millise...
usb_initialize_custom
void usb_initialize_custom(w_usb_cbs *cbs, w_usb_mods *mods)
Starts the internal USB stack with custom descriptors.
code
hal
usb.h
Generated by
1.18.0