1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/* usb_common.h - Common framework for implementing multiple USB devices at once
*
* Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-Licence-Identifier: AGPL-3.0-or-later
*/
#ifndef _USB_COMMON_H_
#define _USB_COMMON_H_
#include "coroutine.h"
/* Strings ********************************************************************/
enum {
/* Be sure to keep this list in-sync with
* usb_common.c:tud_descriptor_string_cb() */
STRID_LANGID = 0,
STRID_MANUF,
STRID_PRODUCT,
STRID_SERIAL,
STRID_CFG,
STRID_KBD_IFC,
STRID_NONE = 0,
};
/* Globals ********************************************************************/
extern uint8_t cfgnum_std;
void usb_common_earlyinit(void);
void usb_common_lateinit(void);
COROUTINE usb_common_cr(void *arg);
/* Main utilities *************************************************************/
/**
* Declare a new TUD configuration.
*
* @param iConfiguration : ID of the string descriptor describing this configuration
* @param bmAttributes : bitmap of flags; TUSB_DESC_CONFIG_ATT_{REMOTE_WAKUP,SELF_POWERED}
* @param bMaxPower_mA : maximum power consumption of the device when in this configuration, in mA
* @return the configuration number for the created config
*/
uint8_t usb_add_config(uint8_t iConfiguration, uint8_t bmAttributes, uint8_t bMaxPower_mA);
/**
* Add an interface to a configuration that has been created with usb_add_config().
*
* @param cfg_num : the value returned from usb_add_config()
* @param ifc_len : the length of ifc_Dat
* @param ifc_dat : the raw descriptor data for the interface (probably created by
* TUD_{CLASS}_DESCRIPTOR(); grep TinyUSB/src/device/usbd.h for '#define
* TUD_\S*_DESCRIPTOR(_itfnum'). The interface number in this data is overwritten with the
* appropriate number for this config.
* @return the interface number for the added interface
*/
uint8_t usb_add_interface(uint8_t cfg_num, uint16_t ifc_len, uint8_t *ifc_dat);
#endif /* _USB_COMMON_H_ */
|