#include <avr/power.h>\r
\r
#include "Descriptors.h"\r
- \r
+\r
#include <LUFA/Version.h>\r
#include <LUFA/Drivers/Board/LEDs.h>\r
#include <LUFA/Drivers/Board/Joystick.h>\r
#include <LUFA/Drivers/Peripheral/ADC.h>\r
#include <LUFA/Drivers/USB/USB.h>\r
#include <LUFA/Drivers/USB/Class/Device/Audio.h>\r
- \r
+\r
/* Macros: */\r
/** ADC channel number for the microphone input. */\r
#define MIC_IN_ADC_CHANNEL 2\r
- \r
+\r
/** Maximum ADC sample value for the microphone input. */\r
#define SAMPLE_MAX_RANGE 0xFFFF\r
\r
\r
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */\r
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)\r
- \r
+\r
/* Function Prototypes: */\r
void SetupHardware(void);\r
void ProcessNextSample(void);\r
- \r
+\r
void EVENT_USB_Connect(void);\r
void EVENT_USB_Disconnect(void);\r
void EVENT_USB_ConfigurationChanged(void);\r
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =\r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},\r
- \r
+\r
.USBSpecification = VERSION_BCD(02.00),\r
.Class = 0x00,\r
.SubClass = 0x00,\r
.Protocol = 0x00,\r
- \r
+\r
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,\r
- \r
+\r
.VendorID = 0x03EB,\r
.ProductID = 0x2047,\r
.ReleaseNumber = 0x0000,\r
- \r
+\r
.ManufacturerStrIndex = 0x01,\r
.ProductStrIndex = 0x02,\r
.SerialNumStrIndex = NO_DESCRIPTOR,\r
- \r
+\r
.NumberOfConfigurations = 1\r
};\r
\r
\r
.ConfigurationNumber = 1,\r
.ConfigurationStrIndex = NO_DESCRIPTOR,\r
- \r
+\r
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),\r
- \r
+\r
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)\r
},\r
- \r
+\r
.AudioControlInterface = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},\r
.AlternateSetting = 0,\r
\r
.TotalEndpoints = 0,\r
- \r
+\r
.Class = 0x01,\r
.SubClass = 0x01,\r
.Protocol = 0x00,\r
- \r
- .InterfaceStrIndex = NO_DESCRIPTOR \r
+\r
+ .InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
- \r
+\r
.AudioControlInterface_SPC = \r
{\r
.Header = {.Size = sizeof(USB_AudioInterface_AC_t), .Type = DTYPE_AudioInterface},\r
.Subtype = DSUBTYPE_Header,\r
- \r
+\r
.ACSpecification = VERSION_BCD(01.00),\r
.TotalLength = (sizeof(USB_AudioInterface_AC_t) +\r
sizeof(USB_AudioInputTerminal_t) +\r
- sizeof(USB_AudioOutputTerminal_t)),\r
+ sizeof(USB_AudioOutputTerminal_t)),\r
\r
.InCollection = 1,\r
- .InterfaceNumbers = {1}, \r
+ .InterfaceNumbers = {1},\r
},\r
\r
.InputTerminal = \r
{\r
.Header = {.Size = sizeof(USB_AudioInputTerminal_t), .Type = DTYPE_AudioInterface},\r
.Subtype = DSUBTYPE_InputTerminal,\r
- \r
+\r
.TerminalID = 0x01,\r
.TerminalType = TERMINAL_IN_MIC,\r
.AssociatedOutputTerminal = 0x00,\r
- \r
+\r
.TotalChannels = 1,\r
.ChannelConfig = 0,\r
- \r
+\r
.ChannelStrIndex = NO_DESCRIPTOR,\r
.TerminalStrIndex = NO_DESCRIPTOR\r
},\r
{\r
.Header = {.Size = sizeof(USB_AudioOutputTerminal_t), .Type = DTYPE_AudioInterface},\r
.Subtype = DSUBTYPE_OutputTerminal,\r
- \r
+\r
.TerminalID = 0x02,\r
.TerminalType = TERMINAL_STREAMING,\r
.AssociatedInputTerminal = 0x00,\r
- \r
+\r
.SourceID = 0x01,\r
- \r
- .TerminalStrIndex = NO_DESCRIPTOR \r
+\r
+ .TerminalStrIndex = NO_DESCRIPTOR\r
},\r
\r
.AudioStreamInterface_Alt0 = \r
\r
.InterfaceNumber = 1,\r
.AlternateSetting = 0,\r
- \r
+\r
.TotalEndpoints = 0,\r
- \r
+\r
.Class = 0x01,\r
.SubClass = 0x02,\r
.Protocol = 0x00,\r
- \r
+\r
.InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
\r
\r
.InterfaceNumber = 1,\r
.AlternateSetting = 1,\r
- \r
+\r
.TotalEndpoints = 1,\r
- \r
+\r
.Class = 0x01,\r
.SubClass = 0x02,\r
.Protocol = 0x00,\r
- \r
+\r
.InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
- \r
+\r
.AudioStreamInterface_SPC = \r
{\r
.Header = {.Size = sizeof(USB_AudioInterface_AS_t), .Type = DTYPE_AudioInterface},\r
.Subtype = DSUBTYPE_General,\r
- \r
+\r
.TerminalLink = 0x02,\r
- \r
+\r
.FrameDelay = 1,\r
.AudioFormat = 0x0001\r
},\r
- \r
+\r
.AudioFormat = \r
{\r
.Header = {.Size = sizeof(USB_AudioFormat_t), .Type = DTYPE_AudioInterface},\r
USB_Descriptor_String_t PROGMEM LanguageString =\r
{\r
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = {LANGUAGE_ID_ENG}\r
};\r
\r
USB_Descriptor_String_t PROGMEM ManufacturerString =\r
{\r
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = L"Dean Camera"\r
};\r
\r
USB_Descriptor_String_t PROGMEM ProductString =\r
{\r
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = L"LUFA Audio In Demo"\r
};\r
\r
/** Endpoint number of the Audio isochronous streaming data endpoint. */\r
#define AUDIO_STREAM_EPNUM 1\r
#else\r
- #define AUDIO_STREAM_EPNUM 3 \r
+ #define AUDIO_STREAM_EPNUM 3\r
#endif\r
\r
/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires\r
* USB AVR models will result in unavoidable distorted output.\r
*/\r
#define AUDIO_STREAM_EPSIZE ENDPOINT_MAX_SIZE(AUDIO_STREAM_EPNUM)\r
- \r
+\r
/** Sample frequency of the data being transmitted through the streaming endpoint. */\r
#define AUDIO_SAMPLE_FREQUENCY 48000\r
- \r
+\r
/* Type Defines: */\r
/** Type define for the device configuration descriptor structure. This must be defined in the\r
* application code, as the configuration descriptor contains several sub-descriptors which\r
USB_AudioStreamEndpoint_Std_t AudioEndpoint;\r
USB_AudioStreamEndpoint_Spc_t AudioEndpoint_SPC;\r
} USB_Descriptor_Configuration_t;\r
- \r
+\r
/* Function Prototypes: */\r
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)\r
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
/* Massage signed 16-bit left and right audio samples into signed 8-bit */\r
int8_t LeftSample_8Bit = (LeftSample_16Bit >> 8);\r
int8_t RightSample_8Bit = (RightSample_16Bit >> 8);\r
- \r
+\r
/* Mix the two channels together to produce a mono, 8-bit sample */\r
int8_t MixedSample_8Bit = (((int16_t)LeftSample_8Bit + (int16_t)RightSample_8Bit) >> 1);\r
\r
#if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO))\r
/* PWM speaker timer initialization */\r
TCCRxA = ((1 << WGMx0) | (1 << COMxA1) | (1 << COMxA0)\r
- | (1 << COMxB1) | (1 << COMxB0)); // Set on match, clear on TOP\r
+ | (1 << COMxB1) | (1 << COMxB0)); // Set on match, clear on TOP\r
TCCRxB = ((1 << WGMx2) | (1 << CSx0)); // Fast 8-Bit PWM, Fcpu speed\r
-#endif \r
+#endif\r
}\r
\r
/** Event handler for the library USB Disconnection event. */\r
#if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO))\r
/* Stop the PWM generation timer */\r
TCCRxB = 0;\r
-#endif \r
+#endif\r
\r
#if defined(AUDIO_OUT_MONO)\r
/* Set speaker as input to reduce current draw */\r
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =\r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},\r
- \r
+\r
.USBSpecification = VERSION_BCD(02.00),\r
.Class = 0x00,\r
.SubClass = 0x00,\r
.Protocol = 0x00,\r
- \r
+\r
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,\r
- \r
+\r
.VendorID = 0x03EB,\r
.ProductID = 0x2046,\r
.ReleaseNumber = 0x0000,\r
- \r
+\r
.ManufacturerStrIndex = 0x01,\r
.ProductStrIndex = 0x02,\r
.SerialNumStrIndex = NO_DESCRIPTOR,\r
- \r
+\r
.NumberOfConfigurations = 1\r
};\r
\r
\r
.ConfigurationNumber = 1,\r
.ConfigurationStrIndex = NO_DESCRIPTOR,\r
- \r
+ \r
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),\r
\r
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)\r
.AlternateSetting = 0,\r
\r
.TotalEndpoints = 0,\r
- \r
+ \r
.Class = 0x01,\r
.SubClass = 0x01,\r
.Protocol = 0x00,\r
- \r
- .InterfaceStrIndex = NO_DESCRIPTOR \r
+ \r
+ .InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
\r
.AudioControlInterface_SPC = \r
\r
.ACSpecification = VERSION_BCD(01.00),\r
.TotalLength = (sizeof(USB_AudioInterface_AC_t) +\r
- sizeof(USB_AudioInputTerminal_t) +\r
- sizeof(USB_AudioOutputTerminal_t)),\r
+ sizeof(USB_AudioInputTerminal_t) +\r
+ sizeof(USB_AudioOutputTerminal_t)),\r
\r
.InCollection = 1,\r
- .InterfaceNumbers = {1}, \r
+ .InterfaceNumbers = {1},\r
},\r
\r
.InputTerminal = \r
\r
.SourceID = 0x01,\r
\r
- .TerminalStrIndex = NO_DESCRIPTOR \r
+ .TerminalStrIndex = NO_DESCRIPTOR\r
},\r
\r
.AudioStreamInterface_Alt0 = \r
.AlternateSetting = 0,\r
\r
.TotalEndpoints = 0,\r
- \r
+ \r
.Class = 0x01,\r
.SubClass = 0x02,\r
.Protocol = 0x00,\r
- \r
+ \r
.InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
\r
.AlternateSetting = 1,\r
\r
.TotalEndpoints = 1,\r
- \r
+ \r
.Class = 0x01,\r
.SubClass = 0x02,\r
.Protocol = 0x00,\r
- \r
+ \r
.InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
\r
USB_Descriptor_String_t PROGMEM LanguageString =\r
{\r
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = {LANGUAGE_ID_ENG}\r
};\r
\r
USB_Descriptor_String_t PROGMEM ManufacturerString =\r
{\r
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = L"Dean Camera"\r
};\r
\r
USB_Descriptor_String_t PROGMEM ProductString =\r
{\r
.Header = {.Size = USB_STRING_LEN(19), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = L"LUFA Audio Out Demo"\r
};\r
\r
/** Endpoint number of the Audio isochronous streaming data endpoint. */\r
#define AUDIO_STREAM_EPNUM 1\r
#else\r
- #define AUDIO_STREAM_EPNUM 3 \r
+ #define AUDIO_STREAM_EPNUM 3\r
#endif\r
\r
/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires\r
\r
/* Function Prototypes: */\r
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)\r
- ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
\r
#endif\r
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =\r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},\r
- \r
+\r
.USBSpecification = VERSION_BCD(01.10),\r
.Class = 0x02,\r
.SubClass = 0x00,\r
.Protocol = 0x00,\r
- \r
+\r
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,\r
- \r
+\r
.VendorID = 0x03EB,\r
.ProductID = 0x2044,\r
.ReleaseNumber = 0x0000,\r
- \r
+\r
.ManufacturerStrIndex = 0x01,\r
.ProductStrIndex = 0x02,\r
.SerialNumStrIndex = NO_DESCRIPTOR,\r
- \r
+\r
.NumberOfConfigurations = 1\r
};\r
\r
\r
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),\r
.TotalInterfaces = 2,\r
- \r
+ \r
.ConfigurationNumber = 1,\r
.ConfigurationStrIndex = NO_DESCRIPTOR,\r
- \r
+ \r
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),\r
\r
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)\r
.AlternateSetting = 0,\r
\r
.TotalEndpoints = 1,\r
- \r
+ \r
.Class = 0x02,\r
.SubClass = 0x02,\r
.Protocol = 0x01,\r
- \r
+ \r
.InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
\r
.ManagementEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),\r
.Attributes = EP_TYPE_INTERRUPT,\r
.EndpointSize = CDC_NOTIFICATION_EPSIZE,\r
.DataOutEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),\r
.Attributes = EP_TYPE_BULK,\r
.EndpointSize = CDC_TXRX_EPSIZE,\r
.DataInEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),\r
.Attributes = EP_TYPE_BULK,\r
.EndpointSize = CDC_TXRX_EPSIZE,\r
USB_Descriptor_String_t PROGMEM LanguageString =\r
{\r
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = {LANGUAGE_ID_ENG}\r
};\r
\r
USB_Descriptor_String_t PROGMEM ManufacturerString =\r
{\r
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = L"Dean Camera"\r
};\r
\r
USB_Descriptor_String_t PROGMEM ProductString =\r
{\r
.Header = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = L"LUFA CDC Demo"\r
};\r
\r
break;\r
}\r
\r
- *DescriptorAddress = Address; \r
+ *DescriptorAddress = Address;\r
return Size;\r
}\r
#include <LUFA/Drivers/USB/USB.h>\r
#include <LUFA/Drivers/USB/Class/Device/CDC.h>\r
\r
- /* Macros: */ \r
+ /* Macros: */\r
/** Endpoint number of the CDC device-to-host notification IN endpoint. */\r
#define CDC_NOTIFICATION_EPNUM 2\r
\r
/** Endpoint number of the CDC device-to-host data IN endpoint. */\r
- #define CDC_TX_EPNUM 3 \r
+ #define CDC_TX_EPNUM 3\r
\r
/** Endpoint number of the CDC host-to-device data OUT endpoint. */\r
- #define CDC_RX_EPNUM 4 \r
+ #define CDC_RX_EPNUM 4\r
\r
/** Size in bytes of the CDC device-to-host notification IN endpoint. */\r
#define CDC_NOTIFICATION_EPSIZE 8\r
\r
/** Size in bytes of the CDC data IN and OUT endpoints. */\r
- #define CDC_TXRX_EPSIZE 16 \r
+ #define CDC_TXRX_EPSIZE 16\r
\r
/* Type Defines: */\r
/** Type define for the device configuration descriptor structure. This must be defined in the\r
\r
/* Function Prototypes: */\r
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)\r
- ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
\r
#endif\r
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =\r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},\r
- \r
+ \r
.USBSpecification = VERSION_BCD(01.10),\r
.Class = 0xEF,\r
.SubClass = 0x02,\r
.Protocol = 0x01,\r
- \r
+ \r
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,\r
- \r
+ \r
.VendorID = 0x03EB,\r
.ProductID = 0x204E,\r
.ReleaseNumber = 0x0000,\r
- \r
+ \r
.ManufacturerStrIndex = 0x01,\r
.ProductStrIndex = 0x02,\r
.SerialNumStrIndex = NO_DESCRIPTOR,\r
- \r
+ \r
.NumberOfConfigurations = 1\r
};\r
\r
\r
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),\r
.TotalInterfaces = 4,\r
- \r
+ \r
.ConfigurationNumber = 1,\r
.ConfigurationStrIndex = NO_DESCRIPTOR,\r
- \r
+ \r
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),\r
\r
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)\r
.AlternateSetting = 0,\r
\r
.TotalEndpoints = 1,\r
- \r
+ \r
.Class = 0x02,\r
.SubClass = 0x02,\r
.Protocol = 0x01,\r
- \r
+ \r
.InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
\r
.CDC1_ManagementEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC1_NOTIFICATION_EPNUM),\r
.Attributes = EP_TYPE_INTERRUPT,\r
.EndpointSize = CDC_NOTIFICATION_EPSIZE,\r
.AlternateSetting = 0,\r
\r
.TotalEndpoints = 2,\r
- \r
+ \r
.Class = 0x0A,\r
.SubClass = 0x00,\r
.Protocol = 0x00,\r
- \r
+ \r
.InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
\r
.CDC1_DataOutEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC1_RX_EPNUM),\r
.Attributes = EP_TYPE_BULK,\r
.EndpointSize = CDC_TXRX_EPSIZE,\r
.CDC1_DataInEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC1_TX_EPNUM),\r
.Attributes = EP_TYPE_BULK,\r
.EndpointSize = CDC_TXRX_EPSIZE,\r
.AlternateSetting = 0,\r
\r
.TotalEndpoints = 1,\r
- \r
+ \r
.Class = 0x02,\r
.SubClass = 0x02,\r
.Protocol = 0x01,\r
- \r
+ \r
.InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
\r
.CDC2_ManagementEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC2_NOTIFICATION_EPNUM),\r
.Attributes = EP_TYPE_INTERRUPT,\r
.EndpointSize = CDC_NOTIFICATION_EPSIZE,\r
.CDC2_DataOutEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC2_RX_EPNUM),\r
.Attributes = EP_TYPE_BULK,\r
.EndpointSize = CDC_TXRX_EPSIZE,\r
.CDC2_DataInEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC2_TX_EPNUM),\r
.Attributes = EP_TYPE_BULK,\r
.EndpointSize = CDC_TXRX_EPSIZE,\r
USB_Descriptor_String_t PROGMEM LanguageString =\r
{\r
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = {LANGUAGE_ID_ENG}\r
};\r
\r
USB_Descriptor_String_t PROGMEM ManufacturerString =\r
{\r
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = L"Dean Camera"\r
};\r
\r
USB_Descriptor_String_t PROGMEM ProductString =\r
{\r
.Header = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String},\r
- \r
+\r
.UnicodeString = L"LUFA Dual CDC Demo"\r
};\r
\r
break;\r
}\r
\r
- *DescriptorAddress = Address; \r
+ *DescriptorAddress = Address;\r
return Size;\r
}\r
#define CDC1_NOTIFICATION_EPNUM 3\r
\r
/** Endpoint number of the first CDC interface's device-to-host data IN endpoint. */\r
- #define CDC1_TX_EPNUM 1 \r
+ #define CDC1_TX_EPNUM 1\r
\r
/** Endpoint number of the first CDC interface's host-to-device data OUT endpoint. */\r
- #define CDC1_RX_EPNUM 2 \r
+ #define CDC1_RX_EPNUM 2\r
\r
/** Endpoint number of the second CDC interface's device-to-host notification IN endpoint. */\r
#define CDC2_NOTIFICATION_EPNUM 4\r
\r
/** Endpoint number of the second CDC interface's device-to-host data IN endpoint. */\r
- #define CDC2_TX_EPNUM 5 \r
+ #define CDC2_TX_EPNUM 5\r
\r
/** Endpoint number of the second CDC interface's host-to-device data OUT endpoint. */\r
- #define CDC2_RX_EPNUM 6 \r
+ #define CDC2_RX_EPNUM 6\r
\r
/** Size in bytes of the CDC device-to-host notification IN endpoints. */\r
#define CDC_NOTIFICATION_EPSIZE 8\r
\r
/** Size in bytes of the CDC data IN and OUT endpoints. */\r
- #define CDC_TXRX_EPSIZE 16 \r
+ #define CDC_TXRX_EPSIZE 16\r
\r
/* Type Defines: */\r
/** Type define for the device configuration descriptor structure. This must be defined in the\r
\r
/* Function Prototypes: */\r
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)\r
- ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
\r
#endif\r
.Class = 0x00,\r
.SubClass = 0x00,\r
.Protocol = 0x00,\r
- \r
+ \r
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,\r
\r
.VendorID = 0x03EB,\r
.JoystickHID = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_HID_t), .Type = DTYPE_HID},\r
- \r
+ \r
.HIDSpec = VERSION_BCD(01.11),\r
.CountryCode = 0x00,\r
.TotalReportDescriptors = 1,\r
.JoystickEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | JOYSTICK_EPNUM),\r
.Attributes = EP_TYPE_INTERRUPT,\r
.EndpointSize = JOYSTICK_EPSIZE,\r
USB_Descriptor_HID_t JoystickHID;\r
USB_Descriptor_Endpoint_t JoystickEndpoint;\r
} USB_Descriptor_Configuration_t;\r
- \r
+\r
/* Macros: */\r
/** Endpoint number of the Joystick HID reporting IN endpoint. */\r
#define JOYSTICK_EPNUM 1\r
\r
/* Function Prototypes: */\r
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)\r
- ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
\r
#endif\r
*/\r
USB_ClassInfo_HID_t Keyboard_HID_Interface =\r
{\r
- .InterfaceNumber = 0,\r
+ .InterfaceNumber = 0,\r
\r
- .ReportINEndpointNumber = KEYBOARD_EPNUM,\r
- .ReportINEndpointSize = KEYBOARD_EPSIZE,\r
+ .ReportINEndpointNumber = KEYBOARD_EPNUM,\r
+ .ReportINEndpointSize = KEYBOARD_EPSIZE,\r
\r
.ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),\r
\r
- .IdleCount = 500,\r
+ .IdleCount = 500,\r
};\r
\r
/** Main program entry point. This routine contains the overall program flow, including initial\r
*/\r
int main(void)\r
{\r
- SetupHardware();\r
-\r
- LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
- \r
- for (;;)\r
- {\r
- USB_HID_USBTask(&Keyboard_HID_Interface);\r
- USB_USBTask();\r
- }\r
+ SetupHardware();\r
+\r
+ LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
+ \r
+ for (;;)\r
+ {\r
+ USB_HID_USBTask(&Keyboard_HID_Interface);\r
+ USB_USBTask();\r
+ }\r
}\r
\r
/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware()\r
{\r
- /* Disable watchdog if enabled by bootloader/fuses */\r
- MCUSR &= ~(1 << WDRF);\r
- wdt_disable();\r
+ /* Disable watchdog if enabled by bootloader/fuses */\r
+ MCUSR &= ~(1 << WDRF);\r
+ wdt_disable();\r
\r
- /* Disable clock division */\r
- clock_prescale_set(clock_div_1);\r
+ /* Disable clock division */\r
+ clock_prescale_set(clock_div_1);\r
\r
- /* Hardware Initialization */\r
- Joystick_Init();\r
- LEDs_Init();\r
- Buttons_Init();\r
- USB_Init();\r
+ /* Hardware Initialization */\r
+ Joystick_Init();\r
+ LEDs_Init();\r
+ Buttons_Init();\r
+ USB_Init();\r
\r
/* Millisecond timer initialization, with output compare interrupt enabled for the idle timing */\r
OCR0A = ((F_CPU / 64) / 1000);\r
/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\r
- LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
+ LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
}\r
\r
/** Event handler for the library USB Disconnection event. */\r
void EVENT_USB_Disconnect(void)\r
{\r
- LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
+ LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
}\r
\r
/** Event handler for the library USB Configuration Changed event. */\r
void EVENT_USB_ConfigurationChanged(void)\r
{\r
- LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
+ LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
\r
- if (!(USB_HID_ConfigureEndpoints(&Keyboard_HID_Interface)))\r
- LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
+ if (!(USB_HID_ConfigureEndpoints(&Keyboard_HID_Interface)))\r
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
}\r
\r
/** Event handler for the library USB Unhandled Control Packet event. */\r
void EVENT_USB_UnhandledControlPacket(void)\r
{\r
- USB_HID_ProcessControlPacket(&Keyboard_HID_Interface);\r
+ USB_HID_ProcessControlPacket(&Keyboard_HID_Interface);\r
}\r
\r
/** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
*/\r
uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)\r
{\r
- USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;\r
- \r
- uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
- uint8_t ButtonStatus_LCL = Buttons_GetStatus();\r
-\r
- if (JoyStatus_LCL & JOY_UP)\r
- KeyboardReport->KeyCode[0] = 0x04; // A\r
- else if (JoyStatus_LCL & JOY_DOWN)\r
- KeyboardReport->KeyCode[0] = 0x05; // B\r
-\r
- if (JoyStatus_LCL & JOY_LEFT)\r
- KeyboardReport->KeyCode[0] = 0x06; // C\r
- else if (JoyStatus_LCL & JOY_RIGHT)\r
- KeyboardReport->KeyCode[0] = 0x07; // D\r
-\r
- if (JoyStatus_LCL & JOY_PRESS)\r
- KeyboardReport->KeyCode[0] = 0x08; // E\r
- \r
- if (ButtonStatus_LCL & BUTTONS_BUTTON1)\r
- KeyboardReport->KeyCode[0] = 0x09; // F\r
- \r
- return sizeof(USB_KeyboardReport_Data_t);\r
+ USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;\r
+ \r
+ uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
+ uint8_t ButtonStatus_LCL = Buttons_GetStatus();\r
+\r
+ if (JoyStatus_LCL & JOY_UP)\r
+ KeyboardReport->KeyCode[0] = 0x04; // A\r
+ else if (JoyStatus_LCL & JOY_DOWN)\r
+ KeyboardReport->KeyCode[0] = 0x05; // B\r
+\r
+ if (JoyStatus_LCL & JOY_LEFT)\r
+ KeyboardReport->KeyCode[0] = 0x06; // C\r
+ else if (JoyStatus_LCL & JOY_RIGHT)\r
+ KeyboardReport->KeyCode[0] = 0x07; // D\r
+\r
+ if (JoyStatus_LCL & JOY_PRESS)\r
+ KeyboardReport->KeyCode[0] = 0x08; // E\r
+ \r
+ if (ButtonStatus_LCL & BUTTONS_BUTTON1)\r
+ KeyboardReport->KeyCode[0] = 0x09; // F\r
+ \r
+ return sizeof(USB_KeyboardReport_Data_t);\r
}\r
\r
/** HID class driver callback function for the processing of HID reports from the host.\r
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,\r
void* ReportData, uint16_t ReportSize)\r
{\r
- uint8_t LEDMask = LEDS_NO_LEDS;\r
- uint8_t* LEDReport = (uint8_t*)ReportData;\r
-\r
- if (*LEDReport & 0x01) // NUM Lock\r
- LEDMask |= LEDS_LED1;\r
- \r
- if (*LEDReport & 0x02) // CAPS Lock\r
- LEDMask |= LEDS_LED3;\r
-\r
- if (*LEDReport & 0x04) // SCROLL Lock\r
- LEDMask |= LEDS_LED4;\r
- \r
- LEDs_SetAllLEDs(LEDMask);\r
+ uint8_t LEDMask = LEDS_NO_LEDS;\r
+ uint8_t* LEDReport = (uint8_t*)ReportData;\r
+\r
+ if (*LEDReport & 0x01) // NUM Lock\r
+ LEDMask |= LEDS_LED1;\r
+ \r
+ if (*LEDReport & 0x02) // CAPS Lock\r
+ LEDMask |= LEDS_LED3;\r
+\r
+ if (*LEDReport & 0x04) // SCROLL Lock\r
+ LEDMask |= LEDS_LED4;\r
+ \r
+ LEDs_SetAllLEDs(LEDMask);\r
}\r
\r
/* Function Prototypes: */\r
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)\r
- ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
\r
#endif\r
.SubClass = 0x01,\r
.Protocol = 0x00,\r
\r
- .InterfaceStrIndex = NO_DESCRIPTOR \r
+ .InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
\r
.AudioControlInterface_SPC = \r
.TotalLength = sizeof(USB_AudioInterface_AC_t),\r
\r
.InCollection = 1,\r
- .InterfaceNumbers = {1}, \r
+ .InterfaceNumbers = {1},\r
},\r
\r
.AudioStreamInterface = \r
.MouseHID = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_HID_t), .Type = DTYPE_HID},\r
- \r
+\r
.HIDSpec = VERSION_BCD(01.11),\r
.CountryCode = 0x00,\r
.TotalReportDescriptors = 1,\r
.MouseEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+\r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | MOUSE_EPNUM),\r
.Attributes = EP_TYPE_INTERRUPT,\r
.EndpointSize = MOUSE_EPSIZE,\r
.PollingIntervalMS = 0x02\r
- } \r
+ }\r
};\r
\r
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests\r
/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\r
- LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
+ LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
}\r
\r
/** Event handler for the library USB Disconnection event. */\r
void EVENT_USB_Disconnect(void)\r
{\r
- LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
+ LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
}\r
\r
/** Event handler for the library USB Configuration Changed event. */\r
.ManagementEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),\r
.Attributes = EP_TYPE_INTERRUPT,\r
.EndpointSize = CDC_NOTIFICATION_EPSIZE,\r
.DataOutEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),\r
.Attributes = EP_TYPE_BULK,\r
.EndpointSize = CDC_TXRX_EPSIZE,\r
.DataInEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),\r
.Attributes = EP_TYPE_BULK,\r
.EndpointSize = CDC_TXRX_EPSIZE,\r
/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\r
- LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
+ LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
}\r
\r
/** Event handler for the library USB Disconnection event. */\r
void EVENT_USB_Disconnect(void)\r
{\r
- LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
+ LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
}\r
\r
/** Event handler for the library USB Configuration Changed event. */\r
.ManagementEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),\r
.Attributes = EP_TYPE_INTERRUPT,\r
.EndpointSize = CDC_NOTIFICATION_EPSIZE,\r
.DataOutEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),\r
.Attributes = EP_TYPE_BULK,\r
.EndpointSize = CDC_TXRX_EPSIZE,\r
.DataInEndpoint = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
+ \r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),\r
- .Attributes = EP_TYPE_BULK,\r
+ .Attributes = EP_TYPE_BULK,\r
.EndpointSize = CDC_TXRX_EPSIZE,\r
- .PollingIntervalMS= 0x00\r
+ .PollingIntervalMS = 0x00\r
}\r
};\r
\r
.SubClass = 0x01,\r
.Protocol = 0x00,\r
\r
- .InterfaceStrIndex = NO_DESCRIPTOR \r
+ .InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
\r
.AudioControlInterface_SPC = \r
.ACSpecification = VERSION_BCD(01.00),\r
.TotalLength = (sizeof(USB_AudioInterface_AC_t) +\r
sizeof(USB_AudioInputTerminal_t) +\r
- sizeof(USB_AudioOutputTerminal_t)),\r
+ sizeof(USB_AudioOutputTerminal_t)),\r
\r
.InCollection = 1,\r
- .InterfaceNumbers = {1}, \r
+ .InterfaceNumbers = {1},\r
},\r
\r
.InputTerminal = \r
\r
.SourceID = 0x01,\r
\r
- .TerminalStrIndex = NO_DESCRIPTOR \r
+ .TerminalStrIndex = NO_DESCRIPTOR\r
},\r
\r
.AudioStreamInterface_Alt0 = \r
#if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO))\r
/* PWM speaker timer initialization */\r
TCCRxA = ((1 << WGMx0) | (1 << COMxA1) | (1 << COMxA0)\r
- | (1 << COMxB1) | (1 << COMxB0)); // Set on match, clear on TOP\r
+ | (1 << COMxB1) | (1 << COMxB0)); // Set on match, clear on TOP\r
TCCRxB = ((1 << WGMx2) | (1 << CSx0)); // Fast 8-Bit PWM, Fcpu speed\r
#endif \r
}\r
.SubClass = 0x01,\r
.Protocol = 0x00,\r
\r
- .InterfaceStrIndex = NO_DESCRIPTOR \r
+ .InterfaceStrIndex = NO_DESCRIPTOR\r
},\r
\r
.AudioControlInterface_SPC = \r
\r
.ACSpecification = VERSION_BCD(01.00),\r
.TotalLength = (sizeof(USB_AudioInterface_AC_t) +\r
- sizeof(USB_AudioInputTerminal_t) +\r
- sizeof(USB_AudioOutputTerminal_t)),\r
+ sizeof(USB_AudioInputTerminal_t) +\r
+ sizeof(USB_AudioOutputTerminal_t)),\r
\r
.InCollection = 1,\r
- .InterfaceNumbers = {1}, \r
+ .InterfaceNumbers = {1},\r
},\r
\r
.InputTerminal = \r
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
\r
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),\r
- .Attributes = EP_TYPE_BULK,\r
+ .Attributes = EP_TYPE_BULK,\r
.EndpointSize = CDC_TXRX_EPSIZE,\r
- .PollingIntervalMS= 0x00\r
+ .PollingIntervalMS = 0x00\r
}\r
};\r
\r