fix dcd_data declared with TUSB_CFG_ATTR_USBRAM

fix lpc43xx UM: non-control unused endpoint type should be set to different than control in ENDPTCTRL
add hid mouse device
fix mouse descriptor with vertical wheel support
This commit is contained in:
hathach
2013-10-30 12:20:00 +07:00
parent d9ce879df8
commit d67a7b7959
8 changed files with 163 additions and 113 deletions

View File

@@ -90,9 +90,9 @@ void keyboard_device_app_task(void * p_para)
static uint32_t count =0;
if (count++ < 10)
{
keyboard_report.keycode[0] = (count%2) ? 0x04 : 0x00;
if (!tusbd_hid_keyboard_is_busy(0))
{
keyboard_report.keycode[0] = (count%2) ? 0x04 : 0x00;
tusbd_hid_keyboard_send(0, &keyboard_report );
}
}
@@ -104,15 +104,18 @@ void keyboard_device_app_task(void * p_para)
hid_mouse_report_t mouse_report TUSB_CFG_ATTR_USBRAM;
void mouse_device_app_task(void * p_para)
{
// if (tusbd_is_configured(0))
// {
// static uint32_t count =0;
// if (count++ < 10)
// {
// mouse_report.x = mouse_report.y = 20;
// tusbd_hid_mouse_send( &mouse_report );
// }
// }
if (tusbd_is_configured(0))
{
static uint32_t count =0;
if (count++ < 10)
{
if ( !tusbd_hid_mouse_is_busy(0) )
{
mouse_report.x = mouse_report.y = 20;
tusbd_hid_mouse_send(0, &mouse_report );
}
}
}
}
#endif

View File

@@ -1,39 +1,40 @@
/*
* tusb_descriptors.c
*
* Created on: Nov 26, 2012
* Author: hathach
*/
/**************************************************************************/
/*!
@file tusb_descriptors.c
@author hathach (tinyusb.org)
/*
* Software License Agreement (BSD License)
* Copyright (c) 2012, hathach (tinyusb.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the tinyUSB stack
*/
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack.
*/
/**************************************************************************/
#include "tusb_descriptors.h"
@@ -49,12 +50,12 @@ uint8_t app_tusb_keyboard_desc_report[] = {
HID_LOGICAL_MIN ( 0 ),
HID_LOGICAL_MAX ( 1 ),
HID_REPORT_COUNT ( 8 ), /* 8 bits */
HID_REPORT_SIZE ( 1 ),
HID_REPORT_COUNT ( 8 ), /* 8 bits */
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* maskable modifier key */
HID_REPORT_COUNT ( 1 ),
HID_REPORT_SIZE ( 8 ),
HID_REPORT_COUNT ( 1 ),
HID_INPUT ( HID_CONSTANT ), /* reserved */
HID_USAGE_PAGE ( HID_USAGE_PAGE_LED ),
@@ -64,8 +65,8 @@ uint8_t app_tusb_keyboard_desc_report[] = {
HID_REPORT_SIZE ( 1 ),
HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* 5-bit Led report */
HID_REPORT_COUNT ( 1 ),
HID_REPORT_SIZE ( 3 ), /* led padding */
HID_REPORT_COUNT ( 1 ),
HID_OUTPUT ( HID_CONSTANT ),
HID_USAGE_PAGE (HID_USAGE_PAGE_KEYBOARD),
@@ -74,8 +75,8 @@ uint8_t app_tusb_keyboard_desc_report[] = {
HID_LOGICAL_MIN ( 0 ),
HID_LOGICAL_MAX ( 101 ),
HID_REPORT_COUNT ( 6 ),
HID_REPORT_SIZE ( 8 ),
HID_REPORT_COUNT ( 6 ),
HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ), /* keycodes array 6 items */
HID_COLLECTION_END
};
@@ -96,13 +97,13 @@ uint8_t app_tusb_mouse_desc_report[] = {
HID_LOGICAL_MIN ( 0 ),
HID_LOGICAL_MAX ( 1 ),
HID_REPORT_COUNT ( 3 ), /* Left, Right and Middle mouse*/
HID_REPORT_SIZE ( 1 ),
HID_REPORT_COUNT ( 3 ), /* Left, Right and Middle mouse*/
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),
HID_REPORT_COUNT ( 1 ),
HID_REPORT_SIZE ( 5 ),
HID_INPUT ( HID_CONSTANT ), /* reserved */
HID_REPORT_COUNT ( 1 ),
HID_INPUT ( HID_CONSTANT ), /* 5 bit padding followed 3 bit buttons */
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
HID_USAGE ( HID_USAGE_DESKTOP_X ),
@@ -110,9 +111,17 @@ uint8_t app_tusb_mouse_desc_report[] = {
HID_LOGICAL_MIN ( 0x81 ), /* -127 */
HID_LOGICAL_MAX ( 0x7f ), /* 127 */
HID_REPORT_COUNT ( 2 ), /* X, Y position */
HID_REPORT_SIZE ( 8 ),
HID_REPORT_COUNT ( 2 ), /* X, Y position */
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */
HID_USAGE ( HID_USAGE_DESKTOP_WHEEL ), /* mouse scroll */
HID_LOGICAL_MIN ( 0x81 ), /* -127 */
HID_LOGICAL_MAX ( 0x7f ), /* 127 */
HID_REPORT_COUNT( 1 ),
HID_REPORT_SIZE ( 8 ), /* 8-bit value */
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */
HID_COLLECTION_END,
HID_COLLECTION_END

View File

@@ -1,34 +1,40 @@
/*
* tusb_descriptors.h
*
* Created on: Nov 26, 2012
* Author: hathachtware License Agreement (BSD License)
* Copyright (c) 2012, hathach (tinyusb.org)All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the tinyUSB stack
*/
/**************************************************************************/
/*!
@file tusb_descriptors.h
@author hathach (tinyusb.org)
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack.
*/
/**************************************************************************/
#ifndef _TUSB_DESCRIPTORS_H_
#define _TUSB_DESCRIPTORS_H_