mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
rename descriptor variables
This commit is contained in:
parent
3b9a616ca9
commit
ed64401e61
@ -23,7 +23,7 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
tusb_init();
|
tusb_init();
|
||||||
|
|
||||||
//print_greeting();
|
print_greeting();
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (current_tick + 1000 < system_ticks)
|
if (current_tick + 1000 < system_ticks)
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
||||||
const uint8_t keyboard_report_descriptor[] = {
|
const uint8_t app_tusb_keyboard_desc_report[] = {
|
||||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
|
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
|
||||||
HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ),
|
HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ),
|
||||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
|
HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
|
||||||
@ -120,7 +120,7 @@ const uint8_t mouse_report_descriptor[] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
||||||
tusb_descriptor_device_t const app_desc_device =
|
tusb_descriptor_device_t const app_tusb_desc_device =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(tusb_descriptor_device_t),
|
.bLength = sizeof(tusb_descriptor_device_t),
|
||||||
.bDescriptorType = TUSB_DESC_TYPE_DEVICE,
|
.bDescriptorType = TUSB_DESC_TYPE_DEVICE,
|
||||||
@ -144,7 +144,7 @@ tusb_descriptor_device_t const app_desc_device =
|
|||||||
|
|
||||||
|
|
||||||
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
||||||
const app_descriptor_configuration_t app_desc_configuration =
|
const app_descriptor_configuration_t app_tusb_desc_configuration =
|
||||||
{
|
{
|
||||||
.configuration =
|
.configuration =
|
||||||
{
|
{
|
||||||
@ -290,7 +290,7 @@ const app_descriptor_configuration_t app_desc_configuration =
|
|||||||
.bCountryCode = HID_Local_NotSupported,
|
.bCountryCode = HID_Local_NotSupported,
|
||||||
.bNumDescriptors = 1,
|
.bNumDescriptors = 1,
|
||||||
.bReportType = HID_DESC_TYPE_REPORT,
|
.bReportType = HID_DESC_TYPE_REPORT,
|
||||||
.wReportLength = sizeof(keyboard_report_descriptor)
|
.wReportLength = sizeof(app_tusb_keyboard_desc_report)
|
||||||
},
|
},
|
||||||
|
|
||||||
.keyboard_endpoint =
|
.keyboard_endpoint =
|
||||||
@ -379,7 +379,7 @@ const app_descriptor_configuration_t app_desc_configuration =
|
|||||||
};
|
};
|
||||||
|
|
||||||
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
||||||
const app_descriptor_string_t app_desc_strings =
|
const app_descriptor_string_t app_tusb_desc_strings =
|
||||||
{
|
{
|
||||||
.LangID = { .bLength = 0x04, .bDescriptorType = TUSB_DESC_TYPE_STRING },
|
.LangID = { .bLength = 0x04, .bDescriptorType = TUSB_DESC_TYPE_STRING },
|
||||||
.strLangID= {0x0409}, // US English
|
.strLangID= {0x0409}, // US English
|
||||||
|
@ -30,15 +30,15 @@
|
|||||||
* This file is part of the tinyUSB stack
|
* This file is part of the tinyUSB stack
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _TUSB_DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _TUSB_DESCRIPTORS_H_
|
||||||
|
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
#define TUSB_CFG_DEVICE_STRING_MANUFACTURER "tinyUSB"
|
#define TUSB_CFG_DEVICE_STRING_MANUFACTURER "tinyUSB"
|
||||||
#define TUSB_CFG_DEVICE_STRING_PRODUCT "Device Keyboard"
|
#define TUSB_CFG_DEVICE_STRING_PRODUCT "Device Keyboard"
|
||||||
#define TUSB_CFG_DEVICE_STRING_SERIAL "1234"
|
#define TUSB_CFG_DEVICE_STRING_SERIAL "1234"
|
||||||
#define TUSB_CFG_DEVICE_VENDORID 0x1FC9
|
#define TUSB_CFG_DEVICE_VENDORID 0x1FC9 // NXP
|
||||||
//#define TUSB_CFG_DEVICE_PRODUCTID
|
//#define TUSB_CFG_DEVICE_PRODUCTID
|
||||||
|
|
||||||
/* USB Serial uses the MCUs unique 128-bit chip ID via an IAP call = 32 hex chars */
|
/* USB Serial uses the MCUs unique 128-bit chip ID via an IAP call = 32 hex chars */
|
||||||
@ -154,10 +154,11 @@ typedef ATTR_PACKED_STRUCT(struct)
|
|||||||
uint8_t null_termination; // NXP rom driver requires this to work
|
uint8_t null_termination; // NXP rom driver requires this to work
|
||||||
} app_descriptor_configuration_t;
|
} app_descriptor_configuration_t;
|
||||||
|
|
||||||
extern const tusb_descriptor_device_t app_desc_device;
|
extern const tusb_descriptor_device_t app_tusb_desc_device;
|
||||||
extern const app_descriptor_configuration_t app_desc_configuration;
|
extern const app_descriptor_configuration_t app_tusb_desc_configuration;
|
||||||
extern const app_descriptor_string_t app_desc_strings;
|
extern const app_descriptor_string_t app_tusb_desc_strings;
|
||||||
extern const uint8_t keyboard_report_descriptor[];
|
|
||||||
|
extern const uint8_t app_tusb_keyboard_desc_report[];
|
||||||
|
|
||||||
//extern const uint8_t HID_MouseReportDescriptor[];
|
//extern const uint8_t HID_MouseReportDescriptor[];
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ void test_usbd_init_ok(void)
|
|||||||
dcd_init_ExpectAndReturn(TUSB_ERROR_NONE);
|
dcd_init_ExpectAndReturn(TUSB_ERROR_NONE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------- Code Under Test -------------//
|
//------------- Code Under Test -------------//
|
||||||
TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, usbd_init() );
|
TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, usbd_init() );
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
|
|
||||||
#define USB_ROM_SIZE (1024*2) // TODO dcd abstract later
|
#define USB_ROM_SIZE (1024*2) // TODO dcd abstract later
|
||||||
uint8_t usb_RomDriver_buffer[USB_ROM_SIZE] ATTR_ALIGNED(2048) TUSB_CFG_ATTR_USBRAM;
|
uint8_t usb_RomDriver_buffer[USB_ROM_SIZE] ATTR_ALIGNED(2048) TUSB_CFG_ATTR_USBRAM;
|
||||||
|
|
||||||
USBD_HANDLE_T g_hUsb;
|
USBD_HANDLE_T g_hUsb;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -84,11 +85,12 @@ typedef struct {
|
|||||||
ErrorCode_t USB_Configure_Event (USBD_HANDLE_T hUsb)
|
ErrorCode_t USB_Configure_Event (USBD_HANDLE_T hUsb)
|
||||||
{
|
{
|
||||||
USB_CORE_CTRL_T* pCtrl = (USB_CORE_CTRL_T*)hUsb;
|
USB_CORE_CTRL_T* pCtrl = (USB_CORE_CTRL_T*)hUsb;
|
||||||
|
|
||||||
if (pCtrl->config_value)
|
if (pCtrl->config_value)
|
||||||
{
|
{
|
||||||
usbd_info.state = TUSB_DEVICE_STATE_CONFIGURED;
|
usbd_info.state = TUSB_DEVICE_STATE_CONFIGURED;
|
||||||
|
|
||||||
#if defined(DEVICE_CLASS_HID)
|
#if DEVICE_CLASS_HID
|
||||||
ASSERT( TUSB_ERROR_NONE == hidd_configured(hUsb), ERR_FAILED );
|
ASSERT( TUSB_ERROR_NONE == hidd_configured(hUsb), ERR_FAILED );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -97,7 +99,6 @@ ErrorCode_t USB_Configure_Event (USBD_HANDLE_T hUsb)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return LPC_OK;
|
return LPC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +108,16 @@ ErrorCode_t USB_Reset_Event (USBD_HANDLE_T hUsb)
|
|||||||
return LPC_OK;
|
return LPC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorCode_t USB_Interface_Event (USBD_HANDLE_T hUsb)
|
||||||
|
{
|
||||||
|
return LPC_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorCode_t USB_Error_Event (USBD_HANDLE_T hUsb, uint32_t param1)
|
||||||
|
{
|
||||||
|
(void) param1;
|
||||||
|
return LPC_OK;
|
||||||
|
}
|
||||||
|
|
||||||
tusb_error_t dcd_init(void)
|
tusb_error_t dcd_init(void)
|
||||||
{
|
{
|
||||||
@ -121,15 +132,17 @@ tusb_error_t dcd_init(void)
|
|||||||
.mem_size = memsize,
|
.mem_size = memsize,
|
||||||
|
|
||||||
.USB_Configure_Event = USB_Configure_Event,
|
.USB_Configure_Event = USB_Configure_Event,
|
||||||
.USB_Reset_Event = USB_Reset_Event
|
.USB_Reset_Event = USB_Reset_Event,
|
||||||
|
.USB_Error_Event = USB_Error_Event,
|
||||||
|
.USB_Interface_Event = USB_Interface_Event
|
||||||
};
|
};
|
||||||
|
|
||||||
USB_CORE_DESCS_T desc_core =
|
USB_CORE_DESCS_T desc_core =
|
||||||
{
|
{
|
||||||
.device_desc = (uint8_t*) &app_desc_device,
|
.device_desc = (uint8_t*) &app_tusb_desc_device,
|
||||||
.string_desc = (uint8_t*) &app_desc_strings,
|
.string_desc = (uint8_t*) &app_tusb_desc_strings,
|
||||||
.full_speed_desc = (uint8_t*) &app_desc_configuration,
|
.full_speed_desc = (uint8_t*) &app_tusb_desc_configuration,
|
||||||
.high_speed_desc = (uint8_t*) &app_desc_configuration,
|
.high_speed_desc = (uint8_t*) &app_tusb_desc_configuration,
|
||||||
.device_qualifier = NULL
|
.device_qualifier = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -142,8 +155,8 @@ tusb_error_t dcd_init(void)
|
|||||||
|
|
||||||
|
|
||||||
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
ASSERT_STATUS( hidd_init(g_hUsb , &app_desc_configuration.keyboard_interface,
|
ASSERT_STATUS( hidd_init(g_hUsb , &app_tusb_desc_configuration.keyboard_interface,
|
||||||
keyboard_report_descriptor, app_desc_configuration.keyboard_hid.wReportLength,
|
app_tusb_keyboard_desc_report, app_tusb_desc_configuration.keyboard_hid.wReportLength,
|
||||||
&membase , &memsize) );
|
&membase , &memsize) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -155,6 +168,7 @@ tusb_error_t dcd_init(void)
|
|||||||
|
|
||||||
hal_interrupt_enable(0);
|
hal_interrupt_enable(0);
|
||||||
ROM_API->hw->Connect(g_hUsb, 1);
|
ROM_API->hw->Connect(g_hUsb, 1);
|
||||||
|
ROM_API->hw->ForceFullSpeed(g_hUsb, 1);
|
||||||
|
|
||||||
return TUSB_ERROR_NONE;
|
return TUSB_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user