All USB class drivers are now automatically included when LUFA/Drivers/USB.h is included, and no longer need to be seperately included.
All LowLevel demos changed to use the constants and types defined in the USB class drivers.
This commit is contained in:
parent
8f3bee7d86
commit
b37d77eab3
208 changed files with 589 additions and 2910 deletions
|
@ -147,12 +147,12 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
|
||||
.HID_KeyboardHID =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_HID_t), .Type = DTYPE_HID},
|
||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||
|
||||
.HIDSpec = VERSION_BCD(01.11),
|
||||
.CountryCode = 0x00,
|
||||
.TotalReportDescriptors = 1,
|
||||
.HIDReportType = DTYPE_Report,
|
||||
.HIDReportType = HID_DTYPE_Report,
|
||||
.HIDReportLength = sizeof(KeyboardReport)
|
||||
},
|
||||
|
||||
|
@ -254,11 +254,11 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
}
|
||||
|
||||
break;
|
||||
case DTYPE_HID:
|
||||
case HID_DTYPE_HID:
|
||||
Address = &ConfigurationDescriptor.HID_KeyboardHID;
|
||||
Size = sizeof(USB_Descriptor_HID_t);
|
||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||
break;
|
||||
case DTYPE_Report:
|
||||
case HID_DTYPE_Report:
|
||||
Address = &KeyboardReport;
|
||||
Size = sizeof(KeyboardReport);
|
||||
break;
|
||||
|
|
|
@ -43,25 +43,6 @@
|
|||
#include <avr/pgmspace.h>
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the HID class specific HID descriptor, to describe the HID device's specifications. Refer to the HID
|
||||
* specification for details on the structure elements.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Header_t Header;
|
||||
|
||||
uint16_t HIDSpec;
|
||||
uint8_t CountryCode;
|
||||
|
||||
uint8_t TotalReportDescriptors;
|
||||
|
||||
uint8_t HIDReportType;
|
||||
uint16_t HIDReportLength;
|
||||
} USB_Descriptor_HID_t;
|
||||
|
||||
/** Type define for the data type used to store HID report descriptor elements. */
|
||||
typedef uint8_t USB_Descriptor_HIDReport_Datatype_t;
|
||||
|
||||
/** 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.
|
||||
|
@ -70,7 +51,7 @@
|
|||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
USB_Descriptor_Interface_t HID_Interface;
|
||||
USB_Descriptor_HID_t HID_KeyboardHID;
|
||||
USB_HID_Descriptor_HID_t HID_KeyboardHID;
|
||||
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
|
||||
USB_Descriptor_Endpoint_t HID_ReportOUTEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
@ -85,12 +66,6 @@
|
|||
/** Size in bytes of the Keyboard HID reporting IN and OUT endpoints. */
|
||||
#define KEYBOARD_EPSIZE 8
|
||||
|
||||
/** Descriptor header type value, to indicate a HID class HID descriptor. */
|
||||
#define DTYPE_HID 0x21
|
||||
|
||||
/** Descriptor header type value, to indicate a HID class HID report descriptor. */
|
||||
#define DTYPE_Report 0x22
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
|
|
|
@ -138,7 +138,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
/* Handle HID Class specific requests */
|
||||
switch (USB_ControlRequest.bRequest)
|
||||
{
|
||||
case REQ_GetReport:
|
||||
case HID_REQ_GetReport:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
USB_KeyboardReport_Data_t KeyboardReportData;
|
||||
|
@ -154,7 +154,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
}
|
||||
|
||||
break;
|
||||
case REQ_SetReport:
|
||||
case HID_REQ_SetReport:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
|
@ -177,7 +177,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
}
|
||||
|
||||
break;
|
||||
case REQ_GetProtocol:
|
||||
case HID_REQ_GetProtocol:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
|
@ -190,7 +190,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
}
|
||||
|
||||
break;
|
||||
case REQ_SetProtocol:
|
||||
case HID_REQ_SetProtocol:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
|
@ -201,7 +201,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
}
|
||||
|
||||
break;
|
||||
case REQ_SetIdle:
|
||||
case HID_REQ_SetIdle:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
|
@ -212,7 +212,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
}
|
||||
|
||||
break;
|
||||
case REQ_GetIdle:
|
||||
case HID_REQ_GetIdle:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
|
@ -251,7 +251,7 @@ void CreateKeyboardReport(USB_KeyboardReport_Data_t* const ReportData)
|
|||
memset(ReportData, 0, sizeof(USB_KeyboardReport_Data_t));
|
||||
|
||||
/* Make sent key uppercase by indicating that the left shift key is pressed */
|
||||
ReportData->Modifier = KEYBOARD_MODIFER_LEFTSHIFT;
|
||||
ReportData->Modifier = HID_KEYBOARD_MODIFER_LEFTSHIFT;
|
||||
|
||||
if (JoyStatus_LCL & JOY_UP)
|
||||
ReportData->KeyCode[UsedKeyCodes++] = 0x04; // A
|
||||
|
@ -278,13 +278,13 @@ void ProcessLEDReport(const uint8_t LEDReport)
|
|||
{
|
||||
uint8_t LEDMask = LEDS_LED2;
|
||||
|
||||
if (LEDReport & KEYBOARD_LED_NUMLOCK)
|
||||
if (LEDReport & HID_KEYBOARD_LED_NUMLOCK)
|
||||
LEDMask |= LEDS_LED1;
|
||||
|
||||
if (LEDReport & KEYBOARD_LED_CAPSLOCK)
|
||||
if (LEDReport & HID_KEYBOARD_LED_CAPSLOCK)
|
||||
LEDMask |= LEDS_LED3;
|
||||
|
||||
if (LEDReport & KEYBOARD_LED_SCROLLLOCK)
|
||||
if (LEDReport & HID_KEYBOARD_LED_SCROLLLOCK)
|
||||
LEDMask |= LEDS_LED4;
|
||||
|
||||
/* Set the status LEDs to the current Keyboard LED status */
|
||||
|
@ -305,7 +305,7 @@ void SendNextReport(void)
|
|||
SendReport = (memcmp(&PrevKeyboardReportData, &KeyboardReportData, sizeof(USB_KeyboardReport_Data_t)) != 0);
|
||||
|
||||
/* Check if the idle period is set and has elapsed */
|
||||
if ((IdleCount != HID_IDLE_CHANGESONLY) && (!(IdleMSRemaining)))
|
||||
if (IdleCount && (!(IdleMSRemaining)))
|
||||
{
|
||||
/* Reset the idle time remaining counter */
|
||||
IdleMSRemaining = IdleCount;
|
||||
|
|
|
@ -54,63 +54,6 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Idle period indicating that reports should be sent only when the inputs have changed. */
|
||||
#define HID_IDLE_CHANGESONLY 0
|
||||
|
||||
/** HID Class specific request to get the next HID report from the device. */
|
||||
#define REQ_GetReport 0x01
|
||||
|
||||
/** HID Class specific request to get the idle timeout period of the device. */
|
||||
#define REQ_GetIdle 0x02
|
||||
|
||||
/** HID Class specific request to send the next HID report to the device. */
|
||||
#define REQ_SetReport 0x09
|
||||
|
||||
/** HID Class specific request to set the idle timeout period of the device. */
|
||||
#define REQ_SetIdle 0x0A
|
||||
|
||||
/** HID Class specific request to get the current HID protocol in use, either report or boot. */
|
||||
#define REQ_GetProtocol 0x03
|
||||
|
||||
/** HID Class specific request to set the current HID protocol in use, either report or boot. */
|
||||
#define REQ_SetProtocol 0x0B
|
||||
|
||||
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */
|
||||
#define KEYBOARD_MODIFER_LEFTCTRL (1 << 0)
|
||||
|
||||
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */
|
||||
#define KEYBOARD_MODIFER_LEFTSHIFT (1 << 1)
|
||||
|
||||
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */
|
||||
#define KEYBOARD_MODIFER_LEFTALT (1 << 2)
|
||||
|
||||
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */
|
||||
#define KEYBOARD_MODIFER_LEFTGUI (1 << 3)
|
||||
|
||||
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */
|
||||
#define KEYBOARD_MODIFER_RIGHTCTRL (1 << 4)
|
||||
|
||||
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */
|
||||
#define KEYBOARD_MODIFER_RIGHTSHIFT (1 << 5)
|
||||
|
||||
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */
|
||||
#define KEYBOARD_MODIFER_RIGHTALT (1 << 6)
|
||||
|
||||
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */
|
||||
#define KEYBOARD_MODIFER_RIGHTGUI (1 << 7)
|
||||
|
||||
/** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */
|
||||
#define KEYBOARD_LED_NUMLOCK (1 << 0)
|
||||
|
||||
/** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */
|
||||
#define KEYBOARD_LED_CAPSLOCK (1 << 1)
|
||||
|
||||
/** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */
|
||||
#define KEYBOARD_LED_SCROLLLOCK (1 << 2)
|
||||
|
||||
/** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */
|
||||
#define KEYBOARD_LED_KATANA (1 << 3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
||||
|
@ -123,17 +66,6 @@
|
|||
/** 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)
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the keyboard HID report structure, for creating and sending HID reports to the host PC.
|
||||
* This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Modifier; /**< Modifier mask byte, containing a mask of modifier keys set (such as shift or CTRL) */
|
||||
uint8_t Reserved; /**< Reserved, always set as 0x00 */
|
||||
uint8_t KeyCode[6]; /**< Array of up to six simultaneous key codes of pressed keys */
|
||||
} USB_KeyboardReport_Data_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
void HID_Task(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue