make keyboard device work with lpc1347
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
<option id="gnu.c.compiler.option.misc.other.204394496" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.1207481236" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/CMSISv2p10_LPC13Uxx/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LPC13Uxx_DriverLib/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/tinyusb/tinyusb}""/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.include.files.318820756" name="Include files (-include)" superClass="gnu.c.compiler.option.include.files"/>
|
||||
@@ -59,10 +60,12 @@
|
||||
</option>
|
||||
<option id="gnu.c.link.option.paths.1465143173" name="Library search path (-L)" superClass="gnu.c.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/CMSISv2p10_LPC13Uxx/Debug}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LPC13Uxx_DriverLib/Debug}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/tinyusb/Debug}""/>
|
||||
</option>
|
||||
<option id="gnu.c.link.option.libs.447978281" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="CMSISv2p10_LPC13Uxx"/>
|
||||
<listOptionValue builtIn="false" value="LPC13Uxx_DriverLib"/>
|
||||
<listOptionValue builtIn="false" value="tinyusb"/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.link.gcc.hdrlib.1111642583" name="Use C library" superClass="com.crt.advproject.link.gcc.hdrlib" value="com.crt.advproject.gcc.link.hdrlib.codered.nohost" valueType="enumerated"/>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>CMSISv2p10_LPC13Uxx</project>
|
||||
<project>LPC13Uxx_DriverLib</project>
|
||||
<project>tinyusb</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
|
||||
#include "descriptors.h"
|
||||
|
||||
#ifdef CFG_USB_HID_KEYBOARD
|
||||
ALIGNED(4) const uint8_t HID_KeyboardReportDescriptor[] = {
|
||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
||||
ATTR_ALIGNED(4) const uint8_t HID_KeyboardReportDescriptor[] = {
|
||||
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
||||
HID_Usage ( HID_USAGE_GENERIC_KEYBOARD ),
|
||||
HID_Collection ( HID_Application ),
|
||||
@@ -81,7 +81,7 @@ ALIGNED(4) const uint8_t HID_KeyboardReportDescriptor[] = {
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_HID_MOUSE
|
||||
ALIGNED(4) const uint8_t HID_MouseReportDescriptor[] = {
|
||||
ATTR_ALIGNED(4) const uint8_t HID_MouseReportDescriptor[] = {
|
||||
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
||||
HID_Usage ( HID_USAGE_GENERIC_MOUSE ),
|
||||
HID_Collection ( HID_Application ),
|
||||
@@ -119,7 +119,7 @@ ALIGNED(4) const uint8_t HID_MouseReportDescriptor[] = {
|
||||
#endif
|
||||
|
||||
/* USB Standard Device Descriptor */
|
||||
ALIGNED(4) const USB_DEVICE_DESCRIPTOR USB_DeviceDescriptor =
|
||||
ATTR_ALIGNED(4) const USB_DEVICE_DESCRIPTOR USB_DeviceDescriptor =
|
||||
{
|
||||
.bLength = sizeof(USB_DEVICE_DESCRIPTOR),
|
||||
.bDescriptorType = USB_DEVICE_DESCRIPTOR_TYPE,
|
||||
@@ -153,7 +153,7 @@ ALIGNED(4) const USB_DEVICE_DESCRIPTOR USB_DeviceDescriptor =
|
||||
.bNumConfigurations = 0x01
|
||||
};
|
||||
|
||||
ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
||||
ATTR_ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
@@ -276,7 +276,7 @@ ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_HID_KEYBOARD
|
||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
||||
///// USB HID Keyboard interface
|
||||
.HID_KeyboardInterface =
|
||||
{
|
||||
@@ -358,7 +358,7 @@ ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
||||
.ConfigDescTermination = 0,
|
||||
};
|
||||
|
||||
ALIGNED(4) const USB_STR_DESCRIPTOR USB_StringDescriptor =
|
||||
ATTR_ALIGNED(4) const USB_STR_DESCRIPTOR USB_StringDescriptor =
|
||||
{
|
||||
.LangID = { .bLength = 0x04, .bDescriptorType = USB_STRING_DESCRIPTOR_TYPE },
|
||||
.strLangID= {0x0409}, // US English
|
||||
|
||||
@@ -88,7 +88,7 @@ typedef PRE_PACK struct POST_PACK _USB_INTERFACE_ASSOCIATION_DESCRIPTOR
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Interface Assosication Descriptor if device is CDC + other class
|
||||
#define IAD_DESC_REQUIRED ( defined(CFG_USB_CDC) && (defined(CFG_USB_HID_KEYBOARD) || defined(CFG_USB_HID_MOUSE)) )
|
||||
#define IAD_DESC_REQUIRED ( defined(CFG_USB_CDC) && (CLASS_HID) )
|
||||
|
||||
#ifdef CFG_USB_CDC
|
||||
#define INTERFACES_OF_CDC 2
|
||||
@@ -96,7 +96,7 @@ typedef PRE_PACK struct POST_PACK _USB_INTERFACE_ASSOCIATION_DESCRIPTOR
|
||||
#define INTERFACES_OF_CDC 0
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_HID_KEYBOARD
|
||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
||||
#define INTERFACES_OF_HID_KEYBOARD 1
|
||||
#else
|
||||
#define INTERFACES_OF_HID_KEYBOARD 0
|
||||
@@ -157,7 +157,7 @@ typedef struct
|
||||
USB_ENDPOINT_DESCRIPTOR CDC_DataInEndpoint;
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_HID_KEYBOARD
|
||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
||||
//Keyboard HID Interface
|
||||
USB_INTERFACE_DESCRIPTOR HID_KeyboardInterface;
|
||||
HID_DESCRIPTOR HID_KeyboardHID;
|
||||
|
||||
@@ -13,12 +13,47 @@ __CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint32_t currentSecond, lastSecond;
|
||||
currentSecond = lastSecond = 0;
|
||||
|
||||
SystemInit();
|
||||
|
||||
systickInit(1);
|
||||
GPIOInit();
|
||||
|
||||
#define CFG_LED_PORT (0)
|
||||
#define CFG_LED_PIN (7)
|
||||
#define CFG_LED_ON (1)
|
||||
#define CFG_LED_OFF (0)
|
||||
|
||||
GPIOSetDir(CFG_LED_PORT, CFG_LED_PIN, 1);
|
||||
LPC_GPIO->CLR[CFG_LED_PORT] = (1 << CFG_LED_PIN);
|
||||
|
||||
tusb_init();
|
||||
|
||||
while (1)
|
||||
{
|
||||
currentSecond = systickGetSecondsActive();
|
||||
if (currentSecond != lastSecond)
|
||||
{
|
||||
/* Toggle LED once per second */
|
||||
lastSecond = currentSecond;
|
||||
GPIOSetBitValue(CFG_LED_PORT, CFG_LED_PIN, lastSecond % 2);
|
||||
|
||||
#if !defined(CFG_USB_CDC)
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
||||
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA};
|
||||
usb_hid_keyboard_sendKeys(0x00, keys, 1);
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_HID_MOUSE
|
||||
usb_hid_mouse_send(0, 10, 10);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user