summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-07-26 20:27:06 +0700
committerhathach <[email protected]>2019-07-26 20:27:06 +0700
commitd79a209aefe498f78350ee3e08b96b8e17fda6b1 (patch)
tree13ff78f60ce1602c86912932517e2f6d5e7aafea /examples
parent77d3124a7060ab55143c65dafc6c80d8f83690cd (diff)
example clean up
Diffstat (limited to 'examples')
-rw-r--r--examples/device/cdc_msc_hid/src/main.c9
-rw-r--r--examples/device/cdc_msc_hid/src/usb_descriptors.c7
-rw-r--r--examples/device/cdc_msc_hid/src/usb_descriptors.h34
-rw-r--r--examples/device/cdc_msc_hid_freertos/src/main.c9
-rw-r--r--examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c7
-rw-r--r--examples/device/cdc_msc_hid_freertos/src/usb_descriptors.h34
-rw-r--r--examples/device/webusb_serial/src/usb_descriptors.h2
7 files changed, 75 insertions, 27 deletions
diff --git a/examples/device/cdc_msc_hid/src/main.c b/examples/device/cdc_msc_hid/src/main.c
index c3295fd50..65ef1dcbd 100644
--- a/examples/device/cdc_msc_hid/src/main.c
+++ b/examples/device/cdc_msc_hid/src/main.c
@@ -30,6 +30,8 @@
#include "bsp/board.h"
#include "tusb.h"
+#include "usb_descriptors.h"
+
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTYPES
//--------------------------------------------------------------------+
@@ -162,13 +164,6 @@ void tud_cdc_rx_cb(uint8_t itf)
//--------------------------------------------------------------------+
#if CFG_TUD_HID
-// Must match with ID declared by HID Report Descriptor, better to be in header file
-enum
-{
- REPORT_ID_KEYBOARD = 1,
- REPORT_ID_MOUSE
-};
-
void hid_task(void)
{
// Poll every 10ms
diff --git a/examples/device/cdc_msc_hid/src/usb_descriptors.c b/examples/device/cdc_msc_hid/src/usb_descriptors.c
index 17a98c9d4..ee79f4ece 100644
--- a/examples/device/cdc_msc_hid/src/usb_descriptors.c
+++ b/examples/device/cdc_msc_hid/src/usb_descriptors.c
@@ -24,6 +24,7 @@
*/
#include "tusb.h"
+#include "usb_descriptors.h"
/* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug.
* Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC.
@@ -79,13 +80,7 @@ uint8_t const * tud_descriptor_device_cb(void)
//--------------------------------------------------------------------+
// HID Report Descriptor
//--------------------------------------------------------------------+
-
#if CFG_TUD_HID
-enum
-{
- REPORT_ID_KEYBOARD = 1,
- REPORT_ID_MOUSE
-};
uint8_t const desc_hid_report[] =
{
diff --git a/examples/device/cdc_msc_hid/src/usb_descriptors.h b/examples/device/cdc_msc_hid/src/usb_descriptors.h
new file mode 100644
index 000000000..6992d3349
--- /dev/null
+++ b/examples/device/cdc_msc_hid/src/usb_descriptors.h
@@ -0,0 +1,34 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef USB_DESCRIPTORS_H_
+#define USB_DESCRIPTORS_H_
+
+enum
+{
+ REPORT_ID_KEYBOARD = 1,
+ REPORT_ID_MOUSE
+};
+
+#endif /* USB_DESCRIPTORS_H_ */
diff --git a/examples/device/cdc_msc_hid_freertos/src/main.c b/examples/device/cdc_msc_hid_freertos/src/main.c
index 56ea3a7a3..cb707675d 100644
--- a/examples/device/cdc_msc_hid_freertos/src/main.c
+++ b/examples/device/cdc_msc_hid_freertos/src/main.c
@@ -36,6 +36,8 @@
#include "bsp/board.h"
#include "tusb.h"
+#include "usb_descriptors.h"
+
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTYPES
//--------------------------------------------------------------------+
@@ -194,13 +196,6 @@ void tud_cdc_rx_cb(uint8_t itf)
//--------------------------------------------------------------------+
#if CFG_TUD_HID
-// Must match with ID declared by HID Report Descriptor, better to be in header file
-enum
-{
- REPORT_ID_KEYBOARD = 1,
- REPORT_ID_MOUSE
-};
-
void hid_task(void* params)
{
(void) params;
diff --git a/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c b/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c
index 03f80f8c0..699067f73 100644
--- a/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c
+++ b/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c
@@ -24,6 +24,7 @@
*/
#include "tusb.h"
+#include "usb_descriptors.h"
/* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug.
* Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC.
@@ -79,13 +80,7 @@ uint8_t const * tud_descriptor_device_cb(void)
//--------------------------------------------------------------------+
// HID Report Descriptor
//--------------------------------------------------------------------+
-
#if CFG_TUD_HID
-enum
-{
- REPORT_ID_KEYBOARD = 1,
- REPORT_ID_MOUSE
-};
uint8_t const desc_hid_report[] =
{
diff --git a/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.h b/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.h
new file mode 100644
index 000000000..6992d3349
--- /dev/null
+++ b/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.h
@@ -0,0 +1,34 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef USB_DESCRIPTORS_H_
+#define USB_DESCRIPTORS_H_
+
+enum
+{
+ REPORT_ID_KEYBOARD = 1,
+ REPORT_ID_MOUSE
+};
+
+#endif /* USB_DESCRIPTORS_H_ */
diff --git a/examples/device/webusb_serial/src/usb_descriptors.h b/examples/device/webusb_serial/src/usb_descriptors.h
index d45e720df..d05843c3e 100644
--- a/examples/device/webusb_serial/src/usb_descriptors.h
+++ b/examples/device/webusb_serial/src/usb_descriptors.h
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2019 hathach for Adafruit Industries
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal