change license email to website
added support for cdc devices
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
* descriptors.c
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -130,7 +130,7 @@ ATTR_ALIGNED(4) const USB_DEVICE_DESCRIPTOR USB_DeviceDescriptor =
|
||||
.bDeviceClass = USB_DEVICE_CLASS_IAD,
|
||||
.bDeviceSubClass = USB_DEVICE_SUBCLASS_IAD,
|
||||
.bDeviceProtocol = USB_DEVICE_PROTOCOL_IAD,
|
||||
#elif defined CFG_USB_CDC
|
||||
#elif defined CFG_CLASS_CDC
|
||||
.bDeviceClass = CDC_COMMUNICATION_INTERFACE_CLASS,
|
||||
.bDeviceSubClass = 0x00,
|
||||
.bDeviceProtocol = 0x00,
|
||||
@@ -187,7 +187,7 @@ ATTR_ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_CDC
|
||||
#ifdef CFG_CLASS_CDC
|
||||
// USB CDC Serial Interface
|
||||
// CDC Control Interface
|
||||
.CDC_CCI_Interface =
|
||||
|
@@ -2,13 +2,8 @@
|
||||
* descriptors.h
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* All rights reserved.
|
||||
* Author: hathachtware License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
@@ -88,9 +83,9 @@ typedef PRE_PACK struct POST_PACK _USB_INTERFACE_ASSOCIATION_DESCRIPTOR
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Interface Assosication Descriptor if device is CDC + other class
|
||||
#define IAD_DESC_REQUIRED ( defined(CFG_USB_CDC) && (CLASS_HID) )
|
||||
#define IAD_DESC_REQUIRED ( defined(CFG_CLASS_CDC) && (CLASS_HID) )
|
||||
|
||||
#ifdef CFG_USB_CDC
|
||||
#ifdef CFG_CLASS_CDC
|
||||
#define INTERFACES_OF_CDC 2
|
||||
#else
|
||||
#define INTERFACES_OF_CDC 0
|
||||
@@ -142,7 +137,7 @@ typedef struct
|
||||
USB_INTERFACE_ASSOCIATION_DESCRIPTOR CDC_IAD;
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_CDC
|
||||
#ifdef CFG_CLASS_CDC
|
||||
//CDC - Serial
|
||||
//CDC Control Interface
|
||||
USB_INTERFACE_DESCRIPTOR CDC_CCI_Interface;
|
||||
|
@@ -40,20 +40,53 @@ int main(void)
|
||||
lastSecond = currentSecond;
|
||||
GPIOSetBitValue(CFG_LED_PORT, CFG_LED_PIN, lastSecond % 2);
|
||||
|
||||
#if !defined(CFG_USB_CDC)
|
||||
#ifndef CFG_CLASS_CDC
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
||||
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA};
|
||||
usb_hid_keyboard_sendKeys(0x00, keys, 1);
|
||||
tusb_hid_keyboard_sendKeys(0x00, keys, 1);
|
||||
#endif
|
||||
|
||||
#ifdef CFG_CLASS_HID_MOUSE
|
||||
usb_hid_mouse_send(0, 10, 10);
|
||||
tusb_hid_mouse_send(0, 10, 10);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CFG_CLASS_CDC
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
uint8_t cdc_char;
|
||||
if( tusb_cdc_getc(&cdc_char) )
|
||||
{
|
||||
switch (cdc_char)
|
||||
{
|
||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
||||
case '1' :
|
||||
{
|
||||
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA + 'e' - 'a'};
|
||||
tusb_hid_keyboard_sendKeys(0x08, keys, 1); // windows + E --> open explorer
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CFG_CLASS_HID_MOUSE
|
||||
case '2' :
|
||||
tusb_hid_mouse_send(0, 10, 10);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default :
|
||||
cdc_char = toupper(cdc_char);
|
||||
tusb_cdc_putc(cdc_char);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user