mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-21 12:40:51 +00:00
rename macro configure in examples
This commit is contained in:
parent
f9aee11063
commit
8c2ec83c59
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
#include "descriptors.h"
|
#include "descriptors.h"
|
||||||
|
|
||||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
ATTR_ALIGNED(4) const uint8_t HID_KeyboardReportDescriptor[] = {
|
ATTR_ALIGNED(4) const uint8_t HID_KeyboardReportDescriptor[] = {
|
||||||
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
||||||
HID_Usage ( HID_USAGE_GENERIC_KEYBOARD ),
|
HID_Usage ( HID_USAGE_GENERIC_KEYBOARD ),
|
||||||
@ -80,7 +80,7 @@ ATTR_ALIGNED(4) const uint8_t HID_KeyboardReportDescriptor[] = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_CLASS_HID_MOUSE
|
#ifdef TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
ATTR_ALIGNED(4) const uint8_t HID_MouseReportDescriptor[] = {
|
ATTR_ALIGNED(4) const uint8_t HID_MouseReportDescriptor[] = {
|
||||||
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
||||||
HID_Usage ( HID_USAGE_GENERIC_MOUSE ),
|
HID_Usage ( HID_USAGE_GENERIC_MOUSE ),
|
||||||
@ -130,7 +130,7 @@ ATTR_ALIGNED(4) const USB_DEVICE_DESCRIPTOR USB_DeviceDescriptor =
|
|||||||
.bDeviceClass = USB_DEVICE_CLASS_IAD,
|
.bDeviceClass = USB_DEVICE_CLASS_IAD,
|
||||||
.bDeviceSubClass = USB_DEVICE_SUBCLASS_IAD,
|
.bDeviceSubClass = USB_DEVICE_SUBCLASS_IAD,
|
||||||
.bDeviceProtocol = USB_DEVICE_PROTOCOL_IAD,
|
.bDeviceProtocol = USB_DEVICE_PROTOCOL_IAD,
|
||||||
#elif defined CFG_CLASS_CDC
|
#elif defined TUSB_CFG_DEVICE_CDC
|
||||||
.bDeviceClass = CDC_COMMUNICATION_INTERFACE_CLASS,
|
.bDeviceClass = CDC_COMMUNICATION_INTERFACE_CLASS,
|
||||||
.bDeviceSubClass = 0x00,
|
.bDeviceSubClass = 0x00,
|
||||||
.bDeviceProtocol = 0x00,
|
.bDeviceProtocol = 0x00,
|
||||||
@ -187,7 +187,7 @@ ATTR_ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
|||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_CLASS_CDC
|
#ifdef TUSB_CFG_DEVICE_CDC
|
||||||
// USB CDC Serial Interface
|
// USB CDC Serial Interface
|
||||||
// CDC Control Interface
|
// CDC Control Interface
|
||||||
.CDC_CCI_Interface =
|
.CDC_CCI_Interface =
|
||||||
@ -276,7 +276,7 @@ ATTR_ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
|||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
///// USB HID Keyboard interface
|
///// USB HID Keyboard interface
|
||||||
.HID_KeyboardInterface =
|
.HID_KeyboardInterface =
|
||||||
{
|
{
|
||||||
@ -316,7 +316,7 @@ ATTR_ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
|||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_CLASS_HID_MOUSE
|
#ifdef TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
.HID_MouseInterface =
|
.HID_MouseInterface =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(USB_INTERFACE_DESCRIPTOR),
|
.bLength = sizeof(USB_INTERFACE_DESCRIPTOR),
|
||||||
|
@ -67,21 +67,21 @@ typedef PRE_PACK struct POST_PACK _USB_STR_DESCRIPTOR
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// Interface Assosication Descriptor if device is CDC + other class
|
// Interface Assosication Descriptor if device is CDC + other class
|
||||||
#define IAD_DESC_REQUIRED ( defined(CFG_CLASS_CDC) && (TUSB_CLASS_HID) )
|
#define IAD_DESC_REQUIRED ( defined(TUSB_CFG_DEVICE_CDC) && (DEVICE_CLASS_HID) )
|
||||||
|
|
||||||
#ifdef CFG_CLASS_CDC
|
#ifdef TUSB_CFG_DEVICE_CDC
|
||||||
#define INTERFACES_OF_CDC 2
|
#define INTERFACES_OF_CDC 2
|
||||||
#else
|
#else
|
||||||
#define INTERFACES_OF_CDC 0
|
#define INTERFACES_OF_CDC 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
#define INTERFACES_OF_HID_KEYBOARD 1
|
#define INTERFACES_OF_HID_KEYBOARD 1
|
||||||
#else
|
#else
|
||||||
#define INTERFACES_OF_HID_KEYBOARD 0
|
#define INTERFACES_OF_HID_KEYBOARD 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_CLASS_HID_MOUSE
|
#ifdef TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
#define INTERFACES_OF_HID_MOUSE 1
|
#define INTERFACES_OF_HID_MOUSE 1
|
||||||
#else
|
#else
|
||||||
#define INTERFACES_OF_HID_MOUSE 0
|
#define INTERFACES_OF_HID_MOUSE 0
|
||||||
@ -121,7 +121,7 @@ typedef struct
|
|||||||
USB_Descriptor_InterfaceAssociation_t CDC_IAD;
|
USB_Descriptor_InterfaceAssociation_t CDC_IAD;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_CLASS_CDC
|
#ifdef TUSB_CFG_DEVICE_CDC
|
||||||
//CDC - Serial
|
//CDC - Serial
|
||||||
//CDC Control Interface
|
//CDC Control Interface
|
||||||
USB_INTERFACE_DESCRIPTOR CDC_CCI_Interface;
|
USB_INTERFACE_DESCRIPTOR CDC_CCI_Interface;
|
||||||
@ -136,14 +136,14 @@ typedef struct
|
|||||||
USB_ENDPOINT_DESCRIPTOR CDC_DataInEndpoint;
|
USB_ENDPOINT_DESCRIPTOR CDC_DataInEndpoint;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
//Keyboard HID Interface
|
//Keyboard HID Interface
|
||||||
USB_INTERFACE_DESCRIPTOR HID_KeyboardInterface;
|
USB_INTERFACE_DESCRIPTOR HID_KeyboardInterface;
|
||||||
HID_DESCRIPTOR HID_KeyboardHID;
|
HID_DESCRIPTOR HID_KeyboardHID;
|
||||||
USB_ENDPOINT_DESCRIPTOR HID_KeyboardEndpoint;
|
USB_ENDPOINT_DESCRIPTOR HID_KeyboardEndpoint;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_CLASS_HID_MOUSE
|
#ifdef TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
//Mouse HID Interface
|
//Mouse HID Interface
|
||||||
USB_INTERFACE_DESCRIPTOR HID_MouseInterface;
|
USB_INTERFACE_DESCRIPTOR HID_MouseInterface;
|
||||||
HID_DESCRIPTOR HID_MouseHID;
|
HID_DESCRIPTOR HID_MouseHID;
|
||||||
|
@ -28,22 +28,22 @@ int main(void)
|
|||||||
|
|
||||||
printf("hello world\n");
|
printf("hello world\n");
|
||||||
|
|
||||||
#ifndef CFG_CLASS_CDC
|
#ifndef TUSB_CFG_DEVICE_CDC
|
||||||
if (usb_isConfigured())
|
if (usb_isConfigured())
|
||||||
{
|
{
|
||||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA};
|
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA};
|
||||||
tusb_hid_keyboard_sendKeys(0x00, keys, 1);
|
tusb_hid_keyboard_sendKeys(0x00, keys, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_CLASS_HID_MOUSE
|
#ifdef TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
tusb_hid_mouse_send(0, 10, 10);
|
tusb_hid_mouse_send(0, 10, 10);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CFG_CLASS_CDC
|
#ifdef TUSB_CFG_DEVICE_CDC
|
||||||
if (usb_isConfigured())
|
if (usb_isConfigured())
|
||||||
{
|
{
|
||||||
uint8_t cdc_char;
|
uint8_t cdc_char;
|
||||||
@ -51,7 +51,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
switch (cdc_char)
|
switch (cdc_char)
|
||||||
{
|
{
|
||||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
case '1' :
|
case '1' :
|
||||||
{
|
{
|
||||||
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA + 'e' - 'a'};
|
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA + 'e' - 'a'};
|
||||||
@ -60,7 +60,7 @@ int main(void)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_CLASS_HID_MOUSE
|
#ifdef TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
case '2' :
|
case '2' :
|
||||||
tusb_hid_mouse_send(0, 10, 10);
|
tusb_hid_mouse_send(0, 10, 10);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user