mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
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:
parent
d9ce879df8
commit
d67a7b7959
@ -90,9 +90,9 @@ void keyboard_device_app_task(void * p_para)
|
|||||||
static uint32_t count =0;
|
static uint32_t count =0;
|
||||||
if (count++ < 10)
|
if (count++ < 10)
|
||||||
{
|
{
|
||||||
keyboard_report.keycode[0] = (count%2) ? 0x04 : 0x00;
|
|
||||||
if (!tusbd_hid_keyboard_is_busy(0))
|
if (!tusbd_hid_keyboard_is_busy(0))
|
||||||
{
|
{
|
||||||
|
keyboard_report.keycode[0] = (count%2) ? 0x04 : 0x00;
|
||||||
tusbd_hid_keyboard_send(0, &keyboard_report );
|
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;
|
hid_mouse_report_t mouse_report TUSB_CFG_ATTR_USBRAM;
|
||||||
void mouse_device_app_task(void * p_para)
|
void mouse_device_app_task(void * p_para)
|
||||||
{
|
{
|
||||||
// if (tusbd_is_configured(0))
|
if (tusbd_is_configured(0))
|
||||||
// {
|
{
|
||||||
// static uint32_t count =0;
|
static uint32_t count =0;
|
||||||
// if (count++ < 10)
|
if (count++ < 10)
|
||||||
// {
|
{
|
||||||
// mouse_report.x = mouse_report.y = 20;
|
if ( !tusbd_hid_mouse_is_busy(0) )
|
||||||
// tusbd_hid_mouse_send( &mouse_report );
|
{
|
||||||
// }
|
mouse_report.x = mouse_report.y = 20;
|
||||||
// }
|
tusbd_hid_mouse_send(0, &mouse_report );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,39 +1,40 @@
|
|||||||
/*
|
/**************************************************************************/
|
||||||
* tusb_descriptors.c
|
/*!
|
||||||
*
|
@file tusb_descriptors.c
|
||||||
* Created on: Nov 26, 2012
|
@author hathach (tinyusb.org)
|
||||||
* Author: hathach
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
@section LICENSE
|
||||||
* Software License Agreement (BSD License)
|
|
||||||
* Copyright (c) 2012, hathach (tinyusb.org)
|
Software License Agreement (BSD License)
|
||||||
* All rights reserved.
|
|
||||||
*
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
All rights reserved.
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
Redistribution and use in source and binary forms, with or without
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
modification, are permitted provided that the following conditions are met:
|
||||||
* this list of conditions and the following disclaimer.
|
1. Redistributions of source code must retain the above copyright
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
notice, this list of conditions and the following disclaimer.
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
* and/or other materials provided with the distribution.
|
notice, this list of conditions and the following disclaimer in the
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
documentation and/or other materials provided with the distribution.
|
||||||
* derived from this software without specific prior written permission.
|
3. Neither the name of the copyright holders nor the
|
||||||
*
|
names of its contributors may be used to endorse or promote products
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
derived from this software without specific prior written permission.
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
||||||
* OF SUCH DAMAGE.
|
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
|
||||||
* This file is part of the tinyUSB stack
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "tusb_descriptors.h"
|
#include "tusb_descriptors.h"
|
||||||
|
|
||||||
@ -49,12 +50,12 @@ uint8_t app_tusb_keyboard_desc_report[] = {
|
|||||||
HID_LOGICAL_MIN ( 0 ),
|
HID_LOGICAL_MIN ( 0 ),
|
||||||
HID_LOGICAL_MAX ( 1 ),
|
HID_LOGICAL_MAX ( 1 ),
|
||||||
|
|
||||||
HID_REPORT_COUNT ( 8 ), /* 8 bits */
|
|
||||||
HID_REPORT_SIZE ( 1 ),
|
HID_REPORT_SIZE ( 1 ),
|
||||||
|
HID_REPORT_COUNT ( 8 ), /* 8 bits */
|
||||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* maskable modifier key */
|
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* maskable modifier key */
|
||||||
|
|
||||||
HID_REPORT_COUNT ( 1 ),
|
|
||||||
HID_REPORT_SIZE ( 8 ),
|
HID_REPORT_SIZE ( 8 ),
|
||||||
|
HID_REPORT_COUNT ( 1 ),
|
||||||
HID_INPUT ( HID_CONSTANT ), /* reserved */
|
HID_INPUT ( HID_CONSTANT ), /* reserved */
|
||||||
|
|
||||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_LED ),
|
HID_USAGE_PAGE ( HID_USAGE_PAGE_LED ),
|
||||||
@ -64,8 +65,8 @@ uint8_t app_tusb_keyboard_desc_report[] = {
|
|||||||
HID_REPORT_SIZE ( 1 ),
|
HID_REPORT_SIZE ( 1 ),
|
||||||
HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* 5-bit Led report */
|
HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* 5-bit Led report */
|
||||||
|
|
||||||
HID_REPORT_COUNT ( 1 ),
|
|
||||||
HID_REPORT_SIZE ( 3 ), /* led padding */
|
HID_REPORT_SIZE ( 3 ), /* led padding */
|
||||||
|
HID_REPORT_COUNT ( 1 ),
|
||||||
HID_OUTPUT ( HID_CONSTANT ),
|
HID_OUTPUT ( HID_CONSTANT ),
|
||||||
|
|
||||||
HID_USAGE_PAGE (HID_USAGE_PAGE_KEYBOARD),
|
HID_USAGE_PAGE (HID_USAGE_PAGE_KEYBOARD),
|
||||||
@ -74,8 +75,8 @@ uint8_t app_tusb_keyboard_desc_report[] = {
|
|||||||
HID_LOGICAL_MIN ( 0 ),
|
HID_LOGICAL_MIN ( 0 ),
|
||||||
HID_LOGICAL_MAX ( 101 ),
|
HID_LOGICAL_MAX ( 101 ),
|
||||||
|
|
||||||
HID_REPORT_COUNT ( 6 ),
|
|
||||||
HID_REPORT_SIZE ( 8 ),
|
HID_REPORT_SIZE ( 8 ),
|
||||||
|
HID_REPORT_COUNT ( 6 ),
|
||||||
HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ), /* keycodes array 6 items */
|
HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ), /* keycodes array 6 items */
|
||||||
HID_COLLECTION_END
|
HID_COLLECTION_END
|
||||||
};
|
};
|
||||||
@ -96,13 +97,13 @@ uint8_t app_tusb_mouse_desc_report[] = {
|
|||||||
HID_LOGICAL_MIN ( 0 ),
|
HID_LOGICAL_MIN ( 0 ),
|
||||||
HID_LOGICAL_MAX ( 1 ),
|
HID_LOGICAL_MAX ( 1 ),
|
||||||
|
|
||||||
HID_REPORT_COUNT ( 3 ), /* Left, Right and Middle mouse*/
|
|
||||||
HID_REPORT_SIZE ( 1 ),
|
HID_REPORT_SIZE ( 1 ),
|
||||||
|
HID_REPORT_COUNT ( 3 ), /* Left, Right and Middle mouse*/
|
||||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),
|
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),
|
||||||
|
|
||||||
HID_REPORT_COUNT ( 1 ),
|
|
||||||
HID_REPORT_SIZE ( 5 ),
|
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_PAGE ( HID_USAGE_PAGE_DESKTOP ),
|
||||||
HID_USAGE ( HID_USAGE_DESKTOP_X ),
|
HID_USAGE ( HID_USAGE_DESKTOP_X ),
|
||||||
@ -110,9 +111,17 @@ uint8_t app_tusb_mouse_desc_report[] = {
|
|||||||
HID_LOGICAL_MIN ( 0x81 ), /* -127 */
|
HID_LOGICAL_MIN ( 0x81 ), /* -127 */
|
||||||
HID_LOGICAL_MAX ( 0x7f ), /* 127 */
|
HID_LOGICAL_MAX ( 0x7f ), /* 127 */
|
||||||
|
|
||||||
HID_REPORT_COUNT ( 2 ), /* X, Y position */
|
|
||||||
HID_REPORT_SIZE ( 8 ),
|
HID_REPORT_SIZE ( 8 ),
|
||||||
|
HID_REPORT_COUNT ( 2 ), /* X, Y position */
|
||||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */
|
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,
|
||||||
|
|
||||||
HID_COLLECTION_END
|
HID_COLLECTION_END
|
||||||
|
@ -1,34 +1,40 @@
|
|||||||
/*
|
/**************************************************************************/
|
||||||
* tusb_descriptors.h
|
/*!
|
||||||
*
|
@file tusb_descriptors.h
|
||||||
* Created on: Nov 26, 2012
|
@author hathach (tinyusb.org)
|
||||||
* Author: hathachtware License Agreement (BSD License)
|
|
||||||
* Copyright (c) 2012, hathach (tinyusb.org)All rights reserved.
|
@section LICENSE
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
Software License Agreement (BSD License)
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
All rights reserved.
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
Redistribution and use in source and binary forms, with or without
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
modification, are permitted provided that the following conditions are met:
|
||||||
* and/or other materials provided with the distribution.
|
1. Redistributions of source code must retain the above copyright
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
notice, this list of conditions and the following disclaimer.
|
||||||
* derived from this software without specific prior written permission.
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
*
|
notice, this list of conditions and the following disclaimer in the
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
documentation and/or other materials provided with the distribution.
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
3. Neither the name of the copyright holders nor the
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
names of its contributors may be used to endorse or promote products
|
||||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
derived from this software without specific prior written permission.
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
||||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
* OF SUCH DAMAGE.
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
*
|
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* This file is part of the tinyUSB stack
|
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_
|
#ifndef _TUSB_DESCRIPTORS_H_
|
||||||
#define _TUSB_DESCRIPTORS_H_
|
#define _TUSB_DESCRIPTORS_H_
|
||||||
|
@ -59,42 +59,64 @@ typedef struct {
|
|||||||
uint8_t interface_number;
|
uint8_t interface_number;
|
||||||
uint8_t idle_rate; // need to be in usb ram
|
uint8_t idle_rate; // need to be in usb ram
|
||||||
|
|
||||||
hid_keyboard_report_t report;
|
hid_keyboard_report_t report; // need to be in usb ram
|
||||||
}hidd_interface_t;
|
}hidd_interface_t;
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// KEYBOARD APPLICATION API
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t keyboardd_data =
|
STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t keyboardd_data =
|
||||||
{
|
{
|
||||||
.p_report_desc = app_tusb_keyboard_desc_report
|
.p_report_desc = app_tusb_keyboard_desc_report
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
#if TUSB_CFG_DEVICE_HID_MOUSE
|
|
||||||
STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t moused_data =
|
|
||||||
{
|
|
||||||
.p_report_desc = app_tusb_mouse_desc_report
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// APPLICATION API
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
bool tusbd_hid_keyboard_is_busy(uint8_t coreid)
|
bool tusbd_hid_keyboard_is_busy(uint8_t coreid)
|
||||||
{
|
{
|
||||||
return dcd_pipe_is_busy(keyboardd_data.ept_handle);
|
return dcd_pipe_is_busy(keyboardd_data.ept_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_kbd_report)
|
tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_report)
|
||||||
{
|
{
|
||||||
//------------- verify data -------------//
|
//------------- verify data -------------//
|
||||||
|
|
||||||
hidd_interface_t * p_kbd = &keyboardd_data; // TODO &keyboardd_data[coreid];
|
hidd_interface_t * p_kbd = &keyboardd_data; // TODO &keyboardd_data[coreid];
|
||||||
|
|
||||||
ASSERT_STATUS( dcd_pipe_xfer(p_kbd->ept_handle, p_kbd_report, sizeof(hid_keyboard_report_t), false) ) ;
|
ASSERT_STATUS( dcd_pipe_xfer(p_kbd->ept_handle, p_report, sizeof(hid_keyboard_report_t), false) ) ;
|
||||||
|
|
||||||
return TUSB_ERROR_NONE;
|
return TUSB_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// MOUSE APPLICATION API
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
#if TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
|
STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t moused_data =
|
||||||
|
{
|
||||||
|
.p_report_desc = app_tusb_mouse_desc_report
|
||||||
|
};
|
||||||
|
|
||||||
|
bool tusbd_hid_mouse_is_busy(uint8_t coreid)
|
||||||
|
{
|
||||||
|
return dcd_pipe_is_busy(moused_data.ept_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_report)
|
||||||
|
{
|
||||||
|
//------------- verify data -------------//
|
||||||
|
|
||||||
|
hidd_interface_t * p_mouse = &moused_data; // TODO &keyboardd_data[coreid];
|
||||||
|
|
||||||
|
ASSERT_STATUS( dcd_pipe_xfer(p_mouse->ept_handle, p_report, sizeof(hid_mouse_report_t), false) ) ;
|
||||||
|
|
||||||
|
return TUSB_ERROR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// USBD-CLASS API
|
// USBD-CLASS API
|
||||||
@ -105,7 +127,7 @@ tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const *
|
|||||||
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
(p_request->wIndex == keyboardd_data.interface_number) ? &keyboardd_data :
|
(p_request->wIndex == keyboardd_data.interface_number) ? &keyboardd_data :
|
||||||
#endif
|
#endif
|
||||||
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
#if TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
(p_request->wIndex == moused_data.interface_number) ? &moused_data :
|
(p_request->wIndex == moused_data.interface_number) ? &moused_data :
|
||||||
#endif
|
#endif
|
||||||
NULL;
|
NULL;
|
||||||
|
@ -100,7 +100,9 @@ void tusbd_hid_keyboard_isr(uint8_t coreid, tusb_event_t event);
|
|||||||
/** \defgroup Mouse_Device Device
|
/** \defgroup Mouse_Device Device
|
||||||
* @{ */
|
* @{ */
|
||||||
|
|
||||||
tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_mouse_report);
|
bool tusbd_hid_mouse_is_busy(uint8_t coreid);
|
||||||
|
|
||||||
|
tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_report);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -122,7 +122,7 @@ typedef struct {
|
|||||||
|
|
||||||
}dcd_data_t;
|
}dcd_data_t;
|
||||||
|
|
||||||
ATTR_ALIGNED(2048) dcd_data_t dcd_data;
|
ATTR_ALIGNED(2048) dcd_data_t dcd_data TUSB_CFG_ATTR_USBRAM;
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||||
@ -200,6 +200,14 @@ void bus_reset(uint8_t coreid)
|
|||||||
{
|
{
|
||||||
// TODO mutliple core id support
|
// TODO mutliple core id support
|
||||||
|
|
||||||
|
// The reset value for all endpoint types is the control endpoint. If one endpoint
|
||||||
|
//direction is enabled and the paired endpoint of opposite direction is disabled, then the
|
||||||
|
//endpoint type of the unused direction must bechanged from the control type to any other
|
||||||
|
//type (e.g. bulk). Leaving an unconfigured endpoint control will cause undefined behavior
|
||||||
|
//for the data PID tracking on the active endpoint.
|
||||||
|
LPC_USB0->ENDPTCTRL1 = LPC_USB0->ENDPTCTRL2 = LPC_USB0->ENDPTCTRL3 = LPC_USB0->ENDPTCTRL4 = LPC_USB0->ENDPTCTRL5 =
|
||||||
|
(TUSB_XFER_BULK << 2) | (TUSB_XFER_BULK << 18);
|
||||||
|
|
||||||
//------------- Clear All Registers -------------//
|
//------------- Clear All Registers -------------//
|
||||||
LPC_USB0->ENDPTNAK = LPC_USB0->ENDPTNAK;
|
LPC_USB0->ENDPTNAK = LPC_USB0->ENDPTNAK;
|
||||||
LPC_USB0->ENDPTNAKEN = 0;
|
LPC_USB0->ENDPTNAKEN = 0;
|
||||||
@ -327,7 +335,7 @@ endpoint_handle_t dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const
|
|||||||
|
|
||||||
//------------- Endpoint Control Register -------------//
|
//------------- Endpoint Control Register -------------//
|
||||||
volatile uint32_t * reg_control = (&LPC_USB0->ENDPTCTRL0) + (p_endpoint_desc->bEndpointAddress & 0x0f);
|
volatile uint32_t * reg_control = (&LPC_USB0->ENDPTCTRL0) + (p_endpoint_desc->bEndpointAddress & 0x0f);
|
||||||
(*reg_control) = ((p_endpoint_desc->bmAttributes.xfer << 2) | ENDPTCTRL_MASK_ENABLE | ENDPTCTRL_MASK_TOGGLE_RESET) << ((p_endpoint_desc->bEndpointAddress & TUSB_DIR_DEV_TO_HOST_MASK) ? 16 : 0);
|
(*reg_control) |= ((p_endpoint_desc->bmAttributes.xfer << 2) | ENDPTCTRL_MASK_ENABLE | ENDPTCTRL_MASK_TOGGLE_RESET) << ((p_endpoint_desc->bEndpointAddress & TUSB_DIR_DEV_TO_HOST_MASK) ? 16 : 0);
|
||||||
|
|
||||||
return (endpoint_handle_t) { .coreid = coreid, .xfer_type = p_endpoint_desc->bmAttributes.xfer, .index = ep_idx };
|
return (endpoint_handle_t) { .coreid = coreid, .xfer_type = p_endpoint_desc->bmAttributes.xfer, .index = ep_idx };
|
||||||
}
|
}
|
||||||
@ -383,7 +391,7 @@ void dcd_isr(uint8_t coreid)
|
|||||||
if (int_status & INT_MASK_USB)
|
if (int_status & INT_MASK_USB)
|
||||||
{
|
{
|
||||||
if (LPC_USB0->ENDPTSETUPSTAT)
|
if (LPC_USB0->ENDPTSETUPSTAT)
|
||||||
{
|
{ // 23.10.10.2 Operational model for setup transfers
|
||||||
tusb_control_request_t control_request = dcd_data.qhd[0].setup_request;
|
tusb_control_request_t control_request = dcd_data.qhd[0].setup_request;
|
||||||
|
|
||||||
LPC_USB0->ENDPTSETUPSTAT = LPC_USB0->ENDPTSETUPSTAT;
|
LPC_USB0->ENDPTSETUPSTAT = LPC_USB0->ENDPTSETUPSTAT;
|
||||||
@ -392,7 +400,8 @@ void dcd_isr(uint8_t coreid)
|
|||||||
|
|
||||||
if (LPC_USB0->ENDPTCOMPLETE)
|
if (LPC_USB0->ENDPTCOMPLETE)
|
||||||
{
|
{
|
||||||
// TransferCompleteISR(DeviceID);
|
// hal_debugger_breakpoint();
|
||||||
|
LPC_USB0->ENDPTCOMPLETE = LPC_USB0->ENDPTCOMPLETE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +146,7 @@ tusb_error_t usbh_set_configure_received(uint8_t coreid, uint8_t config_number)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return TUSB_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usbd_setup_received_isr(uint8_t coreid, tusb_control_request_t * p_request)
|
void usbd_setup_received_isr(uint8_t coreid, tusb_control_request_t * p_request)
|
||||||
|
@ -50,11 +50,9 @@
|
|||||||
// INCLUDE
|
// INCLUDE
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "osal/osal.h" // TODO refractor move to common.h ?
|
#include "osal/osal.h"
|
||||||
|
#include "dcd.h"
|
||||||
|
|
||||||
#ifdef _TINY_USB_SOURCE_FILE_
|
|
||||||
#include "dcd.h" // TODO hide from application include
|
|
||||||
#endif
|
|
||||||
//#include "tusb_descriptors.h"
|
//#include "tusb_descriptors.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Loading…
x
Reference in New Issue
Block a user