diff options
| author | hathach <[email protected]> | 2019-07-26 20:27:06 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-07-26 20:27:06 +0700 |
| commit | d79a209aefe498f78350ee3e08b96b8e17fda6b1 (patch) | |
| tree | 13ff78f60ce1602c86912932517e2f6d5e7aafea /examples/device/cdc_msc_hid/src | |
| parent | 77d3124a7060ab55143c65dafc6c80d8f83690cd (diff) | |
example clean up
Diffstat (limited to 'examples/device/cdc_msc_hid/src')
| -rw-r--r-- | examples/device/cdc_msc_hid/src/main.c | 9 | ||||
| -rw-r--r-- | examples/device/cdc_msc_hid/src/usb_descriptors.c | 7 | ||||
| -rw-r--r-- | examples/device/cdc_msc_hid/src/usb_descriptors.h | 34 |
3 files changed, 37 insertions, 13 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_ */ |
