Squashed 'tmk_core/' changes from caca2c0..dc0e46e
dc0e46e Rename LUFA to LUFA-git 3bfa7fa Remove LUFA-120730 215b764 Merge commit 'afa0f22a9299686fd88f58ce09c5b521ac917e8f' as 'protocol/lufa/LUFA' afa0f22 Squashed 'protocol/lufa/LUFA/' content from commit def7fca c0c42fa Remove submodule of LUFA 30f897d Merge commit '87ced33feb74e79c3281dda36eb6d6d153399b41' as 'protocol/usb_hid/USB_Host_Shield_2.0' 87ced33 Squashed 'protocol/usb_hid/USB_Host_Shield_2.0/' content from commit aab4a69 14f6d49 Remove submodule of USB_Host_Shield_2.0 git-subtree-dir: tmk_core git-subtree-split: dc0e46eaa4367d4e218f8816e3c117895820f07c
This commit is contained in:
parent
4d116a04e9
commit
f6d56675f9
1575 changed files with 421901 additions and 63190 deletions
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2014.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Library Configuration Header File
|
||||
*
|
||||
* This header file is used to configure LUFA's compile time options,
|
||||
* as an alternative to the compile time constants supplied through
|
||||
* a makefile.
|
||||
*
|
||||
* For information on what each token does, refer to the LUFA
|
||||
* manual section "Summary of Compile Tokens".
|
||||
*/
|
||||
|
||||
#ifndef _LUFA_CONFIG_H_
|
||||
#define _LUFA_CONFIG_H_
|
||||
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
|
||||
/* Non-USB Related Configuration Tokens: */
|
||||
// #define DISABLE_TERMINAL_CODES
|
||||
|
||||
/* USB Class Driver Related Tokens: */
|
||||
// #define HID_HOST_BOOT_PROTOCOL_ONLY
|
||||
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_MAX_COLLECTIONS {Insert Value Here}
|
||||
// #define HID_MAX_REPORTITEMS {Insert Value Here}
|
||||
// #define HID_MAX_REPORT_IDS {Insert Value Here}
|
||||
// #define NO_CLASS_DRIVER_AUTOFLUSH
|
||||
|
||||
/* General USB Driver Related Tokens: */
|
||||
// #define ORDERED_EP_CONFIG
|
||||
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
|
||||
// #define USB_DEVICE_ONLY
|
||||
// #define USB_HOST_ONLY
|
||||
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
|
||||
// #define NO_LIMITED_CONTROLLER_CONNECT
|
||||
// #define NO_SOF_EVENTS
|
||||
|
||||
/* USB Device Mode Driver Related Tokens: */
|
||||
// #define USE_RAM_DESCRIPTORS
|
||||
#define USE_FLASH_DESCRIPTORS
|
||||
// #define USE_EEPROM_DESCRIPTORS
|
||||
// #define NO_INTERNAL_SERIAL
|
||||
#define FIXED_CONTROL_ENDPOINT_SIZE 8
|
||||
// #define DEVICE_STATE_AS_GPIOR {Insert Value Here}
|
||||
#define FIXED_NUM_CONFIGURATIONS 1
|
||||
// #define CONTROL_ONLY_DEVICE
|
||||
// #define INTERRUPT_CONTROL_ENDPOINT
|
||||
// #define NO_DEVICE_REMOTE_WAKEUP
|
||||
// #define NO_DEVICE_SELF_POWER
|
||||
|
||||
/* USB Host Mode Driver Related Tokens: */
|
||||
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
|
||||
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
|
||||
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
|
||||
// #define NO_AUTO_VBUS_MANAGEMENT
|
||||
// #define INVERTED_VBUS_ENABLE_LINE
|
||||
|
||||
#else
|
||||
|
||||
#error Unsupported architecture for this LUFA configuration file.
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,221 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2014.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
/** HID class report descriptor. This is a special descriptor constructed with values from the
|
||||
* USBIF HID class specification to describe the reports and capabilities of the HID device. This
|
||||
* descriptor is parsed by the host and its contents used to determine what data (and in what encoding)
|
||||
* the device will send, and what it may be sent back from the host. Refer to the HID specification for
|
||||
* more details on HID report descriptors.
|
||||
*/
|
||||
const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
|
||||
{
|
||||
/* Use the HID class driver's standard Mouse report.
|
||||
* Min X/Y Axis values: -1
|
||||
* Max X/Y Axis values: 1
|
||||
* Min physical X/Y Axis values (used to determine resolution): -1
|
||||
* Max physical X/Y Axis values (used to determine resolution): 1
|
||||
* Buttons: 3
|
||||
* Absolute screen coordinates: false
|
||||
*/
|
||||
HID_DESCRIPTOR_MOUSE(-1, 1, -1, 1, 3, false)
|
||||
};
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
*/
|
||||
const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
.USBSpecification = VERSION_BCD(1,1,0),
|
||||
.Class = USB_CSCP_NoDeviceClass,
|
||||
.SubClass = USB_CSCP_NoDeviceSubclass,
|
||||
.Protocol = USB_CSCP_NoDeviceProtocol,
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2041,
|
||||
.ReleaseNumber = 0x0000,
|
||||
|
||||
.ManufacturerStrIndex = STRING_ID_Manufacturer,
|
||||
.ProductStrIndex = STRING_ID_Product,
|
||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.HID_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = INTERFACE_ID_Mouse,
|
||||
.AlternateSetting = 0x00,
|
||||
|
||||
.TotalEndpoints = 1,
|
||||
|
||||
.Class = HID_CSCP_HIDClass,
|
||||
.SubClass = HID_CSCP_BootSubclass,
|
||||
.Protocol = HID_CSCP_MouseBootProtocol,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.HID_MouseHID =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||
|
||||
.HIDSpec = VERSION_BCD(1,1,1),
|
||||
.CountryCode = 0x00,
|
||||
.TotalReportDescriptors = 1,
|
||||
.HIDReportType = HID_DTYPE_Report,
|
||||
.HIDReportLength = sizeof(MouseReport)
|
||||
},
|
||||
|
||||
.HID_ReportINEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = MOUSE_EPADDR,
|
||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = MOUSE_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
}
|
||||
};
|
||||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
|
||||
*/
|
||||
const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARRAY(LANGUAGE_ID_ENG);
|
||||
|
||||
/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
|
||||
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"Dean Camera");
|
||||
|
||||
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
||||
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"LUFA Mouse Demo");
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
||||
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
|
||||
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
||||
* USB host.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
{
|
||||
const uint8_t DescriptorType = (wValue >> 8);
|
||||
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
||||
|
||||
const void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case STRING_ID_Language:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case STRING_ID_Manufacturer:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case STRING_ID_Product:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case HID_DTYPE_HID:
|
||||
Address = &ConfigurationDescriptor.HID_MouseHID;
|
||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||
break;
|
||||
case HID_DTYPE_Report:
|
||||
Address = &MouseReport;
|
||||
Size = sizeof(MouseReport);
|
||||
break;
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2014.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for Descriptors.c.
|
||||
*/
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
// Mouse HID Interface
|
||||
USB_Descriptor_Interface_t HID_Interface;
|
||||
USB_HID_Descriptor_HID_t HID_MouseHID;
|
||||
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/** Enum for the device interface descriptor IDs within the device. Each interface descriptor
|
||||
* should have a unique ID index associated with it, which can be used to refer to the
|
||||
* interface from other descriptors.
|
||||
*/
|
||||
enum InterfaceDescriptors_t
|
||||
{
|
||||
INTERFACE_ID_Mouse = 0, /**< Mouse interface descriptor ID (must be zero) */
|
||||
};
|
||||
|
||||
/** Enum for the device string descriptor IDs within the device. Each string descriptor should
|
||||
* have a unique ID index associated with it, which can be used to refer to the string from
|
||||
* other descriptors.
|
||||
*/
|
||||
enum StringDescriptors_t
|
||||
{
|
||||
STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
|
||||
STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
|
||||
STRING_ID_Product = 2, /**< Product string ID */
|
||||
};
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint address of the Mouse HID reporting IN endpoint. */
|
||||
#define MOUSE_EPADDR (ENDPOINT_DIR_IN | 1)
|
||||
|
||||
/** Size in bytes of the Mouse HID reporting IN endpoint. */
|
||||
#define MOUSE_EPSIZE 8
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2014.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Device Mode USB Mouse functionality for the MouseHostDevice demo. This file contains the Device mode
|
||||
* USB Mouse related code of the demo and is responsible for all the Device mode Mouse functionality.
|
||||
*/
|
||||
|
||||
#include "DeviceFunctions.h"
|
||||
|
||||
/** Buffer to hold the previously generated Mouse Device HID report, for comparison purposes inside the HID class driver. */
|
||||
static uint8_t PrevMouseHIDReportBuffer[sizeof(USB_MouseReport_Data_t)];
|
||||
|
||||
/** LUFA HID Class driver interface configuration and state information. This structure is
|
||||
* passed to all HID Class driver functions, so that multiple instances of the same class
|
||||
* within a device can be differentiated from one another.
|
||||
*/
|
||||
USB_ClassInfo_HID_Device_t Mouse_HID_Device_Interface =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.InterfaceNumber = INTERFACE_ID_Mouse,
|
||||
.ReportINEndpoint =
|
||||
{
|
||||
.Address = MOUSE_EPADDR,
|
||||
.Size = MOUSE_EPSIZE,
|
||||
.Banks = 1,
|
||||
},
|
||||
.PrevReportINBuffer = PrevMouseHIDReportBuffer,
|
||||
.PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/** Event handler for the library USB WakeUp event. */
|
||||
void EVENT_USB_Device_Connect(void)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Suspend event. */
|
||||
void EVENT_USB_Device_Disconnect(void)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Configuration Changed event. */
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
|
||||
if (!(HID_Device_ConfigureEndpoints(&Mouse_HID_Device_Interface)))
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
USB_Device_EnableSOFEvents();
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Control Request reception event. */
|
||||
void EVENT_USB_Device_ControlRequest(void)
|
||||
{
|
||||
HID_Device_ProcessControlRequest(&Mouse_HID_Device_Interface);
|
||||
}
|
||||
|
||||
/** Event handler for the USB device Start Of Frame event. */
|
||||
void EVENT_USB_Device_StartOfFrame(void)
|
||||
{
|
||||
HID_Device_MillisecondElapsed(&Mouse_HID_Device_Interface);
|
||||
}
|
||||
|
||||
/** HID class driver callback function for the creation of HID reports to the host.
|
||||
*
|
||||
* \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced
|
||||
* \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID
|
||||
* \param[in] ReportType Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent)
|
||||
*
|
||||
* \return Boolean \c true to force the sending of the report, \c false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
uint8_t* const ReportID,
|
||||
const uint8_t ReportType,
|
||||
void* ReportData,
|
||||
uint16_t* const ReportSize)
|
||||
{
|
||||
USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData;
|
||||
|
||||
uint8_t JoyStatus_LCL = Joystick_GetStatus();
|
||||
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
|
||||
|
||||
if (JoyStatus_LCL & JOY_UP)
|
||||
MouseReport->Y = -1;
|
||||
else if (JoyStatus_LCL & JOY_DOWN)
|
||||
MouseReport->Y = 1;
|
||||
|
||||
if (JoyStatus_LCL & JOY_RIGHT)
|
||||
MouseReport->X = 1;
|
||||
else if (JoyStatus_LCL & JOY_LEFT)
|
||||
MouseReport->X = -1;
|
||||
|
||||
if (JoyStatus_LCL & JOY_PRESS)
|
||||
MouseReport->Button |= (1 << 0);
|
||||
|
||||
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
|
||||
MouseReport->Button |= (1 << 1);
|
||||
|
||||
*ReportSize = sizeof(USB_MouseReport_Data_t);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** HID class driver callback function for the processing of HID reports from the host.
|
||||
*
|
||||
* \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced
|
||||
* \param[in] ReportID Report ID of the received report from the host
|
||||
* \param[in] ReportType The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature
|
||||
* \param[in] ReportData Pointer to a buffer where the received report has been stored
|
||||
* \param[in] ReportSize Size in bytes of the received HID report
|
||||
*/
|
||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
const uint8_t ReportID,
|
||||
const uint8_t ReportType,
|
||||
const void* ReportData,
|
||||
const uint16_t ReportSize)
|
||||
{
|
||||
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2014.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for DeviceFunctions.c.
|
||||
*/
|
||||
|
||||
#ifndef _MOUSE_DEVICE_FUNCTIONS_H_
|
||||
#define _MOUSE_DEVICE_FUNCTIONS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include "MouseHostDevice.h"
|
||||
|
||||
/* External Variables: */
|
||||
extern USB_ClassInfo_HID_Device_t Mouse_HID_Device_Interface;
|
||||
|
||||
/* Function Prototypes: */
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
uint8_t* const ReportID,
|
||||
const uint8_t ReportType,
|
||||
void* ReportData,
|
||||
uint16_t* const ReportSize);
|
||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
const uint8_t ReportID,
|
||||
const uint8_t ReportType,
|
||||
const void* ReportData,
|
||||
const uint16_t ReportSize);
|
||||
|
||||
void EVENT_USB_Device_Connect(void);
|
||||
void EVENT_USB_Device_Disconnect(void);
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_ControlRequest(void);
|
||||
void EVENT_USB_Device_StartOfFrame(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2014.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Host Mode USB Mouse functionality for the MouseHostDevice demo. This file contains the Host mode
|
||||
* USB Mouse related code of the demo and is responsible for all the Host mode Mouse functionality.
|
||||
*/
|
||||
|
||||
#include "HostFunctions.h"
|
||||
|
||||
/** LUFA HID Class driver interface configuration and state information. This structure is
|
||||
* passed to all HID Class driver functions, so that multiple instances of the same class
|
||||
* within a device can be differentiated from one another.
|
||||
*/
|
||||
USB_ClassInfo_HID_Host_t Mouse_HID_Host_Interface =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.DataINPipe =
|
||||
{
|
||||
.Address = (PIPE_DIR_IN | 1),
|
||||
.Banks = 1,
|
||||
},
|
||||
.DataINPipe =
|
||||
{
|
||||
.Address = (PIPE_DIR_OUT | 2),
|
||||
.Banks = 1,
|
||||
},
|
||||
.HIDInterfaceProtocol = HID_CSCP_MouseBootProtocol,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and
|
||||
* starts the library USB task to begin the enumeration and USB management process.
|
||||
*/
|
||||
void EVENT_USB_Host_DeviceAttached(void)
|
||||
{
|
||||
puts_P(PSTR("Device Attached.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and
|
||||
* stops the library USB task management process.
|
||||
*/
|
||||
void EVENT_USB_Host_DeviceUnattached(void)
|
||||
{
|
||||
puts_P(PSTR("\r\nDevice Unattached.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully
|
||||
* enumerated by the host and is now ready to be used by the application.
|
||||
*/
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
|
||||
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful)
|
||||
{
|
||||
printf("Error Retrieving Configuration Descriptor.\r\n");
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (HID_Host_ConfigurePipes(&Mouse_HID_Host_Interface,
|
||||
ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError)
|
||||
{
|
||||
printf("Attached Device Not a Valid Mouse.\r\n");
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
printf("Error Setting Device Configuration.\r\n");
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (HID_Host_SetBootProtocol(&Mouse_HID_Host_Interface) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
printf("Could not Set Boot Protocol Mode.\r\n");
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Mouse Enumerated.\r\n");
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode)
|
||||
{
|
||||
USB_Disable();
|
||||
|
||||
printf_P(PSTR(ESC_FG_RED "Host Mode Error\r\n"
|
||||
" -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode);
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
for(;;);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
|
||||
* enumerating an attached USB device.
|
||||
*/
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode)
|
||||
{
|
||||
printf_P(PSTR(ESC_FG_RED "Dev Enum Error\r\n"
|
||||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
/** Host USB management task. This task handles the control of USB Mice while in USB Host mode,
|
||||
* setting up the appropriate data pipes and processing reports from the attached device.
|
||||
*/
|
||||
void MouseHost_Task(void)
|
||||
{
|
||||
if (USB_HostState != HOST_STATE_Configured)
|
||||
return;
|
||||
|
||||
if (HID_Host_IsReportReceived(&Mouse_HID_Host_Interface))
|
||||
{
|
||||
uint8_t LEDMask = LEDS_NO_LEDS;
|
||||
|
||||
USB_MouseReport_Data_t MouseReport;
|
||||
HID_Host_ReceiveReport(&Mouse_HID_Host_Interface, &MouseReport);
|
||||
|
||||
printf_P(PSTR("dX:%2d dY:%2d Button:%d\r\n"), MouseReport.X,
|
||||
MouseReport.Y,
|
||||
MouseReport.Button);
|
||||
if (MouseReport.X > 0)
|
||||
LEDMask |= LEDS_LED1;
|
||||
else if (MouseReport.X < 0)
|
||||
LEDMask |= LEDS_LED2;
|
||||
|
||||
if (MouseReport.Y > 0)
|
||||
LEDMask |= LEDS_LED3;
|
||||
else if (MouseReport.Y < 0)
|
||||
LEDMask |= LEDS_LED4;
|
||||
|
||||
if (MouseReport.Button)
|
||||
LEDMask = LEDS_ALL_LEDS;
|
||||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2014.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for HostFunctions.c.
|
||||
*/
|
||||
|
||||
#ifndef _MOUSE_HOST_FUNCTIONS_H_
|
||||
#define _MOUSE_HOST_FUNCTIONS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include "MouseHostDevice.h"
|
||||
|
||||
/* External Variables: */
|
||||
extern USB_ClassInfo_HID_Host_t Mouse_HID_Host_Interface;
|
||||
|
||||
/* Function Prototypes: */
|
||||
void MouseHost_Task(void);
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2014.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Main source file for the MouseHostDevice demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the overall control flow of the demo.
|
||||
*/
|
||||
|
||||
#include "MouseHostDevice.h"
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
puts_P(PSTR(ESC_FG_CYAN "Mouse Host/Device Demo running.\r\n" ESC_FG_WHITE));
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
GlobalInterruptEnable();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Determine which USB mode we are currently in */
|
||||
if (USB_CurrentMode == USB_MODE_Host)
|
||||
{
|
||||
MouseHost_Task();
|
||||
HID_Host_USBTask(&Mouse_HID_Host_Interface);
|
||||
}
|
||||
else
|
||||
{
|
||||
HID_Device_USBTask(&Mouse_HID_Device_Interface);
|
||||
}
|
||||
|
||||
USB_USBTask();
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
void SetupHardware(void)
|
||||
{
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
#endif
|
||||
|
||||
/* Hardware Initialization */
|
||||
Serial_Init(9600, false);
|
||||
LEDs_Init();
|
||||
Joystick_Init();
|
||||
Buttons_Init();
|
||||
USB_Init(USB_MODE_UID);
|
||||
|
||||
/* Create a stdio stream for the serial port for stdin and stdout */
|
||||
Serial_CreateStream(NULL);
|
||||
}
|
||||
|
||||
/** Event handler for the library USB mode change event. */
|
||||
void EVENT_USB_UIDChange(void)
|
||||
{
|
||||
printf_P(PSTR(ESC_FG_YELLOW "UID Change to %S mode\r\n" ESC_FG_WHITE),
|
||||
(USB_CurrentMode == USB_MODE_Device) ? PSTR("Device") : PSTR("Host"));
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2014.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for MouseHost.c.
|
||||
*/
|
||||
|
||||
#ifndef _MOUSE_HOST_DEVICE_H_
|
||||
#define _MOUSE_HOST_DEVICE_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <LUFA/Drivers/Misc/TerminalCodes.h>
|
||||
#include <LUFA/Drivers/Peripheral/Serial.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/Board/Joystick.h>
|
||||
#include <LUFA/Drivers/Board/Buttons.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Platform/Platform.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
#include "DeviceFunctions.h"
|
||||
#include "HostFunctions.h"
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
||||
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
||||
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
||||
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
void EVENT_USB_UIDChange(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage Mouse Host/Device Dual Role Demo
|
||||
*
|
||||
* \section Sec_Compat Demo Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
*
|
||||
* \section Sec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this demo.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Dual Mode Host/Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF HID Specification, USBIF HID Usage Tables</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Supported USB Speeds:</b></td>
|
||||
* <td>Low Speed Mode, Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section Sec_Description Project Description:
|
||||
*
|
||||
* Mouse host/device dual role demonstration application. This gives a simple
|
||||
* reference application for implementing a dual role USB Mouse, for USB mice
|
||||
* using the standard mouse boot protocol HID profile.
|
||||
*
|
||||
* <b>When in host mode:</b>
|
||||
* Mouse movement and button presses are displayed on the board LEDs,
|
||||
* as well as printed out the serial terminal as formatted dY, dY and
|
||||
* button status information.
|
||||
*
|
||||
* This uses a naive method where the mouse is set to Boot Protocol mode, so
|
||||
* that the report structure is fixed and known. A better implementation
|
||||
* uses the HID report parser for correct report data processing across
|
||||
* all compatible mice with advanced characteristics, as shown in the
|
||||
* MouseHostWithParser Host demo application.
|
||||
*
|
||||
* Currently only single interface mice are supported.
|
||||
*
|
||||
* <b>When in device mode:</b>
|
||||
* Upon enumeration the system will automatically enumerate and function
|
||||
* as a mouse when the USB connection to a host is present. To use
|
||||
* the mouse, move the joystick to move the pointer, and push the
|
||||
* joystick inwards to simulate a left-button click. The HWB serves as
|
||||
* the right mouse button.
|
||||
*
|
||||
* \section Sec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* None
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<asf xmlversion="1.0">
|
||||
<project caption="Mouse HID Dual USB Mode Demo (Class Driver APIs)" id="lufa.demos.dualrole.class.mouse.example.avr8">
|
||||
<require idref="lufa.demos.dualrole.class.mouse"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="at90usb1287"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
</project>
|
||||
|
||||
<module type="application" id="lufa.demos.dualrole.class.mouse" caption="Mouse HID Dual USB Mode Demo (Class Driver APIs)">
|
||||
<info type="description" value="summary">
|
||||
Mouse host and device dual role demo, implementing a basic mouse device and host. This demo uses the user-friendly USB Class Driver APIs to provide a simple, abstracted interface into the USB stack.
|
||||
</info>
|
||||
|
||||
<info type="gui-flag" value="move-to-root"/>
|
||||
|
||||
<info type="keyword" value="Technology">
|
||||
<keyword value="Class Driver APIs"/>
|
||||
<keyword value="USB Dual Role"/>
|
||||
<keyword value="HID Class"/>
|
||||
</info>
|
||||
|
||||
<device-support-alias value="lufa_avr8"/>
|
||||
<device-support-alias value="lufa_xmega"/>
|
||||
<device-support-alias value="lufa_uc3"/>
|
||||
|
||||
<build type="distribute" subtype="user-file" value="doxyfile"/>
|
||||
<build type="distribute" subtype="user-file" value="MouseHostDevice.txt"/>
|
||||
|
||||
<build type="c-source" value="MouseHostDevice.c"/>
|
||||
<build type="c-source" value="Descriptors.c"/>
|
||||
<build type="c-source" value="DeviceFunctions.c"/>
|
||||
<build type="c-source" value="HostFunctions.c"/>
|
||||
<build type="header-file" value="MouseHostDevice.h"/>
|
||||
<build type="header-file" value="Descriptors.h"/>
|
||||
<build type="header-file" value="DeviceFunctions.h"/>
|
||||
<build type="header-file" value="HostFunctions.h"/>
|
||||
|
||||
<build type="module-config" subtype="path" value="Config"/>
|
||||
<build type="header-file" value="Config/LUFAConfig.h"/>
|
||||
|
||||
<require idref="lufa.common"/>
|
||||
<require idref="lufa.platform"/>
|
||||
<require idref="lufa.drivers.usb"/>
|
||||
<require idref="lufa.drivers.peripheral.usart"/>
|
||||
<require idref="lufa.drivers.misc.ansi"/>
|
||||
<require idref="lufa.drivers.board"/>
|
||||
<require idref="lufa.drivers.board.leds"/>
|
||||
<require idref="lufa.drivers.board.joystick"/>
|
||||
<require idref="lufa.drivers.board.buttons"/>
|
||||
</module>
|
||||
</asf>
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2014.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
# --------------------------------------
|
||||
# LUFA Project Makefile.
|
||||
# --------------------------------------
|
||||
|
||||
# Run "make help" for target help.
|
||||
|
||||
MCU = at90usb1287
|
||||
ARCH = AVR8
|
||||
BOARD = USBKEY
|
||||
F_CPU = 8000000
|
||||
F_USB = $(F_CPU)
|
||||
OPTIMIZATION = s
|
||||
TARGET = MouseHostDevice
|
||||
SRC = $(TARGET).c Descriptors.c DeviceFunctions.c HostFunctions.c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS) $(LUFA_SRC_SERIAL)
|
||||
LUFA_PATH = ../../../../LUFA
|
||||
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/
|
||||
LD_FLAGS =
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
include $(LUFA_PATH)/Build/lufa_sources.mk
|
||||
include $(LUFA_PATH)/Build/lufa_build.mk
|
||||
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
|
||||
include $(LUFA_PATH)/Build/lufa_doxygen.mk
|
||||
include $(LUFA_PATH)/Build/lufa_dfu.mk
|
||||
include $(LUFA_PATH)/Build/lufa_hid.mk
|
||||
include $(LUFA_PATH)/Build/lufa_avrdude.mk
|
||||
include $(LUFA_PATH)/Build/lufa_atprogram.mk
|
46
protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/makefile
Normal file
46
protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/makefile
Normal file
|
@ -0,0 +1,46 @@
|
|||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2014.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
# Makefile to build all the LUFA Dual Role Demos. Call with "make all" to
|
||||
# rebuild all Dual Role demos.
|
||||
|
||||
# Projects are pre-cleaned before each one is built, to ensure any
|
||||
# custom LUFA library build options are reflected in the compiled
|
||||
# code.
|
||||
|
||||
PROJECT_DIRECTORIES := $(shell ls -d */)
|
||||
|
||||
# This makefile is potentially infinitely recursive if something really bad
|
||||
# happens when determining the set of project directories - hard-abort if
|
||||
# more than 10 levels deep to avoid angry emails.
|
||||
ifeq ($(MAKELEVEL), 10)
|
||||
$(error EMERGENCY ABORT: INFINITE RECURSION DETECTED)
|
||||
endif
|
||||
|
||||
# Need to special-case building without a per-project object directory
|
||||
ifeq ($(OBJDIR),)
|
||||
# If no target specified, force "clean all" and disallow parallel build
|
||||
ifeq ($(MAKECMDGOALS),)
|
||||
MAKECMDGOALS := clean all
|
||||
.NOTPARALLEL:
|
||||
endif
|
||||
|
||||
# If one of the targets is to build, force "clean" beforehand and disallow parallel build
|
||||
ifneq ($(findstring all, $(MAKECMDGOALS)),)
|
||||
MAKECMDGOALS := clean $(MAKECMDGOALS)
|
||||
.NOTPARALLEL:
|
||||
endif
|
||||
endif
|
||||
|
||||
%: $(PROJECT_DIRECTORIES)
|
||||
@echo . > /dev/null
|
||||
|
||||
$(PROJECT_DIRECTORIES):
|
||||
@$(MAKE) -C $@ $(MAKECMDGOALS)
|
||||
|
||||
.PHONY: $(PROJECT_DIRECTORIES)
|
Loading…
Add table
Add a link
Reference in a new issue