example clean up
This commit is contained in:
parent
77d3124a70
commit
d79a209aef
|
@ -30,6 +30,8 @@
|
||||||
#include "bsp/board.h"
|
#include "bsp/board.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
|
#include "usb_descriptors.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF PROTYPES
|
// MACRO CONSTANT TYPEDEF PROTYPES
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -162,13 +164,6 @@ void tud_cdc_rx_cb(uint8_t itf)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#if CFG_TUD_HID
|
#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)
|
void hid_task(void)
|
||||||
{
|
{
|
||||||
// Poll every 10ms
|
// Poll every 10ms
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tusb.h"
|
#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.
|
/* 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.
|
* 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
|
// HID Report Descriptor
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
#if CFG_TUD_HID
|
#if CFG_TUD_HID
|
||||||
enum
|
|
||||||
{
|
|
||||||
REPORT_ID_KEYBOARD = 1,
|
|
||||||
REPORT_ID_MOUSE
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t const desc_hid_report[] =
|
uint8_t const desc_hid_report[] =
|
||||||
{
|
{
|
||||||
|
|
|
@ -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_ */
|
|
@ -36,6 +36,8 @@
|
||||||
#include "bsp/board.h"
|
#include "bsp/board.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
|
#include "usb_descriptors.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF PROTYPES
|
// MACRO CONSTANT TYPEDEF PROTYPES
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -194,13 +196,6 @@ void tud_cdc_rx_cb(uint8_t itf)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#if CFG_TUD_HID
|
#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 hid_task(void* params)
|
||||||
{
|
{
|
||||||
(void) params;
|
(void) params;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tusb.h"
|
#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.
|
/* 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.
|
* 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
|
// HID Report Descriptor
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
#if CFG_TUD_HID
|
#if CFG_TUD_HID
|
||||||
enum
|
|
||||||
{
|
|
||||||
REPORT_ID_KEYBOARD = 1,
|
|
||||||
REPORT_ID_MOUSE
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t const desc_hid_report[] =
|
uint8_t const desc_hid_report[] =
|
||||||
{
|
{
|
||||||
|
|
|
@ -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_ */
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* The MIT License (MIT)
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
Loading…
Reference in New Issue